diff --git a/source/graphics/CinemaTrack.cpp b/source/graphics/CinemaTrack.cpp index 1be4f6b9bd..c16fe9ff3c 100644 --- a/source/graphics/CinemaTrack.cpp +++ b/source/graphics/CinemaTrack.cpp @@ -205,7 +205,7 @@ float CCinemaPath::EaseCircle(float t) const float CCinemaPath::EaseSine(float t) const { - t = 1.0f - cos(t * M_PI/2); + t = 1.0f - cos(t * (float)M_PI/2); if(m_GrowthCount > 1.0f) { m_GrowthCount--; diff --git a/source/graphics/MapReader.cpp b/source/graphics/MapReader.cpp index c176b10166..ddde2504dd 100644 --- a/source/graphics/MapReader.cpp +++ b/source/graphics/MapReader.cpp @@ -1110,7 +1110,7 @@ int CXMLReader::ReadNonEntities(XMBElement parent, double end_time) if (unit) { CMatrix3D m; - m.SetYRotation(Orientation + M_PI); + m.SetYRotation(Orientation + (float)M_PI); m.Translate(Position); unit->GetModel()->SetTransform(m); diff --git a/source/graphics/MapWriter.cpp b/source/graphics/MapWriter.cpp index 76961b66f9..e604b7c6f6 100644 --- a/source/graphics/MapWriter.cpp +++ b/source/graphics/MapWriter.cpp @@ -265,7 +265,7 @@ void CMapWriter::WriteXML(const VfsPath& filename, CVector3D in = pCamera->m_Orientation.GetIn(); // Convert to spherical coordinates float rotation = atan2(in.X, in.Z); - float declination = atan2(sqrt(in.X*in.X + in.Z*in.Z), in.Y) - M_PI/2; + float declination = atan2(sqrt(in.X*in.X + in.Z*in.Z), in.Y) - (float)M_PI/2; { XML_Element("Rotation"); diff --git a/source/lib/res/graphics/ogl_tex.cpp b/source/lib/res/graphics/ogl_tex.cpp index da358a6114..4b36912e9e 100644 --- a/source/lib/res/graphics/ogl_tex.cpp +++ b/source/lib/res/graphics/ogl_tex.cpp @@ -1017,5 +1017,5 @@ bool ogl_tex_has_s3tc() // ogl_tex_upload must be called before this debug_assert(have_s3tc != -1); - return have_s3tc; + return (have_s3tc != 0); } diff --git a/source/maths/MathUtil.h b/source/maths/MathUtil.h index f564807ea1..6696165dcd 100644 --- a/source/maths/MathUtil.h +++ b/source/maths/MathUtil.h @@ -18,8 +18,8 @@ #ifndef INCLUDED_MATHUTIL #define INCLUDED_MATHUTIL -#define DEGTORAD(a) ((a) * (M_PI/180.0f)) -#define RADTODEG(a) ((a) * (180.0f/M_PI)) +#define DEGTORAD(a) ((a) * ((float)M_PI/180.0f)) +#define RADTODEG(a) ((a) * (180.0f/(float)M_PI)) #define SQR(x) ((x) * (x)) template diff --git a/source/maths/Noise.cpp b/source/maths/Noise.cpp index 2701508e77..d7cef05970 100644 --- a/source/maths/Noise.cpp +++ b/source/maths/Noise.cpp @@ -54,7 +54,7 @@ Noise2D::Noise2D(int f) grads[i] = new CVector2D_Maths[freq]; for(int j=0; j (.5f-EPSILON)*unit) { // singularity at north pole heading = 2 * atan2( m_V.X, m_W); - attitude = M_PI/2; + attitude = (float)M_PI/2; bank = 0; } else if (test < (-.5f+EPSILON)*unit) { // singularity at south pole heading = -2 * atan2(m_V.X, m_W); - attitude = -M_PI/2; + attitude = -(float)M_PI/2; bank = 0; } else diff --git a/source/ps/Interact.cpp b/source/ps/Interact.cpp index 3cf6f57dc9..a33e572d45 100644 --- a/source/ps/Interact.cpp +++ b/source/ps/Interact.cpp @@ -1371,7 +1371,7 @@ void ResetInteraction() customSelectionMode = false; } -static const float angleBias = 3*M_PI/4; // Atlas does the same +static const float angleBias = 3*(float)M_PI/4; // Atlas does the same bool CBuildingPlacer::Activate(CStrW& templateName) { @@ -1480,7 +1480,7 @@ void CBuildingPlacer::Update( float timeStep ) if(x*x + z*z < 3*3) { if(m_dragged || m_timeSinceClick > 0.2f) - m_angle += timeStep * M_PI; + m_angle += timeStep * (float)M_PI; } else { @@ -1517,7 +1517,7 @@ void CBuildingPlacer::Update( float timeStep ) // Set position and angle to the location we decided on CMatrix3D m; - m.SetYRotation(m_angle + M_PI); + m.SetYRotation(m_angle + (float)M_PI); m.Translate(pos); m_actor->GetModel()->SetTransform( m ); m_bounds->SetPosition(pos.X, pos.Z); @@ -1540,7 +1540,7 @@ void CBuildingPlacer::Update( float timeStep ) } else { - float add = ( sin(4*M_PI*m_totalTime) + 1.0f ) * 0.08f; + float add = ( sin(4*(float)M_PI*m_totalTime) + 1.0f ) * 0.08f; col = CColor( 1.4f+add, 0.4f+add, 0.4f+add, 1.0f ); } m_actor->GetModel()->SetShadingColor( col ); diff --git a/source/simulation/BoundingObjects.cpp b/source/simulation/BoundingObjects.cpp index d1a9b460c6..a4b586fdff 100644 --- a/source/simulation/BoundingObjects.cpp +++ b/source/simulation/BoundingObjects.cpp @@ -96,7 +96,7 @@ void CBoundingCircle::Render( float height ) for( int i = 0; i < 10; i++ ) { - float ang = i * 2 * M_PI / 10.0f; + float ang = i * 2 * (float)M_PI / 10.0f; float x = m_pos.x + m_radius * sin( ang ); float y = m_pos.y + m_radius * cos( ang ); glVertex3f( x, height, y ); diff --git a/source/simulation/Entity.cpp b/source/simulation/Entity.cpp index 910a83c384..c1b8fe1ae0 100644 --- a/source/simulation/Entity.cpp +++ b/source/simulation/Entity.cpp @@ -53,7 +53,7 @@ #include "ps/GameSetup/Config.h" -const float MAX_ROTATION_RATE = 2*M_PI; // radians per second +const float MAX_ROTATION_RATE = 2*(float)M_PI; // radians per second CEntity::CEntity( CEntityTemplate* base, CVector3D position, float orientation, const std::set& actorSelections, const CStrW* building ) { @@ -235,7 +235,7 @@ void CEntity::initAuraData() for ( int j=0; j m_orientation_previous.Y + M_PI ) - m_orientation_previous.Y += 2 * M_PI; + while( m_orientation.Y < m_orientation_previous.Y - (float)M_PI ) + m_orientation_previous.Y -= 2 * (float)M_PI; + while( m_orientation.Y > m_orientation_previous.Y + (float)M_PI ) + m_orientation_previous.Y += 2 * (float)M_PI; - while( m_orientation.X < m_orientation_previous.X - M_PI ) - m_orientation_previous.X -= 2 * M_PI; - while( m_orientation.X > m_orientation_previous.X + M_PI ) - m_orientation_previous.X += 2 * M_PI; + while( m_orientation.X < m_orientation_previous.X - (float)M_PI ) + m_orientation_previous.X -= 2 * (float)M_PI; + while( m_orientation.X > m_orientation_previous.X + (float)M_PI ) + m_orientation_previous.X += 2 * (float)M_PI; - while( m_orientation.Z < m_orientation_previous.Z - M_PI ) - m_orientation_previous.Z -= 2 * M_PI; - while( m_orientation.Z > m_orientation_previous.Z + M_PI ) - m_orientation_previous.Z += 2 * M_PI; + while( m_orientation.Z < m_orientation_previous.Z - (float)M_PI ) + m_orientation_previous.Z -= 2 * (float)M_PI; + while( m_orientation.Z > m_orientation_previous.Z + (float)M_PI ) + m_orientation_previous.Z += 2 * (float)M_PI; UpdateXZOrientation(); diff --git a/source/simulation/EntityRendering.cpp b/source/simulation/EntityRendering.cpp index b5412a1f8a..b3b670309d 100644 --- a/source/simulation/EntityRendering.cpp +++ b/source/simulation/EntityRendering.cpp @@ -162,7 +162,7 @@ void CEntity::RenderSelectionOutline( float alpha ) float radius = ((CBoundingCircle*)m_bounds)->m_radius; for( int i = 0; i < SELECTION_CIRCLE_POINTS; i++ ) { - float ang = i * 2 * M_PI / (float)SELECTION_CIRCLE_POINTS; + float ang = i * 2 * (float)M_PI / SELECTION_CIRCLE_POINTS; float x = pos.X + radius * sin( ang ); float y = pos.Z + radius * cos( ang ); #ifdef SELECTION_TERRAIN_CONFORMANCE diff --git a/source/simulation/EntityScriptInterface.cpp b/source/simulation/EntityScriptInterface.cpp index 5349ddd256..508ef7fa2e 100644 --- a/source/simulation/EntityScriptInterface.cpp +++ b/source/simulation/EntityScriptInterface.cpp @@ -154,7 +154,7 @@ JSBool CEntity::Construct( JSContext* cx, JSObject* UNUSED(obj), uintN argc, jsv debug_assert( argc >= 2 ); CVector3D position; - float orientation = g_Game->GetSimulation()->RandFloat() * 2 * M_PI; + float orientation = g_Game->GetSimulation()->RandFloat() * 2 * (float)M_PI; JSObject* jsEntityTemplate = JSVAL_TO_OBJECT( argv[0] ); CStrW templateName; @@ -502,10 +502,10 @@ jsval_t CEntity::GetSpawnPoint( JSContext* UNUSED(cx), uintN argc, jsval* argv ) else if( m_bounds->m_type == CBoundingObject::BOUND_CIRCLE ) { float ang; - ang = g_Game->GetSimulation()->RandFloat() * 2 * M_PI; + ang = g_Game->GetSimulation()->RandFloat() * 2 * (float)M_PI; float radius = m_bounds->m_radius + 1.0f + spawn_clearance; float d_ang = spawn_clearance / ( 2.0f * radius ); - float ang_end = ang + 2.0f * M_PI; + float ang_end = ang + 2.0f * (float)M_PI; float x = 0.0f, y = 0.0f; // make sure they're initialized for( ; ang < ang_end; ang += d_ang ) { diff --git a/source/simulation/EntityStateProcessing.cpp b/source/simulation/EntityStateProcessing.cpp index 63cf949671..7fa23f0322 100644 --- a/source/simulation/EntityStateProcessing.cpp +++ b/source/simulation/EntityStateProcessing.cpp @@ -84,7 +84,7 @@ float CEntity::ChooseMovementSpeed( float distance ) // Modify the speed based on the slope of the terrain in our direction (obtained from our x orientation) float angle = m_orientation_unclamped.x; - int sector = rintf( angle / (M_PI/2) * m_base->m_pitchDivs ); + int sector = rintf( angle / ((float)M_PI/2) * m_base->m_pitchDivs ); speed -= sector * m_base->m_pitchValue; entf_set_to(ENTF_IS_RUNNING, should_run); @@ -130,8 +130,8 @@ int CEntity::ProcessGotoHelper( CEntityOrder* current, int timestep_millis, HEnt m_targetorientation = atan2( delta.x, delta.y ); float deltatheta = m_targetorientation - (float)m_orientation.Y; - while( deltatheta > M_PI ) deltatheta -= 2 * M_PI; - while( deltatheta < -M_PI ) deltatheta += 2 * M_PI; + while( deltatheta > (float)M_PI ) deltatheta -= 2 * (float)M_PI; + while( deltatheta < -(float)M_PI ) deltatheta += 2 * (float)M_PI; if( fabs( deltatheta ) > 0.01f ) { @@ -336,7 +336,7 @@ bool CEntity::ProcessGotoNoPathing( CEntityOrder* current, int timestep_millis ) { delta = interval / r; theta += delta; - r += ( interval * delta ) / ( 2 * M_PI ); + r += ( interval * delta ) / ( 2 * (float)M_PI ); destinationObs.SetPosition( _x + r * cosf( theta ), _y + r * sinf( theta ) ); if( !GetCollisionObject( &destinationObs ) ) break; } diff --git a/source/simulation2/components/CCmpPosition.cpp b/source/simulation2/components/CCmpPosition.cpp index 86974ddd55..233455a6e1 100644 --- a/source/simulation2/components/CCmpPosition.cpp +++ b/source/simulation2/components/CCmpPosition.cpp @@ -334,9 +334,9 @@ public: float rotY = m_RotY.ToFloat(); float delta = rotY - m_InterpolatedRotY; // Wrap delta to -M_PI..M_PI - delta = fmod(delta + M_PI, 2*M_PI); // range -2PI..2PI - if (delta < 0) delta += 2*M_PI; // range 0..2PI - delta -= M_PI; // range -M_PI..M_PI + delta = fmod(delta + (float)M_PI, 2*(float)M_PI); // range -2PI..2PI + if (delta < 0) delta += 2*(float)M_PI; // range 0..2PI + delta -= (float)M_PI; // range -M_PI..M_PI // Clamp to max rate float deltaClamped = clamp(delta, -m_RotYSpeed*msgData.frameTime, +m_RotYSpeed*msgData.frameTime); // Calculate new orientation, in a peculiar way in order to make sure the diff --git a/source/simulation2/helpers/Render.cpp b/source/simulation2/helpers/Render.cpp index f00755a11c..275d7ee0ab 100644 --- a/source/simulation2/helpers/Render.cpp +++ b/source/simulation2/helpers/Render.cpp @@ -38,7 +38,7 @@ void SimRender::ConstructCircleOnGround(const CSimContext& context, float x, flo for (size_t i = 0; i <= RENDER_CIRCLE_POINTS; ++i) // use '<=' so it's a closed loop { - float a = i * 2 * M_PI / RENDER_CIRCLE_POINTS; + float a = i * 2 * (float)M_PI / RENDER_CIRCLE_POINTS; float px = x + radius * sin(a); float pz = z + radius * cos(a); float py = cmpTerrain->GetGroundLevel(px, pz) + RENDER_HEIGHT_DELTA; diff --git a/source/tools/atlas/GameInterface/ActorViewer.cpp b/source/tools/atlas/GameInterface/ActorViewer.cpp index 5067424531..65b6997576 100644 --- a/source/tools/atlas/GameInterface/ActorViewer.cpp +++ b/source/tools/atlas/GameInterface/ActorViewer.cpp @@ -184,9 +184,9 @@ void ActorViewer::SetActor(const CStrW& name, const CStrW& animation) if (! m.Unit) return; - float angle = M_PI; + float angle = (float)M_PI; CMatrix3D mat; - mat.SetYRotation(angle + M_PI); + mat.SetYRotation(angle + (float)M_PI); mat.Translate(CELL_SIZE * PATCH_SIZE/2, 0.f, CELL_SIZE * PATCH_SIZE/2); m.Unit->GetModel()->SetTransform(mat); m.Unit->GetModel()->ValidatePosition(); diff --git a/source/tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp index c7d2a61b1a..38ab36b63a 100644 --- a/source/tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp @@ -50,8 +50,8 @@ sEnvironmentSettings GetSettings() #undef COLOUR float sunrotation = g_LightEnv.GetRotation(); - if (sunrotation > M_PI) - sunrotation -= M_PI*2; + if (sunrotation > (float)M_PI) + sunrotation -= (float)M_PI*2; s.sunrotation = sunrotation; s.sunelevation = g_LightEnv.GetElevation(); diff --git a/source/tools/atlas/GameInterface/SimState.cpp b/source/tools/atlas/GameInterface/SimState.cpp index 85dccafaed..9e351b187b 100644 --- a/source/tools/atlas/GameInterface/SimState.cpp +++ b/source/tools/atlas/GameInterface/SimState.cpp @@ -85,7 +85,7 @@ CUnit* SimState::Nonentity::Thaw() if (! unit) return NULL; CMatrix3D m; - m.SetYRotation(angle + M_PI); + m.SetYRotation(angle + (float)M_PI); m.Translate(position); unit->GetModel()->SetTransform(m);