summaryrefslogtreecommitdiff
path: root/src/peds/Ped.cpp
diff options
context:
space:
mode:
authorerorcun <erorcunerorcun@hotmail.com.tr>2021-07-27 21:51:28 +0300
committerGitHub <noreply@github.com>2021-07-27 21:51:28 +0300
commit1eedf7f0ae9ed1cf5559e1458b4a8b0b25e8e67e (patch)
tree48646df1a9e222727a953aee6f79787a728bf1ba /src/peds/Ped.cpp
parentd77ed4608f22d853452a4e220b7f76f85c2d3b76 (diff)
parent55e83982c31a18474a7789f1a966a25934ad37f8 (diff)
Merge pull request #1257 from Nopey/fixbugs_pedgaplist
Fix bug triggering gnNumTempPedList assertion
Diffstat (limited to 'src/peds/Ped.cpp')
-rw-r--r--src/peds/Ped.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 147b1218..3ccae5d0 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -393,8 +393,20 @@ CPed::BuildPedLists(void)
if (ped != this && !ped->bInVehicle) {
float dist = (ped->GetPosition() - GetPosition()).Magnitude2D();
if (nThreatReactionRangeMultiplier * 30.0f > dist) {
+#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));
}
}