Skip to content

setlocale is weird

Reported by @Boinciel, running commands in the console crashes the game. CONS_Alert prefixes also seem to be broken, NOTICE displays as %s.

This seems to be related to setlocale(LC_ALL, ""). setlocale(LC_ALL, "C") works though...

Error occurred on Sunday, July 5, 2020 at 09:11:46.

srb2win.exe.debug.exe caused an Access Violation at location 74A8D193 in module msvcrt.dll Reading from location 00000024.

Registers:
eax=00000024 ebx=0028fbd0 ecx=0028fb73 edx=7ffffffe esi=0071129f edi=00000024
eip=74a8d193 esp=0028f92c ebp=0028fbb0 iopl=0         nv up ei pl nz na pe nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00210202

AddrPC   Params
74A8D193 0028FBD0 00711299 00000000  msvcrt.dll!_wtoi
74AF7677 07F8DE68 00711299 00000000  msvcrt.dll!_vsprintf_l
74AF76B4 07F8DE68 00711299 0028FC34  msvcrt.dll!vsprintf
00454A78 004553F2 00711299 00000024  srb2win.exe.debug.exe!CONS_Printf  [/home/james/proj/srb2/srb2/src/console.c @ 1270]
74A898DA 00711299 00000024 007F9CE0  msvcrt.dll!free
004553F2 7701FA9D 74833266 00000000  srb2win.exe.debug.exe!CON_Responder  [/home/james/proj/srb2/srb2/src/console.c @ 1019]
5C323EFB 00000000 00000000 7483327B  SDL2.dll!0x3efb
74833266 000000A4 000000A6 00000074  kernel32.dll!RegEnumKeyExW
7483327B 00000000 00000000 00000000  kernel32.dll!RegEnumKeyExW

I'm not sure if it's worth the effort to try fixing this. We don't even make use of gettext, so maybe it's better to just drop support for it?