[Scummvm-git-logs] scummvm master -> 869dd417c8997fce2336a3e01a85d87701db1915
OMGPizzaGuy
noreply at scummvm.org
Wed Dec 7 03:31:26 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
869dd417c8 ULTIMA8: Cleanup save game debugger command
Commit: 869dd417c8997fce2336a3e01a85d87701db1915
https://github.com/scummvm/scummvm/commit/869dd417c8997fce2336a3e01a85d87701db1915
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2022-12-06T21:31:05-06:00
Commit Message:
ULTIMA8: Cleanup save game debugger command
Changed paths:
engines/ultima/ultima8/gumps/u8_save_gump.cpp
engines/ultima/ultima8/misc/debugger.cpp
engines/ultima/ultima8/ultima8.cpp
engines/ultima/ultima8/ultima8.h
diff --git a/engines/ultima/ultima8/gumps/u8_save_gump.cpp b/engines/ultima/ultima8/gumps/u8_save_gump.cpp
index 9ed67a32ebf..108014135c2 100644
--- a/engines/ultima/ultima8/gumps/u8_save_gump.cpp
+++ b/engines/ultima/ultima8/gumps/u8_save_gump.cpp
@@ -274,14 +274,17 @@ bool U8SaveGump::loadgame(int saveIndex) {
bool U8SaveGump::savegame(int saveIndex, const Std::string &name) {
pout << "Save " << saveIndex << ": \"" << name << "\"" << Std::endl;
- if (name.empty()) return false;
+ if (name.empty())
+ return false;
// We are saving, close parent (and ourselves) first so it doesn't
// block the save or appear in the screenshot
_parent->Close();
- Ultima8Engine::get_instance()->saveGame(saveIndex, name);
- return true;
+ if (!Ultima8Engine::get_instance()->canSaveGameStateCurrently())
+ return false;
+
+ return Ultima8Engine::get_instance()->saveGameState(saveIndex, name).getCode() == Common::kNoError;
}
void U8SaveGump::loadDescriptions() {
diff --git a/engines/ultima/ultima8/misc/debugger.cpp b/engines/ultima/ultima8/misc/debugger.cpp
index 5d445ff1d0e..d1cf0d772d8 100644
--- a/engines/ultima/ultima8/misc/debugger.cpp
+++ b/engines/ultima/ultima8/misc/debugger.cpp
@@ -258,8 +258,17 @@ void Debugger::executeCommand(const Common::Array<Common::String> &argv) {
bool Debugger::cmdSaveGame(int argc, const char **argv) {
if (argc == 2) {
+ if (!Ultima8Engine::get_instance()->canSaveGameStateCurrently()) {
+ debugPrintf("Saving game is currently unavailable\n");
+ return true;
+ }
+
// Save a _game with the given name into the quicksave slot
- Ultima8Engine::get_instance()->saveGame(1, argv[1]);
+ Common::Error result = Ultima8Engine::get_instance()->saveGameState(1, argv[1]);
+ if (result.getCode() != Common::kNoError) {
+ debugPrintf("Saving game failed: %s\n", result.getDesc().c_str());
+ return true;
+ }
} else {
Ultima8Engine::get_instance()->saveGameDialog();
}
@@ -790,7 +799,8 @@ bool Debugger::cmdDumpMap(int argc, const char **argv) {
// Save because we're going to potentially break the game by enlarging
// the fast area and available object IDs.
int slot = Ultima8Engine::get_instance()->getAutosaveSlot();
- if (!Ultima8Engine::get_instance()->saveGame(slot, "Pre-dumpMap save")) {
+ Common::Error result = Ultima8Engine::get_instance()->saveGameState(slot, "Pre-dumpMap save");
+ if (result.getCode() != Common::kNoError) {
debugPrintf("Could not dump map: pre-dumpMap save failed\n");
return false;
}
@@ -816,7 +826,8 @@ bool Debugger::cmdDumpAllMaps(int argc, const char **argv) {
// Save because we're going to potentially break the game by enlarging
// the fast area and available object IDs and changing maps
int slot = Ultima8Engine::get_instance()->getAutosaveSlot();
- if (!Ultima8Engine::get_instance()->saveGame(slot, "Pre-dumpMap save")) {
+ Common::Error result = Ultima8Engine::get_instance()->saveGameState(slot, "Pre-dumpMap save");
+ if (result.getCode() != Common::kNoError) {
debugPrintf("Could not dump map: pre-dumpMap save failed\n");
return false;
}
diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index 7512d9e6eb3..bde19bed0aa 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -957,24 +957,6 @@ bool Ultima8Engine::canSaveGameStateCurrently(bool isAutosave) {
return true;
}
-bool Ultima8Engine::saveGame(int slot, const Std::string &desc) {
- // Check for gumps that prevent saving
- if (_desktopGump->FindGump(&HasPreventSaveFlag, true)) {
- pout << "Can't save: open gump preventing save." << Std::endl;
- return false;
- }
-
- // Don't allow saving when avatar is dead.
- // (Avatar is flagged dead by usecode when you finish the _game as well.)
- MainActor *av = getMainActor();
- if (!av || av->hasActorFlags(Actor::ACT_DEAD)) {
- pout << "Can't save: game over." << Std::endl;
- return false;
- }
-
- return saveGameState(slot, desc).getCode() == Common::kNoError;
-}
-
Common::Error Ultima8Engine::loadGameState(int slot) {
Common::Error result = Shared::UltimaEngine::loadGameState(slot);
if (result.getCode() == Common::kNoError)
diff --git a/engines/ultima/ultima8/ultima8.h b/engines/ultima/ultima8/ultima8.h
index 606ce81e3d7..6bc5e047d90 100644
--- a/engines/ultima/ultima8/ultima8.h
+++ b/engines/ultima/ultima8/ultima8.h
@@ -341,11 +341,6 @@ public:
*/
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave) override;
- //! save a game
- //! \param filename the file to save to
- //! \return true if successful
- bool saveGame(int slot, const Std::string &desc);
-
//! start a new game
//! \return true if successful.
bool newGame(int saveSlot = -1);
More information about the Scummvm-git-logs
mailing list