From d662c4aa20342e74ed5d82a14e3fc8e62a45ca8c Mon Sep 17 00:00:00 2001 From: Robert Špalek Date: Fri, 30 Oct 2009 01:56:52 +0000 Subject: Remove the last 2 default parameter values. They usually just add unnecessary confusion and this is definitely such an example. Removal will clarify the code. svn-id: r45512 --- engines/draci/animation.cpp | 20 ++++++++------------ engines/draci/animation.h | 11 +++-------- engines/draci/game.cpp | 18 +++++++++--------- engines/draci/script.cpp | 2 +- 4 files changed, 21 insertions(+), 30 deletions(-) (limited to 'engines/draci') diff --git a/engines/draci/animation.cpp b/engines/draci/animation.cpp index 0c1718c1d7..1c729e9c85 100644 --- a/engines/draci/animation.cpp +++ b/engines/draci/animation.cpp @@ -219,18 +219,14 @@ void Animation::setIndex(int index) { _index = index; } -Drawable *Animation::getFrame(int frameNum) { +Drawable *Animation::getCurrentFrame() { // If there are no frames stored, return NULL - if (_frames.size() == 0) { - return NULL; - } + return _frames.size() > 0 ? _frames[_currentFrame] : NULL; +} - // If no argument is passed, return the current frame - if (frameNum == kCurrentFrame) { - return _frames[_currentFrame]; - } else { - return _frames[frameNum]; - } +Drawable *Animation::getFrame(int frameNum) { + // If there are no frames stored, return NULL + return _frames.size() > 0 ? _frames[frameNum] : NULL; } uint Animation::getFrameCount() const { @@ -417,7 +413,7 @@ void AnimationManager::drawScene(Surface *surf) { continue; } - (*it)->nextFrame(); + (*it)->nextFrame(false); (*it)->drawFrame(surf); } } @@ -559,7 +555,7 @@ int AnimationManager::getTopAnimationID(int x, int y) const { continue; } - const Drawable *frame = anim->getFrame(); + const Drawable *frame = anim->getCurrentFrame(); if (frame == NULL) { continue; diff --git a/engines/draci/animation.h b/engines/draci/animation.h index a0cf43efb8..c0d536f2a2 100644 --- a/engines/draci/animation.h +++ b/engines/draci/animation.h @@ -46,12 +46,6 @@ enum { kInventoryItemsID = -11 }; -/** - * Default argument to Animation::getFrame() that makes it return - * the current frame instead of the user specifying it. - */ -enum { kCurrentFrame = -1 }; - /** * Used by overlays as a neutral index that won't get * released with the GPL Release command. @@ -74,11 +68,12 @@ public: void setID(int id); int getID() const; - void nextFrame(bool force = false); + void nextFrame(bool force); void drawFrame(Surface *surface); void addFrame(Drawable *frame, const SoundSample *sample); - Drawable *getFrame(int frameNum = kCurrentFrame); + Drawable *getCurrentFrame(); + Drawable *getFrame(int frameNum); void setCurrentFrame(uint frame); uint currentFrameNum() const; uint getFrameCount() const; diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index 6d3700cde2..b6d8e08486 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -211,7 +211,7 @@ void Game::init() { _dialogueAnims[i]->setRelative(1, kScreenHeight - (i + 1) * _vm->_smallFont->getFontHeight()); - Text *text = reinterpret_cast(_dialogueAnims[i]->getFrame()); + Text *text = reinterpret_cast(_dialogueAnims[i]->getCurrentFrame()); text->setText(""); } @@ -266,7 +266,7 @@ void Game::loop() { if (_loopStatus == kStatusDialogue && _loopSubstatus == kSubstatusOrdinary) { Text *text; for (int i = 0; i < kDialogueLines; ++i) { - text = reinterpret_cast(_dialogueAnims[i]->getFrame()); + text = reinterpret_cast(_dialogueAnims[i]->getCurrentFrame()); if (_animUnderCursor == _dialogueAnims[i]->getID()) { text->setColour(kLineActiveColour); @@ -285,7 +285,7 @@ void Game::loop() { if (_vm->_mouse->isCursorOn()) { // Fetch the dedicated objects' title animation / current frame Animation *titleAnim = _vm->_anims->getAnimation(kTitleText); - Text *title = reinterpret_cast(titleAnim->getFrame()); + Text *title = reinterpret_cast(titleAnim->getCurrentFrame()); updateCursor(); updateTitle(); @@ -581,7 +581,7 @@ void Game::updateTitle() { // Fetch the dedicated objects' title animation / current frame Animation *titleAnim = _vm->_anims->getAnimation(kTitleText); - Text *title = reinterpret_cast(titleAnim->getFrame()); + Text *title = reinterpret_cast(titleAnim->getCurrentFrame()); // Mark dirty rectangle to delete the previous text titleAnim->markDirtyRect(surface); @@ -672,7 +672,7 @@ void Game::putItem(int itemID, int position) { Sprite *sp = new Sprite(img->_data, img->_length, 0, 0, true); anim->addFrame(sp, NULL); } - Drawable *frame = anim->getFrame(); + Drawable *frame = anim->getCurrentFrame(); const int x = kInventoryX + (column * kInventoryItemWidth) - @@ -810,7 +810,7 @@ int Game::dialogueDraw() { debugC(3, kDraciLogicDebugLevel, "Testing dialogue block %d", i); if (_vm->_script->testExpression(blockTest, 1)) { anim = _dialogueAnims[_dialogueLinesNum]; - dialogueLine = reinterpret_cast(anim->getFrame()); + dialogueLine = reinterpret_cast(anim->getCurrentFrame()); dialogueLine->setText(_dialogueBlocks[i]._title); dialogueLine->setColour(kLineInactiveColour); @@ -823,7 +823,7 @@ int Game::dialogueDraw() { for (i = _dialogueLinesNum; i < kDialogueLines; ++i) { _lines[i] = -1; anim = _dialogueAnims[i]; - dialogueLine = reinterpret_cast(anim->getFrame()); + dialogueLine = reinterpret_cast(anim->getCurrentFrame()); dialogueLine->setText(""); } @@ -853,7 +853,7 @@ int Game::dialogueDraw() { } for (i = 0; i < kDialogueLines; ++i) { - dialogueLine = reinterpret_cast(_dialogueAnims[i]->getFrame()); + dialogueLine = reinterpret_cast(_dialogueAnims[i]->getCurrentFrame()); _dialogueAnims[i]->markDirtyRect(_vm->_screen->getSurface()); dialogueLine->setText(""); } @@ -1421,7 +1421,7 @@ void Game::positionAnimAsHero(Animation *anim) { anim->setZ(_hero.y + 1); // Fetch current frame - Drawable *frame = anim->getFrame(); + Drawable *frame = anim->getCurrentFrame(); // Fetch base dimensions of the frame uint height = frame->getHeight(); diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp index 7fc74e4607..608dac598b 100644 --- a/engines/draci/script.cpp +++ b/engines/draci/script.cpp @@ -708,7 +708,7 @@ void Script::talk(Common::Queue ¶ms) { // Fetch frame for the speech text Animation *speechAnim = _vm->_anims->getAnimation(kSpeechText); - Text *speechFrame = reinterpret_cast(speechAnim->getFrame()); + Text *speechFrame = reinterpret_cast(speechAnim->getCurrentFrame()); // Fetch person info const Person *person = _vm->_game->getPerson(personID); -- cgit v1.2.3