[Scummvm-cvs-logs] SF.net SVN: scummvm: [29855] scummvm/trunk/engines/saga

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Thu Dec 13 21:10:15 CET 2007


Revision: 29855
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29855&view=rev
Author:   thebluegr
Date:     2007-12-13 12:10:13 -0800 (Thu, 13 Dec 2007)

Log Message:
-----------
Use CLIP template for clipping in the SAGA engine

Modified Paths:
--------------
    scummvm/trunk/engines/saga/actor.cpp
    scummvm/trunk/engines/saga/gfx.cpp
    scummvm/trunk/engines/saga/isomap.cpp
    scummvm/trunk/engines/saga/music.cpp
    scummvm/trunk/engines/saga/sprite.cpp

Modified: scummvm/trunk/engines/saga/actor.cpp
===================================================================
--- scummvm/trunk/engines/saga/actor.cpp	2007-12-13 19:44:27 UTC (rev 29854)
+++ scummvm/trunk/engines/saga/actor.cpp	2007-12-13 20:10:13 UTC (rev 29855)
@@ -697,16 +697,10 @@
 		// Both of them are invisible and immovable
 		// There is no point to keep throwing warnings about this, the original checks for
 		// a valid framecount too
-		if (0 == actor->_framesCount) {
+		if (actor->_framesCount == 0) {
 			return &def;
 		}
-		if (frameType >= actor->_framesCount) {
-			frameType = actor->_framesCount - 1;
-		}
-		if (frameType < 0) {
-			frameType = 0;
-		}
-
+		frameType = CLIP(frameType, 0, actor->_framesCount - 1);
 		fourDirection = actorDirectectionsLUT[actor->_facingDirection];
 		return &actor->_frames[frameType].directions[fourDirection];
 	}

Modified: scummvm/trunk/engines/saga/gfx.cpp
===================================================================
--- scummvm/trunk/engines/saga/gfx.cpp	2007-12-13 19:44:27 UTC (rev 29854)
+++ scummvm/trunk/engines/saga/gfx.cpp	2007-12-13 20:10:13 UTC (rev 29855)
@@ -407,10 +407,8 @@
 	PalEntry *palE;
 	double fpercent;
 
-	from = from > 256 ? 256 : from;
-	from = from < 0 ? 0 : from;
-	to = to > 256 ? 256 : to;
-	to = to < 0 ? 0 : to;
+	from = CLIP((int)from, 0, 256);
+	to   = CLIP((int)to,   0, 256);
 
 	if (from == 0 || to == 0) {
 		// This case works like palToBlack or blackToPal, so no changes are needed

Modified: scummvm/trunk/engines/saga/isomap.cpp
===================================================================
--- scummvm/trunk/engines/saga/isomap.cpp	2007-12-13 19:44:27 UTC (rev 29854)
+++ scummvm/trunk/engines/saga/isomap.cpp	2007-12-13 20:10:13 UTC (rev 29855)
@@ -26,9 +26,7 @@
 // Isometric level module
 
 #include "saga/saga.h"
-
 #include "saga/gfx.h"
-
 #include "saga/sagaresnames.h"
 #include "saga/scene.h"
 #include "saga/isomap.h"
@@ -405,24 +403,11 @@
 	spritePointer.x = screenPosition.x + xAlign;
 	spritePointer.y = screenPosition.y + yAlign;
 
-	_tileClip.left = spritePointer.x;
-	_tileClip.top = spritePointer.y;
-	_tileClip.right = spritePointer.x + width;
-	_tileClip.bottom = spritePointer.y + height;
+	_tileClip.left = CLIP((int)spritePointer.x, 0, _vm->getDisplayWidth());
+	_tileClip.right = CLIP((int)spritePointer.x + width, 0, _vm->getDisplayWidth());
+	_tileClip.top = CLIP((int)spritePointer.y, 0, _vm->_scene->getHeight());
+	_tileClip.bottom = CLIP((int)spritePointer.y + height, 0, _vm->_scene->getHeight());
 
-	if (_tileClip.left < 0) {
-		_tileClip.left = 0;
-	}
-	if (_tileClip.right > _vm->getDisplayWidth()) {
-		_tileClip.right = _vm->getDisplayWidth();
-	}
-	if (_tileClip.top < 0) {
-		_tileClip.top = 0;
-	}
-	if (_tileClip.bottom > _vm->_scene->getHeight()) {
-		_tileClip.bottom = _vm->_scene->getHeight();
-	}
-
 	_vm->_sprite->drawClip(ds, clip, spritePointer, width, height, spriteBuffer);
 	drawTiles(ds, &location);
 }

Modified: scummvm/trunk/engines/saga/music.cpp
===================================================================
--- scummvm/trunk/engines/saga/music.cpp	2007-12-13 19:44:27 UTC (rev 29854)
+++ scummvm/trunk/engines/saga/music.cpp	2007-12-13 20:10:13 UTC (rev 29855)
@@ -240,10 +240,7 @@
 }
 
 void MusicPlayer::setVolume(int volume) {
-	if (volume < 0)
-		volume = 0;
-	else if (volume > 255)
-		volume = 255;
+	volume = CLIP(volume, 0, 255);
 
 	if (_masterVolume == volume)
 		return;

Modified: scummvm/trunk/engines/saga/sprite.cpp
===================================================================
--- scummvm/trunk/engines/saga/sprite.cpp	2007-12-13 19:44:27 UTC (rev 29854)
+++ scummvm/trunk/engines/saga/sprite.cpp	2007-12-13 20:10:13 UTC (rev 29855)
@@ -207,16 +207,9 @@
 	bufRowPointer = (byte *)ds->pixels + ds->pitch * spritePointer.y;
 	srcRowPointer = spriteBuffer;
 
-	clipWidth = width;
-	if (width > (clipRect.right - spritePointer.x)) {
-		clipWidth = (clipRect.right - spritePointer.x);
-	}
+	clipWidth = CLIP(width, 0, clipRect.right - spritePointer.x);
+	clipHeight = CLIP(height, 0, clipRect.bottom - spritePointer.y);
 
-	clipHeight = height;
-	if (height > (clipRect.bottom - spritePointer.y)) {
-		clipHeight = (clipRect.bottom - spritePointer.y);
-	}
-
 	jo = 0;
 	io = 0;
 	if (spritePointer.x < clipRect.left) {


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