aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mutationofjb/commands/switchpartcommand.cpp58
-rw-r--r--engines/mutationofjb/commands/switchpartcommand.h47
-rw-r--r--engines/mutationofjb/game.cpp15
-rw-r--r--engines/mutationofjb/game.h5
-rw-r--r--engines/mutationofjb/gamedata.cpp1
-rw-r--r--engines/mutationofjb/inventory.cpp4
-rw-r--r--engines/mutationofjb/module.mk1
-rw-r--r--engines/mutationofjb/script.cpp2
8 files changed, 128 insertions, 5 deletions
diff --git a/engines/mutationofjb/commands/switchpartcommand.cpp b/engines/mutationofjb/commands/switchpartcommand.cpp
new file mode 100644
index 0000000000..8bf7446f97
--- /dev/null
+++ b/engines/mutationofjb/commands/switchpartcommand.cpp
@@ -0,0 +1,58 @@
+/* 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 "mutationofjb/commands/switchpartcommand.h"
+
+#include "mutationofjb/game.h"
+#include "mutationofjb/gamedata.h"
+#include "mutationofjb/script.h"
+
+#include "common/str.h"
+
+/** @file
+ * "SWITCHPART"
+ *
+ * Switches to the second part of the game (part B).
+ */
+
+namespace MutationOfJB {
+
+bool SwitchPartCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
+ if (line != "SWITCHPART") {
+ return false;
+ }
+
+ command = new SwitchPartCommand();
+ return true;
+}
+
+Command::ExecuteResult SwitchPartCommand::execute(ScriptExecutionContext &scriptExeCtx) {
+ scriptExeCtx.getGame().switchToPartB();
+
+ return Command::Finished;
+}
+
+Common::String SwitchPartCommand::debugString() const {
+ return "SWITCHPART";
+}
+
+}
diff --git a/engines/mutationofjb/commands/switchpartcommand.h b/engines/mutationofjb/commands/switchpartcommand.h
new file mode 100644
index 0000000000..ded49a53a7
--- /dev/null
+++ b/engines/mutationofjb/commands/switchpartcommand.h
@@ -0,0 +1,47 @@
+/* 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 MUTATIONOFJB_SWITCHPARTCOMMAND_H
+#define MUTATIONOFJB_SWITCHPARTCOMMAND_H
+
+#include "mutationofjb/commands/seqcommand.h"
+#include "common/scummsys.h"
+
+namespace MutationOfJB {
+
+class ConversationTask;
+
+class SwitchPartCommandParser : public SeqCommandParser {
+public:
+ virtual bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
+};
+
+class SwitchPartCommand : public SeqCommand {
+public:
+ SwitchPartCommand() {}
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
+ virtual Common::String debugString() const override;
+};
+
+}
+
+#endif
diff --git a/engines/mutationofjb/game.cpp b/engines/mutationofjb/game.cpp
index 134dc72e90..96ebe554cf 100644
--- a/engines/mutationofjb/game.cpp
+++ b/engines/mutationofjb/game.cpp
@@ -42,6 +42,7 @@ Game::Game(MutationOfJBEngine *vm)
: _vm(vm),
_randomSource("mutationofjb"),
_delayedLocalScript(nullptr),
+ _runDelayedScriptStartup(false),
_gui(*this, _vm->getScreen()),
_scriptExecCtx(*this),
_taskManager(*this),
@@ -148,8 +149,9 @@ void Game::changeScene(uint8 sceneId, bool partB) {
}
}
-Script *Game::changeSceneDelayScript(uint8 sceneId, bool partB) {
+Script *Game::changeSceneDelayScript(uint8 sceneId, bool partB, bool runDelayedScriptStartup) {
_delayedLocalScript = changeSceneLoadScript(sceneId, partB);
+ _runDelayedScriptStartup = runDelayedScriptStartup;
return _delayedLocalScript;
}
@@ -190,7 +192,12 @@ void Game::update() {
if (res == Command::Finished && _delayedLocalScript) {
delete _localScript;
_localScript = _delayedLocalScript;
+
+ if (_localScript && _runDelayedScriptStartup)
+ _scriptExecCtx.startStartupSection();
+
_delayedLocalScript = nullptr;
+ _runDelayedScriptStartup = false;
}
_taskManager.update();
@@ -263,4 +270,10 @@ Common::Language Game::getLanguage() const {
return _vm->getGameDescription()->language;
}
+void Game::switchToPartB() {
+ getGameData().getInventory().removeAllItems();
+ loadGameData(true);
+ changeSceneDelayScript(3, true, true);
+}
+
}
diff --git a/engines/mutationofjb/game.h b/engines/mutationofjb/game.h
index 27804ea8d8..29ec5f2a16 100644
--- a/engines/mutationofjb/game.h
+++ b/engines/mutationofjb/game.h
@@ -60,7 +60,7 @@ public:
Script *getLocalScript() const;
void changeScene(uint8 sceneId, bool partB);
- Script *changeSceneDelayScript(uint8 sceneId, bool partB);
+ Script *changeSceneDelayScript(uint8 sceneId, bool partB, bool runDelayedScriptStartup = false);
bool startActionSection(ActionInfo::Action action, const Common::String &entity1Name, const Common::String &entity2Name = Common::String());
@@ -84,6 +84,8 @@ public:
Common::Language getLanguage() const;
+ void switchToPartB();
+
private:
bool loadGameData(bool partB);
void runActiveCommand();
@@ -97,6 +99,7 @@ private:
Script *_globalScript;
Script *_localScript;
Script *_delayedLocalScript;
+ bool _runDelayedScriptStartup;
Room *_room;
GameScreen _gui;
diff --git a/engines/mutationofjb/gamedata.cpp b/engines/mutationofjb/gamedata.cpp
index 40be8affd2..4905bbb3e2 100644
--- a/engines/mutationofjb/gamedata.cpp
+++ b/engines/mutationofjb/gamedata.cpp
@@ -374,6 +374,7 @@ GameData::GameData()
_lastScene(0),
_partB(false),
_inventory(),
+ _currentAPK("piggy.apk"),
_color(WHITE) {}
Scene *GameData::getScene(uint8 sceneId) {
diff --git a/engines/mutationofjb/inventory.cpp b/engines/mutationofjb/inventory.cpp
index 6176425ca2..9de65b2dbd 100644
--- a/engines/mutationofjb/inventory.cpp
+++ b/engines/mutationofjb/inventory.cpp
@@ -143,9 +143,7 @@ void Inventory::saveLoadWithSerializer(Common::Serializer &sz) {
if (sz.isLoading()) {
uint32 length = 0;
sz.syncAsUint32LE(length);
- if (length) {
- _items.resize(length);
- }
+ _items.resize(length);
} else {
uint32 length = static_cast<uint32>(_items.size());
sz.syncAsUint32LE(length);
diff --git a/engines/mutationofjb/module.mk b/engines/mutationofjb/module.mk
index d9f536a6fa..cc8eab159c 100644
--- a/engines/mutationofjb/module.mk
+++ b/engines/mutationofjb/module.mk
@@ -22,6 +22,7 @@ MODULE_OBJS := \
commands/seqcommand.o \
commands/setcolorcommand.o \
commands/specialshowcommand.o \
+ commands/switchpartcommand.o \
commands/talkcommand.o \
commands/randomcommand.o \
tasks/conversationtask.o \
diff --git a/engines/mutationofjb/script.cpp b/engines/mutationofjb/script.cpp
index d2b9602c15..4915530f32 100644
--- a/engines/mutationofjb/script.cpp
+++ b/engines/mutationofjb/script.cpp
@@ -47,6 +47,7 @@
#include "mutationofjb/commands/randomcommand.h"
#include "mutationofjb/commands/setcolorcommand.h"
#include "mutationofjb/commands/specialshowcommand.h"
+#include "mutationofjb/commands/switchpartcommand.h"
#include "mutationofjb/game.h"
namespace MutationOfJB {
@@ -77,6 +78,7 @@ static CommandParser **getParsers() {
new RandomBlockStartParser,
new SetColorCommandParser,
new SpecialShowCommandParser,
+ new SwitchPartCommandParser,
nullptr
};