mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Revert "Copy colormaps so Lua cannot modify cached colormaps! (And Z_Free them on garbage collection.)"
This reverts commit 134f94474c.
This commit is contained in:
parent
1a8f07d53c
commit
9c1ca3e2c0
1 changed files with 2 additions and 16 deletions
|
|
@ -269,13 +269,6 @@ static int colormap_set(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int colormap_free(lua_State *L)
|
|
||||||
{
|
|
||||||
UINT8 *colormap = *((UINT8 **)luaL_checkudata(L, 1, META_COLORMAP));
|
|
||||||
Z_Free(colormap);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int patch_get(lua_State *L)
|
static int patch_get(lua_State *L)
|
||||||
{
|
{
|
||||||
patch_t *patch = *((patch_t **)luaL_checkudata(L, 1, META_PATCH));
|
patch_t *patch = *((patch_t **)luaL_checkudata(L, 1, META_PATCH));
|
||||||
|
|
@ -1052,7 +1045,7 @@ static int libd_getColormap(lua_State *L)
|
||||||
|
|
||||||
// all was successful above, now we generate the colormap at last!
|
// all was successful above, now we generate the colormap at last!
|
||||||
|
|
||||||
colormap = R_GetTranslationColormap(skinnum, color, 0);
|
colormap = R_GetTranslationColormap(skinnum, color, GTC_CACHE);
|
||||||
LUA_PushUserdata(L, colormap, META_COLORMAP); // push as META_COLORMAP userdata, specifically for patches to use!
|
LUA_PushUserdata(L, colormap, META_COLORMAP); // push as META_COLORMAP userdata, specifically for patches to use!
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -1061,14 +1054,10 @@ static int libd_getStringColormap(lua_State *L)
|
||||||
{
|
{
|
||||||
INT32 flags = luaL_checkinteger(L, 1);
|
INT32 flags = luaL_checkinteger(L, 1);
|
||||||
UINT8* colormap = NULL;
|
UINT8* colormap = NULL;
|
||||||
UINT8* lua_colormap = NULL;
|
|
||||||
HUDONLY
|
HUDONLY
|
||||||
colormap = V_GetStringColormap(flags & V_CHARCOLORMASK);
|
colormap = V_GetStringColormap(flags & V_CHARCOLORMASK);
|
||||||
if (colormap) {
|
if (colormap) {
|
||||||
lua_colormap = Z_Malloc(256 * sizeof(UINT8), PU_LUA, NULL);
|
LUA_PushUserdata(L, colormap, META_COLORMAP); // push as META_COLORMAP userdata, specifically for patches to use!
|
||||||
memcpy(lua_colormap, colormap, 256 * sizeof(UINT8));
|
|
||||||
|
|
||||||
LUA_PushUserdata(L, lua_colormap, META_COLORMAP); // push as META_COLORMAP userdata, specifically for patches to use!
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1355,9 +1344,6 @@ int LUA_HudLib(lua_State *L)
|
||||||
|
|
||||||
lua_pushcfunction(L, colormap_set);
|
lua_pushcfunction(L, colormap_set);
|
||||||
lua_setfield(L, -2, "__newindex");
|
lua_setfield(L, -2, "__newindex");
|
||||||
|
|
||||||
lua_pushcfunction(L, colormap_free);
|
|
||||||
lua_setfield(L, -2, "__gc");
|
|
||||||
lua_pop(L,1);
|
lua_pop(L,1);
|
||||||
|
|
||||||
luaL_newmetatable(L, META_PATCH);
|
luaL_newmetatable(L, META_PATCH);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue