From 5be2d50e14a37952716c41f896700274510f166a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 14 Sep 2013 19:38:52 +0200 Subject: AVALANCHE: Reduce verbosity related to animation sprites --- engines/avalanche/acci2.cpp | 24 +++---- engines/avalanche/avalanche.cpp | 59 +++++++++-------- engines/avalanche/dropdown2.cpp | 7 +- engines/avalanche/gyro2.cpp | 12 ++-- engines/avalanche/lucerna2.cpp | 142 +++++++++++++++++++++------------------- engines/avalanche/scrolls2.cpp | 5 +- engines/avalanche/timer.cpp | 108 ++++++++++++++++++------------ 7 files changed, 200 insertions(+), 157 deletions(-) (limited to 'engines') diff --git a/engines/avalanche/acci2.cpp b/engines/avalanche/acci2.cpp index c255619299..ad1e3725ee 100644 --- a/engines/avalanche/acci2.cpp +++ b/engines/avalanche/acci2.cpp @@ -1765,13 +1765,14 @@ void Acci::doThat() { i = 3; else i = 0; - if (_vm->_animation->_sprites[0]._id != i) { - int16 x = _vm->_animation->_sprites[0]._x; - int16 y = _vm->_animation->_sprites[0]._y; - _vm->_animation->_sprites[0].remove(); - _vm->_animation->_sprites[0].init(i, true, _vm->_animation); - _vm->_animation->_sprites[0].appear(x, y, Animation::kDirLeft); - _vm->_animation->_sprites[0]._visible = false; + Avalanche::AnimationType *spr = &_vm->_animation->_sprites[0]; + if (spr->_id != i) { + int16 x = spr->_x; + int16 y = spr->_y; + spr->remove(); + spr->init(i, true, _vm->_animation); + spr->appear(x, y, Animation::kDirLeft); + spr->_visible = false; } } break; @@ -1900,11 +1901,12 @@ void Acci::doThat() { if (_vm->_gyro->_whereIs[1] == 12) _vm->_visa->displayScrollChain('q', 18); else { - _vm->_animation->_sprites[1].init(1, false, _vm->_animation); // Avaricius + Avalanche::AnimationType *spr = &_vm->_animation->_sprites[1]; + spr->init(1, false, _vm->_animation); // Avaricius _vm->_animation->appearPed(2, 4); - _vm->_animation->_sprites[1].walkTo(5); - _vm->_animation->_sprites[1]._callEachStepFl = true; - _vm->_animation->_sprites[1]._eachStepProc = Animation::kProcBackAndForth; + spr->walkTo(5); + spr->_callEachStepFl = true; + spr->_eachStepProc = Animation::kProcBackAndForth; _vm->_gyro->_avariciusTalk = 14; _vm->_timer->addTimer(177, Timer::kProcAvariciusTalks, Timer::kReasonAvariciusTalks); } diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp index a5acf0988e..66b7462d63 100644 --- a/engines/avalanche/avalanche.cpp +++ b/engines/avalanche/avalanche.cpp @@ -285,41 +285,43 @@ void AvalancheEngine::synchronize(Common::Serializer &sz) { if (sz.isLoading()) { for (byte i = 0; i < _animation->kSpriteNumbMax; i++) { // Deallocate sprites. - if (_animation->_sprites[i]._quick) - _animation->_sprites[i].remove(); + AnimationType *spr = &_animation->_sprites[i]; + if (spr->_quick) + spr->remove(); } } for (byte i = 0; i < spriteNum; i++) { - sz.syncAsByte(_animation->_sprites[i]._id); - sz.syncAsByte(_animation->_sprites[i]._doCheck); + AnimationType *spr = &_animation->_sprites[i]; + sz.syncAsByte(spr->_id); + sz.syncAsByte(spr->_doCheck); if (sz.isLoading()) { - _animation->_sprites[i]._quick = true; - _animation->_sprites[i].init(_animation->_sprites[i]._id, _animation->_sprites[i]._doCheck, _animation); + spr->_quick = true; + spr->init(spr->_id, spr->_doCheck, _animation); } - sz.syncAsByte(_animation->_sprites[i]._moveX); - sz.syncAsByte(_animation->_sprites[i]._moveY); - sz.syncAsByte(_animation->_sprites[i]._facingDir); - sz.syncAsByte(_animation->_sprites[i]._stepNum); - sz.syncAsByte(_animation->_sprites[i]._visible); - sz.syncAsByte(_animation->_sprites[i]._homing); - sz.syncAsByte(_animation->_sprites[i]._count); - sz.syncAsByte(_animation->_sprites[i]._info._xWidth); - sz.syncAsByte(_animation->_sprites[i]._speedX); - sz.syncAsByte(_animation->_sprites[i]._speedY); - sz.syncAsByte(_animation->_sprites[i]._animCount); - sz.syncAsSint16LE(_animation->_sprites[i]._homingX); - sz.syncAsSint16LE(_animation->_sprites[i]._homingY); - sz.syncAsByte(_animation->_sprites[i]._callEachStepFl); - sz.syncAsByte(_animation->_sprites[i]._eachStepProc); - sz.syncAsByte(_animation->_sprites[i]._vanishIfStill); - sz.syncAsSint16LE(_animation->_sprites[i]._x); - sz.syncAsSint16LE(_animation->_sprites[i]._y); - - if (sz.isLoading() && _animation->_sprites[i]._visible) - _animation->_sprites[i].appear(_animation->_sprites[i]._x, _animation->_sprites[i]._y, _animation->_sprites[i]._facingDir); + sz.syncAsByte(spr->_moveX); + sz.syncAsByte(spr->_moveY); + sz.syncAsByte(spr->_facingDir); + sz.syncAsByte(spr->_stepNum); + sz.syncAsByte(spr->_visible); + sz.syncAsByte(spr->_homing); + sz.syncAsByte(spr->_count); + sz.syncAsByte(spr->_info._xWidth); + sz.syncAsByte(spr->_speedX); + sz.syncAsByte(spr->_speedY); + sz.syncAsByte(spr->_animCount); + sz.syncAsSint16LE(spr->_homingX); + sz.syncAsSint16LE(spr->_homingY); + sz.syncAsByte(spr->_callEachStepFl); + sz.syncAsByte(spr->_eachStepProc); + sz.syncAsByte(spr->_vanishIfStill); + sz.syncAsSint16LE(spr->_x); + sz.syncAsSint16LE(spr->_y); + + if (sz.isLoading() && spr->_visible) + spr->appear(spr->_x, spr->_y, spr->_facingDir); } //groi = 177; @@ -458,7 +460,8 @@ bool AvalancheEngine::loadGame(const int16 slot) { Scrolls::kControlNewLine, expandDate(t.tm_mday, t.tm_mon, t.tm_year).c_str()); _scrolls->displayText(tmpStr); - if (_animation->_sprites[0]._quick && _animation->_sprites[0]._visible) + AnimationType *avvy = &_animation->_sprites[0]; + if (avvy->_quick && avvy->_visible) _animation->changeDirection(0, _animation->_direction); // We push Avvy in the right direction is he was moving. return true; diff --git a/engines/avalanche/dropdown2.cpp b/engines/avalanche/dropdown2.cpp index 62f4680c57..1f499a22af 100644 --- a/engines/avalanche/dropdown2.cpp +++ b/engines/avalanche/dropdown2.cpp @@ -624,10 +624,11 @@ void Dropdown::runMenuAction() { _vm->_lucerna->callVerb(Acci::kVerbCodeInv); break; case 5: { - if (_vm->_animation->_sprites[0]._speedX == _vm->_gyro->kWalk) - _vm->_animation->_sprites[0]._speedX = _vm->_gyro->kRun; + AnimationType *avvy = &_vm->_animation->_sprites[0]; + if (avvy->_speedX == _vm->_gyro->kWalk) + avvy->_speedX = _vm->_gyro->kRun; else - _vm->_animation->_sprites[0]._speedX = _vm->_gyro->kWalk; + avvy->_speedX = _vm->_gyro->kWalk; _vm->_animation->updateSpeed(); } break; diff --git a/engines/avalanche/gyro2.cpp b/engines/avalanche/gyro2.cpp index 58868069a1..9be471c9fd 100644 --- a/engines/avalanche/gyro2.cpp +++ b/engines/avalanche/gyro2.cpp @@ -310,12 +310,14 @@ void Gyro::resetVariables() { void Gyro::newGame() { for (byte i = 0; i < kMaxSprites; i++) { - if (_vm->_animation->_sprites[i]._quick) - _vm->_animation->_sprites[i].remove(); + AnimationType *spr = &_vm->_animation->_sprites[i]; + if (spr->_quick) + spr->remove(); } // Deallocate sprite. Sorry, beta testers! - _vm->_animation->_sprites[0].init(0, true, _vm->_animation); + AnimationType *avvy = &_vm->_animation->_sprites[0]; + avvy->init(0, true, _vm->_animation); _alive = true; resetVariables(); @@ -338,7 +340,7 @@ void Gyro::newGame() { _onToolbar = false; _seeScroll = false; - _vm->_animation->_sprites[0].appear(300, 117, Animation::kDirRight); // Needed to initialize Avalot. + avvy->appear(300, 117, Animation::kDirRight); // Needed to initialize Avalot. //for (gd = 0; gd <= 30; gd++) for (gm = 0; gm <= 1; gm++) also[gd][gm] = nil; // fillchar(previous^,sizeof(previous^),#0); { blank out array } _him = 254; @@ -352,7 +354,7 @@ void Gyro::newGame() { _enidFilename = ""; _vm->_lucerna->enterRoom(1, 1); - _vm->_animation->_sprites[0]._visible = false; + avvy->_visible = false; _vm->_lucerna->drawScore(); _vm->_dropdown->setupMenu(); _vm->_lucerna->_clock.update(); diff --git a/engines/avalanche/lucerna2.cpp b/engines/avalanche/lucerna2.cpp index 76329e3118..88512390e9 100644 --- a/engines/avalanche/lucerna2.cpp +++ b/engines/avalanche/lucerna2.cpp @@ -411,10 +411,12 @@ void Lucerna::enterNewTown() { void Lucerna::putGeidaAt(byte whichPed, byte &ped) { if (ped == 0) return; - _vm->_animation->_sprites[1].init(5, false, _vm->_animation); // load Geida + AnimationType *spr1 = &_vm->_animation->_sprites[1]; + + spr1->init(5, false, _vm->_animation); // load Geida _vm->_animation->appearPed(2, whichPed); - _vm->_animation->_sprites[1]._callEachStepFl = true; - _vm->_animation->_sprites[1]._eachStepProc = Animation::kProcGeida; + spr1->_callEachStepFl = true; + spr1->_eachStepProc = Animation::kProcGeida; } void Lucerna::enterRoom(byte room, byte ped) { @@ -453,28 +455,29 @@ void Lucerna::enterRoom(byte room, byte ped) { case r__outsideyours: if (ped > 0) { + AnimationType *spr1 = &_vm->_animation->_sprites[1]; if (! _vm->_gyro->_talkedToCrapulus) { - _vm->_gyro->_whereIs[Gyro::kPeopleCrapulus - 150] = r__outsideyours; - _vm->_animation->_sprites[1].init(8, false, _vm->_animation); // load Crapulus + spr1->init(8, false, _vm->_animation); // load Crapulus if (_vm->_gyro->_roomCount[r__outsideyours] == 1) { _vm->_animation->appearPed(2, 4); // Start on the right-hand side of the screen. - _vm->_animation->_sprites[1].walkTo(5); // Walks up to greet you. + spr1->walkTo(5); // Walks up to greet you. } else { _vm->_animation->appearPed(2, 5); // Starts where he was before. - _vm->_animation->_sprites[1]._facingDir = Animation::kDirLeft; + spr1->_facingDir = Animation::kDirLeft; } - _vm->_animation->_sprites[1]._callEachStepFl = true; - _vm->_animation->_sprites[1]._eachStepProc = Animation::kProcFaceAvvy; // He always faces Avvy. + spr1->_callEachStepFl = true; + spr1->_eachStepProc = Animation::kProcFaceAvvy; // He always faces Avvy. - } else _vm->_gyro->_whereIs[Gyro::kPeopleCrapulus - 150] = r__nowhere; + } else + _vm->_gyro->_whereIs[Gyro::kPeopleCrapulus - 150] = r__nowhere; if (_vm->_gyro->_crapulusWillTell) { - _vm->_animation->_sprites[1].init(8, false, _vm->_animation); + spr1->init(8, false, _vm->_animation); _vm->_animation->appearPed(2, 2); - _vm->_animation->_sprites[1].walkTo(4); + spr1->walkTo(4); _vm->_timer->addTimer(20, Timer::kProcCrapulusSpludOut, Timer::kReasonCrapulusSaysSpludwickOut); _vm->_gyro->_crapulusWillTell = false; } @@ -490,16 +493,17 @@ void Lucerna::enterRoom(byte room, byte ped) { case r__spludwicks: if (_vm->_gyro->_spludwickAtHome) { + AnimationType *spr1 = &_vm->_animation->_sprites[1]; if (ped > 0) { - _vm->_animation->_sprites[1].init(2, false, _vm->_animation); // load Spludwick + spr1->init(2, false, _vm->_animation); // load Spludwick _vm->_animation->appearPed(2, 2); _vm->_gyro->_whereIs[1] = r__spludwicks; } _vm->_gyro->_dogFoodPos = 0; // _vm->_gyro->also Spludwick pos. - _vm->_animation->_sprites[1]._callEachStepFl = true; - _vm->_animation->_sprites[1]._eachStepProc = Animation::kProcGeida; + spr1->_callEachStepFl = true; + spr1->_eachStepProc = Animation::kProcGeida; } else _vm->_gyro->_whereIs[1] = r__nowhere; break; @@ -512,30 +516,31 @@ void Lucerna::enterRoom(byte room, byte ped) { _vm->_gyro->_whereIs[Gyro::kPeopleCwytalot - 150] = r__nowhere; } else { if (ped > 0) { - _vm->_animation->_sprites[1].init(4, false, _vm->_animation); // 4 = Cwytalot - _vm->_animation->_sprites[1]._callEachStepFl = true; - _vm->_animation->_sprites[1]._eachStepProc = Animation::kProcFollowAvvyY; + AnimationType *spr1 = &_vm->_animation->_sprites[1]; + spr1->init(4, false, _vm->_animation); // 4 = Cwytalot + spr1->_callEachStepFl = true; + spr1->_eachStepProc = Animation::kProcFollowAvvyY; _vm->_gyro->_whereIs[Gyro::kPeopleCwytalot - 150] = r__brummieroad; if (_vm->_gyro->_roomCount[r__brummieroad] == 1) { // First time here... _vm->_animation->appearPed(2, 2); // He appears on the right of the screen... - _vm->_animation->_sprites[1].walkTo(4); // ...and he walks up... + spr1->walkTo(4); // ...and he walks up... } else { // You've been here before. _vm->_animation->appearPed(2, 4); // He's standing in your way straight away... - _vm->_animation->_sprites[1]._facingDir = Animation::kDirLeft; + spr1->_facingDir = Animation::kDirLeft; } } } break; case r__argentroad: - if ((_vm->_gyro->_cwytalotGone) && (! _vm->_gyro->_passedCwytalotInHerts) && (ped == 2) && - (_vm->_gyro->_roomCount[r__argentroad] > 3)) { - _vm->_animation->_sprites[1].init(4, false, _vm->_animation); // 4 = Cwytalot again + if ((_vm->_gyro->_cwytalotGone) && (!_vm->_gyro->_passedCwytalotInHerts) && (ped == 2) && (_vm->_gyro->_roomCount[r__argentroad] > 3)) { + AnimationType *spr1 = &_vm->_animation->_sprites[1]; + spr1->init(4, false, _vm->_animation); // 4 = Cwytalot again _vm->_animation->appearPed(2, 1); - _vm->_animation->_sprites[1].walkTo(2); - _vm->_animation->_sprites[1]._vanishIfStill = true; + spr1->walkTo(2); + spr1->_vanishIfStill = true; _vm->_gyro->_passedCwytalotInHerts = true; // _vm->_gyro->whereis[#157] = r__Nowhere; // can we fit this in? _vm->_timer->addTimer(20, Timer::kProcCwytalotInHerts, Timer::kReasonCwytalotInHerts); @@ -556,9 +561,10 @@ void Lucerna::enterRoom(byte room, byte ped) { if (ped > 0) { if (! _vm->_gyro->_beenTiedUp) { // A welcome party... or maybe not... - _vm->_animation->_sprites[1].init(6, false, _vm->_animation); + AnimationType *spr1 = &_vm->_animation->_sprites[1]; + spr1->init(6, false, _vm->_animation); _vm->_animation->appearPed(2, 2); - _vm->_animation->_sprites[1].walkTo(3); + spr1->walkTo(3); _vm->_timer->addTimer(36, Timer::kProcGetTiedUp, Timer::kReasonGettingTiedUp); } } @@ -577,28 +583,30 @@ void Lucerna::enterRoom(byte room, byte ped) { break; case r__outsidecardiffcastle: - if (ped > 0) + if (ped > 0) { + AnimationType *spr1 = &_vm->_animation->_sprites[1]; switch (_vm->_gyro->_cardiffQuestionNum) { - case 0 : { // You've answered NONE of his questions. - _vm->_animation->_sprites[1].init(9, false, _vm->_animation); + case 0 : // You've answered NONE of his questions. + spr1->init(9, false, _vm->_animation); _vm->_animation->appearPed(2, 2); - _vm->_animation->_sprites[1].walkTo(3); + spr1->walkTo(3); _vm->_timer->addTimer(47, Timer::kProcCardiffSurvey, Timer::kReasonCardiffsurvey); - } - break; + break; case 5 : _vm->_gyro->_magics[1]._operation = Gyro::kMagicNothing; break; // You've answered ALL his questions. => nothing happens. - default: { // You've answered SOME of his questions. - _vm->_animation->_sprites[1].init(9, false, _vm->_animation); + default: // You've answered SOME of his questions. + spr1->init(9, false, _vm->_animation); _vm->_animation->appearPed(2, 3); - _vm->_animation->_sprites[1]._facingDir = Animation::kDirRight; + spr1->_facingDir = Animation::kDirRight; _vm->_timer->addTimer(3, Timer::kProcCardiffReturn, Timer::kReasonCardiffsurvey); } - } + } + if (_vm->_gyro->_cardiffQuestionNum < 5) _vm->_gyro->_interrogation = _vm->_gyro->_cardiffQuestionNum; - else _vm->_gyro->_interrogation = 0; + else + _vm->_gyro->_interrogation = 0; break; case r__map: @@ -717,18 +725,20 @@ void Lucerna::enterRoom(byte room, byte ped) { } break; - case r__wisewomans: - _vm->_animation->_sprites[1].init(11, false, _vm->_animation); + case r__wisewomans: { + AnimationType *spr1 = &_vm->_animation->_sprites[1]; + spr1->init(11, false, _vm->_animation); if ((_vm->_gyro->_roomCount[r__wisewomans] == 1) && (ped > 0)) { _vm->_animation->appearPed(2, 2); // Start on the right-hand side of the screen. - _vm->_animation->_sprites[1].walkTo(4); // Walks up to greet you. + spr1->walkTo(4); // Walks up to greet you. } else { _vm->_animation->appearPed(2, 4); // Starts where she was before. - _vm->_animation->_sprites[1]._facingDir = Animation::kDirLeft; + spr1->_facingDir = Animation::kDirLeft; } - _vm->_animation->_sprites[1]._callEachStepFl = true; - _vm->_animation->_sprites[1]._eachStepProc = Animation::kProcFaceAvvy; // She always faces Avvy. + spr1->_callEachStepFl = true; + spr1->_eachStepProc = Animation::kProcFaceAvvy; // She always faces Avvy. + } break; case r__insidecardiffcastle: @@ -810,7 +820,8 @@ void Lucerna::enterRoom(byte room, byte ped) { break; case r__nottspub: - if (_vm->_gyro->_sittingInPub) _vm->_celer->drawBackgroundSprite(-1, -1, 3); + if (_vm->_gyro->_sittingInPub) + _vm->_celer->drawBackgroundSprite(-1, -1, 3); _vm->_gyro->_dogFoodPos = 1; // Actually, du Lustie pos. break; @@ -833,9 +844,7 @@ void Lucerna::enterRoom(byte room, byte ped) { } _vm->_gyro->_seeScroll = false; // Now it can work again! - - if (_vm->_gyro->isLoaded) - _vm->_gyro->isLoaded = false; + _vm->_gyro->isLoaded = false; } void Lucerna::thinkAbout(byte object, bool type) { @@ -1021,16 +1030,17 @@ void Lucerna::guideAvvy(Common::Point cursorPos) { byte what; // _vm->_animation->tr[0] is Avalot.) - if (cursorPos.x < _vm->_animation->_sprites[0]._x) + AnimationType *avvy = &_vm->_animation->_sprites[0]; + if (cursorPos.x < avvy->_x) what = 1; - else if (cursorPos.x > (_vm->_animation->_sprites[0]._x + _vm->_animation->_sprites[0]._info._xLength)) + else if (cursorPos.x > (avvy->_x + avvy->_info._xLength)) what = 2; else what = 0; // On top - if (cursorPos.y < _vm->_animation->_sprites[0]._y) + if (cursorPos.y < avvy->_y) what += 3; - else if (cursorPos.y > (_vm->_animation->_sprites[0]._y + _vm->_animation->_sprites[0]._info._yLength)) + else if (cursorPos.y > (avvy->_y + avvy->_info._yLength)) what += 6; switch (what) { @@ -1178,13 +1188,14 @@ void Lucerna::drawDirection() { // It's data is loaded in load_digits(). void Lucerna::gameOver() { _vm->_gyro->_userMovesAvvy = false; - int16 sx = _vm->_animation->_sprites[0]._x; - int16 sy = _vm->_animation->_sprites[0]._y; + AnimationType *avvy = &_vm->_animation->_sprites[0]; + int16 sx = avvy->_x; + int16 sy = avvy->_y; - _vm->_animation->_sprites[0].remove(); - _vm->_animation->_sprites[0].init(12, true, _vm->_animation); // 12 = Avalot falls - _vm->_animation->_sprites[0]._stepNum = 0; - _vm->_animation->_sprites[0].appear(sx, sy, 0); + avvy->remove(); + avvy->init(12, true, _vm->_animation); // 12 = Avalot falls + avvy->_stepNum = 0; + avvy->appear(sx, sy, 0); _vm->_timer->addTimer(3, Timer::kProcAvalotFalls, Timer::kReasonFallingOver); _vm->_gyro->_alive = false; @@ -1207,18 +1218,17 @@ void Lucerna::majorRedraw() { } uint16 Lucerna::bearing(byte whichPed) { - byte pedId = whichPed - 1; // Different array indexes in Pascal and C. + static const double rad2deg = 180 / 3.14; // Pi - const double rad2deg = 180 / 3.14; // Pi + byte pedId = whichPed - 1; // Different array indexes in Pascal and C. + AnimationType *avvy = &_vm->_animation->_sprites[0]; - if (_vm->_animation->_sprites[0]._x == _vm->_gyro->_peds[pedId]._x) + if (avvy->_x == _vm->_gyro->_peds[pedId]._x) return 0; - else if (_vm->_animation->_sprites[0]._x < _vm->_gyro->_peds[pedId]._x) { - return (uint16)((atan(double((_vm->_animation->_sprites[0]._y - _vm->_gyro->_peds[pedId]._y)) - / (_vm->_animation->_sprites[0]._x - _vm->_gyro->_peds[pedId]._x)) * rad2deg) + 90); + else if (avvy->_x < _vm->_gyro->_peds[pedId]._x) { + return (uint16)((atan(double((avvy->_y - _vm->_gyro->_peds[pedId]._y)) / (avvy->_x - _vm->_gyro->_peds[pedId]._x)) * rad2deg) + 90); } else { - return (uint16)((atan(double((_vm->_animation->_sprites[0]._y - _vm->_gyro->_peds[pedId]._y)) - / (_vm->_animation->_sprites[0]._x - _vm->_gyro->_peds[pedId]._x)) * rad2deg) + 270); + return (uint16)((atan(double((avvy->_y - _vm->_gyro->_peds[pedId]._y)) / (avvy->_x - _vm->_gyro->_peds[pedId]._x)) * rad2deg) + 270); } } diff --git a/engines/avalanche/scrolls2.cpp b/engines/avalanche/scrolls2.cpp index 3bcb2e0ccc..f6c5dab8f2 100644 --- a/engines/avalanche/scrolls2.cpp +++ b/engines/avalanche/scrolls2.cpp @@ -668,11 +668,12 @@ void Scrolls::callScrollDriver() { if (_param == 0) setBubbleStateNatural(); else if ((1 <= _param) && (_param <= 9)) { - if ((_param > _vm->_animation->kSpriteNumbMax) || (!_vm->_animation->_sprites[_param - 1]._quick)) { // Not valid. + AnimationType *spr = &_vm->_animation->_sprites[_param - 1]; + if ((_param > _vm->_animation->kSpriteNumbMax) || (!spr->_quick)) { // Not valid. _vm->_lucerna->errorLed(); setBubbleStateNatural(); } else - _vm->_animation->_sprites[_param - 1].chatter(); // Normal sprite talking routine. + spr->chatter(); // Normal sprite talking routine. } else if ((10 <= _param) && (_param <= 36)) { // Quasi-peds. (This routine performs the same // thing with QPs as triptype.chatter does with the diff --git a/engines/avalanche/timer.cpp b/engines/avalanche/timer.cpp index 019f2da84f..2df7ce217a 100644 --- a/engines/avalanche/timer.cpp +++ b/engines/avalanche/timer.cpp @@ -308,10 +308,12 @@ void Timer::getTiedUp() { _vm->_gyro->_userMovesAvvy = false; _vm->_gyro->_beenTiedUp = true; _vm->_animation->stopWalking(); - _vm->_animation->_sprites[1].stopWalk(); - _vm->_animation->_sprites[1].stopHoming(); - _vm->_animation->_sprites[1]._callEachStepFl = true; - _vm->_animation->_sprites[1]._eachStepProc = Animation::kProcGrabAvvy; + + AnimationType *spr = &_vm->_animation->_sprites[1]; + spr->stopWalk(); + spr->stopHoming(); + spr->_callEachStepFl = true; + spr->_eachStepProc = Animation::kProcGrabAvvy; addTimer(70, kProcGetTiedUp2, kReasonGettingTiedUp); } @@ -324,22 +326,25 @@ void Timer::getTiedUp2() { void Timer::hangAround() { _vm->_animation->_sprites[1]._doCheck = false; - _vm->_animation->_sprites[0].init(7, true, _vm->_animation); // Robin Hood + + AnimationType *avvy = &_vm->_animation->_sprites[0]; + avvy->init(7, true, _vm->_animation); // Robin Hood _vm->_gyro->_whereIs[Gyro::kPeopleRobinHood - 150] = r__robins; _vm->_animation->appearPed(1, 2); _vm->_visa->displayScrollChain('q', 39); - _vm->_animation->_sprites[0].walkTo(7); + avvy->walkTo(7); addTimer(55, kProcHangAround2, kReasonHangingAround); } void Timer::hangAround2() { _vm->_visa->displayScrollChain('q', 40); - _vm->_animation->_sprites[1]._vanishIfStill = false; - _vm->_animation->_sprites[1].walkTo(4); + AnimationType *spr = &_vm->_animation->_sprites[1]; + spr->_vanishIfStill = false; + spr->walkTo(4); _vm->_gyro->_whereIs[Gyro::kPeopleFriarTuck - 150] = r__robins; _vm->_visa->displayScrollChain('q', 41); _vm->_animation->_sprites[0].remove(); - _vm->_animation->_sprites[1].remove(); // Get rid of Robin Hood and Friar Tuck. + spr->remove(); // Get rid of Robin Hood and Friar Tuck. addTimer(1, kProcAfterTheShootemup, kReasonHangingAround); // Immediately call the following proc (when you have a chance). @@ -424,9 +429,10 @@ void Timer::jacquesWakesUp() { } void Timer::naughtyDuke() { // This is when the Duke comes in and takes your money. - _vm->_animation->_sprites[1].init(9, false, _vm->_animation); // Here comes the Duke. + AnimationType *spr = &_vm->_animation->_sprites[1]; + spr->init(9, false, _vm->_animation); // Here comes the Duke. _vm->_animation->appearPed(2, 1); // He starts at the door... - _vm->_animation->_sprites[1].walkTo(3); // He walks over to you. + spr->walkTo(3); // He walks over to you. // Let's get the door opening. _vm->_celer->drawBackgroundSprite(-1, -1, 1); @@ -437,9 +443,10 @@ void Timer::naughtyDuke() { // This is when the Duke comes in and takes your mon } void Timer::naughtyDuke2() { + AnimationType *spr = &_vm->_animation->_sprites[1]; _vm->_visa->displayScrollChain('q', 48); // "Ha ha, it worked again!" - _vm->_animation->_sprites[1].walkTo(1); // Walk to the door. - _vm->_animation->_sprites[1]._vanishIfStill = true; // Then go away! + spr->walkTo(1); // Walk to the door. + spr->_vanishIfStill = true; // Then go away! addTimer(32, kProcNaughtyDuke3, kReasonNaughtyDuke); } @@ -450,8 +457,9 @@ void Timer::naughtyDuke3() { } void Timer::jump() { - _vm->_gyro->_jumpStatus++; + AnimationType *avvy = &_vm->_animation->_sprites[0]; + _vm->_gyro->_jumpStatus++; switch (_vm->_gyro->_jumpStatus) { case 1: case 2: @@ -459,7 +467,7 @@ void Timer::jump() { case 5: case 7: case 9: - _vm->_animation->_sprites[0]._y--; + avvy->_y--; break; case 12: case 13: @@ -467,7 +475,7 @@ void Timer::jump() { case 16: case 18: case 19: - _vm->_animation->_sprites[0]._y++; + avvy->_y++; break; } @@ -539,8 +547,10 @@ void Timer::greetsMonk() { void Timer::fallDownOubliette() { _vm->_gyro->_magics[8]._operation = Gyro::kMagicNothing; - _vm->_animation->_sprites[0]._moveY++; // Increments dx/dy! - _vm->_animation->_sprites[0]._y += _vm->_animation->_sprites[0]._moveY; // Dowwwn we go... + + AnimationType *avvy = &_vm->_animation->_sprites[0]; + avvy->_moveY++; // Increments dx/dy! + avvy->_y += avvy->_moveY; // Dowwwn we go... addTimer(3, kProcFallDownOubliette, kReasonFallingDownOubliette); } @@ -554,48 +564,59 @@ void Timer::meetAvaroid() { _vm->_gyro->_metAvaroid = true; addTimer(1, kProcRiseUpOubliette, kReasonRisingUpOubliette); - _vm->_animation->_sprites[0]._facingDir = Animation::kDirLeft; - _vm->_animation->_sprites[0]._x = 151; - _vm->_animation->_sprites[0]._moveX = -3; - _vm->_animation->_sprites[0]._moveY = -5; + AnimationType *avvy = &_vm->_animation->_sprites[0]; + avvy->_facingDir = Animation::kDirLeft; + avvy->_x = 151; + avvy->_moveX = -3; + avvy->_moveY = -5; _vm->_gyro->setBackgroundColor(2); } } void Timer::riseUpOubliette() { - _vm->_animation->_sprites[0]._visible = true; - _vm->_animation->_sprites[0]._moveY++; // Decrements dx/dy! - _vm->_animation->_sprites[0]._y -= _vm->_animation->_sprites[0]._moveY; // Uuuupppp we go... - if (_vm->_animation->_sprites[0]._moveY > 0) + AnimationType *avvy = &_vm->_animation->_sprites[0]; + avvy->_visible = true; + avvy->_moveY++; // Decrements dx/dy! + avvy->_y -= avvy->_moveY; // Uuuupppp we go... + if (avvy->_moveY > 0) addTimer(3, kProcRiseUpOubliette, kReasonRisingUpOubliette); else _vm->_gyro->_userMovesAvvy = true; } void Timer::robinHoodAndGeida() { - _vm->_animation->_sprites[0].init(7, true, _vm->_animation); + AnimationType *avvy = &_vm->_animation->_sprites[0]; + avvy->init(7, true, _vm->_animation); _vm->_animation->appearPed(1, 7); - _vm->_animation->_sprites[0].walkTo(6); - _vm->_animation->_sprites[1].stopWalk(); - _vm->_animation->_sprites[1]._facingDir = Animation::kDirLeft; + avvy->walkTo(6); + + AnimationType *spr = &_vm->_animation->_sprites[1]; + spr->stopWalk(); + spr->_facingDir = Animation::kDirLeft; addTimer(20, kProcRobinHoodAndGeidaTalk, kReasonRobinHoodAndGeida); _vm->_gyro->_geidaFollows = false; } void Timer::robinHoodAndGeidaTalk() { _vm->_visa->displayScrollChain('q', 66); - _vm->_animation->_sprites[0].walkTo(2); - _vm->_animation->_sprites[1].walkTo(2); - _vm->_animation->_sprites[0]._vanishIfStill = true; - _vm->_animation->_sprites[1]._vanishIfStill = true; + + AnimationType *avvy = &_vm->_animation->_sprites[0]; + AnimationType *spr = &_vm->_animation->_sprites[1]; + avvy->walkTo(2); + spr->walkTo(2); + avvy->_vanishIfStill = true; + spr->_vanishIfStill = true; + addTimer(162, kProcAvalotReturns, kReasonRobinHoodAndGeida); } void Timer::avalotReturns() { - _vm->_animation->_sprites[0].remove(); - _vm->_animation->_sprites[1].remove(); - _vm->_animation->_sprites[0].init(0, true, _vm->_animation); + AnimationType *avvy = &_vm->_animation->_sprites[0]; + AnimationType *spr = &_vm->_animation->_sprites[1]; + avvy->remove(); + spr->remove(); + avvy->init(0, true, _vm->_animation); _vm->_animation->appearPed(1, 1); _vm->_visa->displayScrollChain('q', 67); _vm->_gyro->_userMovesAvvy = true; @@ -607,18 +628,20 @@ void Timer::avalotReturns() { * @remarks Originally called 'avvy_sit_down' */ void Timer::avvySitDown() { - if (_vm->_animation->_sprites[0]._homing) // Still walking. + AnimationType *avvy = &_vm->_animation->_sprites[0]; + if (avvy->_homing) // Still walking. addTimer(1, kProcAvvySitDown, kReasonSittingDown); else { _vm->_celer->drawBackgroundSprite(-1, -1, 3); _vm->_gyro->_sittingInPub = true; _vm->_gyro->_userMovesAvvy = false; - _vm->_animation->_sprites[0]._visible = false; + avvy->_visible = false; } } void Timer::ghostRoomPhew() { - Common::String tmpStr = Common::String::format("%cPHEW!%c You're glad to get out of %cthere!", Scrolls::kControlItalic, Scrolls::kControlRoman, Scrolls::kControlItalic); + Common::String tmpStr = Common::String::format("%cPHEW!%c You're glad to get out of %cthere!", + Scrolls::kControlItalic, Scrolls::kControlRoman, Scrolls::kControlItalic); _vm->_scrolls->displayText(tmpStr); } @@ -648,8 +671,9 @@ void Timer::winning() { } void Timer::avalotFalls() { - if (_vm->_animation->_sprites[0]._stepNum < 5) { - _vm->_animation->_sprites[0]._stepNum++; + AnimationType *avvy = &_vm->_animation->_sprites[0]; + if (avvy->_stepNum < 5) { + avvy->_stepNum++; addTimer(3, kProcAvalotFalls, kReasonFallingOver); } else { Common::String toDisplay = Common::String::format("%c%c%c%c%c%c%c%c%c%c%c%c%cZ%c", -- cgit v1.2.3