[Scummvm-git-logs] scummvm master -> 2d80b931b3f004265fd08c3182f94a4c5824e063

dreammaster dreammaster at scummvm.org
Mon Feb 20 04:59:57 CET 2017


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:
2d80b931b3 WORKAROUND: Stop resetting bomb code wheels when loading savegames


Commit: 2d80b931b3f004265fd08c3182f94a4c5824e063
    https://github.com/scummvm/scummvm/commit/2d80b931b3f004265fd08c3182f94a4c5824e063
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-02-19T22:57:31-05:00

Commit Message:
WORKAROUND: Stop resetting bomb code wheels when loading savegames

The original kept resetting the bomb's code wheels whenever the view
was entered, which meant reloading a savegame, you lost any progress
you'd made. Presumably this was done as a quick and dirty hack in
case anyone was stupid enough to rearm the bomb after fixing it the
first time. I've added new code that now only resets the wheels when
the bomb is initially armed, and you can now save in the bomb
closeup, and it will remember all your selections

Changed paths:
    engines/titanic/core/saveable_object.cpp
    engines/titanic/game/bomb.cpp
    engines/titanic/game/code_wheel.cpp
    engines/titanic/game/code_wheel.h
    engines/titanic/messages/messages.h


diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp
index 8bb8a92..0257f6a 100644
--- a/engines/titanic/core/saveable_object.cpp
+++ b/engines/titanic/core/saveable_object.cpp
@@ -955,6 +955,7 @@ DEFFN(CUseWithCharMsg);
 DEFFN(CUseWithOtherMsg);
 DEFFN(CVirtualKeyCharMsg);
 DEFFN(CVisibleMsg);
+DEFFN(CCheckCodeWheelsMsg);
 
 DEFFN(CEnterBombRoom);
 DEFFN(CEnterBridge);
@@ -1538,6 +1539,7 @@ void CSaveableObject::initClassList() {
 	ADDFN(CUseWithOtherMsg, CMessage);
 	ADDFN(CVirtualKeyCharMsg, CMessage);
 	ADDFN(CVisibleMsg, CMessage);
+	ADDFN(CCheckCodeWheelsMsg, CMessage);
 
 	ADDFN(CMovePlayerTo, CGameObject);
 	ADDFN(CMovePlayerToFrom, CGameObject);
diff --git a/engines/titanic/game/bomb.cpp b/engines/titanic/game/bomb.cpp
index 0f4ce92..17c10c5 100644
--- a/engines/titanic/game/bomb.cpp
+++ b/engines/titanic/game/bomb.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "titanic/game/bomb.h"
+#include "titanic/game/code_wheel.h"
 
 namespace Titanic {
 
@@ -36,6 +37,8 @@ BEGIN_MESSAGE_MAP(CBomb, CBackground)
 	ON_MESSAGE(SetFrameMsg)
 END_MESSAGE_MAP()
 
+const int CORRECT_WHEELS = 23;
+
 static const char *const HUNDREDS_WAVS[] = {
 	"", "z#353.wav", "z#339.wav", "z#325.wav", "z#311.wav", "z#297.wav",
 	"z#283.wav", "z#269.wav", "z#255.wav", "z#241.wav"
@@ -115,9 +118,13 @@ void CBomb::load(SimpleFile *file) {
 }
 
 bool CBomb::StatusChangeMsg(CStatusChangeMsg *msg) {
-	_numCorrectWheels += msg->_newStatus;
+	// Check whether the wheels are corect
+	CCheckCodeWheelsMsg checkMsg;
+	checkMsg.execute(findRoom(), nullptr, MSGFLAG_SCAN);
+
+	_numCorrectWheels = checkMsg._isCorrect ? CORRECT_WHEELS : 0;
 
-	if (_numCorrectWheels == 23) {
+	if (_numCorrectWheels == CORRECT_WHEELS) {
 		// Nobody likes a smartass
 		startAnimTimer("Disarmed", 2000);
 		lockMouse();
@@ -158,7 +165,7 @@ bool CBomb::StatusChangeMsg(CStatusChangeMsg *msg) {
 }
 
 bool CBomb::EnterViewMsg(CEnterViewMsg *msg) {
-	_numCorrectWheels = 2;
+	// WORKAROUND: Don't keep resetting wheels
 	return true;
 }
 
@@ -169,7 +176,7 @@ bool CBomb::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
 		stopSound(_soundHandle);
 		//stopSound(_unusedHandle);
 
-		if (_numCorrectWheels < 23) {
+		if (_numCorrectWheels < CORRECT_WHEELS) {
 			_tappedCtr = MIN(_tappedCtr + 1, 23);
 
 			CString name;
@@ -263,6 +270,16 @@ bool CBomb::TurnOn(CTurnOn *msg) {
 		_soundHandle = playSound("z#389.wav", _volume);
 		_active = true;
 
+		// WORKAROUND: Only reset the code wheels back to 'O' value
+		// when first arming the bomb, not whenever the bomb view is entered
+		_numCorrectWheels = 2;
+		CRoomItem *room = findRoom();
+		for (CTreeItem *treeItem = room; treeItem; treeItem = treeItem->scan(room)) {
+			CodeWheel *codeWheel = dynamic_cast<CodeWheel *>(treeItem);
+			if (codeWheel)
+				codeWheel->reset();
+		}
+
 		CActMsg actMsg("Arm Bomb");
 		actMsg.execute("EndExplodeShip");
 		addTimer(0);
diff --git a/engines/titanic/game/code_wheel.cpp b/engines/titanic/game/code_wheel.cpp
index 9a3d6fc..1df99ae 100644
--- a/engines/titanic/game/code_wheel.cpp
+++ b/engines/titanic/game/code_wheel.cpp
@@ -30,17 +30,25 @@ BEGIN_MESSAGE_MAP(CodeWheel, CBomb)
 	ON_MESSAGE(EnterViewMsg)
 	ON_MESSAGE(MouseButtonUpMsg)
 	ON_MESSAGE(MovieEndMsg)
+	ON_MESSAGE(CheckCodeWheelsMsg)
 END_MESSAGE_MAP()
 
+static const int START_FRAMES[15] = {
+	0, 5, 10, 15, 19, 24, 28, 33, 38, 42, 47, 52, 57, 61, 66
+};
+static const int END_FRAMES[15] = {
+	5, 10, 15, 19, 24, 28, 33, 38, 42, 47, 52, 57, 61, 66, 70
+};
+
 CodeWheel::CodeWheel() : CBomb(), _correctValue(0), _value(4),
-		_isCorrect(0), _field114(0), _field118(0) {
+		_matched(false), _field114(0), _field118(0) {
 }
 
 void CodeWheel::save(SimpleFile *file, int indent) {
 	file->writeNumberLine(1, indent);
 	file->writeNumberLine(_correctValue, indent);
 	file->writeNumberLine(_value, indent);
-	file->writeNumberLine(_isCorrect, indent);
+	file->writeNumberLine(_matched, indent);
 	if (g_vm->isGerman()) {
 		file->writeNumberLine(_field114, indent);
 		file->writeNumberLine(_field118, indent);
@@ -53,7 +61,7 @@ void CodeWheel::load(SimpleFile *file) {
 	file->readNumber();
 	_correctValue = file->readNumber();
 	_value = file->readNumber();
-	_isCorrect = file->readNumber();
+	_matched = file->readNumber();
 	if (g_vm->isGerman()) {
 		_field114 = file->readNumber();
 		_field118 = file->readNumber();
@@ -63,26 +71,19 @@ void CodeWheel::load(SimpleFile *file) {
 }
 
 bool CodeWheel::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
-	static const int START_FRAMES[15] = {
-		0, 5, 10, 15, 19, 24, 28, 33, 38, 42, 47, 52, 57, 61, 66
-	};
-	static const int END_FRAMES[15] = {
-		5, 10, 15, 19, 24, 28, 33, 38, 42, 47, 52, 57, 61, 66, 70
-	};
-
 	int yp = _bounds.top + _bounds.height() / 2;
-	_isCorrect = false;
+	_matched = false;
 
 	if (msg->_mousePos.y > yp) {
 		if (_value == _correctValue)
-			_isCorrect = true;
+			_matched = true;
 
 		_value = (_value + 1) % 15;
 		playMovie(START_FRAMES[_value], END_FRAMES[_value],
 			MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT);
 	} else {
 		if (_value == _correctValue)
-			_isCorrect = true;
+			_matched = true;
 
 		playMovie(START_FRAMES[14 - _value] + 68, END_FRAMES[14 - _value] + 68,
 			MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT);
@@ -95,8 +96,8 @@ bool CodeWheel::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
 }
 
 bool CodeWheel::EnterViewMsg(CEnterViewMsg *msg) {
-	loadFrame(24);
-	_value = 4;
+	// WORKAROUND: Don't keep resetting code wheels back to default
+	loadFrame(END_FRAMES[_value]);
 	return true;
 }
 
@@ -106,15 +107,18 @@ bool CodeWheel::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
 
 bool CodeWheel::MovieEndMsg(CMovieEndMsg *msg) {
 	sleep(200);
+
+	// Signal that a code wheel has changed
 	CStatusChangeMsg changeMsg;
-	changeMsg._newStatus = 0;
-	if (_isCorrect)
-		changeMsg._newStatus = -1;
-	if (_value == _correctValue)
-		changeMsg._newStatus = 1;
 	changeMsg.execute("Bomb");
 
 	return true;
 }
 
+bool CodeWheel::CheckCodeWheelsMsg(CCheckCodeWheelsMsg *msg) {
+	if (_value != _correctValue)
+		msg->_isCorrect = false;
+	return true;
+}
+
 } // End of namespace Titanic
diff --git a/engines/titanic/game/code_wheel.h b/engines/titanic/game/code_wheel.h
index ac654ff..3d19eeb 100644
--- a/engines/titanic/game/code_wheel.h
+++ b/engines/titanic/game/code_wheel.h
@@ -33,10 +33,11 @@ class CodeWheel : public CBomb {
 	bool EnterViewMsg(CEnterViewMsg *msg);
 	bool MouseButtonUpMsg(CMouseButtonUpMsg *msg);
 	bool MovieEndMsg(CMovieEndMsg *msg);
+	bool CheckCodeWheelsMsg(CCheckCodeWheelsMsg *msg);
 private:
 	int _correctValue;
 	int _value;
-	bool _isCorrect;
+	bool _matched;
 	// German specific fields
 	int _field114;
 	int _field118;
@@ -53,6 +54,11 @@ public:
 	 * Load the data for the class from file
 	 */
 	virtual void load(SimpleFile *file);
+
+	/**
+	 * Resets a code wheel back to the default 'O' value
+	 */
+	void reset() { _value = 4; }
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h
index e62c5e5..a1e9ccb 100644
--- a/engines/titanic/messages/messages.h
+++ b/engines/titanic/messages/messages.h
@@ -378,6 +378,7 @@ MESSAGE1(CUseWithCharMsg, CCharacter *, character, nullptr);
 MESSAGE1(CUseWithOtherMsg, CGameObject *, other, 0);
 MESSAGE1(CVirtualKeyCharMsg, Common::KeyState, keyState, Common::KeyState());
 MESSAGE1(CVisibleMsg, bool, visible, true);
+MESSAGE1(CCheckCodeWheelsMsg, bool, isCorrect, true);
 
 } // End of namespace Titanic
 





More information about the Scummvm-git-logs mailing list