[Scummvm-git-logs] scummvm master -> 8f89a66940bea0c3576e73cba5a2321e51bcda67
alxpnv
a04198622 at gmail.com
Wed Sep 22 12:53:10 UTC 2021
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
2145019341 ASYLUM: fix signed/unsigned mismatch
4901928d5c ASYLUM: allow loading of savegames from the previous versions of the game
c368834a9e ASYLUM: fix memory leak
8f89a66940 ASYLUM: fix crash on exit
Commit: 2145019341eb6aaa9a26135173afdbd2d47b3c73
https://github.com/scummvm/scummvm/commit/2145019341eb6aaa9a26135173afdbd2d47b3c73
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-09-22T15:54:49+03:00
Commit Message:
ASYLUM: fix signed/unsigned mismatch
Reported by Henke37
Changed paths:
engines/asylum/puzzles/pipes.cpp
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 7ce2a259bc..f9d7739723 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -596,7 +596,7 @@ uint32 PuzzlePipes::checkFlags() {
void PuzzlePipes::checkConnections() {
for (uint32 i = 0; i < connectorsCount; i++) {
- uint32 oldState = _connectors[i].getState(),
+ BinNum oldState = _connectors[i].getState(),
newState = calcStateFromPosition(_connectors[i].getType(), _positions[i]);
if (oldState != newState) {
do {
Commit: 4901928d5c2d56b140651d20fd18c331dc7e15fb
https://github.com/scummvm/scummvm/commit/4901928d5c2d56b140651d20fd18c331dc7e15fb
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-09-22T15:54:50+03:00
Commit Message:
ASYLUM: allow loading of savegames from the previous versions of the game
Changed paths:
engines/asylum/POTFILES
engines/asylum/asylum.cpp
engines/asylum/system/savegame.cpp
engines/asylum/system/savegame.h
diff --git a/engines/asylum/POTFILES b/engines/asylum/POTFILES
index dce3cb64ba..f64e4bdeb6 100644
--- a/engines/asylum/POTFILES
+++ b/engines/asylum/POTFILES
@@ -1 +1,2 @@
engines/asylum/metaengine.cpp
+engines/asylum/system/savegame.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 5cac55169e..a2aa07b78b 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -25,9 +25,12 @@
#include "common/achievements.h"
#include "common/debug-channels.h"
#include "common/rect.h"
+#include "common/translation.h"
#include "engines/util.h"
+#include "gui/message.h"
+
#include "asylum/asylum.h"
#include "asylum/resources/actor.h"
@@ -193,6 +196,16 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
if (!_cursor || !_screen || !_savegame)
error("[AsylumEngine::startGame] Subsystems not initialized properly!");
+ if (type == kStartGameLoad && !_savegame->isCompatible()) {
+ Common::U32String message = _("Attempt to load saved game from a previous version: Version %s / Build %d");
+ GUI::MessageDialog dialog(Common::U32String::format(message, _savegame->getVersion(), _savegame->getBuild()), _("Load anyway"), _("Cancel"));
+
+ if (dialog.runModal() != GUI::kMessageOK) {
+ _menu->setDword455C80(false);
+ return;
+ }
+ }
+
// Load the default mouse cursor
if (!checkGameVersion("Demo"))
_cursor->set(MAKE_RESOURCE(kResourcePackSound, 14), 0, kCursorAnimationNone);
@@ -252,11 +265,10 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
break;
case kStartGameLoad:
- if (_savegame->load()) {
- _scene->enterLoad();
- updateReverseStereo();
- switchEventHandler(_scene);
- }
+ _sound->stopAll();
+ _savegame->load();
+ _scene->enterLoad();
+ updateReverseStereo();
break;
case kStartGameScene:
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index e56c9ebe6b..720705a753 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -49,7 +49,7 @@ namespace Asylum {
static const char *savegame_version = "v1.01 FINAL";
-Savegame::Savegame(AsylumEngine *engine) : _vm(engine), _index(0), _valid(false) {
+Savegame::Savegame(AsylumEngine *engine) : _vm(engine), _index(0) {
memset(&_moviesViewed, 0, sizeof(_moviesViewed));
memset(&_savegames, 0, sizeof(_savegames));
memset(&_savegameToScene, 0, sizeof(_savegameToScene));
@@ -88,14 +88,7 @@ void Savegame::loadList() {
}
}
-bool Savegame::load() {
- if (!check()) {
- getMenu()->setDword455C78(true);
- getMenu()->setDword455C80(false);
-
- return false;
- }
-
+void Savegame::load() {
getCursor()->hide();
// Original clears the graphic cache
getScript()->resetQueue();
@@ -104,20 +97,12 @@ bool Savegame::load() {
_vm->reset();
// Original loads encounter data
- if (!loadData(getFilename(_index))) {
- // FIXME convert to GUI dialog
- if (_valid)
- error("[Savegame::load] Could not load game!");
- else
- error("[Savegame::load] Trying to load a game for a different version of Sanitarium!");
- }
+ loadData(getFilename(_index));
loadMoviesViewed();
getMenu()->setDword455C80(false);
getScreen()->clear();
-
- return true;
}
bool Savegame::quickLoad() {
@@ -134,17 +119,9 @@ void Savegame::save() {
// Original creates a folder to hold saved games and checks for disk space, we can skip that
getCursor()->hide();
- if (saveData(getFilename(_index), _names[_index], getWorld()->chapter)) {
- _savegames[_index] = true;
-
- getMenu()->setDword455C78(true);
- } else {
- warning("[Savegame::save] Could not save game: %s", getFilename(_index).c_str());
-
- _savegames[_index] = false;
- _names[_index] = getText()->get(MAKE_RESOURCE(kResourcePackText, 1344));
- }
-
+ saveData(getFilename(_index), _names[_index], getWorld()->chapter);
+ _savegames[_index] = true;
+ getMenu()->setDword455C78(true);
getMenu()->setDword455C80(false);
getCursor()->show();
}
@@ -192,20 +169,16 @@ void Savegame::remove() {
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
-bool Savegame::check() {
+bool Savegame::isCompatible() {
Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(getFilename(_index));
- if (!file)
- return false;
+ assert(file);
seek(file, 2, "Level and Name");
-
- bool valid = false;
- if (readHeader(file))
- valid = true;
+ bool result = readHeader(file);
delete file;
- return valid;
+ return result;
}
Common::String Savegame::getFilename(uint32 index) const {
@@ -235,18 +208,11 @@ bool Savegame::isSavegamePresent(const Common::String &filename) const {
//////////////////////////////////////////////////////////////////////////
bool Savegame::readHeader(Common::InSaveFile *file) {
uint32 versionLength = read(file, "Version Length");
- Common::String version = read(file, versionLength, "Version");
- uint32 build = read(file, "Build");
+ _version = read(file, versionLength, "Version");
+ _build = read(file, "Build");
// Original does not do any version check
- // Until we can verify all versions have compatible savegames, we only handle the final patched version savegames
- if (version != Common::String(savegame_version) || build != SAVEGAME_BUILD) {
- _valid = false;
- return false;
- }
-
- _valid = true;
- return true;
+ return !strcmp(_version.c_str(), savegame_version) && _build == SAVEGAME_BUILD;
}
void Savegame::writeHeader(Common::OutSaveFile *file) const {
@@ -257,20 +223,14 @@ void Savegame::writeHeader(Common::OutSaveFile *file) const {
write(file, SAVEGAME_BUILD, "Build");
}
-bool Savegame::loadData(const Common::String &filename) {
+void Savegame::loadData(const Common::String &filename) {
Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(filename);
- if (!file) {
- getWorld()->chapter = kChapterInvalid;
- return false;
- }
+ assert(file);
seek(file, 1, "Level");
seek(file, 1, "Game Name");
- if (!readHeader(file)) {
- getWorld()->chapter = kChapterInvalid;
- return false;
- }
+ (void)readHeader(file);
read(file, _vm, 1512, 1, "Game Stats");
read(file, getWorld(), 951928, 1, "World Stats");
@@ -288,14 +248,11 @@ bool Savegame::loadData(const Common::String &filename) {
_vm->setTick(tick);
delete file;
-
- return true;
}
-bool Savegame::saveData(const Common::String &filename, const Common::String &name, ChapterIndex chapter) {
+void Savegame::saveData(const Common::String &filename, const Common::String &name, ChapterIndex chapter) {
Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(filename);
- if (!file)
- return false;
+ assert(file);
write(file, (unsigned) (int32)chapter, "Level");
write(file, name, SAVEGAME_NAME_SIZE, "Game Name");
@@ -314,8 +271,6 @@ bool Savegame::saveData(const Common::String &filename, const Common::String &na
_vm->getMetaEngine()->appendExtendedSaveToStream(file, _vm->getTotalPlayTime() / 1000, name, false);
delete file;
-
- return true;
}
void Savegame::seek(Common::InSaveFile *file, uint32 offset, const Common::String &description) {
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index 6ec51b9440..13098d5283 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -54,10 +54,8 @@ public:
/**
* Loads a game
- *
- * @return true if it succeeds, false if it fails.
*/
- bool load();
+ void load();
/**
* Quick loads a game
@@ -85,6 +83,13 @@ public:
*/
void remove();
+ /**
+ * Checks if a savegame is compatible
+ *
+ * @return true if it is, false otherwise.
+ */
+ bool isCompatible();
+
//////////////////////////////////////////////////////////////////////////
// Static methods
//////////////////////////////////////////////////////////////////////////
@@ -179,6 +184,9 @@ public:
bool hasSavegame(uint32 index) const;
ResourcePackId getScenePack() { return (ResourcePackId)(_savegameToScene[_index] + 4); }
+ const char *getVersion() { return _version.c_str(); }
+ uint32 getBuild() { return _build; }
+
private:
AsylumEngine* _vm;
@@ -187,18 +195,13 @@ private:
uint32 _savegameToScene[SAVEGAME_COUNT];
bool _savegames[SAVEGAME_COUNT];
Common::String _names[SAVEGAME_COUNT];
- bool _valid;
+ Common::String _version;
+ uint32 _build;
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
- /**
- * Checks if a savegame is valid
- *
- * @return true if it succeeds, false if it fails.
- */
- bool check();
/**
* Gets a filename for a given save index
@@ -242,10 +245,8 @@ private:
* Loads savegame data
*
* @param filename Filename of the file.
- *
- * @return true if it succeeds, false if it fails.
*/
- bool loadData(const Common::String &filename);
+ void loadData(const Common::String &filename);
/**
* Save savegame data.
@@ -253,10 +254,8 @@ private:
* @param filename Filename of the file.
* @param name The name.
* @param chapter The chapter.
- *
- * @return true if it succeeds, false if it fails.
*/
- bool saveData(const Common::String &filename, const Common::String &name, ChapterIndex chapter);
+ void saveData(const Common::String &filename, const Common::String &name, ChapterIndex chapter);
};
} // End of namespace Asylum
Commit: c368834a9e51d4384cda3c33620a9e99ff2fec69
https://github.com/scummvm/scummvm/commit/c368834a9e51d4384cda3c33620a9e99ff2fec69
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-09-22T15:54:50+03:00
Commit Message:
ASYLUM: fix memory leak
Changed paths:
engines/asylum/metaengine.cpp
diff --git a/engines/asylum/metaengine.cpp b/engines/asylum/metaengine.cpp
index 721ebdbc01..0c7d46fcc3 100644
--- a/engines/asylum/metaengine.cpp
+++ b/engines/asylum/metaengine.cpp
@@ -82,10 +82,14 @@ SaveStateDescriptor AsylumMetaEngine::querySaveMetaInfos(const char *target, int
if (desc.getSaveSlot() == -1) {
Common::InSaveFile *in(g_system->getSavefileManager()->openForLoading(getSavegameFile(slot, target)));
- if (in && in->size()) {
- (void)(uint32)Asylum::Savegame::read(in, "Chapter");
- desc.setSaveSlot(slot);
- desc.setDescription(Asylum::Savegame::read(in, 45, "Game Name"));
+ if (in) {
+ if (in->size() > 60) {
+ (void)(uint32)Asylum::Savegame::read(in, "Chapter");
+ desc.setSaveSlot(slot);
+ desc.setDescription(Asylum::Savegame::read(in, 45, "Game Name"));
+ }
+
+ delete in;
}
}
Commit: 8f89a66940bea0c3576e73cba5a2321e51bcda67
https://github.com/scummvm/scummvm/commit/8f89a66940bea0c3576e73cba5a2321e51bcda67
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-09-22T15:54:50+03:00
Commit Message:
ASYLUM: fix crash on exit
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index a2aa07b78b..cde3f39cdd 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -189,6 +189,10 @@ Common::Error AsylumEngine::run() {
checkAchievements();
}
+ // Stop all sounds & music
+ _sound->stopMusic();
+ _sound->stopAll();
+
return Common::kNoError;
}
@@ -265,6 +269,8 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
break;
case kStartGameLoad:
+ // Stop all sounds & music
+ _sound->stopMusic();
_sound->stopAll();
_savegame->load();
_scene->enterLoad();
More information about the Scummvm-git-logs
mailing list