fix: correct off-by-one in GetSpellLevel for Berserker class

Class::Berserker == 16 and Class::PLAYER_CLASS_COUNT == 16, so the
guard `class_id >= PLAYER_CLASS_COUNT` evaluated 16 >= 16 as true and
returned UINT8_MAX before reaching the array lookup.

The array access `classes[class_id - 1]` is correct — classes[15] is
the valid Berserker slot. The bug was only in the boundary check.

Replace the count-based guard with explicit named-constant bounds so
the valid range (Warrior=1 through Berserker=16) is self-documenting
and both ends are checked (class_id=0 would underflow the index).

Fixes #5056
This commit is contained in:
Roy Love 2026-04-10 20:27:27 -05:00
parent ba2ca5eada
commit 5e6fef4098

View File

@ -999,7 +999,7 @@ uint8 GetSpellLevel(uint16 spell_id, uint8 class_id)
return UINT8_MAX; return UINT8_MAX;
} }
if (class_id >= Class::PLAYER_CLASS_COUNT) { if (class_id < Class::Warrior || class_id > Class::Berserker) {
return UINT8_MAX; return UINT8_MAX;
} }