From 9ca5ce01f1fde4680820af7d0e31dc7ce38181fd Mon Sep 17 00:00:00 2001 From: LJ Sonic <lamr@free.fr> Date: Thu, 14 Mar 2024 13:56:47 +0100 Subject: [PATCH] No longer store wadnum in sprnames --- src/deh_lua.c | 11 +---------- src/deh_soc.c | 7 +------ src/lua_script.c | 3 --- src/r_things.c | 3 --- 4 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/deh_lua.c b/src/deh_lua.c index c056db82a7..b73479263f 100644 --- a/src/deh_lua.c +++ b/src/deh_lua.c @@ -59,23 +59,14 @@ static inline int lib_freeslot(lua_State *L) } else if (fastcmp(type, "SPR")) { - char wad; spritenum_t j; - lua_getfield(L, LUA_REGISTRYINDEX, "WAD"); - wad = (char)lua_tointeger(L, -1); - lua_pop(L, 1); for (j = SPR_FIRSTFREESLOT; j <= SPR_LASTFREESLOT; j++) { if (used_spr[(j-SPR_FIRSTFREESLOT)/8] & (1<<(j%8))) - { - if (!sprnames[j][4] && memcmp(sprnames[j],word,4)==0) - sprnames[j][4] = wad; continue; // Already allocated, next. - } // Found a free slot! CONS_Printf("Sprite SPR_%s allocated.\n",word); strncpy(sprnames[j],word,4); - //sprnames[j][4] = 0; used_spr[(j-SPR_FIRSTFREESLOT)/8] |= 1<<(j%8); // Okay, this sprite slot has been named now. // Lua needs to update the value in _G if it exists LUA_UpdateSprName(word, j); @@ -456,7 +447,7 @@ static int ScanConstants(lua_State *L, boolean mathlib, const char *word) else if (fastncmp("SPR_",word,4)) { p = word+4; for (i = 0; i < NUMSPRITES; i++) - if (!sprnames[i][4] && fastncmp(p,sprnames[i],4)) { + if (fastncmp(p,sprnames[i],4)) { // updating overridden sprnames is not implemented for soc parser, // so don't use cache if (mathlib) diff --git a/src/deh_soc.c b/src/deh_soc.c index 65db63ebb1..6b90b6a86e 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -443,14 +443,9 @@ void readfreeslots(MYFILE *f) for (i = SPR_FIRSTFREESLOT; i <= SPR_LASTFREESLOT; i++) { if (used_spr[(i-SPR_FIRSTFREESLOT)/8] & (1<<(i%8))) - { - if (!sprnames[i][4] && memcmp(sprnames[i],word,4)==0) - sprnames[i][4] = (char)f->wad; continue; // Already allocated, next. - } // Found a free slot! strncpy(sprnames[i],word,4); - //sprnames[i][4] = 0; used_spr[(i-SPR_FIRSTFREESLOT)/8] |= 1<<(i%8); // Okay, this sprite slot has been named now. // Lua needs to update the value in _G if it exists LUA_UpdateSprName(word, i); @@ -4183,7 +4178,7 @@ spritenum_t get_sprite(const char *word) if (fastncmp("SPR_",word,4)) word += 4; // take off the SPR_ for (i = 0; i < NUMSPRITES; i++) - if (!sprnames[i][4] && memcmp(word,sprnames[i],4)==0) + if (memcmp(word,sprnames[i],4)==0) return i; deh_warning("Couldn't find sprite named 'SPR_%s'",word); return SPR_NULL; diff --git a/src/lua_script.c b/src/lua_script.c index b62fa675e2..0578995554 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -622,9 +622,6 @@ static inline boolean LUA_LoadFile(MYFILE *f, char *name) if (!gL) // Lua needs to be initialized LUA_ClearState(); - lua_pushinteger(gL, f->wad); - lua_setfield(gL, LUA_REGISTRYINDEX, "WAD"); - lua_pushcfunction(gL, LUA_GetErrorMessage); errorhandlerindex = lua_gettop(gL); diff --git a/src/r_things.c b/src/r_things.c index 76e6806875..d56b473b87 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -480,9 +480,6 @@ void R_AddSpriteDefs(UINT16 wadnum) // for (i = 0; i < numsprites; i++) { - if (sprnames[i][4] && wadnum >= (UINT16)sprnames[i][4]) - continue; - if (R_AddSingleSpriteDef(sprnames[i], &sprites[i], wadnum, start, end)) { // if a new sprite was added (not just replaced) -- GitLab