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

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Tue Feb 16 04:01:47 CET 2010


Revision: 48070
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48070&view=rev
Author:   mthreepwood
Date:     2010-02-16 03:01:46 +0000 (Tue, 16 Feb 2010)

Log Message:
-----------
Move Riven variable randomization to initVars() and implement randomization for the dome and prison combinations.

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_external.h
    scummvm/trunk/engines/mohawk/riven_vars.cpp

Modified: scummvm/trunk/engines/mohawk/riven.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven.cpp	2010-02-16 01:48:19 UTC (rev 48069)
+++ scummvm/trunk/engines/mohawk/riven.cpp	2010-02-16 03:01:46 UTC (rev 48070)
@@ -25,6 +25,7 @@
 
 #include "common/config-manager.h"
 #include "common/events.h"
+#include "common/EventRecorder.h"
 #include "common/keyboard.h"
 
 #include "mohawk/graphics.h"
@@ -60,6 +61,7 @@
 	delete[] _vars;
 	delete _loadDialog;
 	delete _optionsDialog;
+	delete _rnd;
 	_cardData.scripts.clear();
 }
 
@@ -79,6 +81,9 @@
 	_loadDialog->setSaveMode(false);
 	_optionsDialog = new RivenOptionsDialog(this);
 
+	_rnd = new Common::RandomSource();
+	g_eventRec.registerRandomSource(*_rnd, "riven");
+
 	initVars();
 
 	// Open extras.mhk for common images (non-existant in the demo)

Modified: scummvm/trunk/engines/mohawk/riven.h
===================================================================
--- scummvm/trunk/engines/mohawk/riven.h	2010-02-16 01:48:19 UTC (rev 48069)
+++ scummvm/trunk/engines/mohawk/riven.h	2010-02-16 03:01:46 UTC (rev 48070)
@@ -107,6 +107,7 @@
 
 	RivenGraphics *_gfx;
 	RivenExternal *_externalScriptHandler;
+	Common::RandomSource *_rnd;
 
 	Card _cardData;
 	bool _gameOver;

Modified: scummvm/trunk/engines/mohawk/riven_external.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven_external.cpp	2010-02-16 01:48:19 UTC (rev 48069)
+++ scummvm/trunk/engines/mohawk/riven_external.cpp	2010-02-16 03:01:46 UTC (rev 48070)
@@ -29,20 +29,16 @@
 #include "mohawk/sound.h"
 #include "mohawk/video/video.h"
 
-#include "common/EventRecorder.h"
 #include "gui/message.h"
+#include "common/events.h"
 
 namespace Mohawk {
 
 RivenExternal::RivenExternal(MohawkEngine_Riven *vm) : _vm(vm) {
 	setupCommands();
-	_rnd = new Common::RandomSource();
-	g_eventRec.registerRandomSource(*_rnd, "riven");
 }
 
 RivenExternal::~RivenExternal() {
-	delete _rnd;
-
 	for (uint32 i = 0; i < _externalCommands.size(); i++)
 		delete _externalCommands[i];
 
@@ -1052,27 +1048,27 @@
 
 void RivenExternal::xjplaybeetle_550(uint16 argc, uint16 *argv) {
 	// Play a beetle animation 25% of the time
-	*_vm->matchVarToString("jplaybeetle") = (_rnd->getRandomNumberRng(0, 3) == 0) ? 1 : 0;
+	*_vm->matchVarToString("jplaybeetle") = (_vm->_rnd->getRandomNumberRng(0, 3) == 0) ? 1 : 0;
 }
 
 void RivenExternal::xjplaybeetle_600(uint16 argc, uint16 *argv) {
 	// Play a beetle animation 25% of the time
-	*_vm->matchVarToString("jplaybeetle") = (_rnd->getRandomNumberRng(0, 3) == 0) ? 1 : 0;
+	*_vm->matchVarToString("jplaybeetle") = (_vm->_rnd->getRandomNumberRng(0, 3) == 0) ? 1 : 0;
 }
 
 void RivenExternal::xjplaybeetle_950(uint16 argc, uint16 *argv) {
 	// Play a beetle animation 25% of the time
-	*_vm->matchVarToString("jplaybeetle") = (_rnd->getRandomNumberRng(0, 3) == 0) ? 1 : 0;
+	*_vm->matchVarToString("jplaybeetle") = (_vm->_rnd->getRandomNumberRng(0, 3) == 0) ? 1 : 0;
 }
 
 void RivenExternal::xjplaybeetle_1050(uint16 argc, uint16 *argv) {
 	// Play a beetle animation 25% of the time
-	*_vm->matchVarToString("jplaybeetle") = (_rnd->getRandomNumberRng(0, 3) == 0) ? 1 : 0;
+	*_vm->matchVarToString("jplaybeetle") = (_vm->_rnd->getRandomNumberRng(0, 3) == 0) ? 1 : 0;
 }
 
 void RivenExternal::xjplaybeetle_1450(uint16 argc, uint16 *argv) {
 	// Play a beetle animation 25% of the time as long as the girl is not present
-	*_vm->matchVarToString("jplaybeetle") = (_rnd->getRandomNumberRng(0, 3) == 0 && *_vm->matchVarToString("jgirl") != 1) ? 1 : 0;
+	*_vm->matchVarToString("jplaybeetle") = (_vm->_rnd->getRandomNumberRng(0, 3) == 0 && *_vm->matchVarToString("jgirl") != 1) ? 1 : 0;
 }
 
 void RivenExternal::xjlagoon700_alert(uint16 argc, uint16 *argv) {
@@ -1375,15 +1371,6 @@
 	// Give the player Atrus' Journal and the Trap book
 	*_vm->matchVarToString("aatrusbook") = 1;
 	*_vm->matchVarToString("atrapbook") = 1;
-
-	// Randomize the telescope combination
-	uint32 *teleCombo = _vm->matchVarToString("tcorrectorder");
-	for (byte i = 0; i < 5; i++) {
-		*teleCombo *= 10;
-		*teleCombo += _rnd->getRandomNumberRng(1, 5);
-	}
-
-	// TODO: Randomize Dome Combination
 }
 
 // Trap Book is removed from inventory

Modified: scummvm/trunk/engines/mohawk/riven_external.h
===================================================================
--- scummvm/trunk/engines/mohawk/riven_external.h	2010-02-16 01:48:19 UTC (rev 48069)
+++ scummvm/trunk/engines/mohawk/riven_external.h	2010-02-16 03:01:46 UTC (rev 48070)
@@ -41,7 +41,6 @@
 
 private:
 	MohawkEngine_Riven *_vm;
-	Common::RandomSource *_rnd;
 
 	typedef void (RivenExternal::*ExternalCmd)(uint16 argc, uint16 *argv);
 

Modified: scummvm/trunk/engines/mohawk/riven_vars.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven_vars.cpp	2010-02-16 01:48:19 UTC (rev 48069)
+++ scummvm/trunk/engines/mohawk/riven_vars.cpp	2010-02-16 03:01:46 UTC (rev 48070)
@@ -319,6 +319,34 @@
 	*matchVarToString("bheat") = 1;
 	*matchVarToString("waterenabled") = 1;
 	*matchVarToString("ogehnpage") = 1;
+
+	// Randomize the telescope combination
+	uint32 *teleCombo = matchVarToString("tcorrectorder");
+	for (byte i = 0; i < 5; i++) {
+		*teleCombo *= 10;
+		*teleCombo += _rnd->getRandomNumberRng(1, 5); // 5 buttons
+	}
+
+	// Randomize the prison combination
+	uint32 *prisonCombo = matchVarToString("pcorrectorder");
+	for (byte i = 0; i < 5; i++) {
+		*prisonCombo *= 10;
+		*prisonCombo += _rnd->getRandomNumberRng(1, 3); // 3 buttons/sounds
+	}
+
+	// Randomize the dome combination -- each bit represents a slider position,
+	// the highest bit (1 << 24) represents 1, (1 << 23) represents 2, etc.
+	uint32 *domeCombo = matchVarToString("adomecombo");
+	for (byte bitsSet = 0; bitsSet < 5;) {
+		uint32 randomBit = 1 << (24 - _rnd->getRandomNumber(24));
+
+		// Don't overwrite a bit we already set, and throw out the bottom five bits being set
+		if (*domeCombo & randomBit || (*domeCombo | randomBit) == 31)
+			continue;
+
+		*domeCombo |= randomBit;
+		bitsSet++;
+	}
 }
 
 } // End of namespace Mohawk


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