mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-19 16:52:25 +00:00
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:
parent
ba2ca5eada
commit
5e6fef4098
@ -999,7 +999,7 @@ uint8 GetSpellLevel(uint16 spell_id, uint8 class_id)
|
||||
return UINT8_MAX;
|
||||
}
|
||||
|
||||
if (class_id >= Class::PLAYER_CLASS_COUNT) {
|
||||
if (class_id < Class::Warrior || class_id > Class::Berserker) {
|
||||
return UINT8_MAX;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user