[Scummvm-cvs-logs] SF.net SVN: scummvm:[45512] scummvm/trunk/engines/draci

spalek at users.sourceforge.net spalek at users.sourceforge.net
Fri Oct 30 02:56:53 CET 2009


Revision: 45512
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45512&view=rev
Author:   spalek
Date:     2009-10-30 01:56:52 +0000 (Fri, 30 Oct 2009)

Log Message:
-----------
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.

Modified Paths:
--------------
    scummvm/trunk/engines/draci/animation.cpp
    scummvm/trunk/engines/draci/animation.h
    scummvm/trunk/engines/draci/game.cpp
    scummvm/trunk/engines/draci/script.cpp

Modified: scummvm/trunk/engines/draci/animation.cpp
===================================================================
--- scummvm/trunk/engines/draci/animation.cpp	2009-10-30 01:41:57 UTC (rev 45511)
+++ scummvm/trunk/engines/draci/animation.cpp	2009-10-30 01:56:52 UTC (rev 45512)
@@ -219,18 +219,14 @@
 	_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 @@
 			continue;
 		}
 
-		(*it)->nextFrame();
+		(*it)->nextFrame(false);
 		(*it)->drawFrame(surf);
 	}
 }
@@ -559,7 +555,7 @@
 			continue;
 		}
 
-		const Drawable *frame = anim->getFrame();
+		const Drawable *frame = anim->getCurrentFrame();
 
 		if (frame == NULL) {
 			continue;

Modified: scummvm/trunk/engines/draci/animation.h
===================================================================
--- scummvm/trunk/engines/draci/animation.h	2009-10-30 01:41:57 UTC (rev 45511)
+++ scummvm/trunk/engines/draci/animation.h	2009-10-30 01:56:52 UTC (rev 45512)
@@ -47,12 +47,6 @@
 };
 
 /**
-  * 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 @@
 	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;

Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp	2009-10-30 01:41:57 UTC (rev 45511)
+++ scummvm/trunk/engines/draci/game.cpp	2009-10-30 01:56:52 UTC (rev 45512)
@@ -211,7 +211,7 @@
 		_dialogueAnims[i]->setRelative(1,
 		                      kScreenHeight - (i + 1) * _vm->_smallFont->getFontHeight());
 
-		Text *text = reinterpret_cast<Text *>(_dialogueAnims[i]->getFrame());
+		Text *text = reinterpret_cast<Text *>(_dialogueAnims[i]->getCurrentFrame());
 		text->setText("");
 	}
 
@@ -266,7 +266,7 @@
 		if (_loopStatus == kStatusDialogue && _loopSubstatus == kSubstatusOrdinary) {
 			Text *text;
 			for (int i = 0; i < kDialogueLines; ++i) {
-				text = reinterpret_cast<Text *>(_dialogueAnims[i]->getFrame());
+				text = reinterpret_cast<Text *>(_dialogueAnims[i]->getCurrentFrame());
 
 				if (_animUnderCursor == _dialogueAnims[i]->getID()) {
 					text->setColour(kLineActiveColour);
@@ -285,7 +285,7 @@
 		if (_vm->_mouse->isCursorOn()) {
 			// Fetch the dedicated objects' title animation / current frame
 			Animation *titleAnim = _vm->_anims->getAnimation(kTitleText);
-			Text *title = reinterpret_cast<Text *>(titleAnim->getFrame());
+			Text *title = reinterpret_cast<Text *>(titleAnim->getCurrentFrame());
 
 			updateCursor();
 			updateTitle();
@@ -581,7 +581,7 @@
 
 	// Fetch the dedicated objects' title animation / current frame
 	Animation *titleAnim = _vm->_anims->getAnimation(kTitleText);
-	Text *title = reinterpret_cast<Text *>(titleAnim->getFrame());
+	Text *title = reinterpret_cast<Text *>(titleAnim->getCurrentFrame());
 
 	// Mark dirty rectangle to delete the previous text
 	titleAnim->markDirtyRect(surface);
@@ -672,7 +672,7 @@
 		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 @@
 		debugC(3, kDraciLogicDebugLevel, "Testing dialogue block %d", i);
 		if (_vm->_script->testExpression(blockTest, 1)) {
 			anim = _dialogueAnims[_dialogueLinesNum];
-			dialogueLine = reinterpret_cast<Text *>(anim->getFrame());
+			dialogueLine = reinterpret_cast<Text *>(anim->getCurrentFrame());
 			dialogueLine->setText(_dialogueBlocks[i]._title);
 
 			dialogueLine->setColour(kLineInactiveColour);
@@ -823,7 +823,7 @@
 	for (i = _dialogueLinesNum; i < kDialogueLines; ++i) {
 		_lines[i] = -1;
 		anim = _dialogueAnims[i];
-		dialogueLine = reinterpret_cast<Text *>(anim->getFrame());
+		dialogueLine = reinterpret_cast<Text *>(anim->getCurrentFrame());
 		dialogueLine->setText("");
 	}
 
@@ -853,7 +853,7 @@
 	}
 
 	for (i = 0; i < kDialogueLines; ++i) {
-		dialogueLine = reinterpret_cast<Text *>(_dialogueAnims[i]->getFrame());
+		dialogueLine = reinterpret_cast<Text *>(_dialogueAnims[i]->getCurrentFrame());
 		_dialogueAnims[i]->markDirtyRect(_vm->_screen->getSurface());
 		dialogueLine->setText("");
 	}
@@ -1421,7 +1421,7 @@
 	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();

Modified: scummvm/trunk/engines/draci/script.cpp
===================================================================
--- scummvm/trunk/engines/draci/script.cpp	2009-10-30 01:41:57 UTC (rev 45511)
+++ scummvm/trunk/engines/draci/script.cpp	2009-10-30 01:56:52 UTC (rev 45512)
@@ -708,7 +708,7 @@
 
 	// Fetch frame for the speech text
 	Animation *speechAnim = _vm->_anims->getAnimation(kSpeechText);
-	Text *speechFrame = reinterpret_cast<Text *>(speechAnim->getFrame());
+	Text *speechFrame = reinterpret_cast<Text *>(speechAnim->getCurrentFrame());
 
 	// Fetch person info
 	const Person *person = _vm->_game->getPerson(personID);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list