From b083878dbefeb95c9bc9d4493839121565da6342 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 13 Sep 2013 22:58:24 +0200 Subject: AVALANCHE: Remove duplicated direction enum, move direction to animation class --- engines/avalanche/acci2.cpp | 2 +- engines/avalanche/animation.cpp | 54 ++++++++++++++++++++--------------------- engines/avalanche/animation.h | 2 ++ engines/avalanche/avalanche.cpp | 5 ++-- engines/avalanche/avalot.cpp | 2 +- engines/avalanche/gyro2.cpp | 6 ++--- engines/avalanche/gyro2.h | 14 ----------- engines/avalanche/lucerna2.cpp | 18 +++++++------- 8 files changed, 46 insertions(+), 57 deletions(-) (limited to 'engines/avalanche') diff --git a/engines/avalanche/acci2.cpp b/engines/avalanche/acci2.cpp index 747bcca5b4..8387b0ff84 100644 --- a/engines/avalanche/acci2.cpp +++ b/engines/avalanche/acci2.cpp @@ -1160,7 +1160,7 @@ void Acci::standUp() { _vm->_animation->_sprites[0]._visible = true; _vm->_gyro->_userMovesAvvy = true; _vm->_animation->appearPed(1, 2); - _vm->_gyro->_direction = Gyro::kDirectionLeft; + _vm->_animation->_direction = Animation::kDirLeft; _vm->_celer->drawBackgroundSprite(-1, -1, 4); // Picture of empty pillow. _vm->_lucerna->incScore(1); _vm->_gyro->_avvyInBed = false; diff --git a/engines/avalanche/animation.cpp b/engines/avalanche/animation.cpp index bdca9fdcf1..5ce809c76d 100644 --- a/engines/avalanche/animation.cpp +++ b/engines/avalanche/animation.cpp @@ -1279,7 +1279,7 @@ void Animation::animLink() { void Animation::stopWalking() { _sprites[0].stopWalk(); - _vm->_gyro->_direction = kDirStopped; + _direction = kDirStopped; if (_vm->_gyro->_alive) _sprites[0]._stepNum = 1; } @@ -1348,8 +1348,8 @@ void Animation::flipRoom(byte room, byte ped) { _vm->_lucerna->enterRoom(room, ped); appearPed(1, ped); _vm->_gyro->_enterCatacombsFromLustiesRoom = false; - _vm->_gyro->_oldDirection = _vm->_gyro->_direction; - _vm->_gyro->_direction = _sprites[0]._facingDir; + _oldDirection = _direction; + _direction = _sprites[0]._facingDir; _vm->_lucerna->drawDirection(); _vm->_lucerna->dawn(); @@ -1393,58 +1393,58 @@ void Animation::handleMoveKey(const Common::Event &event) { else { switch (event.kbd.keycode) { case Common::KEYCODE_UP: - if (_vm->_gyro->_direction != kDirUp) { - _vm->_gyro->_direction = kDirUp; - changeDirection(0, _vm->_gyro->_direction); + if (_direction != kDirUp) { + _direction = kDirUp; + changeDirection(0, _direction); } else stopWalking(); break; case Common::KEYCODE_DOWN: - if (_vm->_gyro->_direction != kDirDown) { - _vm->_gyro->_direction = kDirDown; - changeDirection(0, _vm->_gyro->_direction); + if (_direction != kDirDown) { + _direction = kDirDown; + changeDirection(0, _direction); } else stopWalking(); break; case Common::KEYCODE_LEFT: - if (_vm->_gyro->_direction != kDirLeft) { - _vm->_gyro->_direction = kDirLeft; - changeDirection(0, _vm->_gyro->_direction); + if (_direction != kDirLeft) { + _direction = kDirLeft; + changeDirection(0, _direction); } else stopWalking(); break; case Common::KEYCODE_RIGHT: - if (_vm->_gyro->_direction != kDirRight) { - _vm->_gyro->_direction = kDirRight; - changeDirection(0, _vm->_gyro->_direction); + if (_direction != kDirRight) { + _direction = kDirRight; + changeDirection(0, _direction); } else stopWalking(); break; case Common::KEYCODE_PAGEUP: - if (_vm->_gyro->_direction != kDirUpRight) { - _vm->_gyro->_direction = kDirUpRight; - changeDirection(0, _vm->_gyro->_direction); + if (_direction != kDirUpRight) { + _direction = kDirUpRight; + changeDirection(0, _direction); } else stopWalking(); break; case Common::KEYCODE_PAGEDOWN: - if (_vm->_gyro->_direction != kDirDownRight) { - _vm->_gyro->_direction = kDirDownRight; - changeDirection(0, _vm->_gyro->_direction); + if (_direction != kDirDownRight) { + _direction = kDirDownRight; + changeDirection(0, _direction); } else stopWalking(); break; case Common::KEYCODE_END: - if (_vm->_gyro->_direction != kDirDownLeft) { - _vm->_gyro->_direction = kDirDownLeft; - changeDirection(0, _vm->_gyro->_direction); + if (_direction != kDirDownLeft) { + _direction = kDirDownLeft; + changeDirection(0, _direction); } else stopWalking(); break; case Common::KEYCODE_HOME: - if (_vm->_gyro->_direction != kDirUpLeft) { - _vm->_gyro->_direction = kDirUpLeft; - changeDirection(0, _vm->_gyro->_direction); + if (_direction != kDirUpLeft) { + _direction = kDirUpLeft; + changeDirection(0, _direction); } else stopWalking(); break; diff --git a/engines/avalanche/animation.h b/engines/avalanche/animation.h index 73abadac2e..185f2f8e98 100644 --- a/engines/avalanche/animation.h +++ b/engines/avalanche/animation.h @@ -113,6 +113,8 @@ public: AnimationType _sprites[kSpriteNumbMax]; bool _mustExclaim; uint16 _sayWhat; + byte _direction; // The direction Avvy is currently facing. + byte _oldDirection; Animation(AvalancheEngine *vm); ~Animation(); diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp index 611a8ef3a8..a5acf0988e 100644 --- a/engines/avalanche/avalanche.cpp +++ b/engines/avalanche/avalanche.cpp @@ -123,7 +123,7 @@ const char *AvalancheEngine::getCopyrightString() const { void AvalancheEngine::synchronize(Common::Serializer &sz) { //blockwrite(f, dna, sizeof(dna)); - sz.syncAsByte(_gyro->_direction); + sz.syncAsByte(_animation->_direction); sz.syncAsByte(_gyro->_carryNum); for (byte i = 0; i < kObjectNum; i++) sz.syncAsByte(_gyro->_objects[i]); @@ -459,7 +459,7 @@ bool AvalancheEngine::loadGame(const int16 slot) { _scrolls->displayText(tmpStr); if (_animation->_sprites[0]._quick && _animation->_sprites[0]._visible) - _animation->changeDirection(0, _gyro->_direction); // We push Avvy in the right direction is he was moving. + _animation->changeDirection(0, _animation->_direction); // We push Avvy in the right direction is he was moving. return true; } @@ -487,6 +487,7 @@ Common::String AvalancheEngine::expandDate(int d, int m, int y) { day += "th"; } + // Y2K compliant ;) return day + ' ' + month + ' ' + _gyro->intToStr(y + 1900); } diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp index 5a9fa60dc3..a4ead4a508 100644 --- a/engines/avalanche/avalot.cpp +++ b/engines/avalanche/avalot.cpp @@ -147,7 +147,7 @@ void Avalot::setup() { _vm->_gyro->_ledStatus = 177; _vm->_gyro->_defaultLed = 2; // TSkellern = 0; Replace with a more local variable sometime - _vm->_gyro->_direction = Gyro::kDirectionStopped; + _vm->_animation->_direction = Animation::kDirStopped; _vm->_gyro->_enidFilename = ""; // Undefined. _vm->_lucerna->drawToolbar(); _vm->_scrolls->setReadyLight(2); diff --git a/engines/avalanche/gyro2.cpp b/engines/avalanche/gyro2.cpp index d9e0d74804..1b950739fd 100644 --- a/engines/avalanche/gyro2.cpp +++ b/engines/avalanche/gyro2.cpp @@ -227,7 +227,7 @@ void Gyro::drawShadowBox(int16 x1, int16 y1, int16 x2, int16 y2, Common::String void Gyro::resetVariables() { // Replaces memset(&_vm->_gyro->_dna, 0, sizeof(DnaType)); - _direction = 0; + _vm->_animation->_direction = 0; _carryNum = 0; for (int i = 0; i < kObjectNum; i++) _objects[i] = false; @@ -326,7 +326,7 @@ void Gyro::newGame() { _spareEvening = "answer a questionnaire"; _favouriteDrink = "beer"; _money = 30; // 2/6 - _direction = kDirectionStopped; + _vm->_animation->_direction = Animation::kDirStopped; _wearing = kObjectClothes; _objects[kObjectMoney - 1] = true; _objects[kObjectBodkin - 1] = true; @@ -339,7 +339,7 @@ void Gyro::newGame() { _onToolbar = false; _seeScroll = false; - _vm->_animation->_sprites[0].appear(300,117,kDirectionRight); // Needed to initialize Avalot. + _vm->_animation->_sprites[0].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; diff --git a/engines/avalanche/gyro2.h b/engines/avalanche/gyro2.h index 35addc3a50..7581863dca 100644 --- a/engines/avalanche/gyro2.h +++ b/engines/avalanche/gyro2.h @@ -211,24 +211,12 @@ public: // These following static constants should be included in CFG when it's written. static const bool kSlowComputer = false; // Stops walking when mouse touches toolbar. - static const int16 kBorder = 1; // size of border on shadowboxes - - enum Direction { - kDirectionUp, kDirectionRight, kDirectionDown, kDirectionLeft, - kDirectionUpRight, kDirectionDownRight, kDirectionDownLeft, kDirectionUpLeft, - kDirectionStopped - }; - static const int16 kWalk = 3; static const int16 kRun = 5; - static const int32 kCatacombMap[8][8]; - static const bool kDemo = false; // If this is true, we're in a demo of the game. - static const char kSpludwicksOrder[3]; - static const QuasipedType kQuasipeds[16]; enum Pitch { @@ -255,7 +243,6 @@ public: bool _onCanDoPageSwap; // Former DNA structure - byte _direction; // The direction Avvy is currently facing. byte _carryNum; // How many objects you're carrying... bool _objects[kObjectNum]; // ...and which ones they are. int16 _dnascore; // your score, of course @@ -343,7 +330,6 @@ public: ::Graphics::Surface _digits[10]; // digitsize and rwlitesize are defined in Lucerna::load_digits() !!! ::Graphics::Surface _directions[9]; // Maybe it will be needed to move them to the class itself instead. // Called .free() for them in ~Gyro(). - byte _oldDirection; int8 _scoreToDisplay[3]; byte _currentMouse; // current mouse-void Common::String _verbStr; // what you can do with your object. :-) diff --git a/engines/avalanche/lucerna2.cpp b/engines/avalanche/lucerna2.cpp index 12b75523a4..9a7d048763 100644 --- a/engines/avalanche/lucerna2.cpp +++ b/engines/avalanche/lucerna2.cpp @@ -913,7 +913,7 @@ void Lucerna::drawToolbar() { file.close(); CursorMan.showMouse(true); - _vm->_gyro->_oldDirection = 177; + _vm->_animation->_oldDirection = 177; drawDirection(); } @@ -967,22 +967,22 @@ void Lucerna::useCompass(const Common::Point &cursorPos) { switch (color) { case kColorGreen: - _vm->_gyro->_direction = Animation::kDirUp; + _vm->_animation->_direction = Animation::kDirUp; _vm->_animation->changeDirection(0, Animation::kDirUp); drawDirection(); break; case kColorBrown: - _vm->_gyro->_direction = Animation::kDirDown; + _vm->_animation->_direction = Animation::kDirDown; _vm->_animation->changeDirection(0, Animation::kDirDown); drawDirection(); break; case kColorCyan: - _vm->_gyro->_direction = Animation::kDirLeft; + _vm->_animation->_direction = Animation::kDirLeft; _vm->_animation->changeDirection(0, Animation::kDirLeft); drawDirection(); break; case kColorLightmagenta: - _vm->_gyro->_direction = Animation::kDirRight; + _vm->_animation->_direction = Animation::kDirRight; _vm->_animation->changeDirection(0, Animation::kDirRight); drawDirection(); break; @@ -1167,13 +1167,13 @@ void Lucerna::dawn() { } void Lucerna::drawDirection() { // It's data is loaded in load_digits(). - if (_vm->_gyro->_oldDirection == _vm->_gyro->_direction) + if (_vm->_animation->_oldDirection == _vm->_animation->_direction) return; - _vm->_gyro->_oldDirection = _vm->_gyro->_direction; + _vm->_animation->_oldDirection = _vm->_animation->_direction; CursorMan.showMouse(false); - _vm->_graphics->drawPicture(_vm->_graphics->_surface, _vm->_gyro->_directions[_vm->_gyro->_direction], 0, 161); + _vm->_graphics->drawPicture(_vm->_graphics->_surface, _vm->_gyro->_directions[_vm->_animation->_direction], 0, 161); CursorMan.showMouse(true); } @@ -1240,7 +1240,7 @@ void Lucerna::spriteRun() { void Lucerna::fixFlashers() { _vm->_gyro->_ledStatus = 177; - _vm->_gyro->_oldDirection = 177; + _vm->_animation->_oldDirection = 177; _vm->_scrolls->setReadyLight(2); drawDirection(); } -- cgit v1.2.3