[Crash] Add Checks for valid pointers or fix existing. (#3164)

This commit is contained in:
Aeadoin
2023-04-01 12:44:00 -04:00
committed by GitHub
parent 4c2271ff69
commit 0d509a7f3a
19 changed files with 228 additions and 179 deletions
+10 -9
View File
@@ -147,9 +147,10 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
if (spells[spell_id].hit_number > 0) {
int numhit = spells[spell_id].hit_number;
numhit += numhit * caster->GetFocusEffect(focusFcLimitUse, spell_id) / 100;
numhit += caster->GetFocusEffect(focusIncreaseNumHits, spell_id);
if (caster) {
numhit += numhit * caster->GetFocusEffect(focusFcLimitUse, spell_id) / 100;
numhit += caster->GetFocusEffect(focusIncreaseNumHits, spell_id);
}
buffs[buffslot].hit_number = numhit;
}
@@ -262,7 +263,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
// SE_CurrentHP is calculated at first tick if its a dot/buff
if (buffslot >= 0) {
//This is here so dots with hit counters tic down on initial cast.
if (effect_value < 0) {
if (caster && effect_value < 0) {
caster->GetActDoTDamage(spell_id, effect_value, this, false);
}
break;
@@ -1766,7 +1767,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
gid = r->GetGroup(caster->GetName());
if(gid < 11)
{
if(r->GetGroup(TargetClient->GetName()) != gid) {
if (TargetClient && r->GetGroup(TargetClient->GetName()) != gid) {
Message(Chat::Red, "Your target must be a group member for this spell.");
break;
}
@@ -1817,7 +1818,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
{
if (IsClient()) {
Client* client_target = CastToClient();
if (client_target->IsGrouped()) {
if (client_target && client_target->IsGrouped()) {
Group* group = client_target->GetGroup();
if (!group->IsGroupMember(caster)) {
if (caster != this) {
@@ -1830,7 +1831,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
Raid *raid = caster->GetRaid();
uint32 group_id = raid->GetGroup(caster->GetName());
if (group_id > 0 && group_id < MAX_RAID_GROUPS) {
if (raid->GetGroup(client_target->GetName()) != group_id) {
if (client_target && raid->GetGroup(client_target->GetName()) != group_id) {
caster->MessageString(Chat::Red, SUMMON_ONLY_GROUP_CORPSE);
break;
}
@@ -2963,10 +2964,10 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
if (caster && !caster->IsClient())
break;
if (zone->random.Roll(spells[spell_id].base_value[i])) {
if (caster && zone->random.Roll(spells[spell_id].base_value[i])) {
uint32 best_spell_id = caster->CastToClient()->GetHighestScribedSpellinSpellGroup(spells[spell_id].limit_value[i]);
if (caster && IsValidSpell(best_spell_id))
if (IsValidSpell(best_spell_id))
caster->SpellFinished(best_spell_id, this, EQ::spells::CastingSlot::Item, 0, -1, spells[best_spell_id].resist_difficulty);
}
break;