diff options
Diffstat (limited to 'engines/mortevielle/utils.cpp')
-rw-r--r-- | engines/mortevielle/utils.cpp | 125 |
1 files changed, 70 insertions, 55 deletions
diff --git a/engines/mortevielle/utils.cpp b/engines/mortevielle/utils.cpp index 8fa608953d..705237c4eb 100644 --- a/engines/mortevielle/utils.cpp +++ b/engines/mortevielle/utils.cpp @@ -332,7 +332,7 @@ void MortevielleEngine::handleAction() { _caff = _coreVar._currPlace; _crep = 998; } else - tsuiv(); + prepareNextObject(); mennor(); } } @@ -492,8 +492,8 @@ void MortevielleEngine::resetPresenceInRooms(int roomId) { _toiletsPresenceBobMax = false; if (roomId != BATHROOM) _bathRoomPresenceBobMax = false; - if (roomId != ROOM9) - _room9PresenceLeo = false; + if (roomId != JULIA_ROOM) + _juliaRoomPresenceLeo = false; } /** @@ -870,7 +870,7 @@ void MortevielleEngine::setPresencePurpleRoom() { if (_place == PURPLE_ROOM) _purpleRoomPresenceLeo = true; else - _room9PresenceLeo = true; + _juliaRoomPresenceLeo = true; _currBitIndex = 10; } @@ -976,7 +976,7 @@ int MortevielleEngine::setPresenceLanding() { int rand = 0; do { rand = getRandomNumber(1, 8); - test = (((rand == 1) && (_purpleRoomPresenceLeo || _room9PresenceLeo)) || + test = (((rand == 1) && (_purpleRoomPresenceLeo || _juliaRoomPresenceLeo)) || ((rand == 2) && _roomPresencePat) || ((rand == 3) && _roomPresenceGuy) || ((rand == 4) && _roomPresenceEva) || @@ -1050,7 +1050,7 @@ int MortevielleEngine::getPresenceBitIndex(int roomId) { if (_roomPresenceIda) bitIndex = 2; // IDA } else if ( ((roomId == PURPLE_ROOM) && (_purpleRoomPresenceLeo)) - || ((roomId == ROOM9) && (_room9PresenceLeo))) + || ((roomId == JULIA_ROOM) && (_juliaRoomPresenceLeo))) bitIndex = 128; // LEO else if (roomId == DARKBLUE_ROOM) { if (_roomPresenceGuy) @@ -1152,8 +1152,8 @@ void MortevielleEngine::setRandomPresenceRedRoom(int faithScore) { * Engine function - Set Random Presence - Room 9 * @remarks Originally called 'pl9' */ -void MortevielleEngine::setRandomPresenceRoom9(int faithScore) { - if (!_room9PresenceLeo) { +void MortevielleEngine::setRandomPresenceJuliaRoom(int faithScore) { + if (!_juliaRoomPresenceLeo) { faithScore = -10; if (getRandomNumber(1, 100) > faithScore) // always true? displayAloneText(); @@ -1284,7 +1284,7 @@ void MortevielleEngine::startMusicOrSpeech(int so) { void MortevielleEngine::loseGame() { resetOpenObjects(); _roomDoorId = OWN_ROOM; - _mchai = 0; + _curSearchObjId = 0; _menu.unsetSearchMenu(); if (!_blo) getPresence(MANOR_FRONT); @@ -1497,7 +1497,7 @@ void MortevielleEngine::gameLoaded() { _roomDoorId = OWN_ROOM; _syn = true; _heroSearching = true; - _mchai = 0; + _curSearchObjId = 0; _manorDistance = 0; resetOpenObjects(); _takeObjCount = 0; @@ -1914,7 +1914,11 @@ Common::String MortevielleEngine::getString(int num) { return wrkStr; } -void MortevielleEngine::copcha() { +/** + * Reset object place + * @remarks Originally called 'copcha' + */ +void MortevielleEngine::resetObjectPlace() { for (int i = kAcha; i < kAcha + 390; i++) _tabdon[i] = _tabdon[i + 390]; } @@ -1924,7 +1928,7 @@ void MortevielleEngine::copcha() { * @remarks Originally called 'inzon' */ void MortevielleEngine::resetVariables() { - copcha(); + resetObjectPlace(); _coreVar._alreadyEnteredManor = false; _coreVar._selectedObjectId = 0; @@ -2357,8 +2361,8 @@ void MortevielleEngine::prepareRoom() { case GREEN_ROOM2: setRandomPresenceRedRoom(_coreVar._faithScore); break; - case ROOM9: - setRandomPresenceRoom9(_coreVar._faithScore); + case JULIA_ROOM: + setRandomPresenceJuliaRoom(_coreVar._faithScore); break; case DINING_ROOM: setRandomPresenceDiningRoom(_coreVar._faithScore); @@ -2717,8 +2721,8 @@ void MortevielleEngine::mapMessageId(int &mesgId) { * @remarks Originally called 'initouv' */ void MortevielleEngine::resetOpenObjects() { - for (int cx = 1; cx <= 7; ++cx) - _openObjects[cx] = 0; + for (int i = 1; i <= 6; ++i) + _openObjects[i] = 0; _openObjCount = 0; } @@ -2812,7 +2816,7 @@ int MortevielleEngine::getPresenceStats(int &rand, int faithScore, int roomId) { if ( ((roomId == GREEN_ROOM) && (!_roomPresenceLuc) && (!_roomPresenceIda)) || ((roomId == DARKBLUE_ROOM) && (!_roomPresenceGuy) && (!_roomPresenceEva)) ) retVal = getPresenceStatsGreenRoom(); - if ((roomId == PURPLE_ROOM) && (!_purpleRoomPresenceLeo) && (!_room9PresenceLeo)) + if ((roomId == PURPLE_ROOM) && (!_purpleRoomPresenceLeo) && (!_juliaRoomPresenceLeo)) retVal = getPresenceStatsPurpleRoom(); if ( ((roomId == TOILETS) && (!_toiletsPresenceBobMax)) || ((roomId == BATHROOM) && (!_bathRoomPresenceBobMax)) ) @@ -2822,10 +2826,10 @@ int MortevielleEngine::getPresenceStats(int &rand, int faithScore, int roomId) { if ( ((roomId == RED_ROOM) && (!_roomPresenceBob)) || ((roomId == GREEN_ROOM2) && (!_roomPresencePat))) retVal = getPresenceStatsRedRoom(); - if ((roomId == ROOM9) && (!_room9PresenceLeo) && (!_purpleRoomPresenceLeo)) + if ((roomId == JULIA_ROOM) && (!_juliaRoomPresenceLeo) && (!_purpleRoomPresenceLeo)) retVal = 10; - if ( ((roomId == PURPLE_ROOM) && (_room9PresenceLeo)) - || ((roomId == ROOM9) && (_purpleRoomPresenceLeo))) + if ( ((roomId == PURPLE_ROOM) && (_juliaRoomPresenceLeo)) + || ((roomId == JULIA_ROOM) && (_purpleRoomPresenceLeo))) retVal = -400; if (retVal != -500) { retVal += faithScore; @@ -2865,8 +2869,8 @@ void MortevielleEngine::setPresenceFlags(int roomId) { _bathRoomPresenceBobMax = true; else if (roomId == GREEN_ROOM2) _roomPresencePat = true; - else if (roomId == ROOM9) - _room9PresenceLeo = true; + else if (roomId == JULIA_ROOM) + _juliaRoomPresenceLeo = true; } /** @@ -2903,7 +2907,7 @@ int MortevielleEngine::getPresence(int roomId) { retVal = getPresenceBitIndex(_place); } - if (roomId > ROOM9) { + if (roomId > JULIA_ROOM) { if ((roomId > LANDING) && (roomId != CHAPEL) && (roomId != ROOM26)) displayAloneText(); else { @@ -2997,9 +3001,9 @@ void MortevielleEngine::drawPicture() { draw(0, 12); prepareScreenType1(); if ((_caff < 30) || (_caff > 32)) { - for (int cx = 1; cx <= 6; ++cx) { - if (_openObjects[cx] != 0) - displayAnimFrame(1, _openObjects[cx]); + for (int i = 1; i <= 6; ++i) { + if (_openObjects[i] != 0) + displayAnimFrame(1, _openObjects[i]); } if (_caff == ATTIC) { @@ -3098,7 +3102,7 @@ void MortevielleEngine::exitRoom() { resetOpenObjects(); _roomDoorId = OWN_ROOM; - _mchai = 0; + _curSearchObjId = 0; resetRoomVariables(_coreVar._currPlace); } @@ -3171,15 +3175,18 @@ void MortevielleEngine::premtet() { _screenSurface.drawBox(18, 79, 155, 92, 15); } -void MortevielleEngine::ajchai() { - int cy = kAcha + ((_mchai - 1) * 10) - 1; - int cx = 0; - do { - ++cx; - } while ((cx <= 9) && (_tabdon[cy + cx] != 0)); +/** + * Try to put an object somewhere + * @remarks Originally called 'ajchai' + */ +void MortevielleEngine::putObject() { + int putId = kAcha + ((_curSearchObjId - 1) * 10) - 1; + int i; + for (i = 1; (i <= 9) && (_tabdon[putId + i] != 0); i++) + ; - if (_tabdon[cy + cx] == 0) - _tabdon[cy + cx] = _coreVar._selectedObjectId; + if (_tabdon[putId + i] == 0) + _tabdon[putId + i] = _coreVar._selectedObjectId; else _crep = 192; } @@ -3189,10 +3196,10 @@ void MortevielleEngine::ajchai() { * @remarks Originally called 'ajjer' */ void MortevielleEngine::addObjectToInventory(int objectId) { - int i = 0; - do { - ++i; - } while ((i <= 5) && (_coreVar._inventory[i] != 0)); + int i; + + for (i = 1; (i <= 5) && (_coreVar._inventory[i] != 0); i++) + ; if (_coreVar._inventory[i] == 0) { _coreVar._inventory[i] = objectId; @@ -3230,11 +3237,11 @@ L1: _coreVar._faithScore += 3 * (_coreVar._faithScore / 10); exitRoom(); _menu.setDestinationText(LANDING); - int cx = convertBitIndexToCharacterIndex(_currBitIndex); - _caff = 69 + cx; + int charIdx = convertBitIndexToCharacterIndex(_currBitIndex); + _caff = 69 + charIdx; _crep = _caff; _currMenu = MENU_DISCUSS; - _currAction = (_menu._discussMenu[cx]._menuId << 8) | _menu._discussMenu[cx]._actionId; + _currAction = (_menu._discussMenu[charIdx]._menuId << 8) | _menu._discussMenu[charIdx]._actionId; _syn = true; _col = true; } else { @@ -3256,26 +3263,30 @@ L1: _menu.drawMenu(); } -void MortevielleEngine::tsuiv() { - int tbcl; - int cy = kAcha + ((_mchai - 1) * 10) - 1; - int cx = 0; +/** + * Search - Prepare next object + * @remarks Originally called 'tsuiv' + */ +void MortevielleEngine::prepareNextObject() { + int objId; + int tabIdx = kAcha + ((_curSearchObjId - 1) * 10) - 1; + int localSeearchCount = 0; do { - ++cx; + ++localSeearchCount; ++_searchCount; - int cl = cy + _searchCount; - tbcl = _tabdon[cl]; - } while ((tbcl == 0) && (_searchCount <= 9)); + objId = _tabdon[tabIdx + _searchCount]; + } while ((objId == 0) && (_searchCount <= 9)); - if ((tbcl != 0) && (_searchCount < 11)) { - _caff = tbcl; + if ((objId != 0) && (_searchCount < 11)) { + _caff = objId; _crep = _caff + 400; if (_currBitIndex != 0) + // Someone is present in the room _coreVar._faithScore += 2; } else { prepareDisplayText(); endSearch(); - if (cx > 9) + if (localSeearchCount > 9) _crep = 131; } } @@ -3413,13 +3424,17 @@ void MortevielleEngine::putInHand(int &objId) { } } -int MortevielleEngine::rechai() { +/** + * Search - Get the first object + * @remarks Originally called 'rechai' + */ +int MortevielleEngine::getFirstObject() { int tmpPlace = _coreVar._currPlace; if (_coreVar._currPlace == CRYPT) tmpPlace = CELLAR; - return _tabdon[kAchai + (tmpPlace * 7) + _num - 1]; + return _tabdon[kAsearch + (tmpPlace * 7) + _num - 1]; } /** |