haekb / nolf2-modernizer

NOLF 2 Modernizer aims to unlock resolution support, restore multi-player support, and fix a few bugs here and there.
https://haekb.itch.io/nolf2-modernizer
30 stars 4 forks source link

LiteObjectMgr crashing #9

Closed haekb closed 4 years ago

haekb commented 4 years ago

Seems on a particular save file on the first Siberia map, if I quit out, or your pilot activates a certain light switch we get some fun crashing going on!

The object seems to be in the master object list twice, so the first time over it has its memory freed, and then it tries to ->GetClass() on it, and since it's already freed it crashes.

haekb commented 4 years ago

LightSimple02b_13x11x1310.Controller seems to the specific light. I'm not sure if it's also the entity causing crashing during the game destruction.

haekb commented 4 years ago

So this object isn't saved on my quick save, but it is saved on the autosave. I wonder if the object is in an invalid state and is removed by another system sometime after the autosave?

haekb commented 4 years ago

Yeah. So the quick save doesn't seem to save as much stuff as the autosave does.

Very odd. But it makes quick saves more reliable. Oddly enough the assert caused by LightSimple02b_13x11x1310 in the autosave, doesn't seem to occur if I directly load the level. However the disconnection crash still occurs.

haekb commented 4 years ago

Turns out this was caused by CleanList which clears out any null items from the object list. Due to the STLPort->MSVC STD changes I assume this probably worked with STLPort, however it very clearly removes non-null items.

I've replaced it with a std::erase -> std::remove_if -> item == null https://github.com/haekb/nolf2-modernizer/commit/57f3e6a430b2cfd3ffc919c6c08b6fa18f548a9cl

Using the in-game performance counter it's actually faster with larger lists, and pretty much the same with smaller lists. So I'll call that a win.