ILLUSIONS: Fix text handling crash on big-endian systems #3125
From what I understand, Illusions games use wide strings, and we swap their endianness on big-endian systems. However, some strings would sometimes remain in the wrong endianness, such as the second sentence from the army guy at the start: the
The problem appears to be in the loop doing the uint16 endianness swap:
It stops just before
... effectively reversing the string multiple times, and at incorrect positions. Thus, some characters would remain in the incorrect endianness, and the game would crash.
So, I've changed this condition so that the loop stops right before any full-zero uint16 value (since that's also how
Tested with Duckman on Debian 11 PowerPC, and also tested by raziel on AmigaOS4 (thanks!). (Not tested back on little-endian systems, since the change is in a
(I also tried doing a PS3 build, but it seems that
The loop reversing the wide characters on big-endian systems would loop until _tblPtr, which is way past all TalkEntry text parts, effectively reversing the string multiple times at incorrect positions. Thus, some characters would remain in the incorrect endianness, and the game would crash. Trac tickets #11528 and #11236.