KYRA: (LOL) - fix stack access warning

This commit is contained in:
athrxx 2022-05-22 16:51:16 +02:00
parent d8004bebba
commit e5b35d05e9
2 changed files with 3 additions and 4 deletions

View File

@ -61,11 +61,10 @@ struct EMCState {
#ifdef RELEASE_BUILD
#define stackPos(x) (script->stack[script->sp+x])
#define safeStackPos(x) (script->sp+x < EMCState::kStackSize ? stackPos(x) : 0)
#else
#define stackPos(x) emcSafeReadStack(script, x, __LINE__, __FILE__)
#define safeStackPos(x) stackPos(x)
#endif
#define safeStackPos(x) (script->sp+x < EMCState::kStackSize ? stackPos(x) : 0)
#define stackPosString(x) ((const char *)&script->dataPtr->text[READ_BE_UINT16(&script->dataPtr->text[stackPos(x)<<1])])
class Resource;

View File

@ -800,7 +800,7 @@ int LoLEngine::olol_copyRegion(EMCState *script) {
int LoLEngine::olol_initMonster(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_initMonster(%p) (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)", (const void *)script,
stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7), stackPos(8), stackPos(9), stackPos(10));
stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), safeStackPos(7), safeStackPos(8), safeStackPos(9), safeStackPos(10));
uint16 x = 0;
uint16 y = 0;
calcCoordinates(x, y, stackPos(0), stackPos(1), stackPos(2));
@ -841,7 +841,7 @@ int LoLEngine::olol_initMonster(EMCState *script) {
l->destDirection = l->direction;
for (int ii = 0; ii < 4; ii++)
l->equipmentShapes[ii] = stackPos(7 + ii) & 0xFF;
l->equipmentShapes[ii] = safeStackPos(7 + ii) & 0xFF;
checkSceneUpdateNeed(l->block);
return i;