diff --git a/zone/aa.cpp b/zone/aa.cpp index f147c78ed..faf818a12 100644 --- a/zone/aa.cpp +++ b/zone/aa.cpp @@ -1963,7 +1963,7 @@ void Client::TogglePassiveAlternativeAdvancement(const AA::Rank &rank, uint32 ab AA::Rank *rank_next = zone->GetAlternateAdvancementRank(rank.next_id); //Add checks for any special cases for toggle. - if (IsEffectinAlternateAdvancementRankEffects(*rank_next, SE_Weapon_Stance)) { + if (rank_next && IsEffectinAlternateAdvancementRankEffects(*rank_next, SE_Weapon_Stance)) { weaponstance.aabonus_enabled = true; ApplyWeaponsStance(); } @@ -2003,7 +2003,7 @@ bool Client::UseTogglePassiveHotkey(const AA::Rank &rank) { else if (rank.prev_id != -1) {//Check when effect is Enabled. AA::Rank *rank_prev = zone->GetAlternateAdvancementRank(rank.prev_id); - if (IsEffectInSpell(rank_prev->spell, SE_Buy_AA_Rank)) { + if (rank_prev && IsEffectInSpell(rank_prev->spell, SE_Buy_AA_Rank)) { return true; } } diff --git a/zone/aggro.cpp b/zone/aggro.cpp index 2f1355f86..7f5079552 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -904,8 +904,9 @@ bool Mob::IsBeneficialAllowed(Mob *target) { return false; } - else if(mob2->IsBot()) + else if (mob2 && mob2->IsBot()) { return true; + } } else if(_NPC(mob1)) { diff --git a/zone/attack.cpp b/zone/attack.cpp index 36f3bc397..7554b8263 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -1484,7 +1484,6 @@ bool Mob::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool if ( (IsCasting() && GetClass() != BARD && !IsFromSpell) - || other == nullptr || ((IsClient() && CastToClient()->dead) || (other->IsClient() && other->CastToClient()->dead)) || (GetHP() < 0) || (!IsAttackAllowed(other)) diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index 1eccc779b..88a4c6e17 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -1802,8 +1802,9 @@ void Mob::ApplyAABonuses(const AA::Rank &rank, StatBonuses *newbon) case SE_Damage_Taken_Position_Mod: { //Mitigate if damage taken from behind base2 = 0, from front base2 = 1 - if (limit_value < 0 || limit_value > 2) + if (limit_value < 0 || limit_value >= 2) { break; + } else if (base_value < 0 && newbon->Damage_Taken_Position_Mod[limit_value] > base_value) newbon->Damage_Taken_Position_Mod[limit_value] = base_value; else if (base_value > 0 && newbon->Damage_Taken_Position_Mod[limit_value] < base_value) @@ -1813,8 +1814,9 @@ void Mob::ApplyAABonuses(const AA::Rank &rank, StatBonuses *newbon) case SE_Melee_Damage_Position_Mod: { - if (limit_value < 0 || limit_value > 2) + if (limit_value < 0 || limit_value >= 2) { break; + } else if (base_value < 0 && newbon->Melee_Damage_Position_Mod[limit_value] > base_value) newbon->Melee_Damage_Position_Mod[limit_value] = base_value; else if (base_value > 0 && newbon->Melee_Damage_Position_Mod[limit_value] < base_value) @@ -1825,9 +1827,9 @@ void Mob::ApplyAABonuses(const AA::Rank &rank, StatBonuses *newbon) case SE_Damage_Taken_Position_Amt: { //Mitigate if damage taken from behind base2 = 0, from front base2 = 1 - if (limit_value < 0 || limit_value > 2) + if (limit_value < 0 || limit_value >= 2) { break; - + } newbon->Damage_Taken_Position_Amt[limit_value] += base_value; break; } @@ -1835,8 +1837,9 @@ void Mob::ApplyAABonuses(const AA::Rank &rank, StatBonuses *newbon) case SE_Melee_Damage_Position_Amt: { //Mitigate if damage taken from behind base2 = 0, from front base2 = 1 - if (limit_value < 0 || limit_value > 2) + if (limit_value < 0 || limit_value >= 2) { break; + } newbon->Melee_Damage_Position_Amt[limit_value] += base_value; break; @@ -3884,8 +3887,9 @@ void Mob::ApplySpellsBonuses(uint16 spell_id, uint8 casterlevel, StatBonuses *ne case SE_Damage_Taken_Position_Mod: { //Mitigate if damage taken from behind base2 = 0, from front base2 = 1 - if (limit_value < 0 || limit_value > 2) + if (limit_value < 0 || limit_value >= 2) { break; + } if (AdditiveWornBonus) new_bonus->Damage_Taken_Position_Mod[limit_value] += effect_value; else if (effect_value < 0 && new_bonus->Damage_Taken_Position_Mod[limit_value] > effect_value) @@ -3898,8 +3902,9 @@ void Mob::ApplySpellsBonuses(uint16 spell_id, uint8 casterlevel, StatBonuses *ne case SE_Melee_Damage_Position_Mod: { //Increase damage by percent from behind base2 = 0, from front base2 = 1 - if (limit_value < 0 || limit_value > 2) + if (limit_value < 0 || limit_value >= 2) { break; + } if (AdditiveWornBonus) new_bonus->Melee_Damage_Position_Mod[limit_value] += effect_value; else if (effect_value < 0 && new_bonus->Melee_Damage_Position_Mod[limit_value] > effect_value) @@ -3912,8 +3917,9 @@ void Mob::ApplySpellsBonuses(uint16 spell_id, uint8 casterlevel, StatBonuses *ne case SE_Damage_Taken_Position_Amt: { //Mitigate if damage taken from behind base2 = 0, from front base2 = 1 - if (limit_value < 0 || limit_value > 2) + if (limit_value < 0 || limit_value >= 2) { break; + } new_bonus->Damage_Taken_Position_Amt[limit_value] += effect_value; break; @@ -3922,8 +3928,9 @@ void Mob::ApplySpellsBonuses(uint16 spell_id, uint8 casterlevel, StatBonuses *ne case SE_Melee_Damage_Position_Amt: { //Mitigate if damage taken from behind base2 = 0, from front base2 = 1 - if (limit_value < 0 || limit_value > 2) + if (limit_value < 0 || limit_value >= 2) { break; + } new_bonus->Melee_Damage_Position_Amt[limit_value] += effect_value; break; diff --git a/zone/bot.cpp b/zone/bot.cpp index ac43f01ed..568a38e6b 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -1936,6 +1936,11 @@ void Bot::AI_Process() #define NOT_PASSIVE (GetBotStance() != EQ::constants::stancePassive) Client* bot_owner = (GetBotOwner() && GetBotOwner()->IsClient() ? GetBotOwner()->CastToClient() : nullptr); + + if (!bot_owner) { + return; + } + auto raid = entity_list.GetRaidByBotName(GetName()); uint32 r_group = RAID_GROUPLESS; if (raid) { @@ -2983,7 +2988,7 @@ void Bot::HealRotationChecks() { bool Bot::IsAIProcessValid(const Client* bot_owner, const Group* bot_group, const Raid* raid) { - if (!bot_owner || !bot_group && !raid || !IsAIControlled()) { + if (!bot_owner || (!bot_group && !raid) || !IsAIControlled()) { return false; } diff --git a/zone/corpse.cpp b/zone/corpse.cpp index 1dbf01640..ff3bbdba1 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -392,8 +392,7 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob ( /* Check Rule to see if we can leave corpses */ if ( - !RuleB(Character, LeaveNakedCorpses) || - RuleB(Character, LeaveCorpses) && + (!RuleB(Character, LeaveNakedCorpses) || RuleB(Character, LeaveCorpses)) && GetLevel() >= RuleI(Character, DeathItemLossLevel) ) { // cash diff --git a/zone/doors.cpp b/zone/doors.cpp index a21244c0b..f0df1f88b 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -222,7 +222,7 @@ void Doors::HandleClick(Client *sender, uint8 trigger) } } - if (m_dz_switch_id != 0) { + if (sender && m_dz_switch_id != 0) { sender->UpdateTasksOnTouchSwitch(m_dz_switch_id); if (sender->TryMovePCDynamicZoneSwitch(m_dz_switch_id)) { safe_delete(outapp); diff --git a/zone/groups.cpp b/zone/groups.cpp index ed3b9083e..57311b951 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -545,7 +545,6 @@ bool Group::UpdatePlayer(Mob* update) { } void Group::MemberZoned(Mob* removemob) { - uint32 i; if (!removemob) { return; @@ -557,21 +556,21 @@ void Group::MemberZoned(Mob* removemob) { //should NOT clear the name, it is used for world communication. for (auto & m : members) { - if (m && (m == removemob || m->IsBot() && m->CastToBot()->GetBotOwner() == removemob)) { + if (m && (m == removemob || (m->IsBot() && m->CastToBot()->GetBotOwner() == removemob))) { m = nullptr; } } if (removemob->IsClient() && HasRole(removemob, RoleAssist)) { - SetGroupAssistTarget(0); + SetGroupAssistTarget(nullptr); } if (removemob->IsClient() && HasRole(removemob, RoleTank)) { - SetGroupTankTarget(0); + SetGroupTankTarget(nullptr); } if (removemob->IsClient() && HasRole(removemob, RolePuller)) { - SetGroupPullerTarget(0); + SetGroupPullerTarget(nullptr); } if (removemob->IsClient() && removemob == mentoree) { diff --git a/zone/raids.cpp b/zone/raids.cpp index 43f27530d..906407301 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -631,7 +631,7 @@ uint32 Raid::GetPlayerIndex(Client *c) Client *Raid::GetClientByIndex(uint16 index) { - if (index > MAX_RAID_MEMBERS) { + if (index >= MAX_RAID_MEMBERS) { return nullptr; } @@ -2204,4 +2204,4 @@ void Raid::SetNewRaidLeader(uint32 i) } } } -} \ No newline at end of file +}