added an assert to CPed::BuildPedLists, but too many peds still crash the game

This commit is contained in:
aap 2020-03-24 08:49:55 +01:00
parent 4070cad4a7
commit 55b62e2134

View File

@ -2213,15 +2213,18 @@ CPed::BuildPedLists(void)
} }
} else { } else {
CVector centre = CEntity::GetBoundCentre(); CVector centre = CEntity::GetBoundCentre();
CRect rect( CRect rect(centre.x - 20.0f,
CWorld::GetSectorX(centre.x - 20.0f), centre.y - 20.0f,
CWorld::GetSectorY(centre.y - 20.0f), centre.x + 20.0f,
CWorld::GetSectorX(centre.x + 20.0f), centre.y + 20.0f);
CWorld::GetSectorY(centre.y + 20.0f)); int xstart = CWorld::GetSectorIndexX(rect.left);
int ystart = CWorld::GetSectorIndexY(rect.top);
int xend = CWorld::GetSectorIndexX(rect.right);
int yend = CWorld::GetSectorIndexY(rect.bottom);
gnNumTempPedList = 0; gnNumTempPedList = 0;
for(int y = rect.top; y <= rect.bottom; y++) { for(int y = ystart; y <= yend; y++) {
for(int x = rect.left; x <= rect.right; x++) { for(int x = xstart; x <= xend; x++) {
for (CPtrNode *pedPtrNode = CWorld::GetSector(x,y)->m_lists[ENTITYLIST_PEDS].first; pedPtrNode; pedPtrNode = pedPtrNode->next) { for (CPtrNode *pedPtrNode = CWorld::GetSector(x,y)->m_lists[ENTITYLIST_PEDS].first; pedPtrNode; pedPtrNode = pedPtrNode->next) {
CPed *ped = (CPed*)pedPtrNode->item; CPed *ped = (CPed*)pedPtrNode->item;
if (ped != this && !ped->bInVehicle) { if (ped != this && !ped->bInVehicle) {
@ -2229,6 +2232,7 @@ CPed::BuildPedLists(void)
if (nThreatReactionRangeMultiplier * 30.0f > dist) { if (nThreatReactionRangeMultiplier * 30.0f > dist) {
gapTempPedList[gnNumTempPedList] = ped; gapTempPedList[gnNumTempPedList] = ped;
gnNumTempPedList++; gnNumTempPedList++;
assert(gnNumTempPedList < ARRAYSIZE(gapTempPedList));
} }
} }
} }