From 84e807cfa0ec6be569e7b83e460ee01976615367 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 12 Mar 2023 15:55:14 +0000 Subject: [PATCH] UCRP_ISENGINECLASS Checks for the player's character's engine class As before, A-I and J are valid classes --- src/deh_soc.c | 15 +++++++++++++++ src/m_cond.c | 9 +++++++++ src/m_cond.h | 1 + 3 files changed, 25 insertions(+) diff --git a/src/deh_soc.c b/src/deh_soc.c index e1318a429..5dd4d2138 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -2597,6 +2597,21 @@ static void readcondition(UINT8 set, UINT32 id, char *word2) } #endif } + else if (fastcmp(params[0], "ISENGINECLASS")) + { + PARAMCHECK(1); + ty = UCRP_ISENGINECLASS; + if (!params[1][1] + && params[1][0] >= 'A' && params[1][0] <= 'J') + { + re = params[1][0] - 'A'; + } + else + { + deh_warning("engine class requirement \"%s\" invalid for condition ID %d", params[1], id+1); + return; + } + } else if (fastcmp(params[0], "ISDIFFICULTY")) { //PARAMCHECK(1); diff --git a/src/m_cond.c b/src/m_cond.c index eb5fbc537..c2cd117a8 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -796,6 +796,13 @@ boolean M_CheckCondition(condition_t *cn, player_t *player) return (gamemap == cn->requirement+1); case UCRP_ISCHARACTER: return (player->skin == cn->requirement); + case UCRP_ISENGINECLASS: + return (player->skin < numskins + && R_GetEngineClass( + skins[player->skin].kartspeed, + skins[player->skin].kartweight, + skins[player->skin].flags + ) == (unsigned)cn->requirement); case UCRP_ISDIFFICULTY: if (grandprixinfo.gp == false) return (gamespeed >= cn->requirement); @@ -1265,6 +1272,8 @@ static const char *M_GetConditionString(condition_t *cn) if (cn->requirement < 0 || !skins[cn->requirement].realname[0]) return va("INVALID CHAR CONDITION \"%d:%d\"", cn->type, cn->requirement); return va("as %s", skins[cn->requirement].realname); + case UCRP_ISENGINECLASS: + return va("with engine class %c", 'A' + cn->requirement); case UCRP_ISDIFFICULTY: { const char *speedtext = "", *orbetter = ""; diff --git a/src/m_cond.h b/src/m_cond.h index d3b2b73dc..b8e84ddf0 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -73,6 +73,7 @@ typedef enum UCRP_ISMAP, // gamemap == [map] UCRP_ISCHARACTER, // character == [skin] + UCRP_ISENGINECLASS, // engine class [class] UCRP_ISDIFFICULTY, // difficulty >= [difficulty] UCRP_PODIUMCUP, // cup == [cup] [optional: >= grade OR place]