Added mysign() specializations for Coord and Offset
authorMartin Read <martin@blackswordsonics.com>
Tue, 1 Oct 2013 21:21:16 +0000 (22:21 +0100)
committerMartin Read <martin@blackswordsonics.com>
Tue, 1 Oct 2013 21:21:16 +0000 (22:21 +0100)
coord.hh

index c0124d0..f3a06e8 100644 (file)
--- a/coord.hh
+++ b/coord.hh
@@ -52,7 +52,7 @@ struct Coord
     int y;
     int x;
     Offset delta(const Coord& right) const { Offset d = { y - right.y, x - right.x }; return d; }
-    Coord operator +(const Offset& right) const { Coord c = { y + right.y, x - right.x}; return c; }
+    Coord operator +(const Offset& right) const { Coord c = { y + right.y, x + right.x}; return c; }
     Coord operator -(const Offset& right) const { Coord c = { y - right.y, x - right.x}; return c; }
     const Coord& operator +=(const Offset& right) { y += right.y; x += right.x; return *this;}
     const Coord& operator -=(const Offset& right) { y -= right.y; x -= right.x; return *this;}
@@ -63,6 +63,8 @@ struct Coord
 extern const Coord Nowhere;
 extern const Offset North, Northeast, East, Southeast, South, Southwest, West, Northwest, Stationary;
 
+template<> inline Coord mysign<Coord>(Coord val) { Coord c = { mysign(val.y), mysign(val.x) }; return c; }
+template<> inline Offset mysign<Offset>(Offset val) { Offset o = { mysign(val.y), mysign(val.x) }; return o; }
 #endif
 
 /* coord.hh */