Skip to content

Commit

Permalink
Fix ammo, armor, armortype, health not work with if CCMD
Browse files Browse the repository at this point in the history
  • Loading branch information
bradharding committed Oct 19, 2023
1 parent d739b61 commit 1ead38b
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/c_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -3111,7 +3111,36 @@ static void if_cmd_func2(char *cmd, char *parms)

M_StripQuotes(parm2);

if (consolecmds[i].type == CT_CVAR)
if (M_StringCompare(parm1, "ammo"))
{
int value = INT_MIN;

if (sscanf(parms, "%10i", &value) == 1)
condition = (value != INT_MIN
&& value == viewplayer->ammo[weaponinfo[viewplayer->readyweapon].ammotype]);
}
else if (M_StringCompare(parm1, "armor") || M_StringCompare(parm1, "armour"))
{
int value = INT_MIN;

if (sscanf(parms, "%10i", &value) == 1)
condition = (value != INT_MIN && value == viewplayer->armor);
}
else if (M_StringCompare(parm1, "armortype") || M_StringCompare(parm1, "armourtype"))
{
int value = C_LookupValueFromAlias(parm2, ARMORTYPEVALUEALIAS);

if (value != INT_MIN || sscanf(parms, "%10i", &value) == 1)
condition = (value != INT_MIN && value == viewplayer->armortype);
}
else if (M_StringCompare(parm1, "health"))
{
int value = INT_MIN;

if (sscanf(parms, "%10i", &value) == 1)
condition = (value != INT_MIN && value == viewplayer->health);
}
else if (consolecmds[i].type == CT_CVAR)
{
if (consolecmds[i].flags & CF_BOOLEAN)
{
Expand Down

0 comments on commit 1ead38b

Please sign in to comment.