[Scummvm-git-logs] scummvm master -> 5eb0390aca85a53a6bc268e082b776119ca9b997
dreammaster
paulfgilbert at gmail.com
Mon Jun 24 01:20:00 CEST 2019
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
e7fbd9268c GLK: ALAN2: Cleanup of data text file opening
5eb0390aca GLK: ALAN2: Add loading savegames from launcher, deinitialization code
Commit: e7fbd9268c9bd4a21a9f4741d4636c722368847c
https://github.com/scummvm/scummvm/commit/e7fbd9268c9bd4a21a9f4741d4636c722368847c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-06-23T16:19:42-07:00
Commit Message:
GLK: ALAN2: Cleanup of data text file opening
Changed paths:
engines/glk/alan2/alan2.cpp
engines/glk/alan2/alan2.h
engines/glk/alan2/main.cpp
diff --git a/engines/glk/alan2/alan2.cpp b/engines/glk/alan2/alan2.cpp
index 7d5040c..f9077c9 100644
--- a/engines/glk/alan2/alan2.cpp
+++ b/engines/glk/alan2/alan2.cpp
@@ -46,15 +46,18 @@ Alan2::Alan2(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, g
void Alan2::runGame() {
Common::String gameFileName = _gameFile.getName();
- if (!is_gamefile_valid())
+ if (!initialize())
return;
- initialize();
-
Glk::Alan2::run();
}
-void Alan2::initialize() {
+bool Alan2::initialize() {
+ // Set up adventure name
+ _advName = getFilename();
+ if (_advName.size() > 4 && _advName[_advName.size() - 4] == '.')
+ _advName = Common::String(_advName.c_str(), _advName.size() - 4);
+
// first, open a window for error output
glkMainWin = g_vm->glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
if (glkMainWin == nullptr)
@@ -70,10 +73,25 @@ void Alan2::initialize() {
strncpy(codfnm, getFilename().c_str(), 255);
codfnm[255] = '\0';
+ if (_gameFile.size() < 8) {
+ GUIErrorMessage(_("This is too short to be a valid Alan2 file."));
+ return false;
+ }
+
+ if (_gameFile.readUint32BE() != MKTAG(2, 8, 1, 0)) {
+ GUIErrorMessage(_("This is not a valid Alan2 file."));
+ return false;
+ }
+
// 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");
+ if (!txtfil->open(Common::String::format("%s.dat", _advName.c_str()))) {
+ GUIErrorMessage("Could not open adventure text data file");
+ delete txtfil;
+ return false;
+ }
+
+ return true;
}
Common::Error Alan2::readSaveData(Common::SeekableReadStream *rs) {
@@ -149,25 +167,5 @@ void Alan2::synchronizeSave(Common::Serializer &s) {
syncVal(s, &scores[i]);
}
-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;
- }
-
- if (_gameFile.readUint32BE() != MKTAG(2, 8, 1, 0)) {
- GUIErrorMessage(_("This is not a valid Alan2 file."));
- return false;
- }
-
- return Common::File::exists(Common::String::format("%s.dat", advnam));
-}
-
} // End of namespace Alan2
} // End of namespace Glk
diff --git a/engines/glk/alan2/alan2.h b/engines/glk/alan2/alan2.h
index 9d007d0..413800c 100644
--- a/engines/glk/alan2/alan2.h
+++ b/engines/glk/alan2/alan2.h
@@ -42,14 +42,9 @@ public:
Common::String _advName;
private:
/**
- * Validates the game file, and if it's invalid, displays an error dialog
- */
- bool is_gamefile_valid();
-
- /**
* Initialization
*/
- void initialize();
+ bool initialize();
/**
* Synchronize data to or from a save file
diff --git a/engines/glk/alan2/main.cpp b/engines/glk/alan2/main.cpp
index 1371ace..58c483a 100644
--- a/engines/glk/alan2/main.cpp
+++ b/engines/glk/alan2/main.cpp
@@ -1376,23 +1376,6 @@ static void movactor(CONTEXT) {
*/
static void openFiles() {
- {
- char *s = strrchr(codfnm, '\\');
- if (!s) s = strrchr(codfnm, '/');
- g_vm->garglk_set_story_name(s ? s + 1 : codfnm);
- }
-
- // Open Text file
- strcpy(txtfnm, advnam);
- strcat(txtfnm, ".dat");
-
- Common::File *f = new Common::File();
- if (!f->open(txtfnm)) {
- delete f;
- Common::String s = Common::String::format("Can't open adventure text data file '%s'.", txtfnm);
- ::error("%s", s.c_str());
- }
-
// If logging open log file
if (logflg) {
sprintf(logfnm, "%s.log", advnam);
Commit: 5eb0390aca85a53a6bc268e082b776119ca9b997
https://github.com/scummvm/scummvm/commit/5eb0390aca85a53a6bc268e082b776119ca9b997
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-06-23T16:19:42-07:00
Commit Message:
GLK: ALAN2: Add loading savegames from launcher, deinitialization code
Changed paths:
R engines/glk/alan2/readline.cpp
R engines/glk/alan2/readline.h
engines/glk/alan2/alan2.cpp
engines/glk/alan2/alan2.h
engines/glk/alan2/debug.cpp
engines/glk/alan2/exe.cpp
engines/glk/alan2/glkio.cpp
engines/glk/alan2/glkio.h
engines/glk/alan2/main.cpp
engines/glk/alan2/parse.cpp
engines/glk/module.mk
diff --git a/engines/glk/alan2/alan2.cpp b/engines/glk/alan2/alan2.cpp
index f9077c9..0ad524b 100644
--- a/engines/glk/alan2/alan2.cpp
+++ b/engines/glk/alan2/alan2.cpp
@@ -39,17 +39,18 @@ namespace Alan2 {
Alan2 *g_vm = nullptr;
Alan2::Alan2(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc),
- vm_exited_cleanly(false), _restartFlag(false) {
+ vm_exited_cleanly(false), _restartFlag(false), _saveSlot(-1), _pendingLook(false) {
g_vm = this;
+ txtfil = nullptr;
+ logfil = nullptr;
+ memory = nullptr;
}
void Alan2::runGame() {
- Common::String gameFileName = _gameFile.getName();
+ if (initialize())
+ Glk::Alan2::run();
- if (!initialize())
- return;
-
- Glk::Alan2::run();
+ deinitialize();
}
bool Alan2::initialize() {
@@ -91,9 +92,19 @@ bool Alan2::initialize() {
return false;
}
+ // Check for a save being loaded directly from the launcher
+ _saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;
+
return true;
}
+void Alan2::deinitialize() {
+ free(memory);
+
+ delete txtfil;
+ delete logfil;
+}
+
Common::Error Alan2::readSaveData(Common::SeekableReadStream *rs) {
Common::Serializer s(rs, nullptr);
synchronizeSave(s);
diff --git a/engines/glk/alan2/alan2.h b/engines/glk/alan2/alan2.h
index 413800c..baf02c8 100644
--- a/engines/glk/alan2/alan2.h
+++ b/engines/glk/alan2/alan2.h
@@ -40,6 +40,8 @@ private:
public:
bool vm_exited_cleanly;
Common::String _advName;
+ int _saveSlot;
+ bool _pendingLook;
private:
/**
* Initialization
@@ -47,6 +49,11 @@ private:
bool initialize();
/**
+ * Deinitialization
+ */
+ void deinitialize();
+
+ /**
* Synchronize data to or from a save file
*/
void synchronizeSave(Common::Serializer &s);
diff --git a/engines/glk/alan2/debug.cpp b/engines/glk/alan2/debug.cpp
index bea427b..af72c31 100644
--- a/engines/glk/alan2/debug.cpp
+++ b/engines/glk/alan2/debug.cpp
@@ -28,8 +28,6 @@
#include "glk/alan2/inter.h"
#include "glk/alan2/main.h"
#include "glk/alan2/parse.h"
-#include "glk/alan2/readline.h"
-
namespace Glk {
namespace Alan2 {
diff --git a/engines/glk/alan2/exe.cpp b/engines/glk/alan2/exe.cpp
index 5ff79c8..1abe603 100644
--- a/engines/glk/alan2/exe.cpp
+++ b/engines/glk/alan2/exe.cpp
@@ -23,10 +23,10 @@
#include "glk/alan2/alan2.h"
#include "glk/alan2/types.h"
#include "glk/alan2/exe.h"
+#include "glk/alan2/glkio.h"
#include "glk/alan2/inter.h"
#include "glk/alan2/main.h"
#include "glk/alan2/parse.h"
-#include "glk/alan2/readline.h"
#include "glk/alan2/stack.h"
#include "glk/alan2/decode.h"
diff --git a/engines/glk/alan2/glkio.cpp b/engines/glk/alan2/glkio.cpp
index fda54de..9f30531 100644
--- a/engines/glk/alan2/glkio.cpp
+++ b/engines/glk/alan2/glkio.cpp
@@ -23,6 +23,7 @@
#include "glk/glk.h"
#include "glk/alan2/alan2.h"
#include "glk/alan2/glkio.h"
+#include "glk/alan2/main.h"
namespace Glk {
namespace Alan2 {
@@ -31,6 +32,10 @@ winid_t glkMainWin;
winid_t glkStatusWin;
void glkio_printf(const char *fmt, ...) {
+ // If there's a savegame being loaded from the launcher, ignore any text out
+ if (g_vm->_saveSlot != -1)
+ return;
+
va_list argp;
va_start(argp, fmt);
if (glkMainWin) {
@@ -46,6 +51,43 @@ void glkio_printf(const char *fmt, ...) {
va_end(argp);
}
+/*======================================================================
+
+ readline()
+
+ Read a line from the user, with history and editing
+
+ */
+
+ /* 4f - length of user buffer should be used */
+Boolean readline(char usrbuf[]) {
+ if (g_vm->_pendingLook) {
+ g_vm->_pendingLook = false;
+ glkio_printf("look\n");
+ strcpy(usrbuf, "look");
+ } else {
+ event_t event;
+ g_vm->glk_request_line_event(glkMainWin, usrbuf, 255, 0);
+
+ /* FIXME: buffer size should be infallible: all existing calls use 256 or
+ 80 character buffers, except parse which uses LISTLEN (currently 100)
+ */
+ do {
+ g_vm->glk_select(&event);
+ if (evtype_Arrange == event.type)
+ statusline();
+ if (g_vm->shouldQuit())
+ return false;
+
+ } while (event.type != evtype_LineInput);
+
+ usrbuf[event.val1] = 0;
+ }
+
+ return TRUE;
+}
+
+
} // End of namespace Alan2
} // End of namespace Glk
diff --git a/engines/glk/alan2/glkio.h b/engines/glk/alan2/glkio.h
index 2dff66f..4bb2e02 100644
--- a/engines/glk/alan2/glkio.h
+++ b/engines/glk/alan2/glkio.h
@@ -27,6 +27,7 @@
*/
#include "glk/windows.h"
+#include "glk/alan2/types.h"
namespace Glk {
namespace Alan2 {
@@ -41,6 +42,11 @@ extern winid_t glkStatusWin;
void glkio_printf(const char *, ...);
+#define LINELENGTH 80
+#define HISTORYLENGTH 20
+
+extern Boolean readline(char usrbuf[]);
+
} // End of namespace Alan2
} // End of namespace Glk
diff --git a/engines/glk/alan2/main.cpp b/engines/glk/alan2/main.cpp
index 58c483a..551fbe5 100644
--- a/engines/glk/alan2/main.cpp
+++ b/engines/glk/alan2/main.cpp
@@ -116,9 +116,6 @@ Boolean skipsp = FALSE;
*/
void terminate(CONTEXT, int code) {
newline();
- free(memory);
- if (logflg)
- fclose(logfil);
g_vm->glk_exit();
LONG_JUMP
@@ -1404,6 +1401,13 @@ void run() {
g_vm->setRestart(false);
init();
+ if (g_vm->_saveSlot != -1) {
+ if (g_vm->loadGameState(g_vm->_saveSlot).getCode() != Common::kNoError)
+ return;
+ g_vm->_saveSlot = -1;
+ g_vm->_pendingLook = true;
+ }
+
Context ctx;
while (!g_vm->shouldQuit() && !g_vm->shouldRestart()) {
if (!ctx._break) {
diff --git a/engines/glk/alan2/parse.cpp b/engines/glk/alan2/parse.cpp
index 5c9fd35..51bf092 100644
--- a/engines/glk/alan2/parse.cpp
+++ b/engines/glk/alan2/parse.cpp
@@ -28,7 +28,6 @@
#include "glk/alan2/main.h"
#include "glk/alan2/params.h"
#include "glk/alan2/parse.h"
-#include "glk/alan2/readline.h"
#include "glk/alan2/term.h"
#include "glk/alan2/types.h"
diff --git a/engines/glk/alan2/readline.cpp b/engines/glk/alan2/readline.cpp
deleted file mode 100644
index cd05435..0000000
--- a/engines/glk/alan2/readline.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "glk/alan2/alan2.h"
-#include "glk/alan2/types.h"
-#include "glk/alan2/glkio.h"
-#include "glk/alan2/main.h"
-#include "glk/alan2/readline.h"
-
-namespace Glk {
-namespace Alan2 {
-
-/*======================================================================
-
- readline()
-
- Read a line from the user, with history and editing
-
- */
-
-/* 4f - length of user buffer should be used */
-Boolean readline(char usrbuf[]) {
- event_t event;
- g_vm->glk_request_line_event(glkMainWin, usrbuf, 255, 0);
- /* FIXME: buffer size should be infallible: all existing calls use 256 or
- 80 character buffers, except parse which uses LISTLEN (currently 100)
- */
- do {
- g_vm->glk_select(&event);
- if (evtype_Arrange == event.type)
- statusline();
- if (g_vm->shouldQuit())
- return false;
-
- } while (event.type != evtype_LineInput);
-
- usrbuf[event.val1] = 0;
- return TRUE;
-}
-
-} // End of namespace Alan2
-} // End of namespace Glk
-
diff --git a/engines/glk/alan2/readline.h b/engines/glk/alan2/readline.h
deleted file mode 100644
index 249ccbd..0000000
--- a/engines/glk/alan2/readline.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef GLK_ALAN2_READLINE
-#define GLK_ALAN2_READLINE
-
-/* Header file for user input, history andediting support */
-
-#include "glk/alan2/types.h"
-
-namespace Glk {
-namespace Alan2 {
-
-#define LINELENGTH 80
-#define HISTORYLENGTH 20
-
-extern Boolean readline(char usrbuf[]);
-
-} // End of namespace Alan2
-} // End of namespace Glk
-
-#endif
diff --git a/engines/glk/module.mk b/engines/glk/module.mk
index 6536cf0..0a5a83d 100644
--- a/engines/glk/module.mk
+++ b/engines/glk/module.mk
@@ -43,7 +43,6 @@ MODULE_OBJS := \
alan2/main.o \
alan2/params.o \
alan2/parse.o \
- alan2/readline.o \
alan2/reverse.o \
alan2/rules.o \
alan2/stack.o \
More information about the Scummvm-git-logs
mailing list