[BugFix] Remove potential nullptrs in Virus Code (#1658)

This commit is contained in:
KayenEQ
2021-10-31 01:06:32 -04:00
committed by GitHub
parent 9e7a763482
commit 9af7122b1d
2 changed files with 14 additions and 0 deletions
+9
View File
@@ -5237,6 +5237,11 @@ std::vector<Mob*> EntityList::GetTargetsForVirusEffect(Mob *spreader, Mob *origi
bool is_detrimental_spell = IsDetrimentalSpell(spell_id);
for (auto &it : entity_list.GetCloseMobList(spreader, range)) {
Mob *mob = it.second;
if (!mob) {
continue;
}
if (mob == spreader) {
continue;
}
@@ -5259,6 +5264,10 @@ std::vector<Mob*> EntityList::GetTargetsForVirusEffect(Mob *spreader, Mob *origi
// Make sure the target is in range
if (mob->CalculateDistance(spreader->GetX(), spreader->GetY(), spreader->GetZ()) <= range) {
if (!original_caster) {
continue;
}
//Do not allow detrimental spread to anything the original caster couldn't normally attack.
if (is_detrimental_spell && !original_caster->IsAttackAllowed(mob, true)) {
continue;