From d923cd2f240d29a062c91a2b00c110f74986f281 Mon Sep 17 00:00:00 2001 From: Magnus Larsen Date: Mon, 26 Jul 2021 19:23:37 -0700 Subject: Allow sector ped count to exceed gap-list size This solves the gnNumTempPedList assertion. To prove this works, change gapTempPedList's length to 12, and visit the Triad's basketball court. # Conflicts: # src/peds/Ped.cpp --- src/peds/Ped.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/peds/Ped.cpp') diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index eadd9d64..7194d824 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -511,8 +511,20 @@ CPed::BuildPedLists(void) continue; deadsRegistered++; } +#ifdef FIX_BUGS + // If the gap ped list is full, sort it and truncate it + // before pushing more unsorted peds + if( gnNumTempPedList == ARRAY_SIZE(gapTempPedList) - 1 ) + { + gapTempPedList[gnNumTempPedList] = nil; + SortPeds(gapTempPedList, 0, gnNumTempPedList - 1); + gnNumTempPedList = ARRAY_SIZE(m_nearPeds); + } +#endif + gapTempPedList[gnNumTempPedList] = ped; gnNumTempPedList++; + // NOTE: We cannot absolutely fill the gap list, as the list is null-terminated before being passed to SortPeds assert(gnNumTempPedList < ARRAY_SIZE(gapTempPedList)); } } -- cgit v1.2.3