summaryrefslogtreecommitdiffstats
path: root/src/math
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-07-30 22:59:18 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-07-30 22:59:18 +0200
commit5e637ca0288ddd631ec33e1d620cd4a73bcdc2be (patch)
treeb26b0e9572f101744aba712133e646fb93ed58d2 /src/math
parentd8a0c8d32e160e7ae86bb5b85ead8e5f71b1fd01 (diff)
downloadcolobot-5e637ca0288ddd631ec33e1d620cd4a73bcdc2be.tar.gz
colobot-5e637ca0288ddd631ec33e1d620cd4a73bcdc2be.tar.bz2
colobot-5e637ca0288ddd631ec33e1d620cd4a73bcdc2be.zip
Switched to new style casts
- rewrote old C-style casts to new ..._cast<> - corrected some dangerous casts - added -Wold-style-cast to compile flags
Diffstat (limited to 'src/math')
-rw-r--r--src/math/func.h10
-rw-r--r--src/math/matrix.h2
-rw-r--r--src/math/point.h4
-rw-r--r--src/math/vector.h4
4 files changed, 10 insertions, 10 deletions
diff --git a/src/math/func.h b/src/math/func.h
index 9a417dc..2127d1a 100644
--- a/src/math/func.h
+++ b/src/math/func.h
@@ -118,13 +118,13 @@ inline void Swap(float &a, float &b)
Mod(n, 1) = fractional part of n */
inline float Mod(float a, float m)
{
- return a - ((int)(a/m))*m;
+ return a - ( static_cast<int>(a / m) ) * m;
}
//! Returns a random value between 0 and 1.
inline float Rand()
{
- return (float)rand()/RAND_MAX;
+ return static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
}
//! Returns a normalized angle, that is in other words between 0 and 2 * PI
@@ -153,10 +153,10 @@ inline bool TestAngle(float angle, float min, float max)
//! Calculates a value (radians) proportional between a and b (degrees)
inline float PropAngle(int a, int b, float p)
{
- float aa = (float)a * DEG_TO_RAD;
- float bb = (float)b * DEG_TO_RAD;
+ float aa = static_cast<float>(a) * DEG_TO_RAD;
+ float bb = static_cast<float>(b) * DEG_TO_RAD;
- return aa+p*(bb-aa);
+ return aa + p * (bb - aa);
}
//! Calculates the angle to rotate the angle \a a to the angle \a g
diff --git a/src/math/matrix.h b/src/math/matrix.h
index 7ee40e8..45a7d75 100644
--- a/src/math/matrix.h
+++ b/src/math/matrix.h
@@ -121,7 +121,7 @@ struct Matrix
//! Returns the struct cast to \c float* array; use with care!
inline float* Array()
{
- return (float*)this;
+ return reinterpret_cast<float*>(this);
}
//! Transposes the matrix
diff --git a/src/math/point.h b/src/math/point.h
index 740b275..ea20db9 100644
--- a/src/math/point.h
+++ b/src/math/point.h
@@ -71,13 +71,13 @@ struct Point
//! Returns the struct cast to \c float* array; use with care!
inline float* Array()
{
- return (float*)this;
+ return reinterpret_cast<float*>(this);
}
//! Returns the struct cast to <tt>const float*</tt> array; use with care!
inline const float* Array() const
{
- return (const float*)this;
+ return reinterpret_cast<const float*>(this);
}
//! Returns the distance from (0,0) to the point (x,y)
diff --git a/src/math/vector.h b/src/math/vector.h
index 148d648..147869f 100644
--- a/src/math/vector.h
+++ b/src/math/vector.h
@@ -76,13 +76,13 @@ struct Vector
//! Returns the struct cast to \c float* array; use with care!
inline float* Array()
{
- return (float*)this;
+ return reinterpret_cast<float*>(this);
}
//! Returns the struct cast to <tt>const float*</tt> array; use with care!
inline const float* Array() const
{
- return (const float*)this;
+ return reinterpret_cast<const float*>(this);
}
//! Returns the vector length