mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 10:31:29 +00:00
[Bots] Fix a couple potential crashes with GetNumberNeedingHealedInGroup (#4652)
This commit is contained in:
parent
60ba76b39c
commit
05c7e6409d
17
zone/bot.cpp
17
zone/bot.cpp
@ -7684,15 +7684,15 @@ void EntityList::ShowSpawnWindow(Client* client, int Distance, bool NamedOnly) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8 Bot::GetNumberNeedingHealedInGroup(Mob* tar, uint16 spell_type, uint16 spell_id, float range) {
|
uint8 Bot::GetNumberNeedingHealedInGroup(Mob* tar, uint16 spell_type, uint16 spell_id, float range) {
|
||||||
if (!tar->IsBot()) {
|
if (!tar) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 count = 0;
|
uint8 count = 0;
|
||||||
auto target_list = tar->IsClient() ? tar->CastToBot()->GatherSpellTargets() : tar->CastToBot()->GetSpellTargetList();
|
auto target_list = tar->IsClient() ? GatherSpellTargets(false, tar) : tar->CastToBot()->GetSpellTargetList();
|
||||||
|
|
||||||
for (Mob* m : target_list) {
|
for (Mob* m : target_list) {
|
||||||
if (tar->CalculateDistance(m) < range && CastChecks(spell_id, m, spell_type, true, IsGroupBotSpellType(spell_type))) {
|
if (m && tar->CalculateDistance(m) < range && CastChecks(spell_id, m, spell_type, true, IsGroupBotSpellType(spell_type))) {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -11146,11 +11146,14 @@ bool Bot::GetUltimateSpellTypeHold(uint16 spell_type, Mob* tar) {
|
|||||||
return GetSpellTypeHold(spell_type);
|
return GetSpellTypeHold(spell_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tar->IsPet() && tar->GetOwner() && tar->IsPetOwnerBot()) {
|
Mob* owner = tar->IsPet() ? tar->GetOwner() : nullptr;
|
||||||
return tar->GetOwner()->CastToBot()->GetSpellTypeHold(GetPetBotSpellType(spell_type));
|
Bot* bot_owner = (owner && owner->IsBot())
|
||||||
}
|
? owner->CastToBot()
|
||||||
|
: nullptr;
|
||||||
|
|
||||||
return GetSpellTypeHold(spell_type);
|
return bot_owner
|
||||||
|
? bot_owner->GetSpellTypeHold(GetPetBotSpellType(spell_type))
|
||||||
|
: GetSpellTypeHold(spell_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::SetSpellTypePriority(uint16 spell_type, uint8 priority_type, uint16 priority) {
|
void Bot::SetSpellTypePriority(uint16 spell_type, uint8 priority_type, uint16 priority) {
|
||||||
|
|||||||
@ -1294,7 +1294,7 @@ BotSpell Bot::GetBestBotSpellForGroupHeal(Bot* caster, Mob* tar, uint16 spell_ty
|
|||||||
|
|
||||||
for (std::list<BotSpell>::iterator bot_spell_list_itr = bot_spell_list.begin(); bot_spell_list_itr != bot_spell_list.end(); ++bot_spell_list_itr) {
|
for (std::list<BotSpell>::iterator bot_spell_list_itr = bot_spell_list.begin(); bot_spell_list_itr != bot_spell_list.end(); ++bot_spell_list_itr) {
|
||||||
// Assuming all the spells have been loaded into this list by level and in descending order
|
// Assuming all the spells have been loaded into this list by level and in descending order
|
||||||
if (IsGroupHealOverTimeSpell(bot_spell_list_itr->SpellId)) {
|
if (IsRegularGroupHealSpell(bot_spell_list_itr->SpellId)) {
|
||||||
uint16 spell_id = bot_spell_list_itr->SpellId;
|
uint16 spell_id = bot_spell_list_itr->SpellId;
|
||||||
|
|
||||||
if (!caster->IsCommandedSpell() && caster->IsValidSpellRange(spell_id, tar)) {
|
if (!caster->IsCommandedSpell() && caster->IsValidSpellRange(spell_id, tar)) {
|
||||||
@ -1368,7 +1368,7 @@ BotSpell Bot::GetBestBotSpellForGroupCompleteHeal(Bot* caster, Mob* tar, uint16
|
|||||||
|
|
||||||
for (std::list<BotSpell>::iterator bot_spell_list_itr = bot_spell_list.begin(); bot_spell_list_itr != bot_spell_list.end(); ++bot_spell_list_itr) {
|
for (std::list<BotSpell>::iterator bot_spell_list_itr = bot_spell_list.begin(); bot_spell_list_itr != bot_spell_list.end(); ++bot_spell_list_itr) {
|
||||||
// Assuming all the spells have been loaded into this list by level and in descending order
|
// Assuming all the spells have been loaded into this list by level and in descending order
|
||||||
if (IsGroupHealOverTimeSpell(bot_spell_list_itr->SpellId)) {
|
if (IsGroupCompleteHealSpell(bot_spell_list_itr->SpellId)) {
|
||||||
uint16 spell_id = bot_spell_list_itr->SpellId;
|
uint16 spell_id = bot_spell_list_itr->SpellId;
|
||||||
|
|
||||||
if (!caster->IsCommandedSpell() && caster->IsValidSpellRange(spell_id, tar)) {
|
if (!caster->IsCommandedSpell() && caster->IsValidSpellRange(spell_id, tar)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user