Skip to content

GRIM: Fix unknown key error when loading savegame #2790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2021

Conversation

criezy
Copy link
Member

@criezy criezy commented Feb 21, 2021

A user reported a crash with Unknown key! error when trying to load a save game in MI4 today on IRC/Discord.
@henke37 suggested that the likely culprit was the code changed in this pull request.

I don't have the game, and the demo doesn't let me save games. So I am unable to test this. This is why I am proposing this as a pull request so that developers who know the engine or can at least test it can validate the change.

@@ -314,8 +314,9 @@ void PoolObject<T>::Pool::restoreObjects(SaveGame *state) {
Common::HashMap<int32, T *> tempMap;
for (int32 i = 0; i < size; ++i) {
int32 id = state->readLESint32();
T *t = _map.getVal(id);
_map.erase(id);
T *t = nullptr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe?
T *t = _map.getValOrDefault(id, nullptr);

@criezy criezy force-pushed the mission-impossible-4 branch from 289f686 to 894a992 Compare March 7, 2021 19:54
@criezy
Copy link
Member Author

criezy commented Mar 7, 2021

I forgot about this pull request and I will merge it now. I think the change is pretty safe.

@criezy criezy merged commit 2da0a3e into scummvm:master Mar 7, 2021
@criezy criezy deleted the mission-impossible-4 branch July 12, 2021 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants