Temp solution for AE ramp crash

This commit is contained in:
Michael Cook (mackal) 2015-08-21 03:09:27 -04:00
parent 1d6a185f0f
commit 39e35fa011

View File

@ -538,15 +538,22 @@ int HateList::AreaRampage(Mob *caster, Mob *target, int count, ExtraAttackOption
return 0; return 0;
int hit_count = 0; int hit_count = 0;
auto it = list.begin(); // This should prevent crashes if something dies (or mainly more than 1 thing goes away)
while (it != list.end() && (count == -1 || hit_count < count)) { // This is a temp solution until the hate lists can be rewritten to not have that issue
struct_HateList *h = (*it); std::vector<uint16> id_list;
++it; // advancing the iterator here prevents the iterator being invalidated if they die for (auto &h : list) {
if (h && h->entity_on_hatelist && h->entity_on_hatelist != caster) { if (h->entity_on_hatelist && h->entity_on_hatelist != caster &&
if (caster->CombatRange(h->entity_on_hatelist)) { caster->CombatRange(h->entity_on_hatelist))
++hit_count; id_list.push_back(h->entity_on_hatelist->GetID());
caster->ProcessAttackRounds(h->entity_on_hatelist, opts, 1); if (count != -1 && id_list.size() > count)
break;
} }
for (auto &id : id_list) {
auto mob = entity_list.GetMobID(id);
if (mob) {
++hit_count;
caster->ProcessAttackRounds(mob, opts, 1);
} }
} }