r/programminghorror • u/kabiskac • 15m ago
C++ NFS Most Wanted (2005) worked around an ABI mismatch with EA's own memory card library by manually writing mangled C++ symbols
Disclaimer: this isn't leaked code, but reverse engineered code based on debug info that was shipped with the game. The debug info shows that these use extern C and void* parameters with these names.
I've been poking around this game for 1.5 years and this is by far the worst atrocity I've seen. They used an EA library that was compiled with the -fshort-wchar flag, making wchar_t mangle as unsigned wchar_t which is invalid C++ so you can't type it out.
When they tried to link against it, they got a mismatch because their code was calling the wchar_t overload instead of unsigned wchar_t. I'm not sure whether they didn't know they could have just compiled with -fshort-wchar themselves or they had some reason not to, but they ended up coming up with this ugly hack.


