diff --git a/src/deh_lua.c b/src/deh_lua.c index 516f9e2be..66e5bf290 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); @@ -489,7 +480,7 @@ static int ScanConstants(lua_State *L, boolean mathlib, const char *word) return 1; } 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) @@ -737,7 +728,7 @@ void LUA_UpdateSprName(const char *name, lua_Integer value) if (!lua_isnil(gL, -1)) { - lua_pushstring(gL, name); + lua_pushstring(gL, fullname); lua_pushinteger(gL, value); lua_rawset(gL, LUA_GLOBALSINDEX); } diff --git a/src/deh_soc.c b/src/deh_soc.c index c7856f602..3d67364ae 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -430,15 +430,10 @@ 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; CONS_Printf("Sprite SPR_%s allocated.\n",word); + strncpy(sprnames[i],word,4); 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); @@ -4313,7 +4308,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 d6dd46a87..f9c940a92 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -618,11 +618,11 @@ static inline void LUA_LoadFile(MYFILE *f, char *name, boolean noresults) if (!name) name = wadfiles[f->wad]->filename; + CONS_Printf("Loading Lua script from %s\n", name); + if (!gL) // Lua needs to be initialized LUA_ClearState(); - lua_pushinteger(gL, f->wad); - lua_setfield(gL, LUA_REGISTRYINDEX, "WAD"); lua_lumploading++; // turn on loading flag diff --git a/src/r_things.cpp b/src/r_things.cpp index cb6ac9e53..adb407973 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -543,9 +543,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)) { #ifdef HWRENDER