Skip to content

Commit

Permalink
NEVERHOOD: Move Scene2804::initCrystalColors() to GameModule::initCry…
Browse files Browse the repository at this point in the history
…stalColorsPuzzle()

- Add Scene::isMessageList2, only used in Scene2101
  • Loading branch information
johndoe123 authored and wjp committed May 8, 2013
1 parent f945448 commit df43b8b
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 43 deletions.
40 changes: 40 additions & 0 deletions engines/neverhood/gamemodule.cpp
Expand Up @@ -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)];
Expand Down
1 change: 1 addition & 0 deletions engines/neverhood/gamemodule.h
Expand Up @@ -51,6 +51,7 @@ class GameModule : public Module {
void initCannonSymbolsPuzzle();
void initCodeSymbolsPuzzle();
void initCubeSymbolsPuzzle();
void initCrystalColorsPuzzle();
uint32 getCurrRadioMusicFileHash();
protected:
Entity *_prevChildObject;
Expand Down
2 changes: 1 addition & 1 deletion engines/neverhood/module2100.cpp
Expand Up @@ -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();
}
Expand Down
42 changes: 1 addition & 41 deletions engines/neverhood/module2800.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {

Expand Down
1 change: 0 additions & 1 deletion engines/neverhood/module2800.h
Expand Up @@ -273,7 +273,6 @@ class Scene2804 : public Scene {
Sprite *_ssCrystalButtons[5];
void update();
uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
void initCrystalColors();
};

class Scene2805 : public Scene {
Expand Down
4 changes: 4 additions & 0 deletions engines/neverhood/scene.cpp
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions engines/neverhood/scene.h
Expand Up @@ -204,6 +204,7 @@ class Scene : public Entity {
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);
Expand Down

0 comments on commit df43b8b

Please sign in to comment.