From bec37164f840d47bd16b5c094d35f4345eb1d38c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 23 Mar 2016 08:03:33 +0100 Subject: GNAP: Change a couple of variables to boolean, soft refactoring --- engines/gnap/gnap.cpp | 11 +-- engines/gnap/gnap.h | 32 +++---- engines/gnap/scenes/scene49.cpp | 190 +++++++++++++++++++-------------------- engines/gnap/scenes/scene51.cpp | 195 ++++++++++++++++++++-------------------- 4 files changed, 209 insertions(+), 219 deletions(-) (limited to 'engines/gnap') diff --git a/engines/gnap/gnap.cpp b/engines/gnap/gnap.cpp index 30311ea776..e0d2f188ba 100644 --- a/engines/gnap/gnap.cpp +++ b/engines/gnap/gnap.cpp @@ -294,7 +294,6 @@ void GnapEngine::gameUpdateTick() { _soundMan->update(); _system->updateScreen(); _system->delayMillis(5); - } void GnapEngine::saveTimers() { @@ -793,7 +792,6 @@ void GnapEngine::mainLoop() { if (_debugLevel == 4) _gameDone = true; } - } if (_backgroundSurface) @@ -804,11 +802,9 @@ void GnapEngine::mainLoop() { // TODO freeFont(); debug("MainLoop #XXX2"); - } void GnapEngine::initScene() { - Common::String datFilename; _isLeavingScene = false; @@ -856,7 +852,6 @@ void GnapEngine::endSceneInit() { } void GnapEngine::afterScene() { - if (_gameDone) return; @@ -906,7 +901,6 @@ void GnapEngine::startSoundTimerA(int timerIndex) { } int GnapEngine::playSoundA() { - static const int kSoundIdsA[] = { 0x93E, 0x93F, 0x941, 0x942, 0x943, 0x944, 0x945, 0x946, 0x947, 0x948, 0x949 @@ -1030,7 +1024,6 @@ int GnapEngine::getGnapSequenceId(int kind, int gridX, int gridY) { int sequenceId = 0; switch (kind) { - case gskPullOutDevice: if (gridX > 0 && gridY > 0) { if (_gnapY > gridY) { @@ -1364,14 +1357,12 @@ int GnapEngine::getGnapSequenceId(int kind, int gridX, int gridY) { _gnapIdleFacing = 1; } break; - } return sequenceId | 0x10000; } int GnapEngine::getGnapShowSequenceId(int index, int gridX, int gridY) { - int sequenceId; int facing = _gnapIdleFacing; @@ -1761,7 +1752,6 @@ void GnapEngine::gnapInitBrainPulseRndValue() { } void GnapEngine::gnapUseDeviceOnBeaver() { - playGnapSequence(makeRid(1, getGnapSequenceId(gskPullOutDevice, _platX, _platY))); if (_beaverFacing != 0) { @@ -1902,6 +1892,7 @@ void GnapEngine::gnapUseDisguiseOnPlatypus() { setFlag(10); } +// CHECKME: The 3 parameters are always 0 int GnapEngine::getBeaverSequenceId(int kind, int gridX, int gridY) { int sequenceId; diff --git a/engines/gnap/gnap.h b/engines/gnap/gnap.h index 8e23990f52..e13158c245 100644 --- a/engines/gnap/gnap.h +++ b/engines/gnap/gnap.h @@ -214,25 +214,25 @@ enum { // 0x7B0 Gnap walks to the left 2 struct Scene49Obstacle { - int currSequenceId; - int closerSequenceId; - int passedSequenceId; - int splashSequenceId; - int collisionSequenceId; - int prevId; - int currId; - int laneNum; + int _currSequenceId; + int _closerSequenceId; + int _passedSequenceId; + int _splashSequenceId; + int _collisionSequenceId; + int _prevId; + int _currId; + int _laneNum; }; struct Scene51Item { - int currSequenceId; - int droppedSequenceId; - int x, y; - int collisionX; - int canCatch; - int isCollision; - int x2; - int id; + int _currSequenceId; + int _droppedSequenceId; + int _x, _y; + int _collisionX; + bool _canCatch; + bool _isCollision; + int _x2; + int _id; }; class GnapEngine : public Engine { diff --git a/engines/gnap/scenes/scene49.cpp b/engines/gnap/scenes/scene49.cpp index 19da920bf2..9a4714529d 100644 --- a/engines/gnap/scenes/scene49.cpp +++ b/engines/gnap/scenes/scene49.cpp @@ -70,64 +70,64 @@ void GnapEngine::scene49_checkObstacles() { scene49_clearObstacle(i); for (int j = 0; j < 5; ++j) { - if (_s49_obstacles[j].currSequenceId == 0) { + if (_s49_obstacles[j]._currSequenceId == 0) { _timers[3] = 35; - _s49_obstacles[j].currSequenceId = kObstacleDefs[_s49_obstacleIndex].sequenceId; - switch (_s49_obstacles[j].currSequenceId) { + _s49_obstacles[j]._currSequenceId = kObstacleDefs[_s49_obstacleIndex].sequenceId; + switch (_s49_obstacles[j]._currSequenceId) { case 0xB4: - _s49_obstacles[j].laneNum = 1; - _s49_obstacles[j].closerSequenceId = 180; - _s49_obstacles[j].passedSequenceId = 181; - _s49_obstacles[j].splashSequenceId = 182; - _s49_obstacles[j].collisionSequenceId = 192; + _s49_obstacles[j]._laneNum = 1; + _s49_obstacles[j]._closerSequenceId = 180; + _s49_obstacles[j]._passedSequenceId = 181; + _s49_obstacles[j]._splashSequenceId = 182; + _s49_obstacles[j]._collisionSequenceId = 192; break; case 0xB7: - _s49_obstacles[j].laneNum = 2; - _s49_obstacles[j].closerSequenceId = 183; - _s49_obstacles[j].passedSequenceId = 184; - _s49_obstacles[j].splashSequenceId = 185; - _s49_obstacles[j].collisionSequenceId = 193; + _s49_obstacles[j]._laneNum = 2; + _s49_obstacles[j]._closerSequenceId = 183; + _s49_obstacles[j]._passedSequenceId = 184; + _s49_obstacles[j]._splashSequenceId = 185; + _s49_obstacles[j]._collisionSequenceId = 193; break; case 0xBD: - _s49_obstacles[j].laneNum = 3; - _s49_obstacles[j].closerSequenceId = 189; - _s49_obstacles[j].passedSequenceId = 190; - _s49_obstacles[j].splashSequenceId = 191; - _s49_obstacles[j].collisionSequenceId = 195; + _s49_obstacles[j]._laneNum = 3; + _s49_obstacles[j]._closerSequenceId = 189; + _s49_obstacles[j]._passedSequenceId = 190; + _s49_obstacles[j]._splashSequenceId = 191; + _s49_obstacles[j]._collisionSequenceId = 195; break; case 0xBA: - _s49_obstacles[j].laneNum = 2; - _s49_obstacles[j].closerSequenceId = 186; - _s49_obstacles[j].passedSequenceId = 187; - _s49_obstacles[j].splashSequenceId = 188; - _s49_obstacles[j].collisionSequenceId = 194; + _s49_obstacles[j]._laneNum = 2; + _s49_obstacles[j]._closerSequenceId = 186; + _s49_obstacles[j]._passedSequenceId = 187; + _s49_obstacles[j]._splashSequenceId = 188; + _s49_obstacles[j]._collisionSequenceId = 194; break; case 0xCB: - _s49_obstacles[j].laneNum = 1; - _s49_obstacles[j].closerSequenceId = 203; - _s49_obstacles[j].passedSequenceId = 204; - _s49_obstacles[j].splashSequenceId = 0; - _s49_obstacles[j].collisionSequenceId = 209; + _s49_obstacles[j]._laneNum = 1; + _s49_obstacles[j]._closerSequenceId = 203; + _s49_obstacles[j]._passedSequenceId = 204; + _s49_obstacles[j]._splashSequenceId = 0; + _s49_obstacles[j]._collisionSequenceId = 209; break; case 0xCD: - _s49_obstacles[j].laneNum = 2; - _s49_obstacles[j].closerSequenceId = 205; - _s49_obstacles[j].passedSequenceId = 206; - _s49_obstacles[j].splashSequenceId = 0; - _s49_obstacles[j].collisionSequenceId = 210; + _s49_obstacles[j]._laneNum = 2; + _s49_obstacles[j]._closerSequenceId = 205; + _s49_obstacles[j]._passedSequenceId = 206; + _s49_obstacles[j]._splashSequenceId = 0; + _s49_obstacles[j]._collisionSequenceId = 210; break; case 0xCF: - _s49_obstacles[j].laneNum = 3; - _s49_obstacles[j].closerSequenceId = 207; - _s49_obstacles[j].passedSequenceId = 208; - _s49_obstacles[j].splashSequenceId = 0; - _s49_obstacles[j].collisionSequenceId = 211; + _s49_obstacles[j]._laneNum = 3; + _s49_obstacles[j]._closerSequenceId = 207; + _s49_obstacles[j]._passedSequenceId = 208; + _s49_obstacles[j]._splashSequenceId = 0; + _s49_obstacles[j]._collisionSequenceId = 211; break; } - _s49_obstacles[j].prevId = _s49_truckId; - _s49_obstacles[j].currId = _s49_obstacles[j].prevId; - _gameSys->setAnimation(_s49_obstacles[j].currSequenceId, _s49_obstacles[j].currId, j + 2); - _gameSys->insertSequence(_s49_obstacles[j].currSequenceId, _s49_obstacles[j].currId, 0, 0, kSeqNone, 0, 0, -50); + _s49_obstacles[j]._prevId = _s49_truckId; + _s49_obstacles[j]._currId = _s49_obstacles[j]._prevId; + _gameSys->setAnimation(_s49_obstacles[j]._currSequenceId, _s49_obstacles[j]._currId, j + 2); + _gameSys->insertSequence(_s49_obstacles[j]._currSequenceId, _s49_obstacles[j]._currId, 0, 0, kSeqNone, 0, 0, -50); _timers[2] = kObstacleDefs[_s49_obstacleIndex].ticks; ++_s49_obstacleIndex; if (_s49_obstacleIndex == 50) @@ -144,83 +144,83 @@ void GnapEngine::scene49_updateObstacle(int id) { Scene49Obstacle &obstacle = _s49_obstacles[id]; - obstacle.currId = obstacle.prevId; + obstacle._currId = obstacle._prevId; - switch (obstacle.laneNum) { + switch (obstacle._laneNum) { case 1: - obstacle.prevId = _s49_truckId + 1; + obstacle._prevId = _s49_truckId + 1; break; case 2: if (_s49_truckLaneNum != 2 && _s49_truckLaneNum != 3) - obstacle.prevId = _s49_truckId - 1; + obstacle._prevId = _s49_truckId - 1; else - obstacle.prevId = _s49_truckId + 1; + obstacle._prevId = _s49_truckId + 1; break; case 3: if (_s49_truckLaneNum != 1 && _s49_truckLaneNum != 2) - obstacle.prevId = _s49_truckId; + obstacle._prevId = _s49_truckId; else - obstacle.prevId = _s49_truckId - 1; + obstacle._prevId = _s49_truckId - 1; break; } - if (obstacle.currSequenceId == obstacle.closerSequenceId) { - if (_s49_truckLaneNum == obstacle.laneNum) { - if (obstacle.splashSequenceId) { - _gameSys->setAnimation(obstacle.collisionSequenceId, obstacle.prevId, id + 2); - _gameSys->insertSequence(obstacle.collisionSequenceId, obstacle.prevId, - obstacle.currSequenceId, obstacle.currId, + if (obstacle._currSequenceId == obstacle._closerSequenceId) { + if (_s49_truckLaneNum == obstacle._laneNum) { + if (obstacle._splashSequenceId) { + _gameSys->setAnimation(obstacle._collisionSequenceId, obstacle._prevId, id + 2); + _gameSys->insertSequence(obstacle._collisionSequenceId, obstacle._prevId, + obstacle._currSequenceId, obstacle._currId, kSeqSyncWait, 0, 0, -50); - obstacle.currSequenceId = obstacle.collisionSequenceId; + obstacle._currSequenceId = obstacle._collisionSequenceId; playSound(224, 0); scene49_increaseScore(30); - } else if ((obstacle.laneNum == 1 && _s49_truckSequenceId == 0xB0) || - (obstacle.laneNum == 2 && (_s49_truckSequenceId == 0xB1 || _s49_truckSequenceId == 0xB2)) || - (obstacle.laneNum == 3 && _s49_truckSequenceId == 0xB3)) { - _gameSys->setAnimation(obstacle.passedSequenceId, obstacle.prevId, id + 2); - _gameSys->insertSequence(obstacle.passedSequenceId, obstacle.prevId, - obstacle.currSequenceId, obstacle.currId, + } else if ((obstacle._laneNum == 1 && _s49_truckSequenceId == 0xB0) || + (obstacle._laneNum == 2 && (_s49_truckSequenceId == 0xB1 || _s49_truckSequenceId == 0xB2)) || + (obstacle._laneNum == 3 && _s49_truckSequenceId == 0xB3)) { + _gameSys->setAnimation(obstacle._passedSequenceId, obstacle._prevId, id + 2); + _gameSys->insertSequence(obstacle._passedSequenceId, obstacle._prevId, + obstacle._currSequenceId, obstacle._currId, kSeqSyncWait, 0, 0, -50); - obstacle.currSequenceId = obstacle.passedSequenceId; + obstacle._currSequenceId = obstacle._passedSequenceId; } else { - _gameSys->setAnimation(obstacle.collisionSequenceId, 256, 0); - _gameSys->setAnimation(obstacle.passedSequenceId, obstacle.prevId, id + 2); - _gameSys->insertSequence(obstacle.passedSequenceId, obstacle.prevId, - obstacle.currSequenceId, obstacle.currId, + _gameSys->setAnimation(obstacle._collisionSequenceId, 256, 0); + _gameSys->setAnimation(obstacle._passedSequenceId, obstacle._prevId, id + 2); + _gameSys->insertSequence(obstacle._passedSequenceId, obstacle._prevId, + obstacle._currSequenceId, obstacle._currId, kSeqSyncWait, 0, 0, -50); - _gameSys->insertSequence(obstacle.collisionSequenceId, 256, + _gameSys->insertSequence(obstacle._collisionSequenceId, 256, _s49_truckSequenceId, _s49_truckId, kSeqSyncExists, 0, 0, -50); - _s49_truckSequenceId = obstacle.collisionSequenceId; + _s49_truckSequenceId = obstacle._collisionSequenceId; _s49_truckId = 256; - obstacle.currSequenceId = obstacle.passedSequenceId; + obstacle._currSequenceId = obstacle._passedSequenceId; playSound(225, 0); scene49_decreaseScore(30); } } else { - _gameSys->setAnimation(obstacle.passedSequenceId, obstacle.prevId, id + 2); - _gameSys->insertSequence(obstacle.passedSequenceId, obstacle.prevId, - obstacle.currSequenceId, obstacle.currId, + _gameSys->setAnimation(obstacle._passedSequenceId, obstacle._prevId, id + 2); + _gameSys->insertSequence(obstacle._passedSequenceId, obstacle._prevId, + obstacle._currSequenceId, obstacle._currId, kSeqSyncWait, 0, 0, -50); - obstacle.currSequenceId = obstacle.passedSequenceId; + obstacle._currSequenceId = obstacle._passedSequenceId; } - } else if (obstacle.currSequenceId == obstacle.passedSequenceId) { - if (_s49_truckLaneNum == obstacle.laneNum) { - if (obstacle.splashSequenceId) { - _gameSys->setAnimation(obstacle.collisionSequenceId, obstacle.prevId, id + 2); - _gameSys->insertSequence(obstacle.collisionSequenceId, obstacle.prevId, - obstacle.currSequenceId, obstacle.currId, + } else if (obstacle._currSequenceId == obstacle._passedSequenceId) { + if (_s49_truckLaneNum == obstacle._laneNum) { + if (obstacle._splashSequenceId) { + _gameSys->setAnimation(obstacle._collisionSequenceId, obstacle._prevId, id + 2); + _gameSys->insertSequence(obstacle._collisionSequenceId, obstacle._prevId, + obstacle._currSequenceId, obstacle._currId, kSeqSyncWait, 0, 0, -50); - obstacle.currSequenceId = obstacle.collisionSequenceId; + obstacle._currSequenceId = obstacle._collisionSequenceId; playSound(224, 0); scene49_increaseScore(30); } - } else if (obstacle.splashSequenceId) { - _gameSys->setAnimation(obstacle.splashSequenceId, obstacle.prevId, id + 2); - _gameSys->insertSequence(obstacle.splashSequenceId, obstacle.prevId, - obstacle.currSequenceId, obstacle.currId, + } else if (obstacle._splashSequenceId) { + _gameSys->setAnimation(obstacle._splashSequenceId, obstacle._prevId, id + 2); + _gameSys->insertSequence(obstacle._splashSequenceId, obstacle._prevId, + obstacle._currSequenceId, obstacle._currId, kSeqSyncWait, 0, 0, -50); - obstacle.currSequenceId = obstacle.splashSequenceId; + obstacle._currSequenceId = obstacle._splashSequenceId; } } else { _gameSys->setAnimation(0, 0, id + 2); @@ -256,14 +256,14 @@ void GnapEngine::scene49_refreshScoreBar() { } void GnapEngine::scene49_clearObstacle(int index) { - _s49_obstacles[index].currSequenceId = 0; - _s49_obstacles[index].closerSequenceId = 0; - _s49_obstacles[index].passedSequenceId = 0; - _s49_obstacles[index].splashSequenceId = 0; - _s49_obstacles[index].collisionSequenceId = 0; - _s49_obstacles[index].prevId = 0; - _s49_obstacles[index].currId = 0; - _s49_obstacles[index].laneNum = 0; + _s49_obstacles[index]._currSequenceId = 0; + _s49_obstacles[index]._closerSequenceId = 0; + _s49_obstacles[index]._passedSequenceId = 0; + _s49_obstacles[index]._splashSequenceId = 0; + _s49_obstacles[index]._collisionSequenceId = 0; + _s49_obstacles[index]._prevId = 0; + _s49_obstacles[index]._currId = 0; + _s49_obstacles[index]._laneNum = 0; } void GnapEngine::scene49_run() { @@ -498,7 +498,7 @@ void GnapEngine::scene49_updateAnimations() { for (int i = 0; i < 5; ++i) { if (_gameSys->getAnimationStatus(i + 2) == 2) { - if (_s49_obstacles[i].currSequenceId) + if (_s49_obstacles[i]._currSequenceId) scene49_updateObstacle(i); } } diff --git a/engines/gnap/scenes/scene51.cpp b/engines/gnap/scenes/scene51.cpp index 1610e36192..d93506ff00 100644 --- a/engines/gnap/scenes/scene51.cpp +++ b/engines/gnap/scenes/scene51.cpp @@ -58,13 +58,13 @@ void GnapEngine::scene51_updateHotspots() { } void GnapEngine::scene51_clearItem(Scene51Item *item) { - item->currSequenceId = 0; - item->droppedSequenceId = 0; - item->x = 0; - item->y = 0; - item->x2 = 0; - item->collisionX = 0; - item->canCatch = 0; + item->_currSequenceId = 0; + item->_droppedSequenceId = 0; + item->_x = 0; + item->_y = 0; + item->_x2 = 0; + item->_collisionX = 0; + item->_canCatch = false; } void GnapEngine::scene51_dropNextItem() { @@ -74,7 +74,7 @@ void GnapEngine::scene51_dropNextItem() { int index = 0; - while (index < 6 && _s51_items[index].currSequenceId) + while (index < 6 && _s51_items[index]._currSequenceId) ++index; if (index == 6) @@ -84,10 +84,10 @@ void GnapEngine::scene51_dropNextItem() { case 0: if (getRandom(10) != 0 || _s51_itemsCtr2 >= 2) { - _s51_items[index].currSequenceId = 0xBD; + _s51_items[index]._currSequenceId = 0xBD; } else { --_s51_itemsCtr1; - _s51_items[index].currSequenceId = 0xBA; + _s51_items[index]._currSequenceId = 0xBA; ++_s51_itemsCtr2; } break; @@ -100,20 +100,20 @@ void GnapEngine::scene51_dropNextItem() { else _s51_itemInsertX += 70; } - _s51_items[index].currSequenceId = 0xBD; + _s51_items[index]._currSequenceId = 0xBD; } else { --_s51_itemsCtr1; - _s51_items[index].currSequenceId = 0xBA; + _s51_items[index]._currSequenceId = 0xBA; ++_s51_itemsCtr2; } break; case 2: if (getRandom(6) != 0 || _s51_itemsCtr2 >= 2) { - _s51_items[index].currSequenceId = 0xBD; + _s51_items[index]._currSequenceId = 0xBD; } else { --_s51_itemsCtr1; - _s51_items[index].currSequenceId = 0xBA; + _s51_items[index]._currSequenceId = 0xBA; ++_s51_itemsCtr2; } break; @@ -122,19 +122,19 @@ void GnapEngine::scene51_dropNextItem() { case 4: if (_s51_itemsCtr == 0) _s51_itemsCtr1 = 3; - _s51_items[index].currSequenceId = 0xC0; + _s51_items[index]._currSequenceId = 0xC0; break; case 5: case 6: if (getRandom(5) != 0 || _s51_itemsCtr2 >= 2) { if (getRandom(5) != 0) - _s51_items[index].currSequenceId = 0xBD; + _s51_items[index]._currSequenceId = 0xBD; else - _s51_items[index].currSequenceId = 0xC0; + _s51_items[index]._currSequenceId = 0xC0; } else { --_s51_itemsCtr1; - _s51_items[index].currSequenceId = 0xBA; + _s51_items[index]._currSequenceId = 0xBA; ++_s51_itemsCtr2; } break; @@ -148,12 +148,12 @@ void GnapEngine::scene51_dropNextItem() { _s51_itemInsertX += 40; } if (getRandom(9) != 0) - _s51_items[index].currSequenceId = 0xBD; + _s51_items[index]._currSequenceId = 0xBD; else - _s51_items[index].currSequenceId = 0xC0; + _s51_items[index]._currSequenceId = 0xC0; } else { --_s51_itemsCtr1; - _s51_items[index].currSequenceId = 0xBA; + _s51_items[index]._currSequenceId = 0xBA; ++_s51_itemsCtr2; } break; @@ -161,12 +161,12 @@ void GnapEngine::scene51_dropNextItem() { default: if (getRandom(4) != 0 || _s51_itemsCtr2 >= 2) { if (getRandom(9) != 0) - _s51_items[index].currSequenceId = 0xBD; + _s51_items[index]._currSequenceId = 0xBD; else - _s51_items[index].currSequenceId = 0xC0; + _s51_items[index]._currSequenceId = 0xC0; } else { --_s51_itemsCtr1; - _s51_items[index].currSequenceId = 0xBA; + _s51_items[index]._currSequenceId = 0xBA; ++_s51_itemsCtr2; } break; @@ -193,23 +193,23 @@ void GnapEngine::scene51_dropNextItem() { if (_s51_itemInsertX < 129) _s51_itemInsertX = 129; - if (_s51_items[index].currSequenceId == 0xBA) { - _s51_items[index].x2 = getRandom(350) + 200; - _s51_items[index].x = _s51_items[index].x2 - 362; - _s51_items[index].y = 15; - _s51_items[index].id = 249 - index; + if (_s51_items[index]._currSequenceId == 0xBA) { + _s51_items[index]._x2 = getRandom(350) + 200; + _s51_items[index]._x = _s51_items[index]._x2 - 362; + _s51_items[index]._y = 15; + _s51_items[index]._id = 249 - index; } else { - _s51_items[index].collisionX = _s51_itemInsertX; - _s51_items[index].x = _s51_items[index].collisionX - 395; - if (_s51_items[index].currSequenceId == 0xC0) - _s51_items[index].x -= 65; - _s51_items[index].id = index + 250; - _s51_items[index].canCatch = 1; + _s51_items[index]._collisionX = _s51_itemInsertX; + _s51_items[index]._x = _s51_items[index]._collisionX - 395; + if (_s51_items[index]._currSequenceId == 0xC0) + _s51_items[index]._x -= 65; + _s51_items[index]._id = index + 250; + _s51_items[index]._canCatch = true; } - _gameSys->setAnimation(_s51_items[index].currSequenceId, _s51_items[index].id, index + 1); - _gameSys->insertSequence(_s51_items[index].currSequenceId, _s51_items[index].id, 0, 0, - kSeqNone, 0, _s51_items[index].x, _s51_items[index].y); + _gameSys->setAnimation(_s51_items[index]._currSequenceId, _s51_items[index]._id, index + 1); + _gameSys->insertSequence(_s51_items[index]._currSequenceId, _s51_items[index]._id, 0, 0, + kSeqNone, 0, _s51_items[index]._x, _s51_items[index]._y); _timers[0] = _s51_dropSpeedTicks; @@ -234,18 +234,17 @@ void GnapEngine::scene51_updateItemAnimations() { int GnapEngine::scene51_checkCollision(int sequenceId) { bool jumpingLeft = false, jumpingRight = false; - int v6 = 0; - int v2 = 0; int v8, v4; int result = 0; if (!scene51_isJumping(sequenceId)) return false; - while (v6 < 6) - v2 += _s51_items[v6++].isCollision; + bool checkFl = false; + for (int i = 0; i < 6; i++) + checkFl |= _s51_items[i]._isCollision; - if (!v2) + if (!checkFl) return false; if (scene51_isJumpingRight(sequenceId)) { @@ -262,14 +261,14 @@ int GnapEngine::scene51_checkCollision(int sequenceId) { int v5 = 0; int i; for (i = 0; i < 6; ++i) { - if (_s51_items[i].isCollision) { - if (jumpingRight && _s51_items[i].x2 > v8 && _s51_items[i].x2 < v4) { + if (_s51_items[i]._isCollision) { + if (jumpingRight && _s51_items[i]._x2 > v8 && _s51_items[i]._x2 < v4) { v5 = v8 - 359; if (v5 == 0) v5 = 1; _s51_platypusNextSequenceId = 0xB6; break; - } else if (jumpingLeft && _s51_items[i].x2 < v4 && _s51_items[i].x2 > v8) { + } else if (jumpingLeft && _s51_items[i]._x2 < v4 && _s51_items[i]._x2 > v8) { v5 = v8 - 344; if (v5 == 0) v5 = 1; @@ -279,10 +278,10 @@ int GnapEngine::scene51_checkCollision(int sequenceId) { } } if (v5) { - _gameSys->setAnimation(0xBC, _s51_items[i].id, i + 1); - _gameSys->insertSequence(0xBC, _s51_items[i].id, _s51_items[i].currSequenceId, _s51_items[i].id, kSeqSyncWait, 0, _s51_items[i].x, 15); - _s51_items[i].isCollision = 0; - _s51_items[i].currSequenceId = 0xBC; + _gameSys->setAnimation(0xBC, _s51_items[i]._id, i + 1); + _gameSys->insertSequence(0xBC, _s51_items[i]._id, _s51_items[i]._currSequenceId, _s51_items[i]._id, kSeqSyncWait, 0, _s51_items[i]._x, 15); + _s51_items[i]._isCollision = false; + _s51_items[i]._currSequenceId = 0xBC; --_s51_itemsCtr2; } result = v5; @@ -293,14 +292,14 @@ int GnapEngine::scene51_checkCollision(int sequenceId) { void GnapEngine::scene51_updateItemAnimation(Scene51Item *item, int index) { - switch (item->currSequenceId) { + switch (item->_currSequenceId) { case 0xBD: case 0xC0: case 0xC1: // Falling coin and banknote if (!scene51_itemIsCaught(item)) { if (_s51_dropLoseCash) { - if (item->currSequenceId == 0xBD) + if (item->_currSequenceId == 0xBD) _s51_cashAmount -= 2; else _s51_cashAmount -= 25; @@ -308,24 +307,24 @@ void GnapEngine::scene51_updateItemAnimation(Scene51Item *item, int index) { _s51_cashAmount = 0; scene51_updateCash(_s51_cashAmount); } - item->droppedSequenceId = item->currSequenceId + 1; - if (item->currSequenceId != 0xC0) { - item->canCatch = 0; + item->_droppedSequenceId = item->_currSequenceId + 1; + if (item->_currSequenceId != 0xC0) { + item->_canCatch = false; _s51_dropLoseCash = true; _s51_itemsCtr = 0; _timers[0] = 10; } - if (item->droppedSequenceId) { - _gameSys->setAnimation(item->droppedSequenceId, item->id, index + 1); - _gameSys->insertSequence(item->droppedSequenceId, item->id, item->currSequenceId, item->id, kSeqSyncWait, 0, item->x, item->y); - item->currSequenceId = item->droppedSequenceId; - item->y = 0; + if (item->_droppedSequenceId) { + _gameSys->setAnimation(item->_droppedSequenceId, item->_id, index + 1); + _gameSys->insertSequence(item->_droppedSequenceId, item->_id, item->_currSequenceId, item->_id, kSeqSyncWait, 0, item->_x, item->_y); + item->_currSequenceId = item->_droppedSequenceId; + item->_y = 0; } } else { - _gameSys->removeSequence(item->currSequenceId, item->id, true); + _gameSys->removeSequence(item->_currSequenceId, item->_id, true); _gameSys->setAnimation(0, 0, index + 1); playSound(218, 0); - if (scene51_incCashAmount(item->currSequenceId) == 1995) { + if (scene51_incCashAmount(item->_currSequenceId) == 1995) { scene51_winMinigame(); _sceneDone = true; } else { @@ -356,12 +355,12 @@ void GnapEngine::scene51_updateItemAnimation(Scene51Item *item, int index) { case 0xBE: // Fallen coin - item->droppedSequenceId = item->currSequenceId + 1; - if (item->droppedSequenceId) { - _gameSys->setAnimation(item->droppedSequenceId, item->id, index + 1); - _gameSys->insertSequence(item->droppedSequenceId, item->id, item->currSequenceId, item->id, kSeqSyncWait, 0, item->x, item->y); - item->currSequenceId = item->droppedSequenceId; - item->y = 0; + item->_droppedSequenceId = item->_currSequenceId + 1; + if (item->_droppedSequenceId) { + _gameSys->setAnimation(item->_droppedSequenceId, item->_id, index + 1); + _gameSys->insertSequence(item->_droppedSequenceId, item->_id, item->_currSequenceId, item->_id, kSeqSyncWait, 0, item->_x, item->_y); + item->_currSequenceId = item->_droppedSequenceId; + item->_y = 0; } break; @@ -369,40 +368,40 @@ void GnapEngine::scene51_updateItemAnimation(Scene51Item *item, int index) { case 0xC2: // Bouncing coin and banknote _gameSys->setAnimation(0, 0, index + 1); - _gameSys->removeSequence(item->currSequenceId, item->id, true); + _gameSys->removeSequence(item->_currSequenceId, item->_id, true); scene51_clearItem(item); break; case 0xBA: // Falling banana peel - item->droppedSequenceId = 0xBB; - item->y = 15; - if (item->droppedSequenceId) { - _gameSys->setAnimation(item->droppedSequenceId, item->id, index + 1); - _gameSys->insertSequence(item->droppedSequenceId, item->id, item->currSequenceId, item->id, kSeqSyncWait, 0, item->x, item->y); - item->currSequenceId = item->droppedSequenceId; - item->y = 0; + item->_droppedSequenceId = 0xBB; + item->_y = 15; + if (item->_droppedSequenceId) { + _gameSys->setAnimation(item->_droppedSequenceId, item->_id, index + 1); + _gameSys->insertSequence(item->_droppedSequenceId, item->_id, item->_currSequenceId, item->_id, kSeqSyncWait, 0, item->_x, item->_y); + item->_currSequenceId = item->_droppedSequenceId; + item->_y = 0; } break; case 0xBB: - item->isCollision = 1; - item->droppedSequenceId = 0; + item->_isCollision = true; + item->_droppedSequenceId = 0; _gameSys->setAnimation(0, 0, index + 1); break; case 0xBC: - _gameSys->removeSequence(item->currSequenceId, item->id, true); + _gameSys->removeSequence(item->_currSequenceId, item->_id, true); _gameSys->setAnimation(0, 0, index + 1); scene51_clearItem(item); break; default: - if (item->droppedSequenceId) { - _gameSys->setAnimation(item->droppedSequenceId, item->id, index + 1); - _gameSys->insertSequence(item->droppedSequenceId, item->id, item->currSequenceId, item->id, kSeqSyncWait, 0, item->x, item->y); - item->currSequenceId = item->droppedSequenceId; - item->y = 0; + if (item->_droppedSequenceId) { + _gameSys->setAnimation(item->_droppedSequenceId, item->_id, index + 1); + _gameSys->insertSequence(item->_droppedSequenceId, item->_id, item->_currSequenceId, item->_id, kSeqSyncWait, 0, item->_x, item->_y); + item->_currSequenceId = item->_droppedSequenceId; + item->_y = 0; } break; @@ -412,8 +411,8 @@ void GnapEngine::scene51_updateItemAnimation(Scene51Item *item, int index) { void GnapEngine::scene51_removeCollidedItems() { for (int i = 0; i < 6; ++i) { - if (_s51_items[i].isCollision) { - _gameSys->removeSequence(_s51_items[i].currSequenceId, _s51_items[i].id, true); + if (_s51_items[i]._isCollision) { + _gameSys->removeSequence(_s51_items[i]._currSequenceId, _s51_items[i]._id, true); _gameSys->setAnimation(0, 0, i + 1); scene51_clearItem(&_s51_items[i]); } @@ -423,21 +422,21 @@ void GnapEngine::scene51_removeCollidedItems() { int GnapEngine::scene51_itemIsCaught(Scene51Item *item) { - if (!item->canCatch) + if (!item->_canCatch) return 0; if (scene51_isJumpingRight(_s51_platypusJumpSequenceId)) { int v4 = scene51_getPosRight(_s51_platypusJumpSequenceId) + 97; - if (item->collisionX < v4 && v4 - item->collisionX < 56) + if (item->_collisionX < v4 && v4 - item->_collisionX < 56) return 1; } else { int v2 = scene51_getPosLeft(_s51_platypusJumpSequenceId); - if (item->collisionX > v2 && item->collisionX - v2 < 56) + if (item->_collisionX > v2 && item->_collisionX - v2 < 56) return 1; } - if (item->currSequenceId == 0xC1) { - int v3 = item->collisionX + 100; + if (item->_currSequenceId == 0xC1) { + int v3 = item->_collisionX + 100; if (scene51_isJumpingRight(_s51_platypusJumpSequenceId)) { if (ABS(scene51_getPosRight(_s51_platypusJumpSequenceId) + 46 - v3) < 56) return 1; @@ -504,15 +503,15 @@ void GnapEngine::scene51_playIntroAnim() { for (int i = 0; i < 6; ++i) scene51_clearItem(&_s51_items[i]); - _s51_items[0].currSequenceId = 0xBA; - _s51_items[0].x2 = 320; - _s51_items[0].x = -42; - _s51_items[0].y = 15; - _s51_items[0].id = 249; - _s51_items[0].isCollision = 1; + _s51_items[0]._currSequenceId = 0xBA; + _s51_items[0]._x2 = 320; + _s51_items[0]._x = -42; + _s51_items[0]._y = 15; + _s51_items[0]._id = 249; + _s51_items[0]._isCollision = true; _gameSys->insertSequence(_s51_platypusSequenceId, 256, 0, 0, kSeqNone, 0, -179, 0); - _gameSys->insertSequence(0xBA, 249, 0, 0, kSeqNone, 0, _s51_items[0].x, _s51_items[0].y); + _gameSys->insertSequence(0xBA, 249, 0, 0, kSeqNone, 0, _s51_items[0]._x, _s51_items[0]._y); _gameSys->setAnimation(0xBA, 249, 1); _gameSys->setAnimation(_s51_platypusSequenceId, 256, 0); -- cgit v1.2.3