[Scummvm-cvs-logs] scummvm master -> 3c3576a224b92c703b4e8ea20008ac8a069980dd

clone2727 clone2727 at gmail.com
Tue Mar 20 19:14:24 CET 2012


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
3c3576a224 COMMON: Make Rect::center() work properly with odd dimensions


Commit: 3c3576a224b92c703b4e8ea20008ac8a069980dd
    https://github.com/scummvm/scummvm/commit/3c3576a224b92c703b4e8ea20008ac8a069980dd
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-03-20T10:44:20-07:00

Commit Message:
COMMON: Make Rect::center() work properly with odd dimensions

Changed paths:
    common/rect.h



diff --git a/common/rect.h b/common/rect.h
index 768d1eb..50ef020 100644
--- a/common/rect.h
+++ b/common/rect.h
@@ -244,11 +244,12 @@ struct Rect {
 
 	/**
 	 * Create a rectangle around the given center.
+	 * @note the center point is rounded up and left when given an odd width and height
 	 */
 	static Rect center(int16 cx, int16 cy, int16 w, int16 h) {
-		w /= 2;
-		h /= 2;
-		return Rect(cx - w, cy - h, cx + w, cy + h);
+		int dx = w / 2;
+		int dy = h / 2;
+		return Rect(cx - dx, cy - dy, cx + dx + (w & 1), cy + dy + (h & 1));
 	}
 };
 






More information about the Scummvm-git-logs mailing list