[Bug Fix] Fix scenario where dereferenced object could be null. (#2784)

This commit is contained in:
Aeadoin 2023-01-23 18:40:23 -05:00 committed by GitHub
parent 93eddf603b
commit 4d355afe9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 9 deletions

View File

@ -2770,7 +2770,7 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
} }
} }
if (killer_mob->IsBot()) { if (killer_mob && killer_mob->IsBot()) {
parse->EventBot(EVENT_NPC_SLAY, killer_mob->CastToBot(), this, "", 0); parse->EventBot(EVENT_NPC_SLAY, killer_mob->CastToBot(), this, "", 0);
killer_mob->TrySpellOnKill(killed_level, spell); killer_mob->TrySpellOnKill(killed_level, spell);
} }

View File

@ -2358,7 +2358,7 @@ bool BotDatabase::LoadLeaderIDByBotGroupID(const uint32 group_id, uint32& leader
bool BotDatabase::LoadBotGroupNameByBotGroupID(const uint32 group_id, std::string& botgroup_name) bool BotDatabase::LoadBotGroupNameByBotGroupID(const uint32 group_id, std::string& botgroup_name)
{ {
if (!group_id) { if (!group_id) {
false; return false;
} }
query = fmt::format( query = fmt::format(

View File

@ -2901,14 +2901,16 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
since effect can potentially kill caster. since effect can potentially kill caster.
*/ */
case SE_Health_Transfer: { case SE_Health_Transfer: {
effect_value = spells[spell_id].limit_value[i]; if (caster) {
int64 amt = std::abs(caster->GetMaxHP() * effect_value / 1000); effect_value = spells[spell_id].limit_value[i];
int64 amt = std::abs(caster->GetMaxHP() * effect_value / 1000);
if (effect_value < 0) { if (effect_value < 0) {
Damage(caster, amt, spell_id, spell.skill, false, buffslot, false); Damage(caster, amt, spell_id, spell.skill, false, buffslot, false);
} }
else { else {
HealDamage(amt, caster); HealDamage(amt, caster);
}
} }
break; break;
} }