MOHAWK: Improve Riven save/load error messages

This commit is contained in:
Matthew Hoops 2012-03-16 15:55:39 -04:00
parent 03be03bb47
commit 2f6528933d
3 changed files with 14 additions and 14 deletions

View File

@ -171,7 +171,7 @@ Common::Error MohawkEngine_Riven::run() {
error ("Could not find saved game"); error ("Could not find saved game");
// Attempt to load the game. On failure, just send us to the main menu. // Attempt to load the game. On failure, just send us to the main menu.
if (!_saveLoad->loadGame(savedGamesList[gameToLoad])) { if (_saveLoad->loadGame(savedGamesList[gameToLoad]).getCode() != Common::kNoError) {
changeToStack(aspit); changeToStack(aspit);
changeToCard(1); changeToCard(1);
} }
@ -729,7 +729,7 @@ void MohawkEngine_Riven::runLoadDialog() {
} }
Common::Error MohawkEngine_Riven::loadGameState(int slot) { Common::Error MohawkEngine_Riven::loadGameState(int slot) {
return _saveLoad->loadGame(_saveLoad->generateSaveGameList()[slot]) ? Common::kNoError : Common::kUnknownError; return _saveLoad->loadGame(_saveLoad->generateSaveGameList()[slot]);
} }
Common::Error MohawkEngine_Riven::saveGameState(int slot, const Common::String &desc) { Common::Error MohawkEngine_Riven::saveGameState(int slot, const Common::String &desc) {
@ -738,7 +738,7 @@ Common::Error MohawkEngine_Riven::saveGameState(int slot, const Common::String &
if ((uint)slot < saveList.size()) if ((uint)slot < saveList.size())
_saveLoad->deleteSave(saveList[slot]); _saveLoad->deleteSave(saveList[slot]);
return _saveLoad->saveGame(Common::String(desc)) ? Common::kNoError : Common::kUnknownError; return _saveLoad->saveGame(desc);
} }
Common::String MohawkEngine_Riven::getStackName(uint16 stack) const { Common::String MohawkEngine_Riven::getStackName(uint16 stack) const {

View File

@ -88,13 +88,13 @@ static uint16 mapNewStackIDToOld(uint16 newID) {
return 0; return 0;
} }
bool RivenSaveLoad::loadGame(Common::String filename) { Common::Error RivenSaveLoad::loadGame(Common::String filename) {
if (_vm->getFeatures() & GF_DEMO) // Don't load games in the demo if (_vm->getFeatures() & GF_DEMO) // Don't load games in the demo
return false; return Common::kNoError;
Common::InSaveFile *loadFile = _saveFileMan->openForLoading(filename); Common::InSaveFile *loadFile = _saveFileMan->openForLoading(filename);
if (!loadFile) if (!loadFile)
return false; return Common::kReadingFailed;
debug(0, "Loading game from \'%s\'", filename.c_str()); debug(0, "Loading game from \'%s\'", filename.c_str());
@ -103,7 +103,7 @@ bool RivenSaveLoad::loadGame(Common::String filename) {
if (!mhk->openStream(loadFile)) { if (!mhk->openStream(loadFile)) {
warning("Save file is not a Mohawk archive"); warning("Save file is not a Mohawk archive");
delete mhk; delete mhk;
return false; return Common::Error(Common::kUnknownError, "Invalid save file");
} }
// First, let's make sure we're using a saved game file from this version of Riven by checking the VERS resource // First, let's make sure we're using a saved game file from this version of Riven by checking the VERS resource
@ -114,7 +114,7 @@ bool RivenSaveLoad::loadGame(Common::String filename) {
|| (saveGameVersion == kDVDSaveGameVersion && !(_vm->getFeatures() & GF_DVD))) { || (saveGameVersion == kDVDSaveGameVersion && !(_vm->getFeatures() & GF_DVD))) {
warning("Incompatible saved game versions. No support for this yet"); warning("Incompatible saved game versions. No support for this yet");
delete mhk; delete mhk;
return false; return Common::Error(Common::kUnknownError, "Incompatible save version");
} }
// Now, we'll read in the variable values. // Now, we'll read in the variable values.
@ -206,7 +206,7 @@ bool RivenSaveLoad::loadGame(Common::String filename) {
delete zips; delete zips;
delete mhk; delete mhk;
return true; return Common::kNoError;
} }
Common::MemoryWriteStreamDynamic *RivenSaveLoad::genVERSSection() { Common::MemoryWriteStreamDynamic *RivenSaveLoad::genVERSSection() {
@ -273,7 +273,7 @@ Common::MemoryWriteStreamDynamic *RivenSaveLoad::genZIPSSection() {
return stream; return stream;
} }
bool RivenSaveLoad::saveGame(Common::String filename) { Common::Error RivenSaveLoad::saveGame(Common::String filename) {
// NOTE: This code is designed to only output a Mohawk archive // NOTE: This code is designed to only output a Mohawk archive
// for a Riven saved game. It's hardcoded to do this because // for a Riven saved game. It's hardcoded to do this because
// (as of right now) this is the only place in the engine // (as of right now) this is the only place in the engine
@ -295,7 +295,7 @@ bool RivenSaveLoad::saveGame(Common::String filename) {
Common::OutSaveFile *saveFile = _saveFileMan->openForSaving(filename); Common::OutSaveFile *saveFile = _saveFileMan->openForSaving(filename);
if (!saveFile) if (!saveFile)
return false; return Common::kWritingFailed;
debug (0, "Saving game to \'%s\'", filename.c_str()); debug (0, "Saving game to \'%s\'", filename.c_str());
@ -418,7 +418,7 @@ bool RivenSaveLoad::saveGame(Common::String filename) {
delete varsSection; delete varsSection;
delete zipsSection; delete zipsSection;
return true; return Common::kNoError;
} }
void RivenSaveLoad::deleteSave(Common::String saveName) { void RivenSaveLoad::deleteSave(Common::String saveName) {

View File

@ -42,8 +42,8 @@ public:
~RivenSaveLoad(); ~RivenSaveLoad();
Common::StringArray generateSaveGameList(); Common::StringArray generateSaveGameList();
bool loadGame(Common::String); Common::Error loadGame(Common::String);
bool saveGame(Common::String); Common::Error saveGame(Common::String);
void deleteSave(Common::String); void deleteSave(Common::String);
private: private: