diff options
author | Magnus Larsen <golgothasTerror101@gmail.com> | 2021-07-27 04:23:37 +0200 |
---|---|---|
committer | Magnus Larsen <golgothasTerror101@gmail.com> | 2021-07-27 04:50:10 +0200 |
commit | 388dd5cb00dde2053c7eb488c13d608a70ba330c (patch) | |
tree | beb5cd741983a93fb82cc40c884277cd96766480 | |
parent | Physical: division by zero fix (diff) | |
download | re3-388dd5cb00dde2053c7eb488c13d608a70ba330c.tar re3-388dd5cb00dde2053c7eb488c13d608a70ba330c.tar.gz re3-388dd5cb00dde2053c7eb488c13d608a70ba330c.tar.bz2 re3-388dd5cb00dde2053c7eb488c13d608a70ba330c.tar.lz re3-388dd5cb00dde2053c7eb488c13d608a70ba330c.tar.xz re3-388dd5cb00dde2053c7eb488c13d608a70ba330c.tar.zst re3-388dd5cb00dde2053c7eb488c13d608a70ba330c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/peds/Ped.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 4d80cac2..4c47ee7c 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -392,8 +392,21 @@ CPed::BuildPedLists(void) if (ped != this && !ped->bInVehicle) { float dist = (ped->GetPosition() - GetPosition()).Magnitude2D(); if (nThreatReactionRangeMultiplier * 30.0f > dist) { +#ifdef FIX_BUGS + static_assert( ARRAY_SIZE(m_nearPeds) < ARRAY_SIZE(gapTempPedList) - 1, "gapTempPedList needs wiggle room for unsorted peds and nil slot" ); + // 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)); } } |