19.06.2017, 16:59
(
Последний раз редактировалось Salik; 19.06.2017 в 19:13.
)
Quote:
For some reason, GetPlayerName takes the characters in the player's name as signed bytes (someone apparently forgot unsigned char), and does sign extension to store them to the string. Thus characters with codes > 127 (all non-ASCII characters) get stored as negative values instead of values in range 0 - 255. Therefore, 'Ń' is stored as 0xFFFFFFD1 (-47) instead of 209. This produces a packed string, which is recognized by all other natives, but contains wrong characters.
Why hasn't this been spotted before? Because the packedness of a string is determined by the first character in the string, and so far all character names tested (latin with diacritics) apparently didn't start with a non-ASCII letter, thus the string was recognized as unpacked by all routines, and therefore they ignored the redundant FFFFFFs. Nice bug you've found! Fortunately, it is possible to fix this with a simple function: Код:
stock NormSignedCharString(string[]) { for(new i = 0; string[i]; i++) { string[i] &= 0xFF; } } |
The variant from Daniel_Cortez helped, but still you(kurta999) need to fix the fix in the YSF plugin.
PHP код:
FixSVarString(str[], size = sizeof(str))//thx to daniel cortez
for (new i = 0; ((str[i] &= 0xFF) != '\0') && (++i != size);) {}