From a3f9d5e7078aa96b6a632de94b2d98174b58a6af Mon Sep 17 00:00:00 2001 From: SecretsOTheP Date: Thu, 13 Feb 2014 12:02:26 -0500 Subject: [PATCH] bot.cpp was missing nullptr instead of NULL, that is now fixed. hate_list.cpp potential crash fix related to center being nullptr --- zone/bot.cpp | 2 +- zone/hate_list.cpp | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index a1241626f..8a58fc42a 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -16351,7 +16351,7 @@ void EntityList::ShowSpawnWindow(Client* client, int Distance, bool NamedOnly) { std::string WindowText; int LastCon = -1; int CurrentCon = 0; - Mob* curMob = NULL; + Mob* curMob = nullptr; uint32 array_counter = 0; diff --git a/zone/hate_list.cpp b/zone/hate_list.cpp index 49058fc5e..7f986949b 100644 --- a/zone/hate_list.cpp +++ b/zone/hate_list.cpp @@ -268,6 +268,9 @@ Mob *HateList::GetTop(Mob *center) Mob* top = nullptr; int32 hate = -1; + if(center == nullptr) + return nullptr; + if (RuleB(Aggro,SmartAggroList)){ Mob* topClientTypeInRange = nullptr; int32 hateClientTypeInRange = -1; @@ -380,15 +383,15 @@ Mob *HateList::GetTop(Mob *center) } if(!isTopClientType) - return topClientTypeInRange; + return topClientTypeInRange ? topClientTypeInRange : nullptr; - return top; + return top ? top : nullptr; } else { if(top == nullptr && skipped_count > 0) { - return center->GetTarget(); + return center->GetTarget() ? center->GetTarget() : nullptr; } - return top; + return top ? top : nullptr; } } else{ @@ -413,10 +416,11 @@ Mob *HateList::GetTop(Mob *center) ++iterator; } if(top == nullptr && skipped_count > 0) { - return center->GetTarget(); + return center->GetTarget() ? center->GetTarget() : nullptr; } - return top; + return top ? top : nullptr; } + return nullptr; } Mob *HateList::GetMostHate(){