[Scummvm-git-logs] scummvm master -> 68979a013a8fdad142c90d6e2dbbf80c9271c102
neuromancer
noreply at scummvm.org
Sun Mar 13 10:05: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:
68979a013a HYPNO: add score field into saving/loading and show it as restored content in spider
Commit: 68979a013a8fdad142c90d6e2dbbf80c9271c102
https://github.com/scummvm/scummvm/commit/68979a013a8fdad142c90d6e2dbbf80c9271c102
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-03-13T11:05:22+01:00
Commit Message:
HYPNO: add score field into saving/loading and show it as restored content in spider
Changed paths:
engines/hypno/actions.cpp
engines/hypno/hypno.cpp
engines/hypno/hypno.h
engines/hypno/spider/arcade.cpp
engines/hypno/spider/hard.cpp
engines/hypno/spider/spider.cpp
diff --git a/engines/hypno/actions.cpp b/engines/hypno/actions.cpp
index b12fbb5f58e..742caba0d02 100644
--- a/engines/hypno/actions.cpp
+++ b/engines/hypno/actions.cpp
@@ -218,7 +218,7 @@ void HypnoEngine::runLoad(Load *a) {
void HypnoEngine::runLoadCheckpoint(LoadCheckpoint *a) {
if (_checkpoint.empty())
error("Invalid checkpoint!");
- loadGame(_checkpoint, _sceneState["GS_PUZZLELEVEL"], _sceneState["GS_COMBATLEVEL"]);
+ loadGame(_checkpoint, _score, _sceneState["GS_PUZZLELEVEL"], _sceneState["GS_COMBATLEVEL"]);
}
void HypnoEngine::runQuit(Quit *a) {
diff --git a/engines/hypno/hypno.cpp b/engines/hypno/hypno.cpp
index 5448982452f..e9d66e9d318 100644
--- a/engines/hypno/hypno.cpp
+++ b/engines/hypno/hypno.cpp
@@ -256,7 +256,7 @@ void HypnoEngine::runIntro(MVideo &video) {
void HypnoEngine::runCode(Code *code) { error("Function \"%s\" not implemented", __FUNCTION__); }
void HypnoEngine::showCredits() { error("Function \"%s\" not implemented", __FUNCTION__); }
-void HypnoEngine::loadGame(const Common::String &nextLevel, int puzzleDifficulty, int combatDifficulty) {
+void HypnoEngine::loadGame(const Common::String &nextLevel, int score, int puzzleDifficulty, int combatDifficulty) {
error("Function \"%s\" not implemented", __FUNCTION__);
}
diff --git a/engines/hypno/hypno.h b/engines/hypno/hypno.h
index 911a7d8f589..4593bf25af7 100644
--- a/engines/hypno/hypno.h
+++ b/engines/hypno/hypno.h
@@ -126,7 +126,7 @@ public:
bool cursorExit(Common::Point);
bool cursorMask(Common::Point);
- virtual void loadGame(const Common::String &nextLevel, int puzzleDifficulty, int combatDifficulty);
+ virtual void loadGame(const Common::String &nextLevel, int score, int puzzleDifficulty, int combatDifficulty);
bool canLoadGameStateCurrently() override { return (isDemo() ? false : true); }
bool canSaveAutosaveCurrently() override { return false; }
bool canSaveGameStateCurrently() override { return (isDemo() ? false : true); }
@@ -403,7 +403,7 @@ public:
void leftClickedConversation(const Common::Point &mousePos) override;
bool hoverConversation(const Common::Point &mousePos) override;
- void loadGame(const Common::String &nextLevel, int puzzleDifficulty, int combatDifficulty) override;
+ void loadGame(const Common::String &nextLevel, int score, int puzzleDifficulty, int combatDifficulty) override;
Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
bool hasFeature(EngineFeature f) const override {
@@ -421,6 +421,8 @@ private:
void runFileCabinet(Code *code);
void runLock(Code *code);
void runFuseBox(Code *code);
+ void runGiveUp();
+ void showScore(const Common::String prefix);
bool _fuseState[2][10] = {};
bool _isFuseRust = true;
diff --git a/engines/hypno/spider/arcade.cpp b/engines/hypno/spider/arcade.cpp
index f1672ec12f9..34a716c273e 100644
--- a/engines/hypno/spider/arcade.cpp
+++ b/engines/hypno/spider/arcade.cpp
@@ -58,24 +58,11 @@ void SpiderEngine::runBeforeArcade(ArcadeShooting *arc) {
}
void SpiderEngine::runAfterArcade(ArcadeShooting *arc) {
- _checkpoint = _currentLevel;
- if (_restoredContentEnabled) {
- Common::String message;
- if (_health > 0)
- message += "Spider-man won!\n";
- else
- message += "Spider-man was defeated!\n";
+ _checkpoint = _nextLevel;
- message += Common::String::format("%-21s = %7d\n", "Webs fired", _shootsFired);
- message += Common::String::format("%-19s = %7d\n", "Enemy targets", _enemyTargets);
- message += Common::String::format("%-18s = %7d\n", "Targets destroyed", _targetsDestroyed);
- message += Common::String::format("%-19s = %7d\n", "Targets missed", _targetsMissed);
- message += Common::String::format("%-24s = %5d %%\n", "Kill ratio", killRatio());
- message += Common::String::format("%-21s = %5d %%\n", "Accuracy", accuracyRatio());
- message += Common::String::format("%-22s = %5d %%\n", "Energy", _health);
- message += Common::String::format("%-23s = %5d pts", "Score", _score);
- GUI::MessageDialog dialog(message, "OK", "", Graphics::kTextAlignLeft);
- dialog.runModal();
+ if (_health <= 0) {
+ assert(_score >= _bonus);
+ _score -= _bonus;
}
}
diff --git a/engines/hypno/spider/hard.cpp b/engines/hypno/spider/hard.cpp
index d20d58ed30e..2fcfb80443d 100644
--- a/engines/hypno/spider/hard.cpp
+++ b/engines/hypno/spider/hard.cpp
@@ -40,14 +40,16 @@ void SpiderEngine::runCode(Code *code) {
runRecept(code);
else if (code->name == "<office>")
runOffice(code);
- else if (code->name == "<file_cabinet>")
+ else if (code->name == "<file_cabinet>")
runFileCabinet(code);
- else if (code->name == "<lock>")
+ else if (code->name == "<lock>")
runLock(code);
else if (code->name == "<fuse_box>")
runFuseBox(code);
else if (code->name == "<credits>")
showCredits();
+ else if (code->name == "<give_up>")
+ runGiveUp();
else
error("invalid puzzle");
}
@@ -234,8 +236,8 @@ void SpiderEngine::runNote(Code *code) {
const char alphaES[] = "abcdefghijklmnopqrstuvwxyz~";
const char alphaEN[] = "abcdefghijklmnopqrstuvwxyz";
- Common::Rect letterBoxES(22, 442, 554, 455);
- Common::Rect letterBoxEN(22, 442, 535, 455);
+ Common::Rect letterBoxES(22, 442, 554, 455);
+ Common::Rect letterBoxEN(22, 442, 535, 455);
const char solEasyES1[] = "hable cpn el svtp z talwe a";
const char solEasyES2[] = "masz jane";
@@ -294,7 +296,7 @@ void SpiderEngine::runNote(Code *code) {
secondSolution = solEasyEN2;
firstSentenceBox = firstSentenceBoxEasyEN;
secondSentenceBox = secondSentenceBoxEasyEN;
- } else { // hard
+ } else { // hard
firstSentence = (char*) &placeHardEN;
secondSentence = (char*) &placeHardEN2;
firstSolution = solHardEN1;
@@ -303,18 +305,18 @@ void SpiderEngine::runNote(Code *code) {
secondSentenceBox = secondSentenceBoxHardEN;
}
break;
-
+
case Common::ES_ESP:
alpha = alphaES;
letterBox = letterBoxES;
if (_sceneState["GS_PUZZLELEVEL"] == 0) { // easy
firstSentence = (char*) &placeEasyES;
secondSentence = (char*) &placeEasy2;
- firstSolution = solEasyES1;
+ firstSolution = solEasyES1;
secondSolution = solEasyES2;
firstSentenceBox = firstSentenceBoxEasyES;
secondSentenceBox = secondSentenceBoxEasyES;
- } else { // hard
+ } else { // hard
firstSentence = (char*) &placeHardES;
secondSentence = (char*) &placeHardES2;
firstSolution = solHardES1;
@@ -333,9 +335,9 @@ void SpiderEngine::runNote(Code *code) {
}
float firstSentenceLength = strlen(firstSentence);
- float secondSentenceLength = strlen(secondSentence);
+ float secondSentenceLength = strlen(secondSentence);
Frames letters = decodeFrames("int_ball/letters.smk");
- Common::Point size(letters[0]->w, letters[0]->h);
+ Common::Point size(letters[0]->w, letters[0]->h);
MVideo *v = nullptr;
if (_sceneState["GS_PUZZLELEVEL"] == 0) { // easy
@@ -428,7 +430,7 @@ void SpiderEngine::runNote(Code *code) {
if (firstSentence[i] != '?' && firstSentence[i] != ' ') {
if (firstSentence[i] == '~')
drawImage(*letters[26], o1x, o1y, false); // ñ
- else
+ else
drawImage(*letters[firstSentence[i]-97], o1x, o1y, false);
}
@@ -439,7 +441,7 @@ void SpiderEngine::runNote(Code *code) {
if (secondSentence[i] != '?' && secondSentence[i] != ' ') {
if (secondSentence[i] == '~')
drawImage(*letters[26], o2x, o2y, false); // ñ
- else
+ else
drawImage(*letters[secondSentence[i]-97], o2x, o2y, false);
}
o2x = o2x + size.x;
@@ -480,7 +482,7 @@ void SpiderEngine::runRecept(Code *code) {
_nextLevel = "int_roof.mi_";
return;
}
-
+
if (_sceneState["GS_SWITCH2"]) { // camera on
MVideo v("cine/iobs001s.smk", Common::Point(0, 0), false, true, false);
runIntro(v);
@@ -509,11 +511,11 @@ void SpiderEngine::runFusePanel(Code *code) {
defaultCursor();
Common::Rect fuses(363, 52, 598, 408);
- Common::Rect back(0, 446, 640, 480);
+ Common::Rect back(0, 446, 640, 480);
if (_sceneState["GS_PUZZLELEVEL"]) { // hard
if (_isFuseRust) {
- Common::String intro = "cine/spv029s.smk";
+ Common::String intro = "cine/spv029s.smk";
if (!_intros.contains(intro)) {
MVideo v(intro, Common::Point(0, 0), false, false, false);
runIntro(v);
@@ -596,7 +598,7 @@ void SpiderEngine::runFusePanel(Code *code) {
int s = 10*x + y + 1;
if (s == 1) {
- _sceneState["GS_SWITCH1"] = !_sceneState["GS_SWITCH1"];
+ _sceneState["GS_SWITCH1"] = !_sceneState["GS_SWITCH1"];
} else if (s == 2) {
_sceneState["GS_SWITCH2"] = !_sceneState["GS_SWITCH2"];
} else if (s == 18) {
@@ -660,7 +662,7 @@ void SpiderEngine::runFileCabinet(Code *code) {
Graphics::Surface *menu = decodeFrame("int_main/hint1.smk", 0);
Common::Rect menuArea(0, 0, menu->w, menu->h);
- Common::String intro = "cine/spv040s.smk";
+ Common::String intro = "cine/spv040s.smk";
if (!_intros.contains(intro)) {
v = new MVideo(intro, Common::Point(0, 0), false, false, false);
runIntro(*v);
@@ -854,7 +856,7 @@ void SpiderEngine::runLock(Code *code) {
if (_sceneState["GS_PUZZLELEVEL"] == 0) // easy
loadImage("factory/elockbg.smk", 0, 0, false, true);
- else
+ else
loadImage("factory/hlockbg.smk", 0, 0, false, true);
for (int i = 0; i < 5; i++) {
@@ -1020,7 +1022,7 @@ void SpiderEngine::runFuseBox(Code *code) {
}
for (int i = 0; i < 8; i++) {
- for (int j = 0; j < 9; j++) {
+ for (int j = 0; j < 9; j++) {
if (hdata[i][j]) {
hcell.moveTo(i*dxHoriz, j*dyHoriz);
Graphics::Surface sub = fuses[0]->getSubArea(hcell);
@@ -1072,6 +1074,22 @@ void SpiderEngine::runFuseBox(Code *code) {
}
}
+void SpiderEngine::runGiveUp() {
+
+ if (_restoredContentEnabled) {
+ showScore("Spider-man was defeated!");
+ }
+ _score = 0;
+ _nextLevel = "mainmenu.mi_";
+}
+
+void SpiderEngine::showScore(const Common::String prefix) {
+ Common::String message = Common::String::format("%s\n\
+ You finished the game with a score of %d points", prefix.c_str(), _score);
+ GUI::MessageDialog dialog(message);
+ dialog.runModal();
+}
+
void SpiderEngine::showCredits() {
if (_cheatsEnabled && !_arcadeMode.empty()) {
_skipLevel = true;
@@ -1085,6 +1103,10 @@ void SpiderEngine::showCredits() {
changeScreenMode("640x480");
MVideo video("cine/credits.smk", Common::Point(0, 0), false, true, false);
runIntro(video);
+ if (_restoredContentEnabled) {
+ showScore("Spider-Man saved the day!");
+ }
+ _score = 0;
_nextLevel = "mainmenu.mi_";
}
}
diff --git a/engines/hypno/spider/spider.cpp b/engines/hypno/spider/spider.cpp
index e1e154d4cbb..8fac7e5895f 100644
--- a/engines/hypno/spider/spider.cpp
+++ b/engines/hypno/spider/spider.cpp
@@ -78,7 +78,7 @@ void SpiderEngine::loadAssetsFullGame() {
loadSceneLevel("mainmenu.mi_", "", prefix);
loadSceneLevel("tryagain.mi_", "", prefix);
- cl = new ChangeLevel("mainmenu.mi_");
+ cl = new ChangeLevel("<give_up>");
sc = (Scene *) _levels["tryagain.mi_"];
sc->hots[1].actions.push_back(cl);
@@ -971,6 +971,11 @@ void SpiderEngine::loadAssetsFullGame() {
chip_lives_with_spiderman->intros.push_back("spider/cine/vrja003s.smk");
chip_lives_with_spiderman->intros.push_back("spider/cine/wins001s.smk");
_levels["<chip_lives_with_spiderman>"] = chip_lives_with_spiderman;
+
+ Code *give_up = new Code("<give_up>");
+ give_up->prefix = prefix;
+ _levels["<give_up>"] = give_up;
+
_defaultCursor = "mouse/cursor1.smk";
// hints areas
@@ -1124,17 +1129,19 @@ void SpiderEngine::drawString(const Common::String &font, const Common::String &
Common::Error SpiderEngine::loadGameStream(Common::SeekableReadStream *stream) {
int puzzleDifficulty = stream->readUint32LE();
int combatDifficulty = stream->readUint32LE();
+ int score = stream->readUint32LE();
const Common::String nextLevel = stream->readString();
- loadGame(nextLevel, puzzleDifficulty, combatDifficulty);
+ loadGame(nextLevel, score, puzzleDifficulty, combatDifficulty);
return Common::kNoError;
}
-void SpiderEngine::loadGame(const Common::String &nextLevel, int puzzleDifficulty, int combatDifficulty) {
+void SpiderEngine::loadGame(const Common::String &nextLevel, int score, int puzzleDifficulty, int combatDifficulty) {
// We don't want to continue with any sound from a previous game
stopSound();
_sceneState["GS_PUZZLELEVEL"] = puzzleDifficulty;
_sceneState["GS_COMBATLEVEL"] = combatDifficulty;
+ _score = score;
_nextLevel = nextLevel;
_checkpoint = _nextLevel;
@@ -1161,6 +1168,7 @@ Common::Error SpiderEngine::saveGameStream(Common::WriteStream *stream, bool isA
stream->writeUint32LE(_sceneState["GS_PUZZLELEVEL"]);
stream->writeUint32LE(_sceneState["GS_COMBATLEVEL"]);
+ stream->writeUint32LE(_score);
stream->writeString(_checkpoint);
stream->writeByte(0);
return Common::kNoError;
More information about the Scummvm-git-logs
mailing list