more compile-fixing, this is GCC 4.3 with a 64-bit libc and it's damn stupid
authorTero Marttila <terom@fixme.fi>
Thu, 22 Jan 2009 04:24:26 +0200
changeset 425 567144562978
parent 424 f337a86d144e
child 426 510c83aab425
more compile-fixing, this is GCC 4.3 with a 64-bit libc and it's damn stupid
src/Network/Packet.cc
src/Vector.hh
--- a/src/Network/Packet.cc	Thu Jan 22 04:09:53 2009 +0200
+++ b/src/Network/Packet.cc	Thu Jan 22 04:24:26 2009 +0200
@@ -5,6 +5,7 @@
 #include "Packet.hh"
 #include "Platform.hh"
 
+#include <stdlib.h>
 #include <zlib.h>
 
 // XXX: assumes that sizeof(float32) == sizeof(int32);
--- a/src/Vector.hh	Thu Jan 22 04:09:53 2009 +0200
+++ b/src/Vector.hh	Thu Jan 22 04:24:26 2009 +0200
@@ -200,16 +200,9 @@
     return s << "(" << v.x << ", " << v.y << ")";
 }
 
-// Templates function implementations
-#include <cmath>
-#include <cstdlib>
-
-/**
- * Float/int absolute value
+/*
+ * Vector template method implementation
  */
-template<typename T> static T absType (T value);
-template<> static float absType<float> (float value) { return (float) fabs(value); }
-template<> static long absType<long> (long value) { return labs(value); }
 
 /**
  * Direction-normalize the given coordinate against the tangent coordinate.
@@ -218,10 +211,11 @@
  * negative, else zero.
  */
 template<typename T> static T normalizeCoordinate (T coord, T tangent) {
-    if (coord > absType(tangent))
+    // XXX: use hand-crafted abs because GCC 4.3/4.2 static template functions seem to be broken somehow
+    if (coord > (tangent < 0 ? -tangent : tangent))
         return 1;
 
-    else if (coord < -absType(tangent))
+    else if (coord < (tangent > 0 ? -tangent : tangent))
         return -1;
 
     else