load.inc 32 KB

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