Skip to content

Commit

Permalink
GLK: HUGO: Support loading savegames from launcher
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed May 16, 2019
1 parent 68ef5eb commit 0325c93
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
7 changes: 6 additions & 1 deletion engines/glk/hugo/hemisc.cpp
Expand Up @@ -1071,6 +1071,9 @@ void Hugo::InitGame() {
}
}

#if defined (GLK)
if (_savegameSlot == -1) {
#endif
#if defined (DEBUGGER)
for (i=0; i<MAXLOCALS; i++) strcpy(localname[i], "");
window[VIEW_LOCALS].count = current_locals = 0;
Expand All @@ -1081,7 +1084,9 @@ void Hugo::InitGame() {
PassLocals(0);
RunRoutine((long)initaddr*address_scale);
#endif

#if defined (GLK)
}
#endif
ret = 0;
retflag = 0;
var[actor] = var[player];
Expand Down
22 changes: 20 additions & 2 deletions engines/glk/hugo/herun.cpp
Expand Up @@ -177,10 +177,19 @@ void Hugo::playGame() {

Start:
stack_depth = 0;

strcpy(errbuf, "");
strcpy(oops, "");

#if defined (GLK)
// Handle any savegame selected directly from the ScummVM launcher
if (_savegameSlot != -1) {
if (loadGameState(_savegameSlot).getCode() != Common::kNoError) {
GUIErrorMessage("Loading failed");
_savegameSlot = -1;
}
}
#endif

do
{
if (xverb==0)
Expand Down Expand Up @@ -261,7 +270,16 @@ void Hugo::playGame() {
debugger_has_stepped_back = false;
window[VIEW_LOCALS].changed = true;
#endif
if (!playback)
#if defined (GLK)
if (_savegameSlot != -1) {
// Trigger a "look" command so that players will get some initial text
// after loading a savegame directly from the launcher
_savegameSlot = -1;
strcpy(buffer, "look");
}
else
#endif
if (!playback)
{
GetCommand();
}
Expand Down
4 changes: 4 additions & 0 deletions engines/glk/hugo/hugo.cpp
Expand Up @@ -21,6 +21,7 @@
*/

#include "glk/hugo/hugo.h"
#include "common/config-manager.h"

namespace Glk {
namespace Hugo {
Expand Down Expand Up @@ -116,6 +117,9 @@ Hugo::Hugo(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gam
// heset
game_title[0] = '\0';

// Miscellaneous
_savegameSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;

#ifdef DEBUGGER
debug_line[0] = '\0';
Common::fill(&objectname[0], &objectname[MAX_OBJECT], (char *)nullptr);
Expand Down
1 change: 1 addition & 0 deletions engines/glk/hugo/hugo.h
Expand Up @@ -39,6 +39,7 @@ namespace Hugo {
*/
class Hugo : public GlkAPI, public HTokens, public StringFunctions {
private:
int _savegameSlot;
winid_t mainwin, currentwin;
winid_t secondwin, auxwin;
bool runtime_warnings;
Expand Down

0 comments on commit 0325c93

Please sign in to comment.