y_formatin.inc 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328
  1. /*----------------------------------------------------------------------------*\
  2. ==========================
  3. y_colours - X11 colours!
  4. ==========================
  5. Description:
  6. This holds the colour information that used to be part of the text system
  7. but which is far more useful than just for text. This now supports the full
  8. set of X11 colours, both by name and by definition. You can also define
  9. your own if you so choose (up to 32 - should be enough given that this
  10. includes the X11 colours).
  11. Legal:
  12. Version: MPL 1.1
  13. The contents of this file are subject to the Mozilla Public License Version
  14. 1.1 (the "License"); you may not use this file except in compliance with
  15. the License. You may obtain a copy of the License at
  16. http://www.mozilla.org/MPL/
  17. Software distributed under the License is distributed on an "AS IS" basis,
  18. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  19. for the specific language governing rights and limitations under the
  20. License.
  21. The Original Code is the YSI format include.
  22. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  23. Portions created by the Initial Developer are Copyright (C) 2011
  24. the Initial Developer. All Rights Reserved.
  25. Contributors:
  26. ZeeX, koolk, JoeBullet/Google63, g_aSlice/Slice
  27. Thanks:
  28. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  29. ZeeX - Very productive conversations.
  30. koolk - IsPlayerinAreaEx code.
  31. TheAlpha - Danish translation.
  32. breadfish - German translation.
  33. Fireburn - Dutch translation.
  34. yom - French translation.
  35. 50p - Polish translation.
  36. Zamaroht - Spanish translation.
  37. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes
  38. for me to strive to better.
  39. Pixels^ - Running XScripters where the idea was born.
  40. Matite - Pestering me to release it and using it.
  41. Very special thanks to:
  42. Thiadmer - PAWN, whose limits continue to amaze me!
  43. Kye/Kalcor - SA:MP.
  44. SA:MP Team past, present and future - SA:MP.
  45. Version:
  46. 1.0
  47. Changelog:
  48. 29/11/10:
  49. Added the ability to use "X11" prefixes in strings.
  50. Added colourspace resolution for converting {FF0000} to ~r~.
  51. 25/11/10:
  52. First version.
  53. \*----------------------------------------------------------------------------*/
  54. #include <a_samp>
  55. #include "..\y_debug"
  56. #include "..\y_colours"
  57. // Custom specifier data.
  58. #define F@k<%0>(%1) F@k%0(%1)
  59. #if defined FORMAT_CUSTOM_SPEC_BUFFER_SIZE
  60. // Sorry, no can do.
  61. #undef FORMAT_CUSTOM_SPEC_BUFFER_SIZE
  62. #endif
  63. // =====================================================================
  64. // UPDATE Y_RENDER_FIX_NEGATIVE MACRO ON CHANGE!!!!!!!
  65. #define FORMAT_CUSTOM_SPEC_BUFFER_SIZE 130
  66. // Also "ts" in y_textrender.
  67. // =====================================================================
  68. // This is NOT QUITE compatible with Slice's version. I had to modify the
  69. // "FMAT@2" macro to better support extended parameter options (width etc).
  70. #define FormatSpecifier<'%1'>(%2[%3],%4) FMAT@1:F@%1(%2[FORMAT_CUSTOM_SPEC_BUFFER_SIZE],FMAT@2:___unused,%4)
  71. #if defined FMAT@2
  72. #undef FMAT@2
  73. #endif
  74. #define FMAT@2:___unused,%1[%2]%3) %1[%2],__unused%3)
  75. #define FMAT@1:%1(%2) forward %1(%2); public %1(%2)
  76. #define FORMAT_FLAG_LEFT (_:e_COMPRESS_FORMAT_DATA_LEFT)
  77. #define FORMAT_FLAG_ZERO (_:e_COMPRESS_FORMAT_DATA_ZERO)
  78. #define FORMAT:%0(%1) FormatSpecifier<'%0'>(%1)
  79. // Enumeration for the possible keys they can want.
  80. enum e_GAME_TEXT_KEYS
  81. {
  82. e_NO_KEY_SELECTED,
  83. e_PED_ANSWER_PHONE,
  84. e_PED_DUCK,
  85. e_PED_FIREWEAPON,
  86. e_PED_FIREWEAPON_ALT,
  87. e_PED_SPRINT,
  88. e_VEHICLE_ENTER_EXIT,
  89. e_PED_JUMPING,
  90. e_PED_LOCK_TARGET,
  91. e_PED_LOOKBEHIND,
  92. e_SNEAK_ABOUT,
  93. e_VEHICLE_LOOKLEFT,
  94. e_VEHICLE_LOOKRIGHT,
  95. e_GO_FORWARD,
  96. e_GO_BACK,
  97. e_GO_LEFT,
  98. e_GO_RIGHT,
  99. e_VEHICLE_FIREWEAPON,
  100. e_VEHICLE_HORN,
  101. e_VEHICLE_FIREWEAPON_ALT,
  102. e_VEHICLE_ACCELERATE,
  103. e_VEHICLE_BRAKE,
  104. e_VEHICLE_HANDBRAKE,
  105. e_VEHICLE_SUBMISSIONS,
  106. e_VEHICLE_LOOKBEHIND,
  107. e_VEHICLE_TURRETUP,
  108. e_VEHICLE_TURRETDOWN,
  109. e_VEHICLE_TURRETLEFT,
  110. e_VEHICLE_TURRETRIGHT,
  111. e_VEHICLE_STEERUP,
  112. e_VEHICLE_STEERDOWN,
  113. e_VEHICLE_STEERLEFT,
  114. e_VEHICLE_STEERRIGHT
  115. }
  116. // Can support up to 16 specifier types, more requires a rewrite, unfortunately
  117. // there are currently 15, though I can't think of any more...
  118. enum e_COMPRESS_FORMAT_DATA (+= 0x10000000)
  119. {
  120. e_COMPRESS_FORMAT_DATA_WIDTH = 0x00000FFF, // 0x800 = *, 0 = none,
  121. e_COMPRESS_FORMAT_DATA_PREC = 0x00FFF000, // 0xFFF = default
  122. e_COMPRESS_FORMAT_DATA_LEFT = 0x01000000,
  123. e_COMPRESS_FORMAT_DATA_ZERO = 0x02000000,
  124. e_COMPRESS_FORMAT_DATA_LIST = 0x04000000, // Array of data
  125. e_COMPRESS_FORMAT_DATA_FUNC = 0x08000000, // Function of data
  126. e_COMPRESS_FORMAT_DATA_TYPE = 0xF0000000,
  127. e_COMPRESS_FORMAT_DATA_DEC = 0x10000000, // Decimal : d, i
  128. e_COMPRESS_FORMAT_DATA_HEX, // Hex : h, x
  129. e_COMPRESS_FORMAT_DATA_BIN, // Binary : b
  130. e_COMPRESS_FORMAT_DATA_CHAR, // Character : c
  131. e_COMPRESS_FORMAT_DATA_FLOAT, // Float : f
  132. e_COMPRESS_FORMAT_DATA_IEEE, // IEEE : g
  133. e_COMPRESS_FORMAT_DATA_STRING, // String : s
  134. e_COMPRESS_FORMAT_DATA_OCT, // Octal : o
  135. e_COMPRESS_FORMAT_DATA_COMM, // Command : n
  136. e_COMPRESS_FORMAT_DATA_SUFFIX, // Suffix : p
  137. e_COMPRESS_FORMAT_DATA_UNSIGNED, // Unsigned : u
  138. e_COMPRESS_FORMAT_DATA_SIGNED, // Signed : t
  139. e_COMPRESS_FORMAT_DATA_PLAYER, // Player : q
  140. e_COMPRESS_FORMAT_DATA_LOGICAL, // Logical : l
  141. // TODO: Make "custom" ala Slice's formatex.
  142. //e_COMPRESS_FORMAT_DATA_DATE // Date : DATE
  143. e_COMPRESS_FORMAT_DATA_CUSTOM
  144. }
  145. #define Y_FORMAT_GT_LIGHTER (0x10000000)
  146. #define Y_FORMAT_CLOSE_CURR (0x20000000)
  147. #define Y_FORMAT_START_FADE (0x40000000)
  148. #define Y_FORMAT_ALWAYS_SET (0x80000000)
  149. #define Y_FORMAT_IS_INSERT ('\02')
  150. #define Y_FORMAT_IS_COLOUR ('\03')
  151. #define Y_FORMAT_IS_KEY ('\04')
  152. #define Y_COLOURS_CASE(%0:%1) case '%0':return ++iIn,ret|e_COMPRESS_FORMAT_DATA_%1|(e_COMPRESS_FORMAT_DATA:((width&0xFFF)|((prec&0xFFF)<<12)))
  153. #define Y_ESCAPES_CASE(%0:%1) case '%0':(iOut+1<len)&&(output[iOut++]='%1'),++iIn
  154. #define Y_FORMAT_STRING_SKIP(); //if(iOut+1<len)output[iOut]=0,lastChar=iOut++
  155. /*----------------------------------------------------------------------------*\
  156. Function:
  157. Format_GetKeys
  158. Params:
  159. const input[] - String to read from.
  160. &idx - Current read index.
  161. Return:
  162. e_GAME_TEXT_KEYS - Enum representation of keys.
  163. Notes:
  164. Reads a GameText key identifier and compresses it essentially.
  165. \*----------------------------------------------------------------------------*/
  166. stock e_GAME_TEXT_KEYS:Format_GetKeys(const input[], &idx)
  167. {
  168. P:3("e_GAME_TEXT_KEYS:Format_GetKeys called: \"%s\", %i", input, idx);
  169. if (input[idx] != '~')
  170. {
  171. return e_NO_KEY_SELECTED;
  172. }
  173. if (input[++idx])
  174. {
  175. if (!strcmp(input[idx], !"PED_ANSWER_PHONE~", true, 17))
  176. {
  177. idx += 17;
  178. return e_PED_ANSWER_PHONE;
  179. }
  180. else if (!strcmp(input[idx], !"PED_DUCK~", true, 9))
  181. {
  182. idx += 9;
  183. return e_PED_DUCK;
  184. }
  185. else if (!strcmp(input[idx], !"PED_FIREWEAPON~", true, 15))
  186. {
  187. idx += 15;
  188. return e_PED_FIREWEAPON;
  189. }
  190. else if (!strcmp(input[idx], !"PED_FIREWEAPON_ALT~", true, 29))
  191. {
  192. idx += 29;
  193. return e_PED_FIREWEAPON_ALT;
  194. }
  195. else if (!strcmp(input[idx], !"PED_SPRINT~", true, 11))
  196. {
  197. idx += 11;
  198. return e_PED_SPRINT;
  199. }
  200. else if (!strcmp(input[idx], !"VEHICLE_ENTER_EXIT~", true, 19))
  201. {
  202. idx += 19;
  203. return e_VEHICLE_ENTER_EXIT;
  204. }
  205. else if (!strcmp(input[idx], !"PED_JUMPING~", true, 12))
  206. {
  207. idx += 12;
  208. return e_PED_JUMPING;
  209. }
  210. else if (!strcmp(input[idx], !"PED_LOCK_TARGET~", true, 16))
  211. {
  212. idx += 16;
  213. return e_PED_LOCK_TARGET;
  214. }
  215. else if (!strcmp(input[idx], !"PED_LOOKBEHIND~", true, 15))
  216. {
  217. idx += 15;
  218. return e_PED_LOOKBEHIND;
  219. }
  220. else if (!strcmp(input[idx], !"SNEAK_ABOUT~", true, 12))
  221. {
  222. idx += 12;
  223. return e_SNEAK_ABOUT;
  224. }
  225. else if (!strcmp(input[idx], !"VEHICLE_LOOKLEFT~", true, 17))
  226. {
  227. idx += 17;
  228. return e_VEHICLE_LOOKLEFT;
  229. }
  230. else if (!strcmp(input[idx], !"VEHICLE_LOOKRIGHT~", true, 18))
  231. {
  232. idx += 18;
  233. return e_VEHICLE_LOOKRIGHT;
  234. }
  235. else if (!strcmp(input[idx], !"GO_FORWARD~", true, 11))
  236. {
  237. idx += 11;
  238. return e_GO_FORWARD;
  239. }
  240. else if (!strcmp(input[idx], !"GO_BACK~", true, 8))
  241. {
  242. idx += 8;
  243. return e_GO_BACK;
  244. }
  245. else if (!strcmp(input[idx], !"GO_LEFT~", true, 8))
  246. {
  247. idx += 8;
  248. return e_GO_LEFT;
  249. }
  250. else if (!strcmp(input[idx], !"GO_RIGHT~", true, 9))
  251. {
  252. idx += 9;
  253. return e_GO_RIGHT;
  254. }
  255. else if (!strcmp(input[idx], !"VEHICLE_FIREWEAPON~", true, 19))
  256. {
  257. idx += 19;
  258. return e_VEHICLE_FIREWEAPON;
  259. }
  260. else if (!strcmp(input[idx], !"VEHICLE_HORN~", true, 13))
  261. {
  262. idx += 13;
  263. return e_VEHICLE_HORN;
  264. }
  265. else if (!strcmp(input[idx], !"VEHICLE_FIREWEAPON_ALT~", true, 23))
  266. {
  267. idx += 23;
  268. return e_VEHICLE_FIREWEAPON_ALT;
  269. }
  270. else if (!strcmp(input[idx], !"VEHICLE_ACCELERATE~", true, 19))
  271. {
  272. idx += 19;
  273. return e_VEHICLE_ACCELERATE;
  274. }
  275. else if (!strcmp(input[idx], !"VEHICLE_BRAKE~", true, 14))
  276. {
  277. idx += 14;
  278. return e_VEHICLE_BRAKE;
  279. }
  280. else if (!strcmp(input[idx], !"VEHICLE_HANDBRAKE~", true, 18))
  281. {
  282. idx += 18;
  283. return e_VEHICLE_HANDBRAKE;
  284. }
  285. else if (!strcmp(input[idx], !"VEHICLE_SUBMISSIONS~", true, 20))
  286. {
  287. idx += 20;
  288. return e_VEHICLE_SUBMISSIONS;
  289. }
  290. else if (!strcmp(input[idx], !"VEHICLE_LOOKBEHIND~" , true, 19))
  291. {
  292. idx += 19;
  293. return e_VEHICLE_LOOKBEHIND;
  294. }
  295. else if (!strcmp(input[idx], !"VEHICLE_TURRETUP~", true, 17))
  296. {
  297. idx += 17;
  298. return e_VEHICLE_TURRETUP;
  299. }
  300. else if (!strcmp(input[idx], !"VEHICLE_TURRETDOWN~", true, 19))
  301. {
  302. idx += 19;
  303. return e_VEHICLE_TURRETDOWN;
  304. }
  305. else if (!strcmp(input[idx], !"VEHICLE_TURRETLEFT~", true, 19))
  306. {
  307. idx += 19;
  308. return e_VEHICLE_TURRETLEFT;
  309. }
  310. else if (!strcmp(input[idx], !"VEHICLE_TURRETRIGHT~", true, 20))
  311. {
  312. idx += 20;
  313. return e_VEHICLE_TURRETRIGHT;
  314. }
  315. else if (!strcmp(input[idx], !"VEHICLE_STEERUP~", true, 16))
  316. {
  317. idx += 16;
  318. return e_VEHICLE_STEERUP;
  319. }
  320. else if (!strcmp(input[idx], !"VEHICLE_STEERDOWN~", true, 18))
  321. {
  322. idx += 18;
  323. return e_VEHICLE_STEERDOWN;
  324. }
  325. else if (!strcmp(input[idx], !"VEHICLE_STEERLEFT~", true, 18))
  326. {
  327. idx += 18;
  328. return e_VEHICLE_STEERLEFT;
  329. }
  330. else if (!strcmp(input[idx], !"VEHICLE_STEERRIGHT~", true, 19))
  331. {
  332. idx += 19;
  333. return e_VEHICLE_STEERRIGHT;
  334. }
  335. }
  336. return e_NO_KEY_SELECTED;
  337. }
  338. /*----------------------------------------------------------------------------*\
  339. Function:
  340. Format_Standardise
  341. Params:
  342. input[] - The text to read in.
  343. output[] - The destination array. Can be the same as "input".
  344. len - The length of the output array.
  345. pt - Special mode for parsing player text - has "()" but no "%" or keys.
  346. Return:
  347. The length of the string.
  348. Notes:
  349. Takes a string input and converts it to a standardised representation, i.e.
  350. uses byte-codes instead of human readable codes to represent formats and
  351. colours. This makes it faster to format in to any other representation,
  352. instead of having to convert between all possible combinations, we just have
  353. this to convert basically all formats at once (it can handle hybrids of all
  354. the different representations) to a single fast read format and then have
  355. fairly simple to write methods to convert that single format to any other
  356. format (see y_formatout.inc).
  357. \*----------------------------------------------------------------------------*/
  358. stock Format_Standardise(input[], output[], len = sizeof (output), pt = false)
  359. {
  360. P:2("Format_Standardise called: %s, %d, %d", input, len, pt);
  361. new
  362. ch,
  363. iIn = 0,
  364. iOut = 0, //1,
  365. bool:fade = false,
  366. colour,
  367. tmp,
  368. steps;//,
  369. //lastChar = 0;
  370. // Adjust len so we know we can fit the NULL.
  371. --len;
  372. while ((ch = input[iIn]))
  373. {
  374. // Update where the next element of interest is.
  375. //output[lastChar] = iOut;
  376. // This is now ALWAYS candelled by the next colour to be found, but the
  377. // {<COLOUR} syntax is still supported. The reason is that I got
  378. // annoyed by that syntax almost instantly.
  379. fade = false;
  380. colour = -1;
  381. P:7("Format_Standardise: loop pt 1 %c %d %d", ch, iIn, iOut);
  382. switch (ch)
  383. {
  384. case '#':
  385. {
  386. // Hash colours introduced by RyDeR`.
  387. /*if (fade)
  388. {
  389. fade = false;
  390. }*/
  391. if (input[++iIn] == '\0')
  392. {
  393. continue;
  394. }
  395. // Try and find the named colour.
  396. #if _YSI_USE_X11
  397. if (!strcmp(input[iIn], "X11", true, 3))
  398. {
  399. iIn += 3;
  400. if (input[iIn] == ' ' || input[iIn] == '_')
  401. {
  402. ++iIn;
  403. }
  404. }
  405. // This can't do custom colours as there's no way to tell
  406. // where they end.
  407. colour = GetColourStream(input, iIn); //Colours_DoHashParse(input[iIn], iIn);
  408. //return Colours_DoHashParse(input, idx);
  409. if (colour != 0)
  410. {
  411. colour >>>= 8;
  412. goto Format_Standardise_no_switch;
  413. }
  414. #endif
  415. // Need to accept 3 and 6 character hex codes.
  416. colour = 0;
  417. //idx = iIn;
  418. tmp = iIn;
  419. while ((ch = input[tmp++] | 0x20))
  420. {
  421. if ('0' <= ch <= '9')
  422. {
  423. colour = (colour << 4) | (ch - '0');
  424. }
  425. else if ('a' <= ch <= 'f')
  426. {
  427. colour = (colour << 4) | (ch - 'a' + 10);
  428. }
  429. else
  430. {
  431. if (tmp - iIn == 6)
  432. {
  433. iIn += 6;
  434. }
  435. else if (tmp - iIn > 3)
  436. {
  437. // Convert to 3 digit hex.
  438. // First strip off excess.
  439. colour >>>= 4 * (tmp - iIn - 4);
  440. iIn += 3;
  441. // Then dupilcate each value.
  442. colour = ((colour & 0x0F00) * 0x1100) | ((colour & 0x00F0) * 0x0110) | ((colour & 0x000F) * 0x0011);
  443. tmp = iIn;
  444. }
  445. else
  446. {
  447. // Invalid colour.
  448. iIn = tmp;
  449. colour = -1;
  450. }
  451. break;
  452. }
  453. if (tmp - iIn == 6)
  454. {
  455. iIn += 6;
  456. break;
  457. }
  458. }
  459. // Should never be reached. Is called if the string isn't long
  460. // enough to even contain a full colour identifier.
  461. //continue;
  462. if (tmp - iIn)
  463. {
  464. iIn = tmp - 1;
  465. continue;
  466. }
  467. goto Format_Standardise_no_switch;
  468. }
  469. case '~': // Game Text style information
  470. {
  471. /*if (fade)
  472. {
  473. // These never start and always close fades.
  474. fade = false;
  475. }*/
  476. colour = Format_GTToSAMP(input, iIn);
  477. goto Format_Standardise_no_switch;
  478. }
  479. case '(': // Bracket
  480. {
  481. //if (pt)
  482. //{
  483. // //if (iOut + 1 < len)
  484. // //{
  485. // /*if (fade)
  486. // {
  487. // fade = false;
  488. // }*/
  489. // input[iOut++] = '(';
  490. // //}
  491. // // Need more code here to handle players typing in colours,
  492. // // when they may just be putting in something in brackets -
  493. // // need to test if it matches a colour (or just use the "#"
  494. // // style (could make this user specified).
  495. //}
  496. //else
  497. //{
  498. if (iOut + 1 < len)
  499. {
  500. output[iOut++] = ch;
  501. }
  502. ++iIn;
  503. continue;
  504. //}
  505. }
  506. case '{': // Brace
  507. {
  508. /*if (fade)
  509. {
  510. fade = false;
  511. }*/
  512. colour = -3;
  513. }
  514. case '%':
  515. {
  516. ++iIn;
  517. if (pt)
  518. {
  519. // Don't allow players to type "%d", just output it as is.
  520. if (iOut + 1 < len)
  521. {
  522. output[iOut++] = ch;
  523. }
  524. }
  525. else
  526. {
  527. switch ((ch = input[iIn]))
  528. {
  529. case '%', '#', '{', '(', '~':
  530. {
  531. if (iOut + 1 < len)
  532. {
  533. output[iOut++] = ch;
  534. }
  535. ++iIn;
  536. }
  537. case '\0':
  538. {
  539. if (iOut + 1 < len)
  540. {
  541. output[iOut++] = '%';
  542. }
  543. }
  544. default:
  545. {
  546. ch = Format_GetSpecifier(input, iIn);
  547. if (ch)
  548. {
  549. if (e_COMPRESS_FORMAT_DATA:ch & e_COMPRESS_FORMAT_DATA_TYPE == e_COMPRESS_FORMAT_DATA_CUSTOM)
  550. {
  551. // If the return is
  552. // "e_COMPRESS_FORMAT_DATA_CUSTOM", then
  553. // "Format_GetSpecifier" doesn't increment
  554. // "iIn" enough so that we can read it here.
  555. if (input[iIn] == 'k')
  556. {
  557. P:7("Format_Standardise: \"k\" specifier %d, %d, %d", ch, iOut, len);
  558. // Slightly modified "my" style custom
  559. // specifier.
  560. //++iIn;
  561. if (input[iIn + 1] == '<' && (tmp = strfind(input, ">", false, iIn)) != -1)
  562. {
  563. // Compress the name and length.
  564. input[iIn] = tmp - iIn;
  565. input[iIn + 1] = 'k';
  566. input[tmp] = '\0';
  567. if (iOut + 2 + ceildiv(tmp - iIn, 4) <= len)
  568. {
  569. output[iOut++] = Y_FORMAT_IS_INSERT;
  570. output[iOut++] = ch;
  571. strpack(output[iOut], input[iIn], len);
  572. iOut += ceildiv(tmp - iIn, 4);
  573. }
  574. iIn = tmp + 1;
  575. }
  576. else
  577. {
  578. ++iIn;
  579. }
  580. }
  581. else
  582. {
  583. // "Slice" style custom specifier.
  584. P:7("Format_Standardise: Slice specifier %d, %d, %d", ch, iOut, len);
  585. if (iOut + 3 <= len)
  586. {
  587. output[iOut++] = Y_FORMAT_IS_INSERT;
  588. output[iOut++] = ch;
  589. static
  590. sFullName[4 char] = !"F@_";
  591. sFullName{2} = input[iIn];
  592. output[iOut++] = sFullName[0];
  593. }
  594. ++iIn;
  595. }
  596. }
  597. else
  598. {
  599. P:7("Format_Standardise: specifier %d, %d, %d", ch, iOut, len);
  600. if (iOut + 2 <= len)
  601. {
  602. output[iOut++] = Y_FORMAT_IS_INSERT;
  603. output[iOut++] = ch;
  604. }
  605. }
  606. }
  607. }
  608. }
  609. }
  610. Y_FORMAT_STRING_SKIP();
  611. continue;
  612. }
  613. case '\\':
  614. {
  615. ++iIn;
  616. if (pt)
  617. {
  618. // Don't allow players to type "\n", just output it as is.
  619. if (iOut + 1 < len)
  620. {
  621. output[iOut++] = ch;
  622. }
  623. }
  624. else
  625. {
  626. switch ((ch = input[iIn]))
  627. {
  628. Y_ESCAPES_CASE(r:\r);
  629. Y_ESCAPES_CASE(n:\n);
  630. Y_ESCAPES_CASE(a:\a);
  631. Y_ESCAPES_CASE(b:\b);
  632. Y_ESCAPES_CASE(v:\v);
  633. Y_ESCAPES_CASE(t:\t);
  634. Y_ESCAPES_CASE(e:\e);
  635. Y_ESCAPES_CASE(f:\f);
  636. Y_ESCAPES_CASE(s: );
  637. Y_ESCAPES_CASE(%:%);
  638. // These two with quotes can't be macros.
  639. case '\'': (iOut + 1 < len) && (output[iOut++] = '\''), ++iIn;
  640. case '"' : (iOut + 1 < len) && (output[iOut++] = '"' ), ++iIn;
  641. case 'x':
  642. {
  643. new
  644. num = 0;
  645. for ( ; ; )
  646. {
  647. // I don't know what the length restrictions on this
  648. // are - pawn-lang.pdf isn't clear.
  649. ch = input[++iIn];
  650. if ('0' <= ch <= '9')
  651. {
  652. num = (num * 16) + (ch - '0');
  653. }
  654. else if ('a' <= ch <= 'z')
  655. {
  656. num = (num * 16) + (ch - 'a' + 10);
  657. }
  658. else if ('A' <= ch <= 'Z')
  659. {
  660. num = (num * 16) + (ch - 'A' + 10);
  661. }
  662. else
  663. {
  664. break;
  665. }
  666. }
  667. if (ch == ';')
  668. {
  669. ++iIn;
  670. }
  671. if (iOut + 1 < len)
  672. {
  673. output[iOut++] = num;
  674. }
  675. }
  676. case '0' .. '9':
  677. {
  678. new
  679. num = ch - '0';
  680. ++iIn;
  681. // This can only be three characters.
  682. if ('0' <= (ch = input[iIn]) <= '9')
  683. {
  684. num = (num * 10) + (ch - '0');
  685. ++iIn;
  686. if ('0' <= (ch = input[iIn]) <= '9')
  687. {
  688. num = (num * 10) + (ch - '0');
  689. ch = input[++iIn];
  690. }
  691. }
  692. // To put a semi-colon straight after a number code, use
  693. // \; (I never knew what the point of that was before -
  694. // it's just a separator really here).
  695. if (ch == ';')
  696. {
  697. ++iIn;
  698. }
  699. if (iOut + 1 < len)
  700. {
  701. output[iOut++] = num;
  702. }
  703. }
  704. }
  705. }
  706. // Unrecognised symbols are ignored (or the slash is anyway).
  707. continue;
  708. }
  709. case '\01' .. '\04':
  710. {
  711. // Ignore these characters.
  712. ++iIn;
  713. continue;
  714. }
  715. case '\05' .. '\08', '\11', '\12', '\14' .. '\31':
  716. {
  717. // Excludes tabs and newlines.
  718. ++iIn;
  719. if (pt)
  720. {
  721. // Don't allow players to type "\05", just output it as is.
  722. // They can't actually type this, but just in case!
  723. if (iOut + 1 < len)
  724. {
  725. // Make all these things spaces.
  726. output[iOut++] = ' ';
  727. }
  728. }
  729. else
  730. {
  731. // Don't allow players to type "\05", just output it as is.
  732. // They can't actually type this, but just in case!
  733. if (iOut + 1 < len)
  734. {
  735. // Make all these things spaces.
  736. output[iOut++] = ch;
  737. }
  738. }
  739. continue;
  740. }
  741. default:
  742. {
  743. // Just add the character.
  744. if (iOut + 1 < len)
  745. {
  746. output[iOut++] = ch;
  747. }
  748. ++iIn;
  749. continue;
  750. }
  751. }
  752. P:7("Format_Standardise: loop pt 2");
  753. switch ((ch = input[++iIn]))
  754. {
  755. case '>':
  756. {
  757. // Start of a fade.
  758. //if (!fade)
  759. //{
  760. fade = true;
  761. //}
  762. ch = input[++iIn];
  763. if (ch == '[')
  764. {
  765. steps = 0;
  766. while ((ch = input[++iIn]))
  767. {
  768. // Parse the number of steps to use.
  769. if (ch == ']')
  770. {
  771. ch = input[++iIn];
  772. break;
  773. }
  774. else if ('0' <= ch <= '9')
  775. {
  776. steps = (steps * 10) + (ch - '0');
  777. }
  778. else
  779. {
  780. // INNER LOOP, NOT THE MAIN LOOP.
  781. continue;
  782. }
  783. }
  784. }
  785. }
  786. case '<':
  787. {
  788. // End of a fade.
  789. /*if (fade)
  790. {
  791. fade = false;
  792. }*/
  793. ch = input[++iIn];
  794. }
  795. }
  796. P:7("Format_Standardise: loop pt 3");
  797. // Close colours introduced by [FeK]DraKiNs.
  798. if (colour == -2)
  799. {
  800. colour = ')';
  801. }
  802. else
  803. {
  804. colour = '}';
  805. }
  806. if (ch == '/')
  807. {
  808. // Close colour.
  809. while ((ch = input[++iIn]))
  810. {
  811. if (ch == colour)
  812. {
  813. ++iIn;
  814. break;
  815. }
  816. }
  817. // Ignore everything else, skip to the after bit.
  818. colour = -2;
  819. goto Format_Standardise_no_switch;
  820. }
  821. // Finally we can get the real colour.
  822. new
  823. tot = 0,
  824. bool:num = true,
  825. cur = iIn;
  826. //idx = iIn;
  827. P:7("Format_Standardise: loop pt 4");
  828. while (ch)
  829. {
  830. if (ch == colour)
  831. {
  832. break;
  833. }
  834. new
  835. ch2 = ch | 0x20;
  836. if (num)
  837. {
  838. // Check if it's still a valid HEX digit and increment.
  839. if ('0' <= ch <= '9')
  840. {
  841. tot = (tot << 4) | (ch - '0');
  842. }
  843. else if ('a' <= ch2 <= 'f')
  844. {
  845. tot = (tot << 4) | (ch2 - 'a' + 10);
  846. }
  847. else if (('g' <= ch2 <= 'z') || ch == '_' || ch == ' ')
  848. {
  849. // No, but still a valid identifier.
  850. num = false;
  851. }
  852. else
  853. {
  854. colour = -1;
  855. goto Format_Standardise_no_switch;
  856. }
  857. }
  858. else if (!(('0' <= ch <= '9') || ('a' <= ch2 <= 'z') || ch == '_' || ch == ' '))
  859. {
  860. // Not a valid identifier character.
  861. colour = -1;
  862. // Can't use "continue" here as we're in an inner loop.
  863. goto Format_Standardise_no_switch;
  864. }
  865. ch = input[++cur];
  866. }
  867. P:7("Format_Standardise: loop pt 5");
  868. //while ((ch = input[++idx]));
  869. if (ch == '\0')
  870. {
  871. // Not a valid end.
  872. //iIn = cur;
  873. continue;
  874. }
  875. ++cur;
  876. if (cur == iIn + 1)
  877. {
  878. ++iIn;
  879. continue;
  880. }
  881. if (num)
  882. {
  883. // The input was a number.
  884. colour = tot & 0x00FFFFFF;
  885. }
  886. else
  887. {
  888. // The input was a string.
  889. //if (input[iIn] | 0x20 == 'x' && input[iIn + 1] == '1' && input[iIn + 2] == '1')
  890. #if _YSI_USE_X11
  891. if (!strcmp(input[iIn], "X11", true, 3))
  892. {
  893. if (input[iIn + 3] == ' ' || input[iIn + 3] == '_')
  894. {
  895. colour = GetColourHash(YHash(input[iIn + 4], false, hash_bernstein, cur - iIn - 5), 1);
  896. }
  897. else
  898. {
  899. colour = GetColourHash(YHash(input[iIn + 3], false, hash_bernstein, cur - iIn - 4), 1);
  900. }
  901. }
  902. else
  903. #endif
  904. {
  905. colour = GetColourHash(YHash(input[iIn], false, hash_bernstein, cur - iIn - 1), 1);
  906. }
  907. #pragma tabsize 4
  908. if (!colour)
  909. {
  910. continue;
  911. }
  912. colour >>>= 8;
  913. }
  914. P:7("Format_Standardise: loop pt 6");
  915. iIn = cur;
  916. // One of the FEW labels in my code, because in here "break" ends the
  917. // loop enclosing the switch statement, instead of ending the current
  918. // case from the switch statement as in C.
  919. Format_Standardise_no_switch:
  920. if (colour == -1)
  921. {
  922. continue;
  923. }
  924. else if (colour == -2)
  925. {
  926. if (iOut + 2 < len)
  927. {
  928. // Save the close.
  929. colour = Y_FORMAT_CLOSE_CURR;
  930. if (fade)
  931. {
  932. colour |= Y_FORMAT_START_FADE;
  933. }
  934. output[iOut++] = Y_FORMAT_IS_COLOUR;
  935. output[iOut++] = colour | Y_FORMAT_ALWAYS_SET;
  936. }
  937. }
  938. else if (colour & 0x0F000000)
  939. {
  940. // Players can't type these special things.
  941. if (!pt && iOut + 2 < len)
  942. {
  943. // Save the custom key.
  944. output[iOut++] = Y_FORMAT_IS_KEY;
  945. if (colour & 0xFF == 'k')
  946. {
  947. // Add the whole next key definition.
  948. ch = _:Format_GetKeys(input, iIn);
  949. if (ch != _:e_NO_KEY_SELECTED)
  950. {
  951. output[iOut++] = 'k' | (ch << 8);
  952. }
  953. }
  954. else
  955. {
  956. switch (colour & 0xFF)
  957. {
  958. case 'n':
  959. {
  960. output[iOut++] = '\n';
  961. }
  962. case ']':
  963. {
  964. output[iOut++] = '*';
  965. }
  966. default:
  967. {
  968. output[iOut++] = (colour & 0xFF) | Y_FORMAT_ALWAYS_SET;
  969. }
  970. }
  971. colour = colour >> 8 & 0xFF;
  972. if (iOut + 2 < len && colour)
  973. {
  974. // Save the special GameText "lighter" colour.
  975. output[iOut++] = Y_FORMAT_IS_COLOUR;
  976. output[iOut++] = colour | Y_FORMAT_GT_LIGHTER | Y_FORMAT_ALWAYS_SET;
  977. }
  978. }
  979. }
  980. }
  981. else
  982. {
  983. if (iOut + 2 < len)
  984. {
  985. // Save the normal colour.
  986. if (fade)
  987. {
  988. colour |= Y_FORMAT_START_FADE;
  989. }
  990. output[iOut++] = Y_FORMAT_IS_COLOUR;
  991. output[iOut++] = colour | Y_FORMAT_ALWAYS_SET;
  992. }
  993. }
  994. Y_FORMAT_STRING_SKIP();
  995. P:7("Format_Standardise: loop pt 7");
  996. }
  997. output[iOut] = '\0';
  998. /*if (lastChar == iOut + 1)
  999. {
  1000. output[lastChar] = 0;
  1001. }
  1002. else
  1003. {
  1004. output[lastChar] = iOut;
  1005. }*/
  1006. P:5("Format_Standardise: end: %d %d,%d,%d,%d,%d", iOut, output[0], output[1], output[2], output[3], output[4]);
  1007. /*else
  1008. {
  1009. return GetColourHash(YHash(input[start], false, hash_bernstein, cur - start - 1), 0) >>> 8;
  1010. }*/
  1011. return iOut;
  1012. }
  1013. /*----------------------------------------------------------------------------*\
  1014. Function:
  1015. Format_GetSpecifier
  1016. Params:
  1017. input[] - String to read from.
  1018. &iIn - Index to read from.
  1019. Return:
  1020. Single cell representation of the current specifier.
  1021. Notes:
  1022. Reads a series of characters from the input string and interprets them as a
  1023. format specifier (e.g. "%d"). Also returns the new current string index.
  1024. \*----------------------------------------------------------------------------*/
  1025. static stock Format_GetSpecifier(input[], &iIn)
  1026. {
  1027. P:4("Format_GetSpecifier called: \"%s\", %i", input, iIn);
  1028. new
  1029. ch = input[iIn],
  1030. e_COMPRESS_FORMAT_DATA:ret = e_COMPRESS_FORMAT_DATA:0,
  1031. width,
  1032. prec = -1;
  1033. for ( ; ; )
  1034. {
  1035. switch (ch)
  1036. {
  1037. case '\0':
  1038. {
  1039. break;
  1040. }
  1041. case '!':
  1042. {
  1043. ret = (ret & ~e_COMPRESS_FORMAT_DATA_FUNC) | e_COMPRESS_FORMAT_DATA_LIST;
  1044. }
  1045. case '?':
  1046. {
  1047. ret = (ret & ~e_COMPRESS_FORMAT_DATA_LIST) | e_COMPRESS_FORMAT_DATA_FUNC;
  1048. }
  1049. case '-':
  1050. {
  1051. ret |= e_COMPRESS_FORMAT_DATA_LEFT;
  1052. }
  1053. case '.':
  1054. {
  1055. if ((ch = input[++iIn]) == '*')
  1056. {
  1057. prec = 0x800;
  1058. }
  1059. else
  1060. {
  1061. prec = 0;
  1062. while ('0' <= ch <= '9')
  1063. {
  1064. prec = 10 * prec + (ch - '0');
  1065. ch = input[++iIn];
  1066. }
  1067. }
  1068. continue;
  1069. }
  1070. case '0':
  1071. {
  1072. ret |= e_COMPRESS_FORMAT_DATA_ZERO;
  1073. }
  1074. case '1' .. '9':
  1075. {
  1076. width = 0;
  1077. do
  1078. {
  1079. width = 10 * width + (ch - '0');
  1080. ch = input[++iIn];
  1081. }
  1082. while ('0' <= ch <= '9');
  1083. continue;
  1084. }
  1085. case '*':
  1086. {
  1087. width = 0x800;
  1088. }
  1089. case 's':
  1090. {
  1091. ++iIn;
  1092. if (ret & e_COMPRESS_FORMAT_DATA_LIST)
  1093. {
  1094. printf("*** Internal Warning: Ignoring string list format specifier.");
  1095. ret &= e_COMPRESS_FORMAT_DATA_LIST;
  1096. }
  1097. return ret | e_COMPRESS_FORMAT_DATA_STRING | (e_COMPRESS_FORMAT_DATA:((width & 0xFFF) | ((prec & 0xFFF) << 12)));
  1098. }
  1099. Y_COLOURS_CASE(b:BIN);
  1100. Y_COLOURS_CASE(d','i:DEC);
  1101. Y_COLOURS_CASE(h','x:HEX);
  1102. Y_COLOURS_CASE(f:FLOAT);
  1103. Y_COLOURS_CASE(g:IEEE);
  1104. Y_COLOURS_CASE(o:OCT);
  1105. // I *might* half-decouple "%n" so that this doesn't directly rely
  1106. // on y_commands being included first. Or I could do what y_classes
  1107. // does to use y_groups without including it directly.
  1108. Y_COLOURS_CASE(n:COMM);
  1109. Y_COLOURS_CASE(p:SUFFIX);
  1110. Y_COLOURS_CASE(u:UNSIGNED);
  1111. Y_COLOURS_CASE(t:SIGNED);
  1112. Y_COLOURS_CASE(q:PLAYER);
  1113. Y_COLOURS_CASE(l:LOGICAL);
  1114. default:
  1115. {
  1116. // I have removed the "%DATE% sequence and replaced it with the
  1117. // custom system from Slice. Ideally I'd like to support both
  1118. // somehow, like make the "%XYZ%" format an option AND the "%q"
  1119. // format an option - maybe default to mine and fall back on the
  1120. // short version if a function isn't found.
  1121. /*if (!strcmp(input, !"DATE%", true, 5))
  1122. {
  1123. iIn += 5;
  1124. return ret | e_COMPRESS_FORMAT_DATA_DATE | (e_COMPRESS_FORMAT_DATA:((width & 0xFFF) | ((prec & 0xFFF) << 12)));
  1125. }*/
  1126. // Shut up the compiler.
  1127. //break;
  1128. return ret | e_COMPRESS_FORMAT_DATA_CUSTOM | (e_COMPRESS_FORMAT_DATA:((width & 0xFFF) | ((prec & 0xFFF) << 12)));
  1129. }
  1130. }
  1131. ch = input[++iIn];
  1132. }
  1133. return 0;
  1134. }
  1135. /*----------------------------------------------------------------------------*\
  1136. Function:
  1137. Format_GTToSAMP
  1138. Params:
  1139. const str[] - Input.
  1140. &idx - Read index.
  1141. Return:
  1142. Colour.
  1143. Notes:
  1144. Reads a GameText colour format and converts it to single-cell RGB.
  1145. \*----------------------------------------------------------------------------*/
  1146. static stock Format_GTToSAMP(const str[], &idx)
  1147. {
  1148. P:4("Format_GTToSAMP called: \"%s\", %i", str, idx);
  1149. new
  1150. cur = idx;
  1151. if (str[cur] == '~')
  1152. {
  1153. // Check the colour is correctly ended.
  1154. new
  1155. t = str[++cur];
  1156. if (!t)
  1157. {
  1158. ++idx;
  1159. return -1;
  1160. }
  1161. if (str[++cur] != '~')
  1162. {
  1163. ++idx;
  1164. return -1;
  1165. }
  1166. ++cur;
  1167. // Get the number of ~h~s after the colour.
  1168. new
  1169. c = 0;
  1170. while (str[cur] == '~')
  1171. {
  1172. if (str[cur + 1] | 0x20 == 'h' && str[cur + 2] == '~')
  1173. {
  1174. ++c;
  1175. cur += 3;
  1176. }
  1177. else
  1178. {
  1179. break;
  1180. }
  1181. }
  1182. idx = cur;
  1183. // Return the correct colour for the given string.
  1184. switch (t)
  1185. {
  1186. case 'b':
  1187. {
  1188. switch (c)
  1189. {
  1190. case 0:
  1191. return SAMP_GAME_TEXT_B >>> 8;
  1192. case 1:
  1193. return SAMP_GAME_TEXT_BH >>> 8;
  1194. case 2:
  1195. return SAMP_GAME_TEXT_BHH >>> 8;
  1196. case 3:
  1197. return SAMP_GAME_TEXT_BHHH >>> 8;
  1198. default:
  1199. return SAMP_GAME_TEXT_W >>> 8;
  1200. }
  1201. }
  1202. case 'g':
  1203. {
  1204. switch (c)
  1205. {
  1206. case 0:
  1207. return SAMP_GAME_TEXT_G >>> 8;
  1208. case 1:
  1209. return SAMP_GAME_TEXT_GH >>> 8;
  1210. case 2:
  1211. return SAMP_GAME_TEXT_GHH >>> 8;
  1212. case 3:
  1213. return SAMP_GAME_TEXT_GHHH >>> 8;
  1214. case 4:
  1215. return SAMP_GAME_TEXT_GHHHH >>> 8;
  1216. default:
  1217. return SAMP_GAME_TEXT_W >>> 8;
  1218. }
  1219. }
  1220. case 'h':
  1221. {
  1222. switch (c)
  1223. {
  1224. case 0:
  1225. return SAMP_GAME_TEXT_H >>> 8;
  1226. case 1:
  1227. return SAMP_GAME_TEXT_HH >>> 8;
  1228. default:
  1229. return SAMP_GAME_TEXT_W >>> 8;
  1230. }
  1231. }
  1232. case 'l':
  1233. {
  1234. return SAMP_GAME_TEXT_L >>> 8;
  1235. }
  1236. case 'p':
  1237. {
  1238. switch (c)
  1239. {
  1240. case 0:
  1241. return SAMP_GAME_TEXT_P >>> 8;
  1242. case 1:
  1243. return SAMP_GAME_TEXT_PH >>> 8;
  1244. case 2:
  1245. return SAMP_GAME_TEXT_PHH >>> 8;
  1246. default:
  1247. return SAMP_GAME_TEXT_W >>> 8;
  1248. }
  1249. }
  1250. case 'r':
  1251. {
  1252. switch (c)
  1253. {
  1254. case 0:
  1255. return SAMP_GAME_TEXT_R >>> 8;
  1256. case 1:
  1257. return SAMP_GAME_TEXT_RH >>> 8;
  1258. case 2:
  1259. return SAMP_GAME_TEXT_RHH >>> 8;
  1260. case 3:
  1261. return SAMP_GAME_TEXT_RHHH >>> 8;
  1262. case 4:
  1263. return SAMP_GAME_TEXT_RHHHH >>> 8;
  1264. case 5:
  1265. return SAMP_GAME_TEXT_RHHHHH >>> 8;
  1266. default:
  1267. return SAMP_GAME_TEXT_W >>> 8;
  1268. }
  1269. }
  1270. case 'w':
  1271. {
  1272. return SAMP_GAME_TEXT_W >>> 8;
  1273. }
  1274. case 'y':
  1275. {
  1276. switch (c)
  1277. {
  1278. case 0:
  1279. return SAMP_GAME_TEXT_Y >>> 8;
  1280. case 1:
  1281. return SAMP_GAME_TEXT_YH >>> 8;
  1282. case 2:
  1283. return SAMP_GAME_TEXT_YHH >>> 8;
  1284. default:
  1285. return SAMP_GAME_TEXT_W >>> 8;
  1286. }
  1287. }
  1288. default:
  1289. {
  1290. // Return the fact there is a different GT sequence but keep a
  1291. // record of the number of hs which came after it to avoid
  1292. // excess processing.
  1293. //idx -= (c + 1) * 3;
  1294. return 0x0F000000 | t | (c << 8);
  1295. }
  1296. }
  1297. }
  1298. return -1;
  1299. }