[Scummvm-git-logs] scummvm master -> c2db92b7e6873f34da7b4cad4d7999f84c792a35
neuromancer
noreply at scummvm.org
Thu Jan 6 19:05:13 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c2db92b7e6 HYPNO: added autosave checkpoints in spider
Commit: c2db92b7e6873f34da7b4cad4d7999f84c792a35
https://github.com/scummvm/scummvm/commit/c2db92b7e6873f34da7b4cad4d7999f84c792a35
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-01-06T20:04:57+01:00
Commit Message:
HYPNO: added autosave checkpoints in spider
Changed paths:
engines/hypno/actions.cpp
engines/hypno/arcade.cpp
engines/hypno/grammar.h
engines/hypno/hypno.cpp
engines/hypno/hypno.h
engines/hypno/scene.cpp
engines/hypno/spider/spider.cpp
engines/hypno/spider/talk.cpp
diff --git a/engines/hypno/actions.cpp b/engines/hypno/actions.cpp
index ed81da66836..54d0b22a086 100644
--- a/engines/hypno/actions.cpp
+++ b/engines/hypno/actions.cpp
@@ -175,6 +175,13 @@ void HypnoEngine::runLoad(Load *a) {
loadGameDialog();
}
+void HypnoEngine::runLoadCheckpoint(LoadCheckpoint *a) {
+ // TODO: this depends on the game
+ if (_checkpoint.empty())
+ error("Invalid checkpoint!");
+ _nextLevel = _checkpoint;
+}
+
void HypnoEngine::runQuit(Quit *a) {
quitGame();
}
diff --git a/engines/hypno/arcade.cpp b/engines/hypno/arcade.cpp
index ccce798a640..6c36fa64cdf 100644
--- a/engines/hypno/arcade.cpp
+++ b/engines/hypno/arcade.cpp
@@ -257,6 +257,7 @@ void HypnoEngine::runArcade(ArcadeShooting *arc) {
}
assert(!arc->levelIfWin.empty());
_nextLevel = arc->levelIfWin;
+ _checkpoint = _nextLevel;
_arcadeMode = "";
_skipLevel = false;
debugC(1, kHypnoDebugArcade, "Wining level and jumping to %s", _nextLevel.c_str());
diff --git a/engines/hypno/grammar.h b/engines/hypno/grammar.h
index fed83a1c7cf..e2aaff09ce0 100644
--- a/engines/hypno/grammar.h
+++ b/engines/hypno/grammar.h
@@ -55,6 +55,7 @@ enum ActionType {
EscapeAction,
SaveAction,
LoadAction,
+ LoadCheckpointAction,
QuitAction,
CutsceneAction,
PlayAction,
@@ -180,6 +181,12 @@ public:
}
};
+class LoadCheckpoint : public Action {
+public:
+ LoadCheckpoint() {
+ type = LoadCheckpointAction;
+ }
+};
class Quit : public Action {
public:
diff --git a/engines/hypno/hypno.cpp b/engines/hypno/hypno.cpp
index cec18a5059d..3555e894666 100644
--- a/engines/hypno/hypno.cpp
+++ b/engines/hypno/hypno.cpp
@@ -70,6 +70,7 @@ HypnoEngine::HypnoEngine(OSystem *syst, const ADGameDescription *gd)
g_hypno = this;
g_parsedArc = new ArcadeShooting();
_defaultCursor = "";
+ _checkpoint = "";
// Add quit level
Hotspot q(MakeMenu, "");
Action *a = new Quit();
diff --git a/engines/hypno/hypno.h b/engines/hypno/hypno.h
index 2680bc8bc1f..ca380afa67a 100644
--- a/engines/hypno/hypno.h
+++ b/engines/hypno/hypno.h
@@ -126,8 +126,7 @@ public:
bool canLoadGameStateCurrently() override { return true; }
bool canSaveAutosaveCurrently() override { return false; }
bool canSaveGameStateCurrently() override { return true; }
-
- void syncGameStream(Common::Serializer &s);
+ Common::String _checkpoint;
Common::String _prefixDir;
Common::String convertPath(const Common::String &);
@@ -155,6 +154,7 @@ public:
void runEscape();
void runSave(Save *a);
void runLoad(Load *a);
+ void runLoadCheckpoint(LoadCheckpoint *a);
void runQuit(Quit *a);
void runCutscene(Cutscene *a);
void runPlay(Play *a);
diff --git a/engines/hypno/scene.cpp b/engines/hypno/scene.cpp
index 72a1626298d..026327b9754 100644
--- a/engines/hypno/scene.cpp
+++ b/engines/hypno/scene.cpp
@@ -170,10 +170,15 @@ void HypnoEngine::clickedHotspot(Common::Point mousePos) {
case SaveAction:
runSave((Save *)action);
break;
+
case LoadAction:
runLoad((Load *)action);
break;
+ case LoadCheckpointAction:
+ runLoadCheckpoint((LoadCheckpoint *)action);
+ break;
+
case QuitAction:
runQuit((Quit *)action);
break;
@@ -411,17 +416,20 @@ void HypnoEngine::runScene(Scene *scene) {
_videosPlaying.empty() &&
_nextSequentialVideoToPlay.empty() &&
_nextParallelVideoToPlay.empty()) {
+
+ if (_nextLevel.empty()) {
+ assert(!scene->levelIfWin.empty());
+ _nextLevel = scene->levelIfWin;
+ }
+
if (checkLevelWon()) {
debugC(1, kHypnoDebugScene, "Resetting level variables");
resetSceneState();
+ _checkpoint = _nextLevel;
}
_sceneState["GS_LEVELCOMPLETE"] = 0;
- debugC(1, kHypnoDebugScene, "Wining level and jumping to %s", scene->levelIfWin.c_str());
- if (_nextLevel.empty()) {
- assert(!scene->levelIfWin.empty());
- _nextLevel = scene->levelIfWin;
- }
+ debugC(1, kHypnoDebugScene, "Finishing level and jumping to %s", _nextLevel.c_str());
continue;
}
}
diff --git a/engines/hypno/spider/spider.cpp b/engines/hypno/spider/spider.cpp
index 1430ee22270..deaa69dd731 100644
--- a/engines/hypno/spider/spider.cpp
+++ b/engines/hypno/spider/spider.cpp
@@ -75,6 +75,9 @@ void SpiderEngine::loadAssetsFullGame() {
sc = (Scene *) _levels["tryagain.mi_"];
sc->hots[1].actions.push_back(cl);
+ LoadCheckpoint *lc = new LoadCheckpoint();
+ sc->hots[2].actions.push_back(lc);
+
loadSceneLevel("options.mi_", "", prefix);
loadSceneLevel("levels.mi_", "mv0t.mi_", prefix);
loadSceneLevel("combmenu.mi_", "", prefix);
@@ -220,9 +223,16 @@ void SpiderEngine::loadAssetsFullGame() {
sc = (Scene *) _levels["decide1.mi_"];
cl = new ChangeLevel("bank.mi_");
sc->hots[2].actions.push_back(cl);
+
+ gl = new Global("GS_LEVELWON", "TURNON");
+ sc->hots[2].actions.push_back(gl);
+
cl = new ChangeLevel("c1");
sc->hots[4].actions.push_back(cl);
+ gl = new Global("GS_LEVELWON", "TURNON");
+ sc->hots[4].actions.push_back(gl);
+
loadSceneLevel("bank.mi_", "", prefix);
_levels["bank.mi_"]->intros.push_back("cine/swcs001s.smk");
_levels["bank.mi_"]->levelIfWin = "<alley_selector>";
@@ -956,14 +966,11 @@ Common::Error SpiderEngine::saveGameStream(Common::WriteStream *stream, bool isA
if (isAutosave)
return Common::kNoError;
- stream->writeString(_currentLevel);
- stream->writeByte(0);
+ if (_checkpoint.empty())
+ error("Invalid checkpoint!");
- uint32 i = 0;
- while (sceneVariables[i]) {
- stream->writeUint32LE(_sceneState[sceneVariables[i]]);
- i++;
- }
+ stream->writeString(_checkpoint);
+ stream->writeByte(0);
return Common::kNoError;
}
diff --git a/engines/hypno/spider/talk.cpp b/engines/hypno/spider/talk.cpp
index 75d32466583..3be1e0f77fb 100644
--- a/engines/hypno/spider/talk.cpp
+++ b/engines/hypno/spider/talk.cpp
@@ -114,8 +114,8 @@ void SpiderEngine::showConversation() {
Hotspots *hots = stack.back();
if (hots->size() == 2) {
debugC(1, kHypnoDebugScene, "Level should end here, since there is nothing else to do");
- Common::String variable = "GS_LEVELCOMPLETE";
- _sceneState[variable] = 1;
+ _sceneState["GS_LEVELCOMPLETE"] = true;
+ _sceneState["GS_LEVELWON"] = true;
}
}
@@ -153,9 +153,7 @@ void SpiderEngine::leftClickedConversation(const Common::Point &mousePos) {
_sceneState[it->variable] = 1;
_refreshConversation = true;
} else if (it->command == "L") {
- Common::String variable = "GS_LEVELCOMPLETE";
- debugC(1, kHypnoDebugScene, "Enabling variable %s", variable.c_str());
- _sceneState[variable] = 1;
+ _sceneState["GS_LEVELCOMPLETE"] = true;
_refreshConversation = true;
}
@@ -167,9 +165,10 @@ void SpiderEngine::leftClickedConversation(const Common::Point &mousePos) {
}
if (_sceneState["GS_LEVELCOMPLETE"]) {
- debugC(1, kHypnoDebugScene, "Level is complete, cleaning variables");
+ debugC(1, kHypnoDebugScene, "Level is complete, clearing variables");
resetSceneState();
- _sceneState["GS_LEVELCOMPLETE"] = 1;
+ _sceneState["GS_LEVELCOMPLETE"] = true;
+ _sceneState["GS_LEVELWON"] = true;
}
if (videos.size() > 0)
More information about the Scummvm-git-logs
mailing list