Closed V-Sarthou closed 9 months ago
I wonder if it makes more sense to prevent the push_back if full()
already. Though I do not know if that in and of itself is the most correct fix still.
Hello and thank you for your response,
The mNeighbors vector is cleared just before the loop, and the only side effect of the loop is the push_back()
in the vector, so it made sense to me to just exit the loop as soon as the vector is full, since continuing the loop would be useless.
I guess the selected neighbors are not guaranteed to be the "best" neighbors out of the bigger list returned by gi.EntitiesInBox()
.
At least, it does not change the current behavior in non-crashing scenarios.
Sorting the EntitiesInBox()
output before iterating it seems to be a change in behaviour.
Another way of fixing this is to edit the for loop condition to i<numFound && !suser.mNeighbors.full()
but thats just preference at this point.
We loop over EntityList, which can contain MAX_GENTITIES values, but mNeighbors can only contain STEER::MAX_NEIGHBORS values.
I encountered the crash on Windows x64 (with a custom build based on 90e8005b0cef3ce3405ad3f0011a204ca78e4c37) by using the following commands:
Here is the complete callstack i got in Debug:
The assert in the push_back() function fails because mSize == CAPACITY (==20)
I am not sure if this is the most appropriate way to fix the crash, but I still wanted to share this find.