1
0

load.inc 31 KB

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