Skip to content

Commit

Permalink
Fix CBaseMonster::ReportAIState not handling all MONSTERSTATE enum va…
Browse files Browse the repository at this point in the history
…lues

Resolves #233
  • Loading branch information
SamVanheer committed Jan 22, 2022
1 parent d7bef55 commit eca7867
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/game/server/entities/NPCs/monsters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2895,7 +2895,9 @@ void CBaseMonster::ReportAIState()
{
ALERT_TYPE level = at_console;

static const char* pStateNames[] = {"None", "Idle", "Combat", "Alert", "Hunt", "Prone", "Scripted", "Dead"};
static constexpr const char* pStateNames[] = {"None", "Idle", "Combat", "Alert", "Hunt", "Prone", "Scripted", "PlayDead", "Dead"};

static_assert(std::size(pStateNames) == MONSTERSTATE_COUNT, "You forgot to update the array of monster state names");

ALERT(level, "%s: ", STRING(pev->classname));
if ((std::size_t)m_MonsterState < std::size(pStateNames))
Expand Down
4 changes: 3 additions & 1 deletion src/game/server/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ typedef enum
MONSTERSTATE_PRONE,
MONSTERSTATE_SCRIPT,
MONSTERSTATE_PLAYDEAD,
MONSTERSTATE_DEAD
MONSTERSTATE_DEAD,

MONSTERSTATE_COUNT //Must be last, not a valid state

} MONSTERSTATE;

Expand Down

0 comments on commit eca7867

Please sign in to comment.