[Scummvm-git-logs] scummvm master -> 4c23d5f2f5a04ee39afaf20beb412b74d466175b
neuromancer
noreply at scummvm.org
Mon Jan 3 19:48:30 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:
4c23d5f2f5 HYPNO: added basic save/load code to spider
Commit: 4c23d5f2f5a04ee39afaf20beb412b74d466175b
https://github.com/scummvm/scummvm/commit/4c23d5f2f5a04ee39afaf20beb412b74d466175b
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-01-03T20:46:26+01:00
Commit Message:
HYPNO: added basic save/load code to spider
Changed paths:
engines/hypno/actions.cpp
engines/hypno/grammar.h
engines/hypno/hypno.cpp
engines/hypno/hypno.h
engines/hypno/scene.cpp
engines/hypno/spider/spider.cpp
diff --git a/engines/hypno/actions.cpp b/engines/hypno/actions.cpp
index 9b8600f06d6..ed81da66836 100644
--- a/engines/hypno/actions.cpp
+++ b/engines/hypno/actions.cpp
@@ -167,6 +167,14 @@ void HypnoEngine::runWalN(WalN *a) {
error("Invalid WALN command: %s", a->wn.c_str());
}
+void HypnoEngine::runSave(Save *a) {
+ saveGameDialog();
+}
+
+void HypnoEngine::runLoad(Load *a) {
+ loadGameDialog();
+}
+
void HypnoEngine::runQuit(Quit *a) {
quitGame();
}
diff --git a/engines/hypno/grammar.h b/engines/hypno/grammar.h
index 1df25b94b2a..fed83a1c7cf 100644
--- a/engines/hypno/grammar.h
+++ b/engines/hypno/grammar.h
@@ -53,6 +53,8 @@ enum ActionType {
BackgroundAction,
OverlayAction,
EscapeAction,
+ SaveAction,
+ LoadAction,
QuitAction,
CutsceneAction,
PlayAction,
@@ -164,6 +166,21 @@ public:
}
};
+class Save : public Action {
+public:
+ Save() {
+ type = SaveAction;
+ }
+};
+
+class Load : public Action {
+public:
+ Load() {
+ type = LoadAction;
+ }
+};
+
+
class Quit : public Action {
public:
Quit() {
diff --git a/engines/hypno/hypno.cpp b/engines/hypno/hypno.cpp
index 7e992a0337b..cec18a5059d 100644
--- a/engines/hypno/hypno.cpp
+++ b/engines/hypno/hypno.cpp
@@ -138,6 +138,11 @@ Common::Error HypnoEngine::run() {
// Main event loop
loadAssets();
+ int saveSlot = ConfMan.getInt("save_slot");
+ if (saveSlot >= 0) { // load the savegame
+ loadGameState(saveSlot);
+ }
+
assert(!_nextLevel.empty());
while (!shouldQuit()) {
debug("nextLevel: %s", _nextLevel.c_str());
diff --git a/engines/hypno/hypno.h b/engines/hypno/hypno.h
index f8e9b01903f..f84a7c60005 100644
--- a/engines/hypno/hypno.h
+++ b/engines/hypno/hypno.h
@@ -123,9 +123,9 @@ public:
bool cursorExit(Common::Point);
bool cursorMask(Common::Point);
- bool canLoadGameStateCurrently() override { return false; }
+ bool canLoadGameStateCurrently() override { return true; }
bool canSaveAutosaveCurrently() override { return false; }
- bool canSaveGameStateCurrently() override { return false; }
+ bool canSaveGameStateCurrently() override { return true; }
void syncGameStream(Common::Serializer &s);
@@ -153,6 +153,8 @@ public:
void runOverlay(Overlay *a);
void runMice(Mice *a);
void runEscape();
+ void runSave(Save *a);
+ void runLoad(Load *a);
void runQuit(Quit *a);
void runCutscene(Cutscene *a);
void runPlay(Play *a);
@@ -271,6 +273,9 @@ public:
Common::String findNextLevel(const Common::String &level) override;
Common::String findNextLevel(const Transition *trans) override;
+ //virtual Common::Error loadGameStream(Common::SeekableReadStream *stream) = 0;
+ //virtual Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) = 0;
+
private:
void runMainMenu(Code *code);
@@ -296,6 +301,12 @@ public:
void rightClickedConversation(const Common::Point &mousePos) override;
void leftClickedConversation(const Common::Point &mousePos) override;
+ Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
+ Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
+ bool hasFeature(EngineFeature f) const {
+ return (f == kSupportsSavingDuringRuntime || f == kSupportsLoadingDuringRuntime);
+ }
+
private:
void runMatrix(Code *code);
void addIngredient(Code *code);
diff --git a/engines/hypno/scene.cpp b/engines/hypno/scene.cpp
index 1525ab969ff..72a1626298d 100644
--- a/engines/hypno/scene.cpp
+++ b/engines/hypno/scene.cpp
@@ -28,7 +28,7 @@ namespace Hypno {
extern int parse_mis(const char *);
-const static char *sceneVariables[] = {
+const char *sceneVariables[] = {
"GS_NONE",
"GS_SCTEXT",
"GS_AMBIENT",
@@ -167,6 +167,13 @@ void HypnoEngine::clickedHotspot(Common::Point mousePos) {
runTalk((Talk *)action);
break;
+ case SaveAction:
+ runSave((Save *)action);
+ break;
+ case LoadAction:
+ runLoad((Load *)action);
+ break;
+
case QuitAction:
runQuit((Quit *)action);
break;
diff --git a/engines/hypno/spider/spider.cpp b/engines/hypno/spider/spider.cpp
index 0b90bf32728..363cd193d2d 100644
--- a/engines/hypno/spider/spider.cpp
+++ b/engines/hypno/spider/spider.cpp
@@ -28,6 +28,8 @@
namespace Hypno {
+extern char *sceneVariables[];
+
SpiderEngine::SpiderEngine(OSystem *syst, const ADGameDescription *gd) : HypnoEngine(syst, gd) {}
void SpiderEngine::loadAssets() {
@@ -88,6 +90,12 @@ void SpiderEngine::loadAssetsFullGame() {
sc->hots[1].actions.push_back(cl);
sc->music = "sound.lib/menu_mus.raw";
+ Load *ld = new Load();
+ sc->hots[2].actions.push_back(ld);
+
+ //Save *sv = new Save();
+ //sc->hots[3].actions.push_back(sv);
+
cl = new ChangeLevel("options.mi_");
sc->hots[4].actions.push_back(cl);
@@ -881,6 +889,31 @@ Common::String SpiderEngine::findNextLevel(const Transition *trans) {
return trans->nextLevel;
}
+Common::Error SpiderEngine::loadGameStream(Common::SeekableReadStream *stream) {
+ // We don't want to continue with any sound from a previous game
+ //stopSound(true);
+ _nextLevel = stream->readString();
+
+ return Common::kNoError;
+}
+
+Common::Error SpiderEngine::saveGameStream(Common::WriteStream *stream, bool isAutosave) {
+ //debugC(1, kDebugFunction, "saveGameStream(%d)", isAutosave);
+ if (isAutosave)
+ return Common::kNoError;
+
+ stream->writeString(_currentLevel);
+ stream->writeByte(0);
+
+ uint32 i = 0;
+ while (sceneVariables[i]) {
+ stream->writeUint32LE(_sceneState[sceneVariables[i]]);
+ i++;
+ }
+ return Common::kNoError;
+}
+
+
Common::String SpiderEngine::findNextLevel(const Common::String &level) {
if (Common::matchString(level.c_str(), "c#") || Common::matchString(level.c_str(), "c##") || Common::matchString(level.c_str(), "c##?"))
return level + (_sceneState["GS_COMBATLEVEL"] == 0 ? "" : "h") + ".mi_";
More information about the Scummvm-git-logs
mailing list