Fixup LegoOmni::World LegoOmni::GetWorldId()

Hopefully this is fine... No idea if its still matching but the previous impl relies on UB and I *heavily* doubt that was anything like the original code that Mindscape wrote.

Signed-off-by: kernaltrap <kernaltrap@gmail.com>
This commit is contained in:
kernaltrap 2025-05-24 02:46:10 -05:00
parent 390fef9f9a
commit 773079147d
No known key found for this signature in database
GPG Key ID: EB4ED0175E6CB025

View File

@ -530,13 +530,13 @@ MxAtomId* LegoOmni::GetWorldAtom(LegoOmni::World p_worldId)
// FUNCTION: LEGO1 0x1005b490 // FUNCTION: LEGO1 0x1005b490
LegoOmni::World LegoOmni::GetWorldId(const char* p_key) LegoOmni::World LegoOmni::GetWorldId(const char* p_key)
{ {
// Hoping my fix doesn't have any adverse effects
for (MxS32 i = 0; i < e_numWorlds; i++) { for (MxS32 i = 0; i < e_numWorlds; i++) {
// FIXME: this looks very fishy. Is this guarding against out-of-bounds access? const char* key = m_worlds[i].GetKey();
if ((MxS32*) &m_worlds[i] != (MxS32*) -4 && !SDL_strcasecmp(m_worlds[i].GetKey(), p_key)) { if (key && !SDL_strcasecmp(key, p_key)) {
return m_worlds[i].GetId(); return m_worlds[i].GetId();
} }
} }
return e_undefined; return e_undefined;
} }