From eb2cb338dbdc27c9ecfd105303472877ff5a104a Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Tue, 16 Dec 2025 22:10:02 +0100 Subject: [PATCH] Add compatibility for KRITEM constants --- src/d_main.cpp | 2 +- src/deh_lua.c | 21 +++++++++++++++++++++ src/lua_baselib.c | 28 ++++++++++++++++++++++++++-- src/lua_script.h | 2 +- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 7089f629f..939e10b59 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -93,7 +93,7 @@ #define ASSET_HASH_TEXTURES_KART 0xb4211b2f32b6a291 #define ASSET_HASH_CHARS_KART 0x1e68a3e01aa5c68b #define ASSET_HASH_MAPS_KART 0x38558ed00da41ce9 -#define ASSET_HASH_MAIN_PK3 0x1959d577439a2b7f +#define ASSET_HASH_MAIN_PK3 0xbbd57453623962af #define ASSET_HASH_MAPPATCH_PK3 0x6ad99efcfaafb70f #define ASSET_HASH_BONUSCHARS_KART 0x60e6f13d822a7461 #ifdef USE_PATCH_FILE diff --git a/src/deh_lua.c b/src/deh_lua.c index 30d9d4560..56fc35502 100644 --- a/src/deh_lua.c +++ b/src/deh_lua.c @@ -459,6 +459,27 @@ static int ScanConstants(lua_State *L, boolean mathlib, const char *word) } return luaL_error(L, "kartitem '%s' could not be found.\n", word); } + else if (fastncmp("KRITEM_", word, 7)) { + if (!lua_compatmode) + return luaL_error(L, "KRITEM constants are not supported in BlanKart. See the wiki for information about the new item system.\n"); + + p = word+7; + if (fastcmp(p, "TRIPLESNEAKER")) + lua_pushinteger(L, 17); + else if (fastcmp(p, "TRIPLEBANANA")) + lua_pushinteger(L, 18); + else if (fastcmp(p, "TENFOLDBANANA")) + lua_pushinteger(L, 19); + else if (fastcmp(p, "TRIPLEORBINAUT")) + lua_pushinteger(L, 20); + else if (fastcmp(p, "QUADORBINAUT")) + lua_pushinteger(L, 21); + else if (fastcmp(p, "DUALJAWZ")) + lua_pushinteger(L, 22); + else + return 0; + return 1; + } else if (fastncmp("SKINCOLOR_",word,10)) { p = word+10; i = DEH_FindSkincolor(p); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 5bd9bec8c..10b84d341 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4159,9 +4159,33 @@ static int lib_kGetItemPatch(lua_State *L) { kartitemtype_e item = (kartitemtype_e)luaL_optinteger(L, 1, KITEM_NONE); boolean tiny = lua_optboolean(L, 2); + UINT8 index = 0; //HUDSAFE - // TODO: compatmode KRITEM + if (!lua_compatmode) + LUA_Deprecated(L, "K_GetItemPatch", "K_GetItemGraphics"); + + switch ((UINT8)item) // dualjawz moment + { + case 17: // KRITEM_TRIPLESNEAKER + item = KITEM_SNEAKER; + break; + case 18: // KRITEM_TRIPLEBANANA + case 19: // KRITEM_TENFOLDBANANA + item = KITEM_BANANA; + break; + case 20: // KRITEM_TRIPLEORBINAUT + case 21: // KRITEM_QUADORBINAUT + index = item - 18; + item = KITEM_ORBINAUT; + break; + case 22: // KRITEM_DUALJAWZ + item = KITEM_JAWZ; + break; + default: + break; + } + const char *sad = tiny ? "K_ISSAD" : "K_ITSAD"; if (item <= 0 || item >= numkartitems) { @@ -4170,7 +4194,7 @@ static int lib_kGetItemPatch(lua_State *L) } kartitemgraphics_t *graphics = &kartitems[item].graphics[(tiny ? 1 : 0) + (K_IsKartItemAlternate(item) ? 2 : 0)]; - lua_pushstring(L, graphics->numpatches == 0 ? sad : graphics->patchnames[0]); + lua_pushstring(L, index >= graphics->numpatches ? sad : graphics->patchnames[index]); return 1; } diff --git a/src/lua_script.h b/src/lua_script.h index 41b9ee590..e28c37dc8 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -131,7 +131,7 @@ void COM_Lua_f(void); static UINT8 seen = 0;\ if (!seen) {\ seen = 1;\ - CONS_Alert(CONS_WARNING,"\"%s\" is deprecated and will be removed.\nUse \"%s\" instead.\n", this_func, use_instead);\ + CONS_Alert(CONS_WARNING,"\"%s\" is deprecated in BlanKart.\nUse \"%s\" instead.\n", this_func, use_instead);\ }\ }