Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
game.cpp: Fix loading commander droids without
psGroup
When a commander transitions from an offworld mission, it will currently lose its group (actually, this is kind of a bug, too), i.e. its `psGroup` is `nullptr`. If a player attempts to save the game right after this transition and then loads the savegame again, the game will crash. `loadSaveDroid()` function will try to allocate a new group for these "orphaned" returning commanders. But this new group ID is not in sync with other group IDs that may already be present in the currently-processed "droid.json" file and thus may clash with other groups, leading to various memory-related bugs. For example, this may happen when there is a commander back at the players' base with some commander group assigned. There is a non-zero probability that the commander which returns from an offworld mission, will try to allocate the same group ID as the commander back at the base. Signed-off-by: Pavel Solodovnikov <[email protected]>
- Loading branch information