aboutsummaryrefslogtreecommitdiff
path: root/engines/neverhood
diff options
context:
space:
mode:
authorjohndoe1232013-01-17 10:04:17 +0000
committerWillem Jan Palenstijn2013-05-08 20:47:40 +0200
commitdf43b8bd6889ebf39c1642b9648b10d64cc5fcdd (patch)
tree31c4f4f4aa801472545987692060259f37b08b6c /engines/neverhood
parentf945448c7ba3884cded68314a13aa2132603121d (diff)
downloadscummvm-rg350-df43b8bd6889ebf39c1642b9648b10d64cc5fcdd.tar.gz
scummvm-rg350-df43b8bd6889ebf39c1642b9648b10d64cc5fcdd.tar.bz2
scummvm-rg350-df43b8bd6889ebf39c1642b9648b10d64cc5fcdd.zip
NEVERHOOD: Move Scene2804::initCrystalColors() to GameModule::initCrystalColorsPuzzle()
- Add Scene::isMessageList2, only used in Scene2101
Diffstat (limited to 'engines/neverhood')
-rw-r--r--engines/neverhood/gamemodule.cpp40
-rw-r--r--engines/neverhood/gamemodule.h1
-rw-r--r--engines/neverhood/module2100.cpp2
-rw-r--r--engines/neverhood/module2800.cpp42
-rw-r--r--engines/neverhood/module2800.h1
-rw-r--r--engines/neverhood/scene.cpp4
-rw-r--r--engines/neverhood/scene.h1
7 files changed, 48 insertions, 43 deletions
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp
index c9310571f0..6ba3e98261 100644
--- a/engines/neverhood/gamemodule.cpp
+++ b/engines/neverhood/gamemodule.cpp
@@ -284,6 +284,46 @@ void GameModule::initCubeSymbolsPuzzle() {
}
}
+void GameModule::initCrystalColorsPuzzle() {
+ // TODO Maybe move this into the GameModule so all puzzle init code is together
+ if (getGlobalVar(V_CRYSTAL_COLORS_INIT) == 0) {
+ TextResource textResource(_vm);
+ const char *textStart, *textEnd;
+ textResource.load(0x46691611);
+ textStart = textResource.getString(0, textEnd);
+ for (uint index = 0; index < 5; index++) {
+ char colorLetter = (byte)textStart[index];
+ byte correctColorNum = 0, misalignedColorNum;
+ switch (colorLetter) {
+ case 'B':
+ correctColorNum = 4;
+ break;
+ case 'G':
+ correctColorNum = 3;
+ break;
+ case 'O':
+ correctColorNum = 1;
+ break;
+ case 'R':
+ correctColorNum = 0;
+ break;
+ case 'V':
+ correctColorNum = 5;
+ break;
+ case 'Y':
+ correctColorNum = 2;
+ break;
+ }
+ do {
+ misalignedColorNum = _vm->_rnd->getRandomNumber(6 - 1);
+ } while (misalignedColorNum == correctColorNum);
+ setSubVar(VA_GOOD_CRYSTAL_COLORS, index, correctColorNum);
+ setSubVar(VA_CURR_CRYSTAL_COLORS, index, misalignedColorNum);
+ }
+ setGlobalVar(V_CRYSTAL_COLORS_INIT, 1);
+ }
+}
+
uint32 GameModule::getCurrRadioMusicFileHash() {
uint musicIndex = getGlobalVar(V_CURR_RADIO_MUSIC_INDEX);
return (musicIndex % 5 != 0) ? 0 : kRadioMusicFileHashes[CLIP<uint>(musicIndex / 5, 0, 17)];
diff --git a/engines/neverhood/gamemodule.h b/engines/neverhood/gamemodule.h
index 93373a1a3f..ee6b000533 100644
--- a/engines/neverhood/gamemodule.h
+++ b/engines/neverhood/gamemodule.h
@@ -51,6 +51,7 @@ public:
void initCannonSymbolsPuzzle();
void initCodeSymbolsPuzzle();
void initCubeSymbolsPuzzle();
+ void initCrystalColorsPuzzle();
uint32 getCurrRadioMusicFileHash();
protected:
Entity *_prevChildObject;
diff --git a/engines/neverhood/module2100.cpp b/engines/neverhood/module2100.cpp
index 423f93c325..5b5f5af2f3 100644
--- a/engines/neverhood/module2100.cpp
+++ b/engines/neverhood/module2100.cpp
@@ -285,7 +285,7 @@ void Scene2101::update() {
}
}
}
- } else if (_doorStatus == 1 && _messageValue >= 0 && _klayman->getX() > 470 /* TODO ! && _messageList2 != 0x004B8F48*/)
+ } else if (_doorStatus == 1 && _messageValue >= 0 && _klayman->getX() > 470 && !isMessageList2(0x004B8F48))
setMessageList2(0x004B8F50);
Scene::update();
}
diff --git a/engines/neverhood/module2800.cpp b/engines/neverhood/module2800.cpp
index 7c7c097696..214e65e62e 100644
--- a/engines/neverhood/module2800.cpp
+++ b/engines/neverhood/module2800.cpp
@@ -1734,7 +1734,7 @@ Scene2804::Scene2804(NeverhoodEngine *vm, Module *parentModule, int which)
: Scene(vm, parentModule), _countdown1(0), _countdown2(0), _countdown3(0),
_beamStatus(0), _isSolved(false), _isWorking(false) {
- initCrystalColors();
+ _vm->gameModule()->initCrystalColorsPuzzle();
SetMessageHandler(&Scene2804::handleMessage);
SetUpdateHandler(&Scene2804::update);
@@ -1841,46 +1841,6 @@ void Scene2804::update() {
}
-void Scene2804::initCrystalColors() {
- // TODO Maybe move this into the GameModule so all puzzle init code is together
- if (getGlobalVar(V_CRYSTAL_COLORS_INIT) == 0) {
- TextResource textResource(_vm);
- const char *textStart, *textEnd;
- textResource.load(0x46691611);
- textStart = textResource.getString(0, textEnd);
- for (uint index = 0; index < 5; index++) {
- char colorLetter = (byte)textStart[index];
- byte correctColorNum = 0, misalignedColorNum;
- switch (colorLetter) {
- case 'B':
- correctColorNum = 4;
- break;
- case 'G':
- correctColorNum = 3;
- break;
- case 'O':
- correctColorNum = 1;
- break;
- case 'R':
- correctColorNum = 0;
- break;
- case 'V':
- correctColorNum = 5;
- break;
- case 'Y':
- correctColorNum = 2;
- break;
- }
- do {
- misalignedColorNum = _vm->_rnd->getRandomNumber(6 - 1);
- } while (misalignedColorNum == correctColorNum);
- setSubVar(VA_GOOD_CRYSTAL_COLORS, index, correctColorNum);
- setSubVar(VA_CURR_CRYSTAL_COLORS, index, misalignedColorNum);
- }
- setGlobalVar(V_CRYSTAL_COLORS_INIT, 1);
- }
-}
-
Scene2805::Scene2805(NeverhoodEngine *vm, Module *parentModule, int which)
: Scene(vm, parentModule) {
diff --git a/engines/neverhood/module2800.h b/engines/neverhood/module2800.h
index 1dd7bca402..a341c23944 100644
--- a/engines/neverhood/module2800.h
+++ b/engines/neverhood/module2800.h
@@ -273,7 +273,6 @@ protected:
Sprite *_ssCrystalButtons[5];
void update();
uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
- void initCrystalColors();
};
class Scene2805 : public Scene {
diff --git a/engines/neverhood/scene.cpp b/engines/neverhood/scene.cpp
index c22683ae37..1f2f479ba3 100644
--- a/engines/neverhood/scene.cpp
+++ b/engines/neverhood/scene.cpp
@@ -381,6 +381,10 @@ bool Scene::setMessageList2(MessageList *messageList, bool canAcceptInput, bool
return false;
}
+bool Scene::isMessageList2(uint32 id) {
+ return _messageList2 == _vm->_staticData->getMessageList(id);
+}
+
void Scene::processMessageList() {
debug(7, "Scene::processMessageList() _isMessageListBusy = %d; _isKlaymanBusy = %d", _isMessageListBusy, _isKlaymanBusy);
diff --git a/engines/neverhood/scene.h b/engines/neverhood/scene.h
index f03275f569..39455c78fa 100644
--- a/engines/neverhood/scene.h
+++ b/engines/neverhood/scene.h
@@ -204,6 +204,7 @@ protected:
void setMessageList(MessageList *messageList, bool canAcceptInput = true, bool doConvertMessages = false);
bool setMessageList2(uint32 id, bool canAcceptInput = true, bool doConvertMessages = false);
bool setMessageList2(MessageList *messageList, bool canAcceptInput = true, bool doConvertMessages = false);
+ bool isMessageList2(uint32 id);
void processMessageList();
void setRectList(uint32 id);
void setRectList(RectList *rectList);