aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/riven_vars.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2010-02-16 03:01:46 +0000
committerMatthew Hoops2010-02-16 03:01:46 +0000
commit5fd7dbb4061d808e4bc4c0cfba5e2eabf2687544 (patch)
treefe996c14b52c9211651a8106fb9637e3822bba80 /engines/mohawk/riven_vars.cpp
parentb3ab83d8c125f8a7d8bafce04a3db11c3cdddec1 (diff)
downloadscummvm-rg350-5fd7dbb4061d808e4bc4c0cfba5e2eabf2687544.tar.gz
scummvm-rg350-5fd7dbb4061d808e4bc4c0cfba5e2eabf2687544.tar.bz2
scummvm-rg350-5fd7dbb4061d808e4bc4c0cfba5e2eabf2687544.zip
Move Riven variable randomization to initVars() and implement randomization for the dome and prison combinations.
svn-id: r48070
Diffstat (limited to 'engines/mohawk/riven_vars.cpp')
-rw-r--r--engines/mohawk/riven_vars.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/engines/mohawk/riven_vars.cpp b/engines/mohawk/riven_vars.cpp
index ed540cd82e..3f7cd5a8b6 100644
--- a/engines/mohawk/riven_vars.cpp
+++ b/engines/mohawk/riven_vars.cpp
@@ -319,6 +319,34 @@ void MohawkEngine_Riven::initVars() {
*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