storm-devs / storm-engine

Game engine behind Sea Dogs, Pirates of the Caribbean and Age of Pirates games.
https://storm-devs.github.io/storm-engine
GNU General Public License v3.0
847 stars 120 forks source link

Fix IsEntity sometimes returning true for previously deleted entities #508

Open Hammie opened 1 year ago

Hammie commented 1 year ago

When deleting an entity, saving the game and then loading that save game, it is possible for a newly created entity to have the same id as the old deleted entity id.

If the old entity variable is not yet overwritten, it will then return true for IsEntity(&entity).

This can be fixed by making sure the variable value is reset after calling DeleteEntity

Also fixes https://github.com/PiratesAhoy/new-horizons/issues/141

espkk commented 1 year ago

While it helps in some cases it's not the root cause and has to be fixed differently... So, we probably don't want to merge this. Instead, we shouldn't zero the cookie counter during entity manager's full-erase