Fix overwriting states too
This commit is contained in:
1 parent
6c7131ff80
commit
0c5a1e95b0
3 files changed
+19
No files matched your search
@@ -653,6 +653,9 @@ static void readfreeslots(MYFILE *f)
|
||||
for (i = 0; i < NUMSTATEFREESLOTS; i++)
|
||||
if (!FREE_STATES[i]) {
|
||||
CONS_Printf("State S_%s allocated.\n",word);
|
||||
|
||||
LUA_InvalidateMathlibStateCache(word);
|
||||
|
||||
FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
|
||||
strcpy(FREE_STATES[i],word);
|
||||
freeslotusage[0][0]++;
|
||||
@@ -9212,6 +9215,11 @@ static inline int lib_freeslot(lua_State *L)
|
||||
for (i = 0; i < NUMSTATEFREESLOTS; i++)
|
||||
if (!FREE_STATES[i]) {
|
||||
CONS_Printf("State S_%s allocated.\n",word);
|
||||
|
||||
lua_pushcfunction(L, lua_glib_invalidate_cache);
|
||||
lua_pushfstring(L, "S_%s", word);
|
||||
lua_call(L, 1, 0);
|
||||
|
||||
FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
|
||||
strcpy(FREE_STATES[i],word);
|
||||
freeslotusage[0][0]++;
|
||||
|
||||
@@ -415,6 +415,16 @@ void LUA_InvalidateMathlibMobjCache(const char *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_call(mL, 1, 0);
|
||||
}
|
||||
|
||||
// Takes a pointer, any pointer, and a metatable name
|
||||
// Creates a userdata for that pointer with the given metatable
|
||||
// Pushes it to the stack and stores it in the registry.
|
||||
|
||||
@@ -50,6 +50,7 @@ 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_PushUserdata(lua_State *L, void *data, const char *meta);
|
||||
void LUA_InvalidateUserdata(void *data);
|
||||
|
||||
Reference in new issue
Block a user