gemidyne / microtf2

A custom gamemode for Team Fortress 2 - Players compete against each other to get the most points by playing a series of rapid fire microgames in order to win the round!
https://www.gemidyne.com/projects/microtf2
GNU General Public License v2.0
30 stars 16 forks source link

Reverse text doesn't work properly on Unicode texts #199

Closed whysodrooled closed 3 years ago

whysodrooled commented 3 years ago

Hello, I've just checked out that there was a bug that Unicode characters wasn't properly reversed. It shows the ? characters and some garbled texts.

I got the temporary workaround for this one just in case:

// unicode support
if(c >= 1 && buffer[c-1] & 0xC0 == 0xC0) // 2 bytes
{
    for(int j = 0; j < 2; j++)
    {
        rewritten[rc] = buffer[c-1+j];
        rc++;
    }
    c--;
}
else if(c >= 2 && buffer[c-2] & 0xE0 == 0xE0) // 3 bytes
{
    for(int j = 0; j < 3; j++)
    {
        rewritten[rc] = buffer[c-2+j];
        rc++;
    }
    c -= 2;
}
else
{
    rewritten[rc] = buffer[c];
    rc++;
}

Hoping the bug is fixed on this one since the game uses translations. Thanks!

EDIT: Just added to check if the array number is valid. No wonder why server lagged hell when I was testing. Sorry.

safalin1 commented 3 years ago

Thanks - I'll get this added in and tested. I might back port this to the stable version too since the v5 will take a while longer before release

safalin1 commented 3 years ago

Hi,

We have tested & released the fix in v4.2.0 - it has been merged up into the v5 dev branch too.

Thanks for your contribution to the gamemode & my apologies for the fix not making it out sooner.