From e55638d081e2e1ff6fbc06e0e8ac0381a04308e7 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 15 Sep 2010 21:29:18 +0000 Subject: updated comments, updated buy menu, info support for map window, added const to target selection --- src/math/functions.cc | 6 +++--- src/math/functions.h | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'src/math') diff --git a/src/math/functions.cc b/src/math/functions.cc index c4b832c..7fb40be 100644 --- a/src/math/functions.cc +++ b/src/math/functions.cc @@ -66,10 +66,10 @@ float sgnf(float value) { if (value < 0) return -1; - else if (value == 0) - return 0; + else if (value > 0) + return 1; - return 1; + return 0; } } // namespace math diff --git a/src/math/functions.h b/src/math/functions.h index c301969..5a53d44 100644 --- a/src/math/functions.h +++ b/src/math/functions.h @@ -31,7 +31,7 @@ int max(int a, int b); /** The value returned will be in the interval [0-max] * @param max the maximum value returned **/ -float randomf(const float max = 1); +float randomf(const float max = 1.0f); /// returns a random integer /** The value returned will be in the interval [0-(max-1)] @@ -58,12 +58,9 @@ inline void clamp(float &value, const float min = 0.0f, const float max = 1.0f) } /// return the absolute value of a float -inline float absf(float f) +inline float absf(const float f) { - if (f < 0) - return -f; - else - return f; + return ( f < 0.0f ? -f : f ); } } // namespace math -- cgit v1.2.3