Loading map with invalid version crashes editor #1100
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CEditorMap::Load returned true in some cases even if the map failed to load. CEditor::CallbackOpenMap didn't reset in case of a failed load.
In particular the editor checks MAPITEMTYPE_VERSION in the datafile to be 1 but just continues if it isn't (or if this item isn't even in the file) whereas the game itself doesn't use this item at all. It seems to have been used to distinguish the current map format from an older one (see CEditorMap::Load, game/editor/io.cpp:420)
This patch just gets rid of the crash (the map loading dialog will just stay open). It might be better to get rid of this version item along with the (mostly commented out) legacy code.
The patch is based on the 0.6 branch but the same problem exists in the development branch too.