aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/glulxe/glulxe.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2018-12-08 17:28:57 -0800
committerPaul Gilbert2018-12-08 19:05:59 -0800
commitac9830614d07d80f0c02d9d7c75d709f9d534466 (patch)
treec87d78b6a90fbe405a9f34dfe2efd847b9d6e1ec /engines/glk/glulxe/glulxe.cpp
parent290196946dab0ee60498be16d8e33bb911e5a166 (diff)
downloadscummvm-rg350-ac9830614d07d80f0c02d9d7c75d709f9d534466.tar.gz
scummvm-rg350-ac9830614d07d80f0c02d9d7c75d709f9d534466.tar.bz2
scummvm-rg350-ac9830614d07d80f0c02d9d7c75d709f9d534466.zip
GLK: GLULXE: Validate game file version
Diffstat (limited to 'engines/glk/glulxe/glulxe.cpp')
-rw-r--r--engines/glk/glulxe/glulxe.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/engines/glk/glulxe/glulxe.cpp b/engines/glk/glulxe/glulxe.cpp
index 25af4c2f4d..e2e1a477e5 100644
--- a/engines/glk/glulxe/glulxe.cpp
+++ b/engines/glk/glulxe/glulxe.cpp
@@ -27,10 +27,16 @@
namespace Glk {
namespace Glulxe {
-Glulxe::Glulxe(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc) {
+Glulxe::Glulxe(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc),
+ vm_exited_cleanly(false) {
}
void Glulxe::runGame(Common::SeekableReadStream *gameFile) {
+ _gameFile = gameFile;
+
+ if (!is_gamefile_valid())
+ return;
+
// TODO
}
@@ -44,5 +50,30 @@ Common::Error Glulxe::saveGameData(strid_t file, const Common::String &desc) {
return Common::kNoError;
}
+bool Glulxe::is_gamefile_valid() {
+ if (_gameFile->size() < 8) {
+ GUIError(_("This is too short to be a valid Glulx file."));
+ return false;
+ }
+
+ if (_gameFile->readUint32BE() != MKTAG('G', 'l', 'u', 'l')) {
+ GUIError(_("This is not a valid Glulx file."));
+ return false;
+ }
+
+ // We support version 2.0 through 3.1.*
+ uint version = _gameFile->readUint32BE();
+ if (version < 0x20000) {
+ GUIError(_("This Glulx file is too old a version to execute."));
+ return false;
+ }
+ if (version >= 0x30200) {
+ GUIError(_("This Glulx file is too new a version to execute."));
+ return false;
+ }
+
+ return true;
+}
+
} // End of namespace Glulxe
} // End of namespace Glk