[Scummvm-cvs-logs] CVS: scummvm/common rect.h,1.4,1.5 util.h,1.14,1.15

Max Horn fingolfin at users.sourceforge.net
Thu May 15 14:41:07 CEST 2003


Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1:/tmp/cvs-serv2763

Modified Files:
	rect.h util.h 
Log Message:
make SWAP a template function, so that it works for swapping non-int stuff, too; 'int16' should be sufficient for points/rects

Index: rect.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/rect.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- rect.h	15 May 2003 21:33:39 -0000	1.4
+++ rect.h	15 May 2003 21:40:35 -0000	1.5
@@ -31,12 +31,12 @@
 	This small class is an helper for position and size values.
 */
 struct Point {
-	int x;	//!< The horizontal part of the point
-	int y;	//!< The vertical part of the point
+	int16 x;	//!< The horizontal part of the point
+	int16 y;	//!< The vertical part of the point
 
 	Point() : x(0), y(0) {};
 	Point(const Point & p) : x(p.x), y(p.y) {};
-	explicit Point(int x1, int y1) : x(x1), y(y1) {};
+	explicit Point(int16 x1, int16 y1) : x(x1), y(y1) {};
 	Point & operator=(const Point & p) { x = p.x; y = p.y; return *this; };
 	bool operator==(const Point & p) const { return x == p.x && y == p.y; };
 };
@@ -47,14 +47,14 @@
 	It is mostly used by the blitter class.
 */
 struct Rect {
-	int top, left;		//!< The point at the top left of the rectangle (part of the rect).
-	int bottom, right;	//!< The point at the bottom right of the rectangle (not part of the rect).
+	int16 top, left;		//!< The point at the top left of the rectangle (part of the rect).
+	int16 bottom, right;	//!< The point at the bottom right of the rectangle (not part of the rect).
 
 	Rect() : top(0), left(0), bottom(0), right(0) {}
-	Rect(int x, int y) : top(0), left(0), bottom(x), right(y) {}
-	Rect(int x1, int y1, int x2, int y2) : top(x1), left(y1), bottom(x2), right(y2) {}
-	int width() const { return right - left; }
-	int height() const { return top - bottom; }
+	Rect(int16 x, int16 y) : top(0), left(0), bottom(x), right(y) {}
+	Rect(int16 x1, int16 y1, int16 x2, int16 y2) : top(x1), left(y1), bottom(x2), right(y2) {}
+	int16 width() const { return right - left; }
+	int16 height() const { return top - bottom; }
 
 	/*!	@brief check if given position is inside the rectangle
 		
@@ -63,7 +63,7 @@
 		
 		@return true if the given position is inside the rectangle, false otherwise
 	*/
-	bool isInside(int x, int y) const {
+	bool isInside(int16 x, int16 y) const {
 		return (left <= x) && (x < right) && (top <= y) && (y < bottom);
 	}
 	/*!	@brief check if given point is inside the rectangle

Index: util.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/util.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- util.h	4 May 2003 13:46:06 -0000	1.14
+++ util.h	15 May 2003 21:40:36 -0000	1.15
@@ -35,7 +35,9 @@
 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
 #endif
 
-static inline void SWAP(int &a, int &b) { int tmp = a; a = b; b = tmp; }
+template<class T>
+static inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; }
+
 #define ARRAYSIZE(x) (sizeof(x) / sizeof(x[0]))
 
 int RGBMatch(byte *palette, int r, int g, int b);





More information about the Scummvm-git-logs mailing list