-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed display_text_formatted texts overwriting themself #243
Conversation
…ple scripts at once.
gxt[6] += CTheScripts::NumberOfIntroTextLinesThisFrame; // unique label for each possible entry | ||
char gxt[9] = { 0x01, 'C', 'L', 'E', 0x00, 0x00, 0x00, 0x00, 0x00 }; // enough space for even worst case scenario | ||
_itoa(genericLabelCounter, gxt + 4, 36); // 0xFFFF -> "1ekf" | ||
genericLabelCounter++; | ||
|
||
textManager.AddFxt(gxt, text); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these keys ever removed from textManager, or we keep adding them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are kept, but names are procedural and reused on each frame. So total sum of keys never exceeds max count of display_text_formatted calls in single draw frame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, and why we convert the counter to text if previously we added it to the last byte?
in other words, why not:
gxt[6] += genericLabelCounter++;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
genericLabelCounter is cleared once peer render frame, so in theory multiple scripts can print total sum of more than 255 texts. Writing 2 byte number there is also no solution as 0x100 will result in string termination and 1 will be lost.
Base 36 'zzz' represents something around 46k of entries, so more than enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the game support that many draws? I thought the limit is 96
https://github.com/sannybuilder/docs/blob/en/scm-documentation/gta-limits.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fact draw texts buffer index is getting zeroed for every single script makes me start thinking the 96 limit might be peer script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eh? 96 * 96 = 9216 draws?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
32 scripts drawing 96 texts each.
Works, but as usually in case of GTA it is hard to tell if some array is not getting overflown.
Anyway, I'm not the one clearing drawn texts counter. Not sure if they copy text entries to some other array or actually just draw accumulated requests after processing of each script.
Apparently CTheScripts::NumberOfIntroTextLinesThisFrame is cleared on every script processing, not once peer render frame.
This caused GXT labels generated by multiple scripts to not be unique.