From a0cfe3fa08940b9f74f55f02cb31bee90a4661ee Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 15 Feb 2011 23:53:48 +0000 Subject: [PATCH] - a few changes and now seems to compile in VC++ 2010 (still need to checkin project files) --- source/glest_game/game/game_camera.cpp | 4 +++ source/glest_game/graphics/renderer.cpp | 9 +++++- source/glest_game/main/main.cpp | 1 + .../menu/menu_state_custom_game.cpp | 4 +-- source/glest_game/sound/sound_renderer.cpp | 5 +++ source/glest_game/world/map.cpp | 5 +++ source/glest_game/world/unit_updater.cpp | 7 ++++- .../include/platform/common/math_wrapper.h | 1 + source/shared_lib/sources/map/map_preview.cpp | 31 +++++++++++++++++-- .../sources/platform/sdl/window.cpp | 6 +++- 10 files changed, 66 insertions(+), 7 deletions(-) diff --git a/source/glest_game/game/game_camera.cpp b/source/glest_game/game/game_camera.cpp index 8c79df7e..d02736b0 100644 --- a/source/glest_game/game/game_camera.cpp +++ b/source/glest_game/game/game_camera.cpp @@ -123,7 +123,11 @@ void GameCamera::update(){ //free state if(state==sFree){ +#ifdef USE_STREFLOP + if(streflop::fabs(rotate) == 1){ +#else if(fabs(rotate) == 1){ +#endif rotateHV(speed*5*rotate, 0); } if(move.y>0){ diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index bfa16732..7798427e 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -4622,15 +4622,22 @@ void Renderer::renderUnitTitles(Font2D *font, Vec3f color) { if(unit != NULL && unit->getCurrentUnitTitle() != "") { //get the screen coordinates Vec3f screenPos = unit->getScreenPos(); +#ifdef USE_STREFLOP + renderText(unit->getCurrentUnitTitle(), font, color, streflop::fabs(screenPos.x) + 5, streflop::fabs(screenPos.y) + 5, false); +#else renderText(unit->getCurrentUnitTitle(), font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false); - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] screenPos.x = %f, screenPos.y = %f, screenPos.z = %f\n",__FILE__,__FUNCTION__,__LINE__,screenPos.x,screenPos.y,screenPos.z); +#endif unitRenderedList[unit->getId()] = true; } else { string str = unit->getFullName() + " - " + intToStr(unit->getId()); Vec3f screenPos = unit->getScreenPos(); +#ifdef USE_STREFLOP + renderText(str, font, color, streflop::fabs(screenPos.x) + 5, streflop::fabs(screenPos.y) + 5, false); +#else renderText(str, font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false); +#endif } } visibleFrameUnitList.clear(); diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index ae1f9875..0a4d9f3a 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -36,6 +36,7 @@ #include "font_gl.h" #include "FileReader.h" #include "cache_manager.h" +#include // For gcc backtrace on crash! #if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD) diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 28658e6b..59c1d4e7 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -28,9 +28,9 @@ #include #include #include "cache_manager.h" -#include "leak_dumper.h" +#include #include "map_preview.h" - +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/sound/sound_renderer.cpp b/source/glest_game/sound/sound_renderer.cpp index 0db49e99..97615b65 100644 --- a/source/glest_game/sound/sound_renderer.cpp +++ b/source/glest_game/sound/sound_renderer.cpp @@ -168,7 +168,12 @@ void SoundRenderer::playFx(StaticSound *staticSound, Vec3f soundPos, Vec3f camPo if(d < audibleDist){ float vol= (1.f-d/audibleDist)*fxVolume; +#ifdef USE_STREFLOP + float correctedVol= streflop::log10(streflop::log10(vol*9+1)*9+1); +#else float correctedVol= log10(log10(vol*9+1)*9+1); +#endif + staticSound->setVolume(correctedVol); if(soundPlayer != NULL) { diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index 617f25a5..e96661ca 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -1120,8 +1120,13 @@ void Map::smoothSurface(Tileset *tileset) { float numUsedToSmooth = 0.f; for (int k = -1; k <= 1; ++k) { for (int l = -1; l <= 1; ++l) { +#ifdef USE_STREFLOP + if (cliffLevel<=0.1f || cliffLevel > streflop::fabs(oldHeights[(j) * surfaceW + (i)] + - oldHeights[(j + k) * surfaceW + (i + l)])) { +#else if (cliffLevel<=0.1f || cliffLevel > fabs(oldHeights[(j) * surfaceW + (i)] - oldHeights[(j + k) * surfaceW + (i + l)])) { +#endif height += oldHeights[(j + k) * surfaceW + (i + l)]; numUsedToSmooth++; } diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index e2d7442d..96caa575 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -1939,7 +1939,12 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr, delete toDelete; // old one } else { - currentDistance=floor(enemyFloatCenter.dist(attackWarnings[i]->attackPosition)); // no need for streflops here! +#ifdef USE_STREFLOP + currentDistance = streflop::floor(enemyFloatCenter.dist(attackWarnings[i]->attackPosition)); // no need for streflops here! +#else + currentDistance = floor(enemyFloatCenter.dist(attackWarnings[i]->attackPosition)); // no need for streflops here! +#endif + if( nearest==NULL ){ nearest=attackWarnings[i]; nearestDistance=currentDistance; diff --git a/source/shared_lib/include/platform/common/math_wrapper.h b/source/shared_lib/include/platform/common/math_wrapper.h index 15a59d34..4a003f7d 100644 --- a/source/shared_lib/include/platform/common/math_wrapper.h +++ b/source/shared_lib/include/platform/common/math_wrapper.h @@ -14,6 +14,7 @@ #ifdef USE_STREFLOP +#include #include "streflop_cond.h" #else diff --git a/source/shared_lib/sources/map/map_preview.cpp b/source/shared_lib/sources/map/map_preview.cpp index 4e8831ea..b377be62 100644 --- a/source/shared_lib/sources/map/map_preview.cpp +++ b/source/shared_lib/sources/map/map_preview.cpp @@ -102,7 +102,11 @@ int MapPreview::getStartLocationY(int index) const { static int get_dist(int delta_x, int delta_y) { float dx = (float)delta_x; float dy = (float)delta_y; +#ifdef USE_STREFLOP + return static_cast(streflop::sqrtf(dx * dx + dy * dy)+0.5); // round correctly +#else return static_cast(sqrtf(dx * dx + dy * dy)+0.5); // round correctly +#endif } void MapPreview::glestChangeHeight(int x, int y, int height, int radius) { @@ -265,7 +269,26 @@ void MapPreview::pirateChangeHeight(int x, int y, int height, int radius) { } // Determine which gradients to use and take a weighted average +#ifdef USE_STREFLOP + if (streflop::fabs(normIf) > streflop::fabs(normJf)) { + + usedGrad = + gradient[normI[0]] [normJ[0]] * streflop::fabs(normJf) + + gradient[normI[0]] [normJ[1]] * (1 - streflop::fabs(normJf)); + } + else if (streflop::fabs(normIf) < streflop::fabs(normJf)) { + usedGrad = + gradient[normI[0]] [normJ[0]] * streflop::fabs(normIf) + + gradient[normI[1]] [normJ[0]] * (1 - streflop::fabs(normIf)); + } + else { + usedGrad = + gradient[normI[0]] [normJ[0]]; + } + +#else if (fabs(normIf) > fabs(normJf)) { + usedGrad = gradient[normI[0]] [normJ[0]] * fabs(normJf) + gradient[normI[0]] [normJ[1]] * (1 - fabs(normJf)); @@ -279,7 +302,7 @@ void MapPreview::pirateChangeHeight(int x, int y, int height, int radius) { usedGrad = gradient[normI[0]] [normJ[0]]; } - +#endif float newAlt = usedGrad * dist + goalAlt; @@ -812,9 +835,13 @@ void MapPreview::sinRandomize(int strenght) { float normH = static_cast(i) / w; float normV = static_cast(j) / h; +#ifdef USE_STREFLOP + float sh = (streflop::sinf(normH * sinH1) + streflop::sin(normH * sinH2)) / 2.f; + float sv = (streflop::sinf(normV * sinV1) + streflop::sin(normV * sinV2)) / 2.f; +#else float sh = (sinf(normH * sinH1) + sin(normH * sinH2)) / 2.f; float sv = (sinf(normV * sinV1) + sin(normV * sinV2)) / 2.f; - +#endif float newHeight = (ah + bh * sh + av + bv * sv) / 2.f; applyNewHeight(newHeight, i, j, strenght); } diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index b3fa7a4a..36ca7ce5 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -386,7 +386,11 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a // setup LOD bias factor //const float lodBias = std::max(std::min( configHandler->Get("TextureLODBias", 0.0f) , 4.0f), -4.0f); const float lodBias = max(min(0.0f,4.0f),-4.0f); - if (fabs(lodBias)>0.01f) { +#ifdef USE_STREFLOP + if (streflop::fabs(lodBias) > 0.01f) { +#else + if (fabs(lodBias) > 0.01f) { +#endif glTexEnvf(GL_TEXTURE_FILTER_CONTROL,GL_TEXTURE_LOD_BIAS, lodBias ); } }