From b4ae2ec4374a8f920fa3287b6906e09c6c68f57f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 19 Jun 2019 20:28:19 -0700 Subject: GLK: ALAN2: Open text data file on startup --- engines/glk/alan2/alan2.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/engines/glk/alan2/alan2.cpp b/engines/glk/alan2/alan2.cpp index 05a024d4d4..c9625a7076 100644 --- a/engines/glk/alan2/alan2.cpp +++ b/engines/glk/alan2/alan2.cpp @@ -63,14 +63,15 @@ void Alan2::initialize() { winmethod_Fixed, 1, wintype_TextGrid, 0); g_vm->glk_set_window(glkMainWin); - _advName = getFilename(); - while (_advName.contains('.')) - _advName.deleteLastChar(); - advnam = _advName.c_str(); - + // Set up the code file to point to the already opened game file codfil = &_gameFile; strncpy(codfnm, getFilename().c_str(), 255); codfnm[255] = '\0'; + + // Open up the text file + txtfil = new Common::File(); + if (!txtfil->open(Common::String::format("%s.dat", advnam))) + ::error("Could not open adventure text data file"); } Common::Error Alan2::readSaveData(Common::SeekableReadStream *rs) { @@ -84,6 +85,12 @@ Common::Error Alan2::writeGameData(Common::WriteStream *ws) { } bool Alan2::is_gamefile_valid() { + // Set up adventure name + _advName = getFilename(); + while (_advName.contains('.')) + _advName.deleteLastChar(); + advnam = _advName.c_str(); + if (_gameFile.size() < 8) { GUIErrorMessage(_("This is too short to be a valid Alan2 file.")); return false; @@ -94,7 +101,7 @@ bool Alan2::is_gamefile_valid() { return false; } - return true; + return Common::File::exists(Common::String::format("%s.dat", advnam)); } } // End of namespace Alan2 -- cgit v1.2.3