You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The method CBaseMonster::ReportAIState prints the string name of the MONSTERSTATE enum value currently used by the monster. The array of names doesn't consider all values and won't print the last 2 values correctly (PlayDead is printed as "Dead", Dead isn't printed at all).
For good measure you could also add in a static_assert (C++11 or newer) to verify that the number of enum values matches the array size:
typedefenum
{
MONSTERSTATE_NONE = 0,
MONSTERSTATE_IDLE,
MONSTERSTATE_COMBAT,
MONSTERSTATE_ALERT,
MONSTERSTATE_HUNT,
MONSTERSTATE_PRONE,
MONSTERSTATE_SCRIPT,
MONSTERSTATE_PLAYDEAD,
MONSTERSTATE_DEAD,
MONSTERSTATE_COUNT //Must be last, not a valid state
} MONSTERSTATE;
//In CBaseMonster::ReportAIStatestatic_assert(ARRAYSIZE(pStateNames) == MONSTERSTATE_COUNT, "You forgot to update the array of monster state names");
The text was updated successfully, but these errors were encountered:
The method
CBaseMonster::ReportAIState
prints the string name of theMONSTERSTATE
enum value currently used by the monster. The array of names doesn't consider all values and won't print the last 2 values correctly (PlayDead is printed as "Dead", Dead isn't printed at all).Enum definition:
halflife/dlls/util.h
Lines 171 to 184 in c7240b9
Affected code:
halflife/dlls/monsters.cpp
Lines 2895 to 2899 in c7240b9
To fix this the array needs to have a matching number of elements:
For good measure you could also add in a
static_assert
(C++11 or newer) to verify that the number of enum values matches the array size:The text was updated successfully, but these errors were encountered: