From 20afbe95e64b4368d1380a533598fea8aa90dbd5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 6 Nov 2012 12:08:55 +0200 Subject: DREAMWEB: Fix bug #3582582 - "GUI: "Grid View" Loader Triggers Immediately in Dreamweb" --- engines/dreamweb/saveload.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'engines/dreamweb/saveload.cpp') diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp index ea9cdc0249..162ad53cde 100644 --- a/engines/dreamweb/saveload.cpp +++ b/engines/dreamweb/saveload.cpp @@ -156,8 +156,16 @@ void DreamWebEngine::doLoad(int savegameId) { } else { if (savegameId == -1) { - // Open dialog to get savegameId + // Wait till both mouse buttons are up. We should wait till the user + // releases the mouse button, otherwise the follow-up mouseup event + // will trigger a load of the save slot under the mouse cursor. Fixes + // bug #3582582. + while (_oldMouseState > 0) { + readMouse(); + g_system->delayMillis(10); + } + // Open dialog to get savegameId GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); savegameId = dialog->runModalWithCurrentTarget(); delete dialog; @@ -241,6 +249,15 @@ void DreamWebEngine::saveGame() { } return; } else { + // Wait till both mouse buttons are up. We should wait till the user + // releases the mouse button, otherwise the follow-up mouseup event + // will trigger a save into the save slot under the mouse cursor. Fixes + // bug #3582582. + while (_oldMouseState > 0) { + readMouse(); + g_system->delayMillis(10); + } + GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); int savegameId = dialog->runModalWithCurrentTarget(); Common::String game_description = dialog->getResultString(); -- cgit v1.2.3 From 02fe2ded354ecbfd87acdc4493be4b41a759d1d9 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 1 Dec 2012 12:29:17 +0100 Subject: DREAMWEB: Check for exFrame data corruption on load This provides earlier detection for corrupted savegames caused by bug #3591088 --- engines/dreamweb/saveload.cpp | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'engines/dreamweb/saveload.cpp') diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp index 162ad53cde..8a0791d19b 100644 --- a/engines/dreamweb/saveload.cpp +++ b/engines/dreamweb/saveload.cpp @@ -574,6 +574,14 @@ void DreamWebEngine::savePosition(unsigned int slot, const char *descbuf) { delete outSaveFile; } + +// Utility struct for a savegame sanity check in loadPosition +struct FrameExtent { + uint16 start; + uint16 length; + bool operator<(const struct FrameExtent& other) const { return start flist; + for (unsigned int i = 0; i < kNumexobjects; ++i) { + if (_exData[i].mapad[0] != 0xff) { + FrameExtent fe; + Frame *frame = &_exFrames._frames[3*i+0]; + fe.start = frame->ptr(); + fe.length = frame->width * frame->height; + flist.push_back(fe); + + frame = &_exFrames._frames[3*i+1]; + fe.start = frame->ptr(); + fe.length = frame->width * frame->height; + flist.push_back(fe); + } + } + // ...and check if the frames overlap. + Common::sort(flist.begin(), flist.end(), Common::Less()); + Common::List::const_iterator iter; + uint16 curEnd = 0; + for (iter = flist.begin(); iter != flist.end(); ++iter) { + if (iter->start < curEnd) + error("exFrames data corruption in savegame"); + curEnd = iter->start + iter->length; + } + if (curEnd > _vars._exFramePos) { + if (curEnd > kExframeslen) + error("exFrames data corruption in savegame"); + warning("Fixing up exFramePos"); + _vars._exFramePos = curEnd; + } + // (end of sanity check) } // Count number of save files, and load their descriptions into _saveNames -- cgit v1.2.3