Fix potential crashes in attack.cpp

This commit is contained in:
Michael Cook (mackal) 2016-08-13 15:26:07 -04:00
parent 7a4c9b36a8
commit 00cfe2d25f

View File

@ -3261,7 +3261,7 @@ void Mob::CommonDamage(Mob* attacker, int32 &damage, const uint16 spell_id, cons
a->damage = damage;
a->spellid = spell_id;
a->special = special;
a->meleepush_xy = attacker->GetHeading() * 2.0f;
a->meleepush_xy = attacker ? attacker->GetHeading() * 2.0f : 0.0f;
if (RuleB(Combat, MeleePush) && damage > 0 && !IsRooted() &&
(IsClient() || zone->random.Roll(RuleI(Combat, MeleePushChance)))) {
a->force = EQEmu::skills::GetSkillMeleePushForce(skill_used);
@ -3798,7 +3798,7 @@ void Mob::TryPetCriticalHit(Mob *defender, uint16 skill, int32 &damage)
void Mob::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage, ExtraAttackOptions *opts)
{
if(damage < 1)
if(damage < 1 || !defender)
return;
// decided to branch this into it's own function since it's going to be duplicating a lot of the
@ -3819,8 +3819,8 @@ void Mob::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage, ExtraAttack
bool IsBerskerSPA = false;
//1: Try Slay Undead
if (defender && (defender->GetBodyType() == BT_Undead ||
defender->GetBodyType() == BT_SummonedUndead || defender->GetBodyType() == BT_Vampire)) {
if (defender->GetBodyType() == BT_Undead ||
defender->GetBodyType() == BT_SummonedUndead || defender->GetBodyType() == BT_Vampire) {
int32 SlayRateBonus = aabonuses.SlayUndead[0] + itembonuses.SlayUndead[0] + spellbonuses.SlayUndead[0];
if (SlayRateBonus) {
float slayChance = static_cast<float>(SlayRateBonus) / 10000.0f;