From 756324ad0507f44769e639e994ddf8c5318578e8 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sun, 23 Feb 2025 18:00:59 -0600 Subject: [PATCH] Exclude more invalid indices from damage_target --- src/game/boe.combat.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/game/boe.combat.cpp b/src/game/boe.combat.cpp index 4d3d747f..bdd829e7 100644 --- a/src/game/boe.combat.cpp +++ b/src/game/boe.combat.cpp @@ -4022,10 +4022,14 @@ bool monst_cast_priest(cCreature *caster,short targ) { } short damage_target(short target,short dam,eDamageType type,short sound_type, bool do_print, short who_hit, eRace race) { - if(target == 6) return 0; - if(target < 6) - return damage_pc(univ.party[target],dam,type,race,sound_type, do_print); - else return damage_monst(univ.town.monst[target - 100], who_hit, dam, type,sound_type, do_print); + if(target >= 6 && target < 100) return 0; + if(target < 6){ + return damage_pc(univ.party[target], dam, type, race, sound_type, do_print); + }else{ + int monst_idx = target - 100; + if(monst_idx >= univ.town.monst.size()) return 0; + return damage_monst(univ.town.monst[monst_idx], who_hit, dam, type, sound_type, do_print); + } } short damage_target(iLiving& target,short dam,eDamageType type,short sound_type, bool do_print, short who_hit, eRace race) {