Ensure extracolormap_t is valid and that extra_colormap is invalidated

This commit is contained in:
Lactozilla 2023-11-30 20:08:09 -03:00
parent eb3129490f
commit 5bbcffe6f9
2 changed files with 8 additions and 0 deletions

View file

@ -116,6 +116,9 @@ static int extracolormap_get(lua_State *L)
extracolormap_t *exc = *((extracolormap_t **)luaL_checkudata(L, 1, META_EXTRACOLORMAP)); extracolormap_t *exc = *((extracolormap_t **)luaL_checkudata(L, 1, META_EXTRACOLORMAP));
enum extracolormap_e field = luaL_checkoption(L, 2, NULL, extracolormap_opt); enum extracolormap_e field = luaL_checkoption(L, 2, NULL, extracolormap_opt);
if (!exc)
return LUA_ErrInvalid(L, "extracolormap_t");
switch (field) switch (field)
{ {
case extracolormap_red: case extracolormap_red:
@ -198,6 +201,9 @@ static int extracolormap_set(lua_State *L)
extracolormap_t *exc = *((extracolormap_t **)luaL_checkudata(L, 1, META_EXTRACOLORMAP)); extracolormap_t *exc = *((extracolormap_t **)luaL_checkudata(L, 1, META_EXTRACOLORMAP));
enum extracolormap_e field = luaL_checkoption(L, 2, NULL, extracolormap_opt); enum extracolormap_e field = luaL_checkoption(L, 2, NULL, extracolormap_opt);
if (!exc)
return LUA_ErrInvalid(L, "extracolormap_t");
UINT8 r = R_GetRgbaR(exc->rgba); UINT8 r = R_GetRgbaR(exc->rgba);
UINT8 g = R_GetRgbaG(exc->rgba); UINT8 g = R_GetRgbaG(exc->rgba);
UINT8 b = R_GetRgbaB(exc->rgba); UINT8 b = R_GetRgbaB(exc->rgba);

View file

@ -892,6 +892,8 @@ void LUA_InvalidateLevel(void)
LUA_InvalidateUserdata(&sectors[i]); LUA_InvalidateUserdata(&sectors[i]);
LUA_InvalidateUserdata(&sectors[i].lines); LUA_InvalidateUserdata(&sectors[i].lines);
LUA_InvalidateUserdata(&sectors[i].tags); LUA_InvalidateUserdata(&sectors[i].tags);
if (sectors[i].extra_colormap)
LUA_InvalidateUserdata(sectors[i].extra_colormap);
if (sectors[i].ffloors) if (sectors[i].ffloors)
{ {
for (rover = sectors[i].ffloors; rover; rover = rover->next) for (rover = sectors[i].ffloors; rover; rover = rover->next)