Hatelist crash fix

This commit is contained in:
SecretsOTheP 2014-04-20 20:54:21 -04:00
parent c16fe3c810
commit 8aa13b51f4
2 changed files with 12 additions and 0 deletions

View File

@ -4,6 +4,7 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50)
Secrets: Changed the functionality of EQDEBUG cmake flag. It now suppresses logs, but shows crashes in any scenario when set to 1. It will also now show crashes even if the log system is disabled.
KLS: Change to how quest signals work, signals with no delay will now be added to the signal queue. This addresses an odd timing issue where NPCs are in a state of life/death flux when a signal from event_death goes off.
KLS: Added cmake flags to define how logging behavior works for each different log type.
Secrets: Crash fix for Hatelist crash observed
== 04/18/2014 ==
Akkadius: Added #command error message suppression for those who don't want to see 'Command is not recognized' constantly

View File

@ -445,6 +445,17 @@ Mob *HateList::GetMostHate(){
Mob *HateList::GetRandom()
{
int count = list.size();
if(count == 0) //If we don't have any entries it'll crash getting a random 0, -1 position.
return NULL;
if(count == 1) //No need to do all that extra work if we only have one hate entry
{
if(*list.begin()) // Just in case tHateEntry is invalidated somehow...
return (*list.begin())->ent;
return NULL;
}
auto iterator = list.begin();
int random = MakeRandomInt(0, count - 1);
for (int i = 0; i < random; i++)