From c98ebc9f35b87c5f0546348b574d6fece5ca1eeb Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 20 Jun 2024 17:08:41 +0200 Subject: [PATCH] Try fix glib preallocating too much space for sound freeslots idk why git keeps removing credits but thx indev <3 --- src/dehacked.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index d02b38482..8fe562aab 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9138,12 +9138,15 @@ int LUA_EnumLib(lua_State *L) char *str = NULL; int size = 0; + // Sound enum tables preallocated for sfx_freeslot0 elements because using NUMSFX may be too + // much if number of skins increased a lot (because of skinsound freeslots) + /* SFX (SFX_) */ lua_pushcfunction(L, lua_glib_new_enum); - lua_createtable(L, 0, NUMSFX); + lua_createtable(L, 0, sfx_freeslot0); for (int i = 0; i < NUMSFX; i++) { - if (!S_sfx[i].name) continue; + if (!S_sfx[i].name || !S_sfx[i].priority) continue; if (lua_enumlib_sprintf_upper(&str, &size, "SFX_%s", S_sfx[i].name) == NULL) return luaL_error(L, "Ran out of memory."); @@ -9158,10 +9161,10 @@ int LUA_EnumLib(lua_State *L) /* SFX (DS) */ lua_pushcfunction(L, lua_glib_new_enum); - lua_createtable(L, 0, NUMSFX); + lua_createtable(L, 0, sfx_freeslot0); for (int i = 0; i < NUMSFX; i++) { - if (!S_sfx[i].name) continue; + if (!S_sfx[i].name || !S_sfx[i].priority) continue; if (lua_enumlib_sprintf_upper(&str, &size, "DS%s", S_sfx[i].name) == NULL) return luaL_error(L, "Ran out of memory."); @@ -9196,10 +9199,10 @@ int LUA_EnumLib(lua_State *L) { /* SFX (sfx_) */ lua_pushcfunction(L, lua_glib_new_enum); - lua_createtable(L, 0, NUMSFX); + lua_createtable(L, 0, sfx_freeslot0); for (int i = 0; i < NUMSFX; i++) { - if (!S_sfx[i].name) continue; + if (!S_sfx[i].name || !S_sfx[i].priority) continue; lua_pushfstring(L, "sfx_%s", S_sfx[i].name); lua_pushinteger(L, i);