Fix sprite freeslots behaving differently from vanilla (same as for MT_ and S_)
This commit is contained in:
1 parent
0c5a1e95b0
commit
7054b8658e
3 files changed
+14
-17
No files matched your search
+11
-3
@@ -642,6 +642,9 @@ static void readfreeslots(MYFILE *f)
|
||||
strncpy(sprnames[i],word,4);
|
||||
//sprnames[i][4] = 0;
|
||||
CONS_Printf("Sprite SPR_%s allocated.\n",word);
|
||||
|
||||
LUA_InvalidateMathlibCache(va("SPR_%s", word));
|
||||
|
||||
used_spr[(i-SPR_FIRSTFREESLOT)/8] |= 1<<(i%8); // Okay, this sprite slot has been named now.
|
||||
break;
|
||||
}
|
||||
@@ -654,7 +657,7 @@ static void readfreeslots(MYFILE *f)
|
||||
if (!FREE_STATES[i]) {
|
||||
CONS_Printf("State S_%s allocated.\n",word);
|
||||
|
||||
LUA_InvalidateMathlibStateCache(word);
|
||||
LUA_InvalidateMathlibCache(va("S_%s", word));
|
||||
|
||||
FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
|
||||
strcpy(FREE_STATES[i],word);
|
||||
@@ -671,7 +674,7 @@ static void readfreeslots(MYFILE *f)
|
||||
if (!FREE_MOBJS[i]) {
|
||||
CONS_Printf("MobjType MT_%s allocated.\n",word);
|
||||
|
||||
LUA_InvalidateMathlibMobjCache(word);
|
||||
LUA_InvalidateMathlibCache(va("MT_%s", word));
|
||||
|
||||
FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
|
||||
strcpy(FREE_MOBJS[i],word);
|
||||
@@ -9199,6 +9202,11 @@ static inline int lib_freeslot(lua_State *L)
|
||||
}
|
||||
// Found a free slot!
|
||||
CONS_Printf("Sprite SPR_%s allocated.\n",word);
|
||||
|
||||
lua_pushcfunction(L, lua_glib_invalidate_cache);
|
||||
lua_pushfstring(L, "SPR_%s", word);
|
||||
lua_call(L, 1, 0);
|
||||
|
||||
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.
|
||||
@@ -9427,7 +9435,7 @@ static int lua_enumlib_sprite_get(lua_State *L)
|
||||
const char *s = lua_tostring(L, 1);
|
||||
for (int i = 0; i < NUMSPRITES; i++)
|
||||
{
|
||||
if (fastncmp(s+4, sprnames[i], 4))
|
||||
if (!sprnames[i][4] && fastncmp(s+4, sprnames[i], 4))
|
||||
{
|
||||
lua_pushinteger(L, i);
|
||||
return 1;
|
||||
|
||||
+2
-12
@@ -405,23 +405,13 @@ fixed_t LUA_EvalMath(const char *word)
|
||||
return res;
|
||||
}
|
||||
|
||||
void LUA_InvalidateMathlibMobjCache(const char *name)
|
||||
void LUA_InvalidateMathlibCache(const char *name)
|
||||
{
|
||||
// No state => no cache => nothing to invalidate :3
|
||||
if (mL == NULL) return;
|
||||
|
||||
lua_pushcfunction(mL, lua_glib_invalidate_cache);
|
||||
lua_pushfstring(mL, "MT_%s", name);
|
||||
lua_call(mL, 1, 0);
|
||||
}
|
||||
|
||||
void LUA_InvalidateMathlibStateCache(const char *name)
|
||||
{
|
||||
// No state => no cache => nothing to invalidate :3
|
||||
if (mL == NULL) return;
|
||||
|
||||
lua_pushcfunction(mL, lua_glib_invalidate_cache);
|
||||
lua_pushfstring(mL, "S_%s", name);
|
||||
lua_pushstring(mL, name);
|
||||
lua_call(mL, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -49,8 +49,7 @@ void LUA_DumpFile(const char *filename);
|
||||
fixed_t LUA_EvalMath(const char *word);
|
||||
|
||||
// Need better name for this ;-;
|
||||
void LUA_InvalidateMathlibMobjCache(const char *name);
|
||||
void LUA_InvalidateMathlibStateCache(const char *name);
|
||||
void LUA_InvalidateMathlibCache(const char *name);
|
||||
|
||||
void LUA_PushUserdata(lua_State *L, void *data, const char *meta);
|
||||
void LUA_InvalidateUserdata(void *data);
|
||||
|
||||
Reference in new issue
Block a user