mirror of
https://github.com/EQEmu/Server.git
synced 2026-08-29 16:58:02 +00:00
Hatelist crash fix
This commit is contained in:
@@ -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++)
|
||||
|
||||
Reference in New Issue
Block a user