[Scummvm-git-logs] scummvm master -> c9b5c524cabb20d2db6924a388c23057d3c973d6
dreammaster
dreammaster at scummvm.org
Wed Jun 21 01:52:23 CEST 2017
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:
c9b5c524ca TITANIC: Show GUI error dialog if titanic.dat is missing
Commit: c9b5c524cabb20d2db6924a388c23057d3c973d6
https://github.com/scummvm/scummvm/commit/c9b5c524cabb20d2db6924a388c23057d3c973d6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-06-20T19:52:11-04:00
Commit Message:
TITANIC: Show GUI error dialog if titanic.dat is missing
Changed paths:
engines/titanic/support/files_manager.cpp
engines/titanic/support/files_manager.h
engines/titanic/titanic.cpp
engines/titanic/titanic.h
diff --git a/engines/titanic/support/files_manager.cpp b/engines/titanic/support/files_manager.cpp
index 8fd5107..5fc9379 100644
--- a/engines/titanic/support/files_manager.cpp
+++ b/engines/titanic/support/files_manager.cpp
@@ -30,21 +30,24 @@ namespace Titanic {
CFilesManager::CFilesManager(TitanicEngine *vm) : _vm(vm), _gameManager(nullptr),
_assetsPath("Assets"), _drive(-1) {
- loadResourceIndex();
}
CFilesManager::~CFilesManager() {
_datFile.close();
}
-void CFilesManager::loadResourceIndex() {
- if (!_datFile.open("titanic.dat"))
- error("Could not find titanic.dat data file");
+bool CFilesManager::loadResourceIndex() {
+ if (!_datFile.open("titanic.dat")) {
+ g_vm->GUIError("Could not find titanic.dat data file");
+ return false;
+ }
uint headerId = _datFile.readUint32BE();
uint version = _datFile.readUint16LE();
- if (headerId != MKTAG('S', 'V', 'T', 'N') || version < 1)
- error("Invalid data file");
+ if (headerId != MKTAG('S', 'V', 'T', 'N') || version < 1) {
+ g_vm->GUIError("titanic.dat has invalid contents");
+ return false;
+ }
// Read in entries
uint offset, size;
@@ -62,6 +65,8 @@ void CFilesManager::loadResourceIndex() {
_resources[resName] = ResourceEntry(offset, size);
}
+
+ return true;
}
bool CFilesManager::fileExists(const CString &name) {
diff --git a/engines/titanic/support/files_manager.h b/engines/titanic/support/files_manager.h
index 45b067e..7627ece 100644
--- a/engines/titanic/support/files_manager.h
+++ b/engines/titanic/support/files_manager.h
@@ -52,13 +52,16 @@ private:
CFilesManagerList _list;
int _drive;
const CString _assetsPath;
-private:
- void loadResourceIndex();
public:
CFilesManager(TitanicEngine *vm);
~CFilesManager();
/**
+ * Opens up the titanic.dat support file and loads it's index
+ */
+ bool loadResourceIndex();
+
+ /**
* Sets the game manager
*/
void setGameManager(CGameManager *gameManager) {
diff --git a/engines/titanic/titanic.cpp b/engines/titanic/titanic.cpp
index d95098c..ab3c961 100644
--- a/engines/titanic/titanic.cpp
+++ b/engines/titanic/titanic.cpp
@@ -77,9 +77,14 @@ void TitanicEngine::initializePath(const Common::FSNode &gamePath) {
SearchMan.addSubDirectoryMatching(gamePath, "assets");
}
-void TitanicEngine::initialize() {
- _debugger = new Debugger(this);
+bool TitanicEngine::initialize() {
_filesManager = new CFilesManager(this);
+ if (!_filesManager->loadResourceIndex()) {
+ delete _filesManager;
+ return false;
+ }
+
+ _debugger = new Debugger(this);
CSaveableObject::initClassList();
CEnterExitFirstClassState::init();
@@ -107,6 +112,7 @@ void TitanicEngine::initialize() {
setRoomNames();
_window->applicationStarting();
+ return true;
}
void TitanicEngine::deinitialize() {
@@ -132,14 +138,15 @@ void TitanicEngine::deinitialize() {
}
Common::Error TitanicEngine::run() {
- initialize();
+ if (initialize()) {
+ // Main event loop
+ while (!shouldQuit()) {
+ _events->pollEventsAndWait();
+ }
- // Main event loop
- while (!shouldQuit()) {
- _events->pollEventsAndWait();
+ deinitialize();
}
- deinitialize();
return Common::kNoError;
}
@@ -168,7 +175,6 @@ void TitanicEngine::setRoomNames() {
delete r;
}
-
bool TitanicEngine::canLoadGameStateCurrently() {
if (!_window->_inputAllowed)
return false;
@@ -227,4 +233,16 @@ CString TitanicEngine::getSavegameName(int slot) {
return CString();
}
+void TitanicEngine::GUIError(const char *msg, ...) {
+ char buffer[STRINGBUFLEN];
+ va_list va;
+
+ // Generate the full error message
+ va_start(va, msg);
+ vsnprintf(buffer, STRINGBUFLEN, msg, va);
+ va_end(va);
+
+ GUIErrorMessage(buffer);
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/titanic.h b/engines/titanic/titanic.h
index ea664a8..68f2445 100644
--- a/engines/titanic/titanic.h
+++ b/engines/titanic/titanic.h
@@ -80,7 +80,7 @@ private:
/**
* Handles basic initialization
*/
- void initialize();
+ bool initialize();
/**
* Handles game deinitialization
@@ -185,6 +185,11 @@ public:
* and if it exists, returns it's description
*/
CString getSavegameName(int slot);
+
+ /**
+ * Displays an error message in a GUI dialog
+ */
+ void GUIError(const char *msg, ...) GCC_PRINTF(2, 3);
};
extern TitanicEngine *g_vm;
More information about the Scummvm-git-logs
mailing list