Skip to content

Commit

Permalink
GLK: ALAN3: Fix setup and outputing of text data
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jul 6, 2019
1 parent b8a737a commit ae6ae33
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
29 changes: 13 additions & 16 deletions engines/glk/alan3/alan3.cpp
Expand Up @@ -46,10 +46,13 @@ Alan3::Alan3(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, g

// main
codfil = nullptr;
// txtfil = nullptr;
textFile = nullptr;
// logfil = nullptr;
memory = nullptr;

// exe
printFlag = false;

// options
verboseOption = false;
ignoreErrorOption = false;
Expand Down Expand Up @@ -93,25 +96,21 @@ bool Alan3::initialize() {

// Set up the code file to point to the already opened game file
codfil = &_gameFile;
/*

if (_gameFile.size() < 8) {
GUIErrorMessage(_("This is too short to be a valid Alan3 file."));
return false;
}

if (_gameFile.readUint32BE() != MKTAG(2, 8, 1, 0)) {
GUIErrorMessage(_("This is not a valid Alan3 file."));
// In Alan 3, the text data comes from the adventure file itself
Common::File *txt = new Common::File();
if (!txt->open(getFilename())) {
GUIErrorMessage("Could not open adventure file for text data");
delete txt;
return false;
}
textFile = txt;

// Open up the text file
txtfil = new Common::File();
if (!txtfil->open(Common::String::format("%s.dat", _advName.c_str()))) {
GUIErrorMessage("Could not open adventure text data file");
delete txtfil;
return false;
}
*/
// Check for a save being loaded directly from the launcher
_saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;

Expand All @@ -120,10 +119,8 @@ bool Alan3::initialize() {

void Alan3::deinitialize() {
free(memory);
/*
delete txtfil;
delete logfil;
*/
delete textFile;
// delete logfil;
}

Common::Error Alan3::readSaveData(Common::SeekableReadStream *rs) {
Expand Down
12 changes: 7 additions & 5 deletions engines/glk/alan3/exe.cpp
Expand Up @@ -50,10 +50,12 @@
namespace Glk {
namespace Alan3 {

/* PUBLIC DATA */

// PUBLIC DATA
Common::SeekableReadStream *textFile;

// PUBLIC DATA - formerly method statics
bool printFlag; // Printing already?

/* Long jump buffers */
// TODO move to longjump.c? or error.c, and abstract them into functions?
//jmp_buf restartLabel; /* Restart long jump return point */
Expand Down Expand Up @@ -94,7 +96,6 @@ void print(Aword fpos, Aword len) {
int ch = 0;
int i;
long savfp = 0; /* Temporary saved text file position */
static bool printFlag = FALSE; /* Printing already? */
bool savedPrintFlag = printFlag;
void *info = NULL; /* Saved decoding info */

Expand Down Expand Up @@ -126,9 +127,10 @@ void print(Aword fpos, Aword len) {
else
ch = textFile->readByte();

if (ch == EOFChar)
break; // Or end of text?

str[i] = ch;
if (textFile->pos() >= textFile->size()) /* Or end of text? */
break;
}
str[i] = '\0';

Expand Down
4 changes: 2 additions & 2 deletions engines/glk/alan3/exe.h
Expand Up @@ -43,8 +43,8 @@ namespace Alan3 {

/* DATA */

/* The text and message file */
extern Common::SeekableReadStream *textFile;
extern Common::SeekableReadStream *textFile; // The text and message file
extern bool printFlag;

/* Long jump buffer for restart, errors and undo */
//extern jmp_buf restartLabel;
Expand Down

0 comments on commit ae6ae33

Please sign in to comment.