[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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

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;

View File

@ -8591,6 +8591,11 @@ void Mob::VirusEffectProcess()
void Mob::SpreadVirusEffect(int32 spell_id, uint32 caster_id, int32 buff_tics_remaining)
{
Mob *caster = entity_list.GetMob(caster_id);
if (!caster) {
return;
}
std::vector<Mob *> targets_in_range = entity_list.GetTargetsForVirusEffect(
this,
caster,