[Scummvm-cvs-logs] CVS: scummvm/common rect.h,1.17,1.18
Max Horn
fingolfin at users.sourceforge.net
Sun Jan 18 13:42:02 CET 2004
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sword2/driver animation.cpp,1.11,1.12 animation.h,1.12,1.13
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm/imuse_digi dimuse.cpp,1.37,1.38 dimuse.h,1.29,1.30 dimuse_music.cpp,1.13,1.14
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1:/tmp/cvs-serv32314
Modified Files:
rect.h
Log Message:
improved rect clipping & verification
Index: rect.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/rect.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- rect.h 8 Jan 2004 03:24:01 -0000 1.17
+++ rect.h 18 Jan 2004 21:41:38 -0000 1.18
@@ -54,7 +54,9 @@
Rect() : top(0), left(0), bottom(0), right(0) {}
Rect(int16 x, int16 y) : top(0), left(0), bottom(x), right(y) {}
- Rect(int16 x1, int16 y1, int16 x2, int16 y2) : top(y1), left(x1), bottom(y2), right(x2) {}
+ Rect(int16 x1, int16 y1, int16 x2, int16 y2) : top(y1), left(x1), bottom(y2), right(x2) {
+ assert(isValidRect());
+ }
int16 width() const { return right - left; }
int16 height() const { return bottom - top; }
@@ -112,15 +114,29 @@
}
void clip(const Rect & r) {
+ assert(isValidRect());
+ assert(r.isValidRect());
+
if (top < r.top) top = r.top;
+ else if (top > r.bottom) top = r.bottom;
+
if (left < r.left) left = r.left;
+ else if (left > r.right) left = r.right;
+
if (bottom > r.bottom) bottom = r.bottom;
+ else if (bottom < r.top) bottom = r.top;
+
if (right > r.right) right = r.right;
+ else if (right < r.left) right = r.left;
}
void clip(int maxw, int maxh) {
clip(Rect(0, 0, maxw, maxh));
}
+
+ bool isValidRect() const {
+ return (left <= right && top <= bottom);
+ }
};
} // End of namespace Common
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sword2/driver animation.cpp,1.11,1.12 animation.h,1.12,1.13
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm/imuse_digi dimuse.cpp,1.37,1.38 dimuse.h,1.29,1.30 dimuse_music.cpp,1.13,1.14
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list