From c1047bee92148ddd8cbe3d2c138dd32a112395ad Mon Sep 17 00:00:00 2001 From: NepDisk Date: Tue, 8 Apr 2025 09:22:52 -0400 Subject: [PATCH] Making zero indexing require compatmode --- src/lua_infolib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index a14b1b31c..a330bb900 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -1396,8 +1396,8 @@ static int lib_getSfxInfo(lua_State *L) lua_remove(L, 1); i = luaL_checkinteger(L, 1); - if (i >= NUMSFX) - return luaL_error(L, "sfxinfo[] index %d out of range (0 - %d)", i, NUMSFX-1); + if ((!lua_compatmode && i == 0) || i >= NUMSFX) + return luaL_error(L, "sfxinfo[] index %d out of range (1 - %d)", i, NUMSFX-1); LUA_PushUserdata(L, &S_sfx[i], META_SFXINFO); return 1; } @@ -1410,8 +1410,8 @@ static int lib_setSfxInfo(lua_State *L) lua_remove(L, 1); { UINT32 i = luaL_checkinteger(L, 1); - if (i >= NUMSFX) - return luaL_error(L, "sfxinfo[] index %d out of range (0 - %d)", i, NUMSFX-1); + if ((!lua_compatmode && i == 0) || i >= NUMSFX) + return luaL_error(L, "sfxinfo[] index %d out of range (1 - %d)", i, NUMSFX-1); info = &S_sfx[i]; // get the sfxinfo to assign to. } luaL_checktype(L, 2, LUA_TTABLE); // check that we've been passed a table.