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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Fri Sep 25 11:48:48 CEST 2009


Revision: 44337
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44337&view=rev
Author:   thebluegr
Date:     2009-09-25 09:48:43 +0000 (Fri, 25 Sep 2009)

Log Message:
-----------
Created a macro for lround(), for non-C99 compilers, and used that in places where lround() is used

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

Modified: scummvm/trunk/engines/draci/draci.h
===================================================================
--- scummvm/trunk/engines/draci/draci.h	2009-09-25 09:13:33 UTC (rev 44336)
+++ scummvm/trunk/engines/draci/draci.h	2009-09-25 09:48:43 UTC (rev 44337)
@@ -88,6 +88,9 @@
 	kDraciAnimationDebugLevel =	1 << 4
 };
 
+// Macro to simulate lround() for non-C99 compilers
+static inline long scummvm_lround(double val) { return (long)floor(val + 0.5); }
+
 } // End of namespace Draci
 
 #endif // DRACI_H

Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp	2009-09-25 09:13:33 UTC (rev 44336)
+++ scummvm/trunk/engines/draci/game.cpp	2009-09-25 09:48:43 UTC (rev 44337)
@@ -1045,8 +1045,8 @@
 	uint height = frame->getHeight();
 	uint width = frame->getWidth();
 
-  	_persons[kDragonObject]._x = x + (floor(scaleX) * width) / 2;
-	_persons[kDragonObject]._y = y - floor(scaleY) * height;
+  	_persons[kDragonObject]._x = x + (scummvm_lround(scaleX) * width) / 2;
+	_persons[kDragonObject]._y = y - scummvm_lround(scaleY) * height;
 
 	// Set the per-animation scaling factor
 	anim->setScaleFactors(scaleX, scaleY);

Modified: scummvm/trunk/engines/draci/sprite.cpp
===================================================================
--- scummvm/trunk/engines/draci/sprite.cpp	2009-09-25 09:13:33 UTC (rev 44336)
+++ scummvm/trunk/engines/draci/sprite.cpp	2009-09-25 09:48:43 UTC (rev 44337)
@@ -140,8 +140,8 @@
 	double scaleX = double(_scaledWidth) / _width;
 	double scaleY = double(_scaledHeight) / _height;
 
-	int sy = floor(dy * scaleY);
-	int sx = floor(dx * scaleX);
+	int sy = scummvm_lround(dy * scaleY);
+	int sx = scummvm_lround(dx * scaleX);
 
 	if (_mirror)
 		return _data[sy * _width + (_width - sx)];
@@ -190,11 +190,11 @@
 
 	// Precalculate pixel indexes
 	for (int i = 0; i < rows; ++i) {
-		rowIndices[i] = floor(i / scaleY);
+		rowIndices[i] = scummvm_lround(i / scaleY);
 	}
 
 	for (int j = 0; j < columns; ++j) {
-		columnIndices[j] = floor(j / scaleX);
+		columnIndices[j] = scummvm_lround(j / scaleX);
 	}
 
 	// Blit the sprite to the surface


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