[Scummvm-git-logs] scummvm master -> 176c87dd4a2d5b0ee5563789797f269ac6113033

LubomirR lubomirr at lubomirr.eu
Tue Oct 30 18:56:59 CET 2018


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:
176c87dd4a MUTATIONOFJB: Add stub for switching game chapter.


Commit: 176c87dd4a2d5b0ee5563789797f269ac6113033
    https://github.com/scummvm/scummvm/commit/176c87dd4a2d5b0ee5563789797f269ac6113033
Author: Ľubomír Remák (lubomirr at lubomirr.eu)
Date: 2018-10-30T18:56:37+01:00

Commit Message:
MUTATIONOFJB: Add stub for switching game chapter.

Changed paths:
  A engines/mutationofjb/commands/switchpartcommand.cpp
  A engines/mutationofjb/commands/switchpartcommand.h
    engines/mutationofjb/game.cpp
    engines/mutationofjb/game.h
    engines/mutationofjb/gamedata.cpp
    engines/mutationofjb/inventory.cpp
    engines/mutationofjb/module.mk
    engines/mutationofjb/script.cpp


diff --git a/engines/mutationofjb/commands/switchpartcommand.cpp b/engines/mutationofjb/commands/switchpartcommand.cpp
new file mode 100644
index 0000000..8bf7446
--- /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 0000000..ded49a5
--- /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 134dc72..96ebe55 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 27804ea..29ec5f2 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 40be8af..4905bbb 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 6176425..9de65b2 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 d9f536a..cc8eab1 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 d2b9602..4915530 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
 	};
 





More information about the Scummvm-git-logs mailing list