Add compatibility for KRITEM constants

This commit is contained in:
GenericHeroGuy 2025-12-16 22:10:02 +01:00
parent aab0f90781
commit eb2cb338db
4 changed files with 49 additions and 4 deletions

View file

@ -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

View file

@ -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);

View file

@ -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;
}

View file

@ -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);\
}\
}