[Scummvm-cvs-logs] SF.net SVN: scummvm:[48134] scummvm/trunk/engines/mohawk

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Fri Feb 26 09:14:34 CET 2010


Revision: 48134
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48134&view=rev
Author:   mthreepwood
Date:     2010-02-26 08:14:33 +0000 (Fri, 26 Feb 2010)

Log Message:
-----------
Slightly rework refreshing cards in Riven (and remove the hackish changeToCard(0)).

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/riven.cpp
    scummvm/trunk/engines/mohawk/riven.h
    scummvm/trunk/engines/mohawk/riven_external.cpp
    scummvm/trunk/engines/mohawk/riven_scripts.cpp

Modified: scummvm/trunk/engines/mohawk/riven.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven.cpp	2010-02-26 08:11:45 UTC (rev 48133)
+++ scummvm/trunk/engines/mohawk/riven.cpp	2010-02-26 08:14:33 UTC (rev 48134)
@@ -127,16 +127,13 @@
 				needsUpdate = true;
 				break;
 			case Common::EVENT_LBUTTONDOWN:
-				if (_curHotspot >= 0) {
+				if (_curHotspot >= 0)
 					runHotspotScript(_curHotspot, kMouseDownScript);
-					//scheduleScript(_hotspots[_curHotspot].script, kMouseMovedPressedReleasedScript);
-				}
 				break;
 			case Common::EVENT_LBUTTONUP:
-				if (_curHotspot >= 0) {
+				if (_curHotspot >= 0)
 					runHotspotScript(_curHotspot, kMouseUpScript);
-					//scheduleScript(_hotspots[_curHotspot].script, kMouseMovedPressedReleasedScript);
-				} else
+				else
 					checkInventoryClick();
 				break;
 			case Common::EVENT_KEYDOWN:
@@ -156,9 +153,8 @@
 						for (uint16 i = 0; i < _hotspotCount; i++)
 							_gfx->drawRect(_hotspots[i].rect, _hotspots[i].enabled);
 						needsUpdate = true;
-					} else {
-						changeToCard();
-					}
+					} else
+						refreshCard();
 					break;
 				case Common::KEYCODE_F5:
 					runDialog(*_optionsDialog);
@@ -180,10 +176,8 @@
 			}
 		}
 
-		if (_curHotspot >= 0) {
+		if (_curHotspot >= 0)
 			runHotspotScript(_curHotspot, kMouseInsideScript);
-			//scheduleScript(_hotspots[_curHotspot].script, kMouseMovedPressedReleasedScript);
-		}
 
 		if (shouldQuit()) {
 			if (_eventMan->shouldRTL() && (getFeatures() & GF_DEMO) && !(_curStack == aspit && _curCard == 12)) {
@@ -274,29 +268,26 @@
 	{ tspit, 0x21b69, ospit,  0x2e76 }		// Dome Linking Book
 };
 
-void MohawkEngine_Riven::changeToCard(uint16 n) {
-	bool refreshMode = (n == 0);
+void MohawkEngine_Riven::changeToCard(uint16 dest) {
+	_curCard = dest;
+	debug (1, "Changing to card %d", _curCard);
 
-	// While this could be run without harm, it doesn't need to be. This should add a speed boost.
-	if (!refreshMode) {
-		debug (1, "Changing to card %d", n);
-		_curCard = n;
+	if (!(getFeatures() & GF_DEMO)) {
+		for (byte i = 0; i < 13; i++)
+			if (_curStack == rivenSpecialChange[i].startStack && _curCard == matchRMAPToCard(rivenSpecialChange[i].startCardRMAP)) {
+				changeToStack(rivenSpecialChange[i].targetStack);
+				_curCard = matchRMAPToCard(rivenSpecialChange[i].targetCardRMAP);
+			}
+	}
 
-		if (!(getFeatures() & GF_DEMO)) {
-			for (byte i = 0; i < 13; i++)
-				if (_curStack == rivenSpecialChange[i].startStack && _curCard == matchRMAPToCard(rivenSpecialChange[i].startCardRMAP)) {
-					changeToStack(rivenSpecialChange[i].targetStack);
-					_curCard = matchRMAPToCard(rivenSpecialChange[i].targetCardRMAP);
-				}
-		}
+	if (_cardData.hasData)
+		runCardScript(kCardLeaveScript);
 
-		if (_cardData.hasData)
-			runCardScript(kCardLeaveScript);
+	loadCard(_curCard);
+	refreshCard(); // Handles hotspots and scripts
+}
 
-		loadCard(_curCard);
-	}
-
-	// We need to reload hotspots when refreshing, however
+void MohawkEngine_Riven::refreshCard() {
 	loadHotspots(_curCard);
 
 	_gfx->_updatesEnabled = true;

Modified: scummvm/trunk/engines/mohawk/riven.h
===================================================================
--- scummvm/trunk/engines/mohawk/riven.h	2010-02-26 08:11:45 UTC (rev 48133)
+++ scummvm/trunk/engines/mohawk/riven.h	2010-02-26 08:14:33 UTC (rev 48134)
@@ -149,8 +149,9 @@
 	bool _activatedSLST;
 	void runLoadDialog();
 
-	void changeToCard(uint16 = 0);
+	void changeToCard(uint16 dest);
 	void changeToStack(uint16);
+	void refreshCard();
 	Common::String getName(uint16 nameResource, uint16 nameID);
 	Common::String getStackName(uint16 stack);
 	void runCardScript(uint16 scriptType);

Modified: scummvm/trunk/engines/mohawk/riven_external.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven_external.cpp	2010-02-26 08:11:45 UTC (rev 48133)
+++ scummvm/trunk/engines/mohawk/riven_external.cpp	2010-02-26 08:14:33 UTC (rev 48134)
@@ -357,13 +357,13 @@
 void RivenExternal::xatrapbookclose(uint16 argc, uint16 *argv) {
 	// Close the trap book
 	*_vm->matchVarToString("atrap") = 0;
-	_vm->changeToCard(); // Refresh
+	_vm->refreshCard();
 }
 
 void RivenExternal::xatrapbookopen(uint16 argc, uint16 *argv) {
 	// Open the trap book
 	*_vm->matchVarToString("atrap") = 1;
-	_vm->changeToCard(); // Refresh
+	_vm->refreshCard();
 }
 
 void RivenExternal::xarestoregame(uint16 argc, uint16 *argv) {
@@ -523,7 +523,7 @@
 		// TODO: Stop MLST's 7 and 8
 	}
 
-	_vm->changeToCard();
+	_vm->refreshCard();
 }
 
 void RivenExternal::xbsettrap(uint16 argc, uint16 *argv) {
@@ -659,21 +659,21 @@
 				if (*valve == 0 && changeY <= -10) {
 					*valve = 1;
 					// TODO: Play movie
-					_vm->changeToCard(); // Refresh
+					_vm->refreshCard();
 				} else if (*valve == 1) {
 					if (changeX >= 0 && changeY >= 10) {
 						*valve = 0;
 						// TODO: Play movie
-						_vm->changeToCard(); // Refresh
+						_vm->refreshCard();
 					} else if (changeX <= -10 && changeY <= 10) {
 						*valve = 2;
 						// TODO: Play movie
-						_vm->changeToCard(); // Refresh
+						_vm->refreshCard();
 					}
 				} else if (*valve == 2 && changeX >= 10) {
 					*valve = 1;
 					// TODO: Play movie
-					_vm->changeToCard(); // Refresh
+					_vm->refreshCard();
 				}
 				return;
 			default:
@@ -1150,7 +1150,7 @@
 
 	// We now need to draw PLST 1 and refresh, but PLST 1 is
 	// drawn when refreshing anyway, so don't worry about that.
-	_vm->changeToCard();
+	_vm->refreshCard();
 }
 
 void RivenExternal::xobedroom5_closedrawer(uint16 argc, uint16 *argv) {
@@ -1230,7 +1230,7 @@
 	_vm->_video->playMovieBlocking(1);
 
 	// And, finally, refresh
-	_vm->changeToCard();
+	_vm->refreshCard();
 }
 
 // ------------------------------------------------------------------------------------
@@ -1369,7 +1369,7 @@
 
 		// Now move the telescope down a position and refresh
 		*telescopePos -= 1;
-		_vm->changeToCard();
+		_vm->refreshCard();
 	}
 }
 
@@ -1393,7 +1393,7 @@
 
 	// Now move the telescope up a position and refresh
 	*telescopePos += 1;
-	_vm->changeToCard();
+	_vm->refreshCard();
 }
 
 void RivenExternal::xtisland390_covercombo(uint16 argc, uint16 *argv) {

Modified: scummvm/trunk/engines/mohawk/riven_scripts.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven_scripts.cpp	2010-02-26 08:11:45 UTC (rev 48133)
+++ scummvm/trunk/engines/mohawk/riven_scripts.cpp	2010-02-26 08:14:33 UTC (rev 48134)
@@ -417,17 +417,16 @@
 // Parameter 0: transition type
 // Parameters 1-4: transition rectangle
 void RivenScript::transition(uint16 op, uint16 argc, uint16 *argv) {
-	if (argc == 1) {
+	if (argc == 1)
 		_vm->_gfx->scheduleTransition(argv[0]);
-	} else {
+	else
 		_vm->_gfx->scheduleTransition(argv[0], Common::Rect(argv[1], argv[2], argv[3], argv[4]));
-	}
 }
 
 // Command 19: reload card
 void RivenScript::refreshCard(uint16 op, uint16 argc, uint16 *argv) {
-	debug(2, "Reloading card");
-	_vm->changeToCard();
+	debug(2, "Refreshing card");
+	_vm->refreshCard();
 }
 
 // Command 20: disable screen update


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list