From 0f42dd4511ed4cc279acb075344fb62bc25300a9 Mon Sep 17 00:00:00 2001 From: uruk Date: Sun, 6 Oct 2013 00:03:49 +0200 Subject: AVALANCHE: Use floats instead of double. Use M_PI where it is possible. --- engines/avalanche/avalot.cpp | 3 ++- engines/avalanche/graphics.cpp | 13 ++++++------- engines/avalanche/parser.cpp | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp index f80a915508..e6cf310d54 100644 --- a/engines/avalanche/avalot.cpp +++ b/engines/avalanche/avalot.cpp @@ -30,6 +30,7 @@ #include "avalanche/avalanche.h" #include "common/random.h" #include "common/config-manager.h" +#include namespace Avalanche { @@ -1360,7 +1361,7 @@ void AvalancheEngine::majorRedraw() { } uint16 AvalancheEngine::bearing(byte whichPed) { - static const double rad2deg = 180 / 3.14; // Pi + const float rad2deg = 180 / M_PI; AnimationType *avvy = &_animation->_sprites[0]; PedType *curPed = &_peds[whichPed]; diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp index 62ac1653ba..d442c13d51 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -199,8 +199,7 @@ void GraphicManager::fleshColors() { Common::Point GraphicManager::drawArc(Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color) { Common::Point endPoint; - const double pi = 3.14; - const double convfac = pi / 180.0; + const float convfac = M_PI / 180.0; int32 xRadius = radius; int32 yRadius = radius * kScreenWidth / (8 * kScreenHeight); // Just don't ask why... @@ -233,20 +232,20 @@ Common::Point GraphicManager::drawArc(Graphics::Surface &surface, int16 x, int16 uint16 numOfPixels = (uint16)floor(sqrt(3.0) * sqrt(pow(double(xRadius), 2) + pow(double(yRadius), 2)) + 0.5); // Calculate the angle precision required. - double delta = 90.0 / numOfPixels; + float delta = 90.0 / numOfPixels; // Always just go over the first 90 degrees. Could be optimized a // bit if startAngle and endAngle lie in the same quadrant, left as an // exercise for the reader. :) - double j = 0; + float j = 0; // Calculate stop position, go 1 further than 90 because otherwise 1 pixel is sometimes not drawn. uint16 deltaEnd = 91; // Set the end point. - double tempTerm = endAngle * convfac; + float tempTerm = endAngle * convfac; endPoint.x = (int16)floor(xRadius * cos(tempTerm) + 0.5) + x; - endPoint.y = (int16)floor(yRadius * sin(tempTerm + pi) + 0.5) + y; + endPoint.y = (int16)floor(yRadius * sin(tempTerm + M_PI) + 0.5) + y; // Calculate points. int16 xNext = xRadius; @@ -258,7 +257,7 @@ Common::Point GraphicManager::drawArc(Graphics::Surface &surface, int16 x, int16 tempTerm = (j + delta) * convfac; xNext = (int16)floor(xRadius * cos(tempTerm) + 0.5); - yNext = (int16)floor(yRadius * sin(tempTerm + pi) + 0.5); + yNext = (int16)floor(yRadius * sin(tempTerm + M_PI) + 0.5); int16 xp = x + xTemp; int16 xm = x - xTemp; diff --git a/engines/avalanche/parser.cpp b/engines/avalanche/parser.cpp index 28c3b3bdd1..05d402617d 100644 --- a/engines/avalanche/parser.cpp +++ b/engines/avalanche/parser.cpp @@ -533,7 +533,7 @@ Common::String Parser::rank() { Common::String Parser::totalTime() { // There are 65535 clock ticks in a second, 1092.25 in a minute, and 65535 in an hour. - const double ticksInOneSec = (double)(65535) / 3600; + const float ticksInOneSec = (float)(65535) / 3600; uint16 h, m, s; h = (uint16)floor(_vm->_totalTime / ticksInOneSec); // No. of seconds. -- cgit v1.2.3