Fix integer overflow in LegoAnimationManager::Tickle

This PR fixes a integer overflow in the `rand()` call inside of `LegoAnimationManager::Tickle`.
During animation sequences, like the one that plays when you first get in-game and the Infomaniac tells you about the Pizzeria, the `rand` function could return a massive value that would overflow the `int` type of `MxLong`.

Signed-off-by: kernaltrap <kernaltrap@gmail.com>
This commit is contained in:
kernaltrap 2025-05-28 22:23:01 -05:00
parent ea7cac8359
commit e3ccf198a5
No known key found for this signature in database
GPG Key ID: EB4ED0175E6CB025

View File

@ -1562,7 +1562,8 @@ MxResult LegoAnimationManager::Tickle()
return SUCCESS;
}
m_unk0x410 = (rand() * 10000 / SHRT_MAX) + 5000;
MxLong r = rand() % 32768;
m_unk0x410 = (r * 10000 / 32767) + 5000;
m_unk0x408 = time;
if (time - m_unk0x404 > 10000) {
@ -1585,6 +1586,7 @@ MxResult LegoAnimationManager::Tickle()
return SUCCESS;
}
// FUNCTION: LEGO1 0x10062110
// FUNCTION: BETA10 0x10042f41
MxU16 LegoAnimationManager::FUN_10062110(