diff --git a/CMakeLists.txt b/CMakeLists.txt index 1339fbcf..3f4efd7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,24 +83,34 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW) ENDIF() #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") - IF(NOT MAX_SSE_LEVEL_DESIRED) - SET(MAX_SSE_LEVEL_DESIRED "1" CACHE STRING "Set the max SSE level to use if supported (0-3)" FORCE) + #MESSAGE(STATUS "*TEST: Checking for max SSE LEVEL [${MAX_SSE_LEVEL_DESIRED}]") + + IF(NOT STREFLOP_SOFTWRAPPER_FORCE) + SET(STREFLOP_SOFTWRAPPER_FORCE "0" CACHE STRING "Set the streflop library to be forced to use the software emulator") + ENDIF() + + IF(NOT MAX_SSE_LEVEL_DESIRED AND NOT STREFLOP_SOFTWRAPPER_FORCE) + SET(MAX_SSE_LEVEL_DESIRED "1" CACHE STRING "Set the max SSE level to use if supported (0-3)") ENDIF() - MESSAGE(STATUS "*NOTE: Checking for max SSE LEVEL [${MAX_SSE_LEVEL_DESIRED}]") - special_check_for_sse( ${MAX_SSE_LEVEL_DESIRED} ) + IF(NOT STREFLOP_SOFTWRAPPER_FORCE) + MESSAGE(STATUS "*NOTE: Checking for max SSE LEVEL [${MAX_SSE_LEVEL_DESIRED}]") + special_check_for_sse( ${MAX_SSE_LEVEL_DESIRED} ) + ENDIF() OPTION(WANT_STREFLOP "use the library streflop" ON) IF(WANT_STREFLOP) - ADD_DEFINITIONS("-DUSE_STREFLOP -DSTREFLOP_RANDOM_GEN_SIZE=32 -DLIBM_COMPILING_FLT32") + ADD_DEFINITIONS("-DUSE_STREFLOP -DSTREFLOP_RANDOM_GEN_SIZE=32 -DLIBM_COMPILING_FLT32 -DN_SPECIALIZED=32") - IF(HAS_SSE_EXTENSIONS) + IF(HAS_SSE_EXTENSIONS AND NOT ${MAX_SSE_LEVEL_DESIRED} MATCHES "0" AND NOT STREFLOP_SOFTWRAPPER_FORCE) ADD_DEFINITIONS("-DSTREFLOP_SSE") MESSAGE(STATUS "*NOTE: using SSE for STREFLOP.") ELSE() - special_check_for_x87() + IF(NOT STREFLOP_SOFTWRAPPER_FORCE) + special_check_for_x87() + ENDIF() - IF(HAS_X87_SUPPORT) + IF(HAS_X87_SUPPORT AND NOT STREFLOP_SOFTWRAPPER_FORCE) ADD_DEFINITIONS("-DSTREFLOP_X87") MESSAGE(STATUS "*NOTE: using X87 for STREFLOP.") ELSE() diff --git a/mk/cmake/Modules/SpecialMacros.cmake b/mk/cmake/Modules/SpecialMacros.cmake index a71b22ee..d6309168 100644 --- a/mk/cmake/Modules/SpecialMacros.cmake +++ b/mk/cmake/Modules/SpecialMacros.cmake @@ -70,13 +70,13 @@ macro(special_check_for_sse _max_sse_level_desired) set(CMAKE_REQUIRED_FLAGS) - if(HAS_SSE3_EXTENSIONS AND (NOT ${_max_sse_level_desired} OR ${_max_sse_level_desired} MATCHES "3")) + if(HAS_SSE3_EXTENSIONS AND (${_max_sse_level_desired} MATCHES "3")) set(SSE_FLAGS "-msse3 -mfpmath=sse") message(STATUS "Found SSE3 extensions, using flags: ${SSE_FLAGS}") - elseif(HAS_SSE2_EXTENSIONS AND (NOT ${_max_sse_level_desired} OR ${_max_sse_level_desired} MATCHES "2" OR ${_max_sse_level_desired} MATCHES "3")) + elseif(HAS_SSE2_EXTENSIONS AND (${_max_sse_level_desired} MATCHES "2" OR ${_max_sse_level_desired} MATCHES "3")) set(SSE_FLAGS "-msse2 -mfpmath=sse") message(STATUS "Found SSE2 extensions, using flags: ${SSE_FLAGS}") - elseif(HAS_SSE_EXTENSIONS AND (NOT ${_max_sse_level_desired} OR ${_max_sse_level_desired} MATCHES "1" OR ${_max_sse_level_desired} MATCHES "2" OR ${_max_sse_level_desired} MATCHES "3")) + elseif(HAS_SSE_EXTENSIONS AND (${_max_sse_level_desired} MATCHES "1" OR ${_max_sse_level_desired} MATCHES "2" OR ${_max_sse_level_desired} MATCHES "3")) set(SSE_FLAGS "-msse -mfpmath=sse") message(STATUS "Found SSE extensions, using flags: ${SSE_FLAGS}") endif() diff --git a/source/glest_game/game/game_camera.cpp b/source/glest_game/game/game_camera.cpp index 91e61461..0270ad3d 100644 --- a/source/glest_game/game/game_camera.cpp +++ b/source/glest_game/game/game_camera.cpp @@ -135,7 +135,7 @@ void GameCamera::update(){ //free state if(state==sFree){ #ifdef USE_STREFLOP - if(streflop::fabs(rotate) == 1){ + if(streflop::fabs(static_cast(rotate)) == 1){ #else if(fabs(rotate) == 1){ #endif @@ -216,9 +216,9 @@ Quad2i GameCamera::computeVisibleQuad() { const float viewDegree = 180.f; #ifdef USE_STREFLOP - Vec2f v(streflop::sinf(degToRad(viewDegree - hAng)), streflop::cosf(degToRad(viewDegree - hAng))); - Vec2f v1(streflop::sinf(degToRad(viewDegree - hAng - fov)), streflop::cosf(degToRad(viewDegree - hAng - fov))); - Vec2f v2(streflop::sinf(degToRad(viewDegree - hAng + fov)), streflop::cosf(degToRad(viewDegree - hAng + fov))); + Vec2f v(streflop::sinf(static_cast(degToRad(viewDegree - hAng))), streflop::cosf(static_cast(degToRad(viewDegree - hAng)))); + Vec2f v1(streflop::sinf(static_cast(degToRad(viewDegree - hAng - fov))), streflop::cosf(static_cast(degToRad(viewDegree - hAng - fov)))); + Vec2f v2(streflop::sinf(static_cast(degToRad(viewDegree - hAng + fov))), streflop::cosf(static_cast(degToRad(viewDegree - hAng + fov)))); #else Vec2f v(sinf(degToRad(viewDegree - hAng)), cosf(degToRad(viewDegree - hAng))); Vec2f v1(sinf(degToRad(viewDegree - hAng - fov)), cosf(degToRad(viewDegree - hAng - fov))); @@ -318,8 +318,8 @@ void GameCamera::transitionVH(float v, float h) { void GameCamera::zoom(float dist) { #ifdef USE_STREFLOP - float flatDist = dist * streflop::cosf(degToRad(vAng)); - Vec3f offset(flatDist * streflop::sinf(degToRad(hAng)), dist * streflop::sinf(degToRad(vAng)), flatDist * -streflop::cosf(degToRad(hAng))); + float flatDist = dist * streflop::cosf(static_cast(degToRad(vAng))); + Vec3f offset(flatDist * streflop::sinf(static_cast(degToRad(hAng))), dist * streflop::sinf(static_cast(degToRad(vAng))), flatDist * -streflop::cosf(static_cast(degToRad(hAng)))); #else float flatDist = dist * cosf(degToRad(vAng)); Vec3f offset(flatDist * sinf(degToRad(hAng)), dist * sinf(degToRad(vAng)), flatDist * -cosf(degToRad(hAng))); @@ -386,7 +386,7 @@ void GameCamera::clampAng() { //move camera forwad but never change heightFactor void GameCamera::moveForwardH(float d, float response) { #ifdef USE_STREFLOP - Vec3f offset(streflop::sinf(degToRad(hAng)) * d, 0.f, -streflop::cosf(degToRad(hAng)) * d); + Vec3f offset(streflop::sinf(static_cast(degToRad(hAng))) * d, 0.f, -streflop::cosf(static_cast(degToRad(hAng))) * d); #else Vec3f offset(sinf(degToRad(hAng)) * d, 0.f, -cosf(degToRad(hAng)) * d); #endif @@ -398,7 +398,7 @@ void GameCamera::moveForwardH(float d, float response) { //move camera to a side but never change heightFactor void GameCamera::moveSideH(float d, float response){ #ifdef USE_STREFLOP - Vec3f offset(streflop::sinf(degToRad(hAng+90)) * d, 0.f, -streflop::cosf(degToRad(hAng+90)) * d); + Vec3f offset(streflop::sinf(static_cast(degToRad(hAng+90))) * d, 0.f, -streflop::cosf(static_cast(degToRad(hAng+90))) * d); #else Vec3f offset(sinf(degToRad(hAng+90)) * d, 0.f, -cosf(degToRad(hAng+90)) * d); #endif diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 1a6b3fd6..874dd104 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -980,7 +980,7 @@ static Vec2i _unprojectMap(const Vec2i& pt,const GLdouble* model,const GLdouble* w = start-plane; const float d = norm.x*u.x + norm.y*u.y + norm.z*u.z; #ifdef USE_STREFLOP - if(streflop::fabs(d) < 0.00001) + if(streflop::fabs(static_cast(d)) < 0.00001) #else if(fabs(d) < 0.00001) #endif @@ -996,28 +996,28 @@ static Vec2i _unprojectMap(const Vec2i& pt,const GLdouble* model,const GLdouble* Vec2i pos; if(strcmp(label,"tl") == 0) { #ifdef USE_STREFLOP - pos = Vec2i(streflop::floor(i.x),streflop::floor(i.z)); + pos = Vec2i(streflop::floor(static_cast(i.x)),streflop::floor(static_cast(i.z))); #else pos = Vec2i(floor(i.x),floor(i.z)); #endif } else if(strcmp(label,"tr") == 0) { #ifdef USE_STREFLOP - pos = Vec2i(streflop::ceil(i.x),streflop::floor(i.z)); + pos = Vec2i(streflop::ceil(static_cast(i.x)),streflop::floor(static_cast(i.z))); #else pos = Vec2i(ceil(i.x),floor(i.z)); #endif } else if(strcmp(label,"bl") == 0) { #ifdef USE_STREFLOP - pos = Vec2i(streflop::floor(i.x),streflop::ceil(i.z)); + pos = Vec2i(streflop::floor(static_cast(i.x)),streflop::ceil(static_cast(i.z))); #else pos = Vec2i(floor(i.x),ceil(i.z)); #endif } else if(strcmp(label,"br") == 0) { #ifdef USE_STREFLOP - pos = Vec2i(streflop::ceil(i.x),streflop::ceil(i.z)); + pos = Vec2i(streflop::ceil(static_cast(i.x)),streflop::ceil(static_cast(i.z))); #else pos = Vec2i(ceil(i.x),ceil(i.z)); #endif @@ -1149,7 +1149,7 @@ bool Renderer::ExtractFrustum(VisibleQuadContainerCache &quadCacheItem) { /* Normalize the result */ #ifdef USE_STREFLOP - t = streflop::sqrt( frustum[0][0] * frustum[0][0] + frustum[0][1] * frustum[0][1] + frustum[0][2] * frustum[0][2] ); + t = streflop::sqrt( static_cast(frustum[0][0] * frustum[0][0] + frustum[0][1] * frustum[0][1] + frustum[0][2] * frustum[0][2]) ); #else t = sqrt( frustum[0][0] * frustum[0][0] + frustum[0][1] * frustum[0][1] + frustum[0][2] * frustum[0][2] ); #endif @@ -1172,7 +1172,7 @@ bool Renderer::ExtractFrustum(VisibleQuadContainerCache &quadCacheItem) { /* Normalize the result */ #ifdef USE_STREFLOP - t = streflop::sqrt( frustum[1][0] * frustum[1][0] + frustum[1][1] * frustum[1][1] + frustum[1][2] * frustum[1][2] ); + t = streflop::sqrt( static_cast(frustum[1][0] * frustum[1][0] + frustum[1][1] * frustum[1][1] + frustum[1][2] * frustum[1][2]) ); #else t = sqrt( frustum[1][0] * frustum[1][0] + frustum[1][1] * frustum[1][1] + frustum[1][2] * frustum[1][2] ); #endif @@ -1195,7 +1195,7 @@ bool Renderer::ExtractFrustum(VisibleQuadContainerCache &quadCacheItem) { /* Normalize the result */ #ifdef USE_STREFLOP - t = streflop::sqrt( frustum[2][0] * frustum[2][0] + frustum[2][1] * frustum[2][1] + frustum[2][2] * frustum[2][2] ); + t = streflop::sqrt( static_cast(frustum[2][0] * frustum[2][0] + frustum[2][1] * frustum[2][1] + frustum[2][2] * frustum[2][2]) ); #else t = sqrt( frustum[2][0] * frustum[2][0] + frustum[2][1] * frustum[2][1] + frustum[2][2] * frustum[2][2] ); #endif @@ -1218,7 +1218,7 @@ bool Renderer::ExtractFrustum(VisibleQuadContainerCache &quadCacheItem) { /* Normalize the result */ #ifdef USE_STREFLOP - t = streflop::sqrt( frustum[3][0] * frustum[3][0] + frustum[3][1] * frustum[3][1] + frustum[3][2] * frustum[3][2] ); + t = streflop::sqrt( static_cast(frustum[3][0] * frustum[3][0] + frustum[3][1] * frustum[3][1] + frustum[3][2] * frustum[3][2]) ); #else t = sqrt( frustum[3][0] * frustum[3][0] + frustum[3][1] * frustum[3][1] + frustum[3][2] * frustum[3][2] ); #endif @@ -1242,7 +1242,7 @@ bool Renderer::ExtractFrustum(VisibleQuadContainerCache &quadCacheItem) { /* Normalize the result */ #ifdef USE_STREFLOP - t = streflop::sqrt( frustum[4][0] * frustum[4][0] + frustum[4][1] * frustum[4][1] + frustum[4][2] * frustum[4][2] ); + t = streflop::sqrt( static_cast(frustum[4][0] * frustum[4][0] + frustum[4][1] * frustum[4][1] + frustum[4][2] * frustum[4][2]) ); #else t = sqrt( frustum[4][0] * frustum[4][0] + frustum[4][1] * frustum[4][1] + frustum[4][2] * frustum[4][2] ); #endif @@ -1266,7 +1266,7 @@ bool Renderer::ExtractFrustum(VisibleQuadContainerCache &quadCacheItem) { /* Normalize the result */ #ifdef USE_STREFLOP - t = streflop::sqrt( frustum[5][0] * frustum[5][0] + frustum[5][1] * frustum[5][1] + frustum[5][2] * frustum[5][2] ); + t = streflop::sqrt( static_cast(frustum[5][0] * frustum[5][0] + frustum[5][1] * frustum[5][1] + frustum[5][2] * frustum[5][2]) ); #else t = sqrt( frustum[5][0] * frustum[5][0] + frustum[5][1] * frustum[5][1] + frustum[5][2] * frustum[5][2] ); #endif @@ -2379,7 +2379,7 @@ Vec2f Renderer::getCentered3DPos(const string &text, Font3D *font, Vec2f &pos, i //printf("line %d, lineHeight [%f] h [%d] text [%s]\n",__LINE__,lineHeight,h,text.c_str()); #ifdef USE_STREFLOP - pos.y += (streflop::ceil((float)lineHeight - (float)h)); + pos.y += (float)(streflop::ceil( static_cast( ((float)lineHeight - (float)h)) )); #else pos.y += (ceil(lineHeight - h)); #endif @@ -5285,8 +5285,8 @@ void Renderer::renderMinimap(){ int x1 = 0; int y1 = 0; #ifdef USE_STREFLOP - x1 = mx + x + static_cast(20*streflop::sin(ang-pi/5)); - y1 = my + mh - (y-static_cast(20*streflop::cos(ang-pi/5))); + x1 = mx + x + static_cast(20*streflop::sin(static_cast(ang-pi/5))); + y1 = my + mh - (y-static_cast(20*streflop::cos(static_cast(ang-pi/5)))); #else x1 = mx + x + static_cast(20*sin(ang-pi/5)); y1 = my + mh - (y-static_cast(20*cos(ang-pi/5))); @@ -5295,8 +5295,8 @@ void Renderer::renderMinimap(){ int x2 = 0; int y2 = 0; #ifdef USE_STREFLOP - x2 = mx + x + static_cast(20*streflop::sin(ang+pi/5)); - y2 = my + mh - (y-static_cast(20*streflop::cos(ang+pi/5))); + x2 = mx + x + static_cast(20*streflop::sin(static_cast(ang+pi/5))); + y2 = my + mh - (y-static_cast(20*streflop::cos(static_cast(ang+pi/5)))); #else x2 = mx + x + static_cast(20*sin(ang+pi/5)); y2 = my + mh - (y-static_cast(20*cos(ang+pi/5))); @@ -6461,7 +6461,7 @@ float Renderer::computeMoonAngle(float time) { Vec4f Renderer::computeSunPos(float time) { float ang= computeSunAngle(time); #ifdef USE_STREFLOP - return Vec4f(-streflop::cos(ang)*sunDist, streflop::sin(ang)*sunDist, 0.f, 0.f); + return Vec4f(-streflop::cos(static_cast(ang))*sunDist, streflop::sin(static_cast(ang))*sunDist, 0.f, 0.f); #else return Vec4f(-cos(ang)*sunDist, sin(ang)*sunDist, 0.f, 0.f); #endif @@ -6470,7 +6470,7 @@ Vec4f Renderer::computeSunPos(float time) { Vec4f Renderer::computeMoonPos(float time) { float ang= computeMoonAngle(time); #ifdef USE_STREFLOP - return Vec4f(-streflop::cos(ang)*moonDist, streflop::sin(ang)*moonDist, 0.f, 0.f); + return Vec4f(-streflop::cos(static_cast(ang))*moonDist, streflop::sin(static_cast(ang))*moonDist, 0.f, 0.f); #else return Vec4f(-cos(ang)*moonDist, sin(ang)*moonDist, 0.f, 0.f); #endif @@ -7446,7 +7446,7 @@ void Renderer::renderUnitTitles3D(Font3D *font, Vec3f color) { //get the screen coordinates Vec3f screenPos = unit->getScreenPos(); #ifdef USE_STREFLOP - renderText3D(unit->getCurrentUnitTitle(), font, color, streflop::fabs(screenPos.x) + 5, streflop::fabs(screenPos.y) + 5, false); + renderText3D(unit->getCurrentUnitTitle(), font, color, streflop::fabs(static_cast(screenPos.x)) + 5, streflop::fabs(static_cast(screenPos.y)) + 5, false); #else renderText3D(unit->getCurrentUnitTitle(), font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false); #endif @@ -7457,7 +7457,7 @@ void Renderer::renderUnitTitles3D(Font3D *font, Vec3f color) { string str = unit->getFullName() + " - " + intToStr(unit->getId()) + " [" + unit->getPos().getString() + "]"; Vec3f screenPos = unit->getScreenPos(); #ifdef USE_STREFLOP - renderText3D(str, font, color, streflop::fabs(screenPos.x) + 5, streflop::fabs(screenPos.y) + 5, false); + renderText3D(str, font, color, streflop::fabs(static_cast(screenPos.x)) + 5, streflop::fabs(static_cast(screenPos.y)) + 5, false); #else renderText3D(str, font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false); #endif @@ -7508,7 +7508,7 @@ void Renderer::renderUnitTitles(Font2D *font, Vec3f color) { //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); + renderText(unit->getCurrentUnitTitle(), font, color, streflop::fabs(static_cast(screenPos.x)) + 5, streflop::fabs(static_cast(screenPos.y)) + 5, false); #else renderText(unit->getCurrentUnitTitle(), font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false); #endif @@ -7519,7 +7519,7 @@ void Renderer::renderUnitTitles(Font2D *font, Vec3f color) { string str = unit->getFullName() + " - " + intToStr(unit->getId()) + " [" + unit->getPos().getString() + "]"; Vec3f screenPos = unit->getScreenPos(); #ifdef USE_STREFLOP - renderText(str, font, color, streflop::fabs(screenPos.x) + 5, streflop::fabs(screenPos.y) + 5, false); + renderText(str, font, color, streflop::fabs(static_cast(screenPos.x)) + 5, streflop::fabs(static_cast(screenPos.y)) + 5, false); #else renderText(str, font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false); #endif diff --git a/source/glest_game/menu/menu_state_join_game.cpp b/source/glest_game/menu/menu_state_join_game.cpp index 11c8a58b..76c0d0b7 100644 --- a/source/glest_game/menu/menu_state_join_game.cpp +++ b/source/glest_game/menu/menu_state_join_game.cpp @@ -625,7 +625,7 @@ void MenuStateJoinGame::connectToServer() { for(time_t elapsedWait = time(NULL); clientInterface->getIntroDone() == false && clientInterface->isConnected() && - difftime(time(NULL),elapsedWait) <= 5;) { + difftime(time(NULL),elapsedWait) <= 8;) { if(clientInterface->isConnected()) { //update lobby clientInterface->updateLobby(); diff --git a/source/glest_game/menu/menu_state_masterserver.cpp b/source/glest_game/menu/menu_state_masterserver.cpp index ab196870..41b2eba4 100644 --- a/source/glest_game/menu/menu_state_masterserver.cpp +++ b/source/glest_game/menu/menu_state_masterserver.cpp @@ -1060,10 +1060,11 @@ bool MenuStateMasterserver::connectToServer(string ipString, int port) { for(time_t elapsedWait = time(NULL); clientInterface->getIntroDone() == false && clientInterface->isConnected() && - difftime(time(NULL),elapsedWait) <= 3;) { + difftime(time(NULL),elapsedWait) <= 8;) { if(clientInterface->isConnected()) { //update lobby clientInterface->updateLobby(); + sleep(0); } } if( clientInterface->isConnected() == true && diff --git a/source/glest_game/sound/sound_renderer.cpp b/source/glest_game/sound/sound_renderer.cpp index 0eb5929b..3b96e60b 100644 --- a/source/glest_game/sound/sound_renderer.cpp +++ b/source/glest_game/sound/sound_renderer.cpp @@ -184,7 +184,7 @@ 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); + float correctedVol= streflop::log10(streflop::log10(static_cast(vol*9+1))*9+1); #else float correctedVol= log10(log10(vol*9+1)*9+1); #endif diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index f7c09ff3..067b9470 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -574,7 +574,7 @@ void Unit::calculateXZRotation(){ const Vec3f normal= sc->getNormal(); #ifdef USE_STREFLOP - targetRotationZ= radToDeg(streflop::atan2(abs(normal.x), abs(normal.y))); + targetRotationZ= radToDeg(streflop::atan2(static_cast(abs(normal.x)), static_cast(abs(normal.y)))); #else targetRotationZ= radToDeg(atan2(abs(normal.x), abs(normal.y))); #endif @@ -585,7 +585,7 @@ void Unit::calculateXZRotation(){ targetRotationZ= targetRotationZ * -1; #ifdef USE_STREFLOP - targetRotationX= radToDeg(streflop::atan2(abs(normal.z), abs(normal.y))); + targetRotationX= radToDeg(streflop::atan2(static_cast(abs(normal.z)), static_cast(abs(normal.y)))); #else targetRotationX= radToDeg(atan2(abs(normal.z), abs(normal.y))); #endif @@ -946,7 +946,7 @@ void Unit::setTargetPos(const Vec2i &targetPos) { Vec2f relPosf= Vec2f((float)relPos.x, (float)relPos.y); #ifdef USE_STREFLOP - targetRotation= radToDeg(streflop::atan2(relPosf.x, relPosf.y)); + targetRotation= radToDeg(streflop::atan2(static_cast(relPosf.x), static_cast(relPosf.y))); #else targetRotation= radToDeg(atan2(relPosf.x, relPosf.y)); #endif @@ -2581,7 +2581,7 @@ void Unit::updateTarget(){ Vec2i relPos= targetPos - pos; Vec2f relPosf= Vec2f((float)relPos.x, (float)relPos.y); #ifdef USE_STREFLOP - targetRotation= radToDeg(streflop::atan2(relPosf.x, relPosf.y)); + targetRotation= radToDeg(streflop::atan2(static_cast(relPosf.x), static_cast(relPosf.y))); #else targetRotation= radToDeg(atan2(relPosf.x, relPosf.y)); #endif diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index 1dfb2136..8ad2ba04 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -1537,8 +1537,8 @@ void Map::smoothSurface(Tileset *tileset) { 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)])) { + if (cliffLevel<=0.1f || cliffLevel > streflop::fabs(static_cast(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)])) { @@ -1673,7 +1673,7 @@ bool PosCircularIterator::next(){ return false; } #ifdef USE_STREFLOP - while(streflop::floor(pos.dist(center)) >= (radius+1) || !map->isInside(pos) || !map->isInsideSurface(map->toSurfCoords(pos)) ); + while(streflop::floor(static_cast(pos.dist(center))) >= (radius+1) || !map->isInside(pos) || !map->isInsideSurface(map->toSurfCoords(pos)) ); #else while(floor(pos.dist(center)) >= (radius+1) || !map->isInside(pos) || !map->isInsideSurface(map->toSurfCoords(pos)) ); #endif diff --git a/source/glest_game/world/tileset.cpp b/source/glest_game/world/tileset.cpp index 1b3f94ff..f4cb7f8b 100644 --- a/source/glest_game/world/tileset.cpp +++ b/source/glest_game/world/tileset.cpp @@ -330,7 +330,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); #ifdef USE_STREFLOP - float rnd= streflop::fabs(random.randRange(-1.f, 1.f)); + float rnd= streflop::fabs(static_cast(random.randRange(-1.f, 1.f))); #else float rnd= fabs(random.randRange(-1.f, 1.f)); #endif diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index 323703d7..e9675b14 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -2289,7 +2289,7 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr, for(int j = center.y - range; j < center.y + range + size; ++j) { //cells inside map and in range #ifdef USE_STREFLOP - if(map->isInside(i, j) && streflop::floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range+1)){ + if(map->isInside(i, j) && streflop::floor(static_cast(floatCenter.dist(Vec2f((float)i, (float)j)))) <= (range+1)){ #else if(map->isInside(i, j) && floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range+1)){ #endif @@ -2394,7 +2394,7 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr, } else { #ifdef USE_STREFLOP - currentDistance = streflop::floor(enemyFloatCenter.dist(attackWarnings[i]->attackPosition)); // no need for streflops here! + currentDistance = streflop::floor(static_cast(enemyFloatCenter.dist(attackWarnings[i]->attackPosition))); // no need for streflops here! #else currentDistance = floor(enemyFloatCenter.dist(attackWarnings[i]->attackPosition)); // no need for streflops here! #endif @@ -2473,7 +2473,7 @@ vector UnitUpdater::enemyUnitsOnRange(const Unit *unit,const AttackSkillT for(int j = center.y - range; j < center.y + range + size; ++j) { //cells inside map and in range #ifdef USE_STREFLOP - if(map->isInside(i, j) && streflop::floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range+1)){ + if(map->isInside(i, j) && streflop::floor(static_cast(floatCenter.dist(Vec2f((float)i, (float)j)))) <= (range+1)){ #else if(map->isInside(i, j) && floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range+1)){ #endif @@ -2527,7 +2527,7 @@ vector UnitUpdater::findUnitsInRange(const Unit *unit, int radius) { for(int j = center.y - range; j < center.y + range + size; ++j) { //cells inside map and in range #ifdef USE_STREFLOP - if(map->isInside(i, j) && streflop::floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range+1)){ + if(map->isInside(i, j) && streflop::floor(static_cast(floatCenter.dist(Vec2f((float)i, (float)j)))) <= (range+1)){ #else if(map->isInside(i, j) && floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range+1)){ #endif diff --git a/source/shared_lib/CMakeLists.txt b/source/shared_lib/CMakeLists.txt index 3700b6d2..ebc1228b 100644 --- a/source/shared_lib/CMakeLists.txt +++ b/source/shared_lib/CMakeLists.txt @@ -295,6 +295,8 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST set(CMAKE_REQUIRED_INCLUDES "${IRCCLIENT_INCLUDE_DIR}") set(CMAKE_REQUIRED_LIBRARIES "${IRCCLIENT_LIBRARY}") + include(CheckCXXSourceRuns) + check_cxx_source_runs(" #include #include diff --git a/source/shared_lib/include/graphics/vec.h b/source/shared_lib/include/graphics/vec.h index 1d2e2cba..cecd3e97 100644 --- a/source/shared_lib/include/graphics/vec.h +++ b/source/shared_lib/include/graphics/vec.h @@ -145,7 +145,7 @@ public: float length() const{ #ifdef USE_STREFLOP - return static_cast(streflop::sqrt(static_cast(x*x + y*y))); + return static_cast(streflop::sqrt(static_cast(x*x + y*y))); #else return static_cast(sqrt(static_cast(x*x + y*y))); #endif @@ -331,7 +331,7 @@ public: float length() const{ #ifdef USE_STREFLOP - return static_cast(streflop::sqrt(x*x + y*y + z*z)); + return static_cast(streflop::sqrt(static_cast(x*x + y*y + z*z))); #else return static_cast(sqrt(x*x + y*y + z*z)); #endif diff --git a/source/shared_lib/include/platform/posix/socket.h b/source/shared_lib/include/platform/posix/socket.h index 79d70721..05912145 100644 --- a/source/shared_lib/include/platform/posix/socket.h +++ b/source/shared_lib/include/platform/posix/socket.h @@ -162,7 +162,7 @@ public: static void setBlock(bool block, PLATFORM_SOCKET socket); bool isReadable(); - bool isWritable(); + bool isWritable(struct timeval *timeVal=NULL); bool isConnected(); static string getHostName(); diff --git a/source/shared_lib/sources/graphics/gl/particle_renderer_gl.cpp b/source/shared_lib/sources/graphics/gl/particle_renderer_gl.cpp index 5d806133..3337c443 100644 --- a/source/shared_lib/sources/graphics/gl/particle_renderer_gl.cpp +++ b/source/shared_lib/sources/graphics/gl/particle_renderer_gl.cpp @@ -245,7 +245,7 @@ void ParticleRendererGl::renderModel(GameParticleSystem *ps, ModelRenderer *mr){ Vec3f rotVector= Vec3f(0.f, 1.f, 0.f).cross(flatDirection); #ifdef USE_STREFLOP - float angleV= radToDeg(streflop::atan2(flatDirection.length(), direction.y)) - 90.f; + float angleV= radToDeg(streflop::atan2(static_cast(flatDirection.length()), static_cast(direction.y))) - 90.f; #else float angleV= radToDeg(atan2(flatDirection.length(), direction.y)) - 90.f; #endif @@ -253,7 +253,7 @@ void ParticleRendererGl::renderModel(GameParticleSystem *ps, ModelRenderer *mr){ glRotatef(angleV, rotVector.x, rotVector.y, rotVector.z); #ifdef USE_STREFLOP - float angleH= radToDeg(streflop::atan2(direction.x, direction.z)); + float angleH= radToDeg(streflop::atan2(static_cast(direction.x), static_cast(direction.z))); #else float angleH= radToDeg(atan2(direction.x, direction.z)); #endif diff --git a/source/shared_lib/sources/graphics/particle.cpp b/source/shared_lib/sources/graphics/particle.cpp index 922e8040..1ecf6b83 100644 --- a/source/shared_lib/sources/graphics/particle.cpp +++ b/source/shared_lib/sources/graphics/particle.cpp @@ -344,19 +344,19 @@ void FireParticleSystem::initParticle(Particle *p, int particleIndex){ float ang= random.randRange(-2.0f * pi, 2.0f * pi); #ifdef USE_STREFLOP - float mod= streflop::fabsf(random.randRange(-radius, radius)); + float mod= streflop::fabsf(static_cast(random.randRange(-radius, radius))); - float x= streflop::sinf(ang)*mod; - float y= streflop::cosf(ang)*mod; + float x= streflop::sinf(static_cast(ang))*mod; + float y= streflop::cosf(static_cast(ang))*mod; - float radRatio= streflop::sqrtf(streflop::sqrtf(mod/radius)); + float radRatio= streflop::sqrtf(static_cast(mod/radius)); #else float mod= fabsf(random.randRange(-radius, radius)); float x= sinf(ang) * mod; float y= cosf(ang) * mod; - float radRatio= sqrtf(sqrtf(mod / radius)); + float radRatio= sqrtf((mod / radius)); #endif p->color= colorNoEnergy * 0.5f + colorNoEnergy * 0.5f * radRatio; @@ -392,9 +392,9 @@ void FireParticleSystem::setRadius(float radius){ void FireParticleSystem::setWind(float windAngle, float windSpeed){ #ifdef USE_STREFLOP - this->windSpeed.x= streflop::sinf(degToRad(windAngle))*windSpeed; + this->windSpeed.x= streflop::sinf(static_cast(degToRad(windAngle)))*windSpeed; this->windSpeed.y= 0.0f; - this->windSpeed.z= streflop::cosf(degToRad(windAngle))*windSpeed; + this->windSpeed.z= streflop::cosf(static_cast(degToRad(windAngle)))*windSpeed; #else this->windSpeed.x= sinf(degToRad(windAngle)) * windSpeed; this->windSpeed.y= 0.0f; @@ -498,7 +498,7 @@ void GameParticleSystem::setTween(float relative,float absolute) { } else { #ifdef USE_STREFLOP - if(streflop::fabs(absolute) <= 0.00001f){ + if(streflop::fabs(static_cast(absolute)) <= 0.00001f){ #else if(fabs(absolute) <= 0.00001f){ #endif @@ -506,7 +506,7 @@ void GameParticleSystem::setTween(float relative,float absolute) { } else { #ifdef USE_STREFLOP - tween= streflop::fmod(absolute, modelCycle); + tween= streflop::fmod(static_cast(absolute), static_cast(modelCycle)); #else tween= fmod(absolute, modelCycle); #endif @@ -628,11 +628,11 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){ const float ang= random.randRange(-2.0f * pi, 2.0f * pi); #ifdef USE_STREFLOP - const float mod= streflop::fabsf(random.randRange(-radius, radius)); - const float radRatio= streflop::sqrtf(streflop::sqrtf(mod/radius)); + const float mod= streflop::fabsf(static_cast(random.randRange(-radius, radius))); + const float radRatio= streflop::sqrtf(static_cast(mod/radius)); #else const float mod= fabsf(random.randRange(-radius, radius)); - const float radRatio= sqrtf(sqrtf(mod / radius)); + const float radRatio= sqrtf(mod / radius); #endif p->color= color; if(radiusBasedStartenergy == true){ @@ -663,8 +663,8 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){ } break; case sLinear:{ #ifdef USE_STREFLOP - float x= streflop::sinf(ang)*mod; - float y= streflop::cosf(ang)*mod; + float x= streflop::sinf(static_cast(ang))*mod; + float y= streflop::cosf(static_cast(ang))*mod; #else float x= sinf(ang) * mod; float y= cosf(ang) * mod; @@ -676,7 +676,7 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){ } else{// rotate it according to rotation #ifdef USE_STREFLOP - p->pos= Vec3f(pos.x+x+offset.z*streflop::sinf(rad)+offset.x*streflop::cosf(rad), pos.y+random.randRange(-radius/2, radius/2)+offset.y, pos.z+y+(offset.z*streflop::cosf(rad)-offset.x*streflop::sinf(rad))); + p->pos= Vec3f(pos.x+x+offset.z*streflop::sinf(static_cast(rad))+offset.x*streflop::cosf(static_cast(rad)), pos.y+random.randRange(-radius/2, radius/2)+offset.y, pos.z+y+(offset.z*streflop::cosf(static_cast(rad))-offset.x*streflop::sinf(static_cast(rad)))); #else p->pos= Vec3f(pos.x + x + offset.z * sinf(rad) + offset.x * cosf(rad), pos.y + random.randRange(-radius / 2, radius / 2) + offset.y, pos.z + y + (offset.z * cosf(rad) - offset.x * sinf(rad))); @@ -687,7 +687,7 @@ void UnitParticleSystem::initParticle(Particle *p, int particleIndex){ p->speed= p->speed * speed; if(relative && relativeDirection){ #ifdef USE_STREFLOP - p->speed=Vec3f(p->speed.z*streflop::sinf(rad)+p->speed.x*streflop::cosf(rad),p->speed.y,(p->speed.z*streflop::cosf(rad)-p->speed.x*streflop::sinf(rad))); + p->speed=Vec3f(p->speed.z*streflop::sinf(static_cast(rad))+p->speed.x*streflop::cosf(static_cast(rad)),p->speed.y,(p->speed.z*streflop::cosf(static_cast(rad))-p->speed.x*streflop::sinf(static_cast(rad)))); #else p->speed= Vec3f(p->speed.z * sinf(rad) + p->speed.x * cosf(rad), p->speed.y, (p->speed.z * cosf(rad) - p->speed.x * sinf(rad))); @@ -778,9 +778,9 @@ void UnitParticleSystem::updateParticle(Particle *p){ void UnitParticleSystem::setWind(float windAngle, float windSpeed){ #ifdef USE_STREFLOP - this->windSpeed.x= streflop::sinf(degToRad(windAngle))*windSpeed; + this->windSpeed.x= streflop::sinf(static_cast(degToRad(windAngle)))*windSpeed; this->windSpeed.y= 0.0f; - this->windSpeed.z= streflop::cosf(degToRad(windAngle))*windSpeed; + this->windSpeed.z= streflop::cosf(static_cast(degToRad(windAngle)))*windSpeed; #else this->windSpeed.x= sinf(degToRad(windAngle)) * windSpeed; this->windSpeed.y= 0.0f; @@ -833,9 +833,9 @@ void RainParticleSystem::setRadius(float radius){ void RainParticleSystem::setWind(float windAngle, float windSpeed){ #ifdef USE_STREFLOP - this->windSpeed.x= streflop::sinf(degToRad(windAngle))*windSpeed; + this->windSpeed.x= streflop::sinf(static_cast(degToRad(windAngle)))*windSpeed; this->windSpeed.y= 0.0f; - this->windSpeed.z= streflop::cosf(degToRad(windAngle))*windSpeed; + this->windSpeed.z= streflop::cosf(static_cast(degToRad(windAngle)))*windSpeed; #else this->windSpeed.x= sinf(degToRad(windAngle)) * windSpeed; this->windSpeed.y= 0.0f; @@ -884,9 +884,9 @@ void SnowParticleSystem::setRadius(float radius){ void SnowParticleSystem::setWind(float windAngle, float windSpeed){ #ifdef USE_STREFLOP - this->windSpeed.x= streflop::sinf(degToRad(windAngle))*windSpeed; + this->windSpeed.x= streflop::sinf(static_cast(degToRad(windAngle)))*windSpeed; this->windSpeed.y= 0.0f; - this->windSpeed.z= streflop::cosf(degToRad(windAngle))*windSpeed; + this->windSpeed.z= streflop::cosf(static_cast(degToRad(windAngle)))*windSpeed; #else this->windSpeed.x= sinf(degToRad(windAngle)) * windSpeed; this->windSpeed.y= 0.0f; @@ -950,7 +950,7 @@ void ProjectileParticleSystem::update(){ // ratio float relative= clamp(currentVector.length() / targetVector.length(), 0.0f, 1.0f); #ifdef USE_STREFLOP - float absolute= clamp(streflop::fabs(currentVector.length()), 0.0f, 1.0f); + float absolute= clamp(streflop::fabs(static_cast(currentVector.length())), 0.0f, 1.0f); #else float absolute= clamp(fabs(currentVector.length()), 0.0f, 1.0f); #endif @@ -975,8 +975,8 @@ void ProjectileParticleSystem::update(){ case tSpiral: { pos= flatPos; #ifdef USE_STREFLOP - pos+= xVector * streflop::cos(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale; - pos+= yVector * streflop::sin(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale; + pos+= xVector * streflop::cos(static_cast(relative * trajectoryFrequency * targetVector.length())) * trajectoryScale; + pos+= yVector * streflop::sin(static_cast(relative * trajectoryFrequency * targetVector.length())) * trajectoryScale; #else pos+= xVector * cos(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale; pos+= yVector * sin(relative * trajectoryFrequency * targetVector.length()) * trajectoryScale; @@ -1017,7 +1017,7 @@ void ProjectileParticleSystem::update(){ void ProjectileParticleSystem::rotateChildren() { //### only on horizontal plane :( #ifdef USE_STREFLOP - float rotation = streflop::atan2(direction.x, direction.z); + float rotation = streflop::atan2(static_cast(direction.x), static_cast(direction.z)); #else float rotation = atan2(direction.x, direction.z); #endif diff --git a/source/shared_lib/sources/graphics/pixmap.cpp b/source/shared_lib/sources/graphics/pixmap.cpp index 7e7b5560..309b5cd7 100644 --- a/source/shared_lib/sources/graphics/pixmap.cpp +++ b/source/shared_lib/sources/graphics/pixmap.cpp @@ -1173,11 +1173,11 @@ void Pixmap2D::splat(const Pixmap2D *leftUp, const Pixmap2D *rightUp, const Pixm const float powFactor= 2.0f; #ifdef USE_STREFLOP - distLu= streflop::pow(distLu, powFactor); - distRu= streflop::pow(distRu, powFactor); - distLd= streflop::pow(distLd, powFactor); - distRd= streflop::pow(distRd, powFactor); - avg= streflop::pow(avg, powFactor); + distLu= streflop::pow(static_cast(distLu), static_cast(powFactor)); + distRu= streflop::pow(static_cast(distRu), static_cast(powFactor)); + distLd= streflop::pow(static_cast(distLd), static_cast(powFactor)); + distRd= streflop::pow(static_cast(distRd), static_cast(powFactor)); + avg= streflop::pow(static_cast(avg), static_cast(powFactor)); #else distLu= pow(distLu, powFactor); distRu= pow(distRu, powFactor); diff --git a/source/shared_lib/sources/graphics/quaternion.cpp b/source/shared_lib/sources/graphics/quaternion.cpp index b5620738..28619732 100644 --- a/source/shared_lib/sources/graphics/quaternion.cpp +++ b/source/shared_lib/sources/graphics/quaternion.cpp @@ -68,10 +68,10 @@ void Quaternion::setAddIdentity(){ void Quaternion::setAxisAngle(const AxisAngle &axisAngle){ #ifdef USE_STREFLOP - w= streflop::cosf(axisAngle.angle/2.0f); - v.x= axisAngle.axis.x * streflop::sinf(axisAngle.angle/2.0f); - v.y= axisAngle.axis.y * streflop::sinf(axisAngle.angle/2.0f); - v.z= axisAngle.axis.z * streflop::sinf(axisAngle.angle/2.0f); + w= streflop::cosf(static_cast(axisAngle.angle/2.0f)); + v.x= axisAngle.axis.x * streflop::sinf(static_cast(axisAngle.angle/2.0f)); + v.y= axisAngle.axis.y * streflop::sinf(static_cast(axisAngle.angle/2.0f)); + v.z= axisAngle.axis.z * streflop::sinf(static_cast(axisAngle.angle/2.0f)); #else w= cosf(axisAngle.angle/2.0f); v.x= axisAngle.axis.x * sinf(axisAngle.angle/2.0f); @@ -84,14 +84,14 @@ void Quaternion::setEuler(const EulerAngles &eulerAngles){ Quaternion qx, qy, qz, qr; #ifdef USE_STREFLOP - qx.w= streflop::cosf(eulerAngles.x/2.0f); - qx.v= Vec3f(streflop::sinf(eulerAngles.x/2.0f), 0.0f, 0.0f); + qx.w= streflop::cosf(static_cast(eulerAngles.x/2.0f)); + qx.v= Vec3f(streflop::sinf(static_cast(eulerAngles.x/2.0f)), 0.0f, 0.0f); - qy.w= streflop::cosf(eulerAngles.y/2.0f); - qy.v= Vec3f(0.0f, streflop::sinf(eulerAngles.y/2.0f), 0.0f); + qy.w= streflop::cosf(static_cast(eulerAngles.y/2.0f)); + qy.v= Vec3f(0.0f, streflop::sinf(static_cast(eulerAngles.y/2.0f)), 0.0f); - qz.w= streflop::cosf(eulerAngles.z/2.0f); - qz.v= Vec3f(0.0f, 0.0f, streflop::sinf(eulerAngles.z/2.0f)); + qz.w= streflop::cosf(static_cast(eulerAngles.z/2.0f)); + qz.v= Vec3f(0.0f, 0.0f, streflop::sinf(static_cast(eulerAngles.z/2.0f))); #else qx.w= cosf(eulerAngles.x/2.0f); qx.v= Vec3f(sinf(eulerAngles.x/2.0f), 0.0f, 0.0f); @@ -111,7 +111,7 @@ void Quaternion::setEuler(const EulerAngles &eulerAngles){ float Quaternion::length(){ #ifdef USE_STREFLOP - return streflop::sqrt(w*w+v.x*v.x+v.y*v.y+v.z*v.z); + return streflop::sqrt(static_cast(w*w+v.x*v.x+v.y*v.y+v.z*v.z)); #else return sqrt(w*w+v.x*v.x+v.y*v.y+v.z*v.z); #endif @@ -207,7 +207,7 @@ Matrix4f Quaternion::toMatrix4() const{ AxisAngle Quaternion::toAxisAngle() const{ float scale= 1.0f/(v.x*v.x + v.y*v.y + v.z*v.z); #ifdef USE_STREFLOP - return AxisAngle(v*scale, 2*streflop::acosf(w)); + return AxisAngle(v*scale, 2*streflop::acosf(static_cast(w))); #else return AxisAngle(v*scale, 2*acosf(w)); #endif diff --git a/source/shared_lib/sources/map/map_preview.cpp b/source/shared_lib/sources/map/map_preview.cpp index 24b1f47e..188d97ff 100644 --- a/source/shared_lib/sources/map/map_preview.cpp +++ b/source/shared_lib/sources/map/map_preview.cpp @@ -112,7 +112,7 @@ 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 + return static_cast(streflop::sqrtf(static_cast(dx * dx + dy * dy))+0.5); // round correctly #else return static_cast(sqrtf(dx * dx + dy * dy)+0.5); // round correctly #endif @@ -279,16 +279,16 @@ 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)) { + if (streflop::fabs(static_cast(normIf)) > streflop::fabs(static_cast(normJf))) { usedGrad = - gradient[normI[0]] [normJ[0]] * streflop::fabs(normJf) + - gradient[normI[0]] [normJ[1]] * (1 - streflop::fabs(normJf)); + gradient[normI[0]] [normJ[0]] * streflop::fabs(static_cast(normJf)) + + gradient[normI[0]] [normJ[1]] * (1 - streflop::fabs(static_cast(normJf))); } - else if (streflop::fabs(normIf) < streflop::fabs(normJf)) { + else if (streflop::fabs(static_cast(normIf)) < streflop::fabs(static_cast(normJf))) { usedGrad = - gradient[normI[0]] [normJ[0]] * streflop::fabs(normIf) + - gradient[normI[1]] [normJ[0]] * (1 - streflop::fabs(normIf)); + gradient[normI[0]] [normJ[0]] * streflop::fabs(static_cast(normIf)) + + gradient[normI[1]] [normJ[0]] * (1 - streflop::fabs(static_cast(normIf))); } else { usedGrad = @@ -888,8 +888,8 @@ void MapPreview::sinRandomize(int strenght) { 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; + float sh = (streflop::sinf(static_cast(normH * sinH1)) + streflop::sin(static_cast(normH * sinH2))) / 2.f; + float sv = (streflop::sinf(static_cast(normV * sinV1)) + streflop::sin(static_cast(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; diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index f44abbfd..8b75277b 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -595,6 +595,11 @@ std::pair getFolderTreeContentsCheckSumCacheKey(vector pa pair hasCachedFileCRCValue(string crcCacheFile, int32 &value) { //bool result = false; + + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d for Cache file [%s]\n",__FILE__,__FUNCTION__,__LINE__,crcCacheFile.c_str()); + } + pair result = make_pair(false,0); if(fileExists(crcCacheFile) == true) { #ifdef WIN32 @@ -615,6 +620,16 @@ pair hasCachedFileCRCValue(string crcCacheFile, int32 &value) { result.first = true; value = crcValue; + + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) { + struct tm *loctime = localtime (&refreshDate); + char szBuf1[100]=""; + strftime(szBuf1,100,"%Y-%m-%d %H:%M:%S",loctime); + + SystemFlags::OutputDebug(SystemFlags::debugSystem, + "=-=-=-=- READ CACHE for Cache file [%s] refreshDate = %ld [%s], crcValue = %d\n", + crcCacheFile.c_str(),refreshDate, szBuf1, crcValue); + } } else { time_t now = time(NULL); @@ -626,9 +641,23 @@ pair hasCachedFileCRCValue(string crcCacheFile, int32 &value) { char szBuf2[100]=""; strftime(szBuf2,100,"%Y-%m-%d %H:%M:%S",loctime); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"=-=-=-=- NEED TO CALCULATE CRC for Cache file [%s] now = %ld [%s], refreshDate = %ld [%s], crcValue = %d\n",crcCacheFile.c_str(),now, szBuf1, refreshDate, szBuf2, crcValue); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) { + SystemFlags::OutputDebug(SystemFlags::debugSystem, + "=-=-=-=- NEED TO CALCULATE CRC for Cache file [%s] now = %ld [%s], refreshDate = %ld [%s], crcValue = %d\n", + crcCacheFile.c_str(),now, szBuf1, refreshDate, szBuf2, crcValue); + } } } + else { + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"FILE NOT FOUND(1) for Cache file [%s]\n",crcCacheFile.c_str()); + } + } + } + else { + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"FILE NOT FOUND(2) for Cache file [%s]\n",crcCacheFile.c_str()); + } } return result; diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 80950ed6..1865c304 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -1227,10 +1227,10 @@ int Socket::send(const void *data, int dataSize) { int lastSocketError = getLastSocketError(); if(bytesSent < 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR WRITING SOCKET DATA, err = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesSent,getLastSocketErrorFormattedText(&lastSocketError).c_str()); + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR WRITING SOCKET DATA, err = %d error = %s dataSize = %d\n",__FILE__,__FUNCTION__,__LINE__,bytesSent,getLastSocketErrorFormattedText(&lastSocketError).c_str(),dataSize); } else if(bytesSent < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN && isConnected() == true) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 EAGAIN during send, trying again...\n",__FILE__,__FUNCTION__,__LINE__); + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 EAGAIN during send, trying again... dataSize = %d\n",__FILE__,__FUNCTION__,__LINE__,dataSize); int attemptCount = 0; time_t tStartTimer = time(NULL); @@ -1240,7 +1240,12 @@ int Socket::send(const void *data, int dataSize) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount); if(isConnected() == true) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, sock = %d, dataSize = %d, data = %p\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,sock,dataSize,data); + struct timeval timeVal; + timeVal.tv_sec = 1; + timeVal.tv_usec = 0; + bool canWrite = isWritable(&timeVal); + + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, sock = %d, dataSize = %d, data = %p, canWrite = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,sock,dataSize,data,canWrite); // MutexSafeWrapper safeMutexSocketDestructorFlag(&inSocketDestructorSynchAccessor,CODE_AT_LINE); // if(this->inSocketDestructor == true) { @@ -1293,7 +1298,12 @@ int Socket::send(const void *data, int dataSize) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, totalBytesSent = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,totalBytesSent); if(isConnected() == true) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, sock = %d, dataSize = %d, data = %p\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,sock,dataSize,data); + struct timeval timeVal; + timeVal.tv_sec = 1; + timeVal.tv_usec = 0; + bool canWrite = isWritable(&timeVal); + + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, sock = %d, dataSize = %d, data = %p, canWrite = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,sock,dataSize,data,canWrite); // MutexSafeWrapper safeMutexSocketDestructorFlag(&inSocketDestructorSynchAccessor,CODE_AT_LINE); // if(this->inSocketDestructor == true) { @@ -1602,13 +1612,18 @@ bool Socket::isReadable() { return result; } -bool Socket::isWritable() { +bool Socket::isWritable(struct timeval *timeVal) { if(isSocketValid() == false) return false; struct timeval tv; - tv.tv_sec= 0; - //tv.tv_usec= 1; - tv.tv_usec= 0; + if(timeVal != NULL) { + tv = *timeVal; + } + else { + tv.tv_sec= 0; + //tv.tv_usec= 1; + tv.tv_usec= 0; + } fd_set set; FD_ZERO(&set); diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index 2ff6e2cf..68a257e1 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -445,7 +445,7 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a const float lodBias = max(min(0.0f,4.0f),-4.0f); //if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("\n\n\n\n\n$$$$ In [%s::%s Line: %d] lodBias = %f\n\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,lodBias); #ifdef USE_STREFLOP - if (streflop::fabs(lodBias) > 0.01f) { + if (streflop::fabs(static_cast(lodBias)) > 0.01f) { #else if (fabs(lodBias) > 0.01f) { #endif diff --git a/source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp b/source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp index fa4312b5..a6647d39 100644 --- a/source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp +++ b/source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp @@ -521,7 +521,7 @@ bool SoundPlayerDs8::findStrBuffer(Sound *sound, int *bufferIndex){ long dsVolume(float floatVolume){ #ifdef USE_STREFLOP - float correctedVol= streflop::log10f(floatVolume*9.f+1.f); + float correctedVol= streflop::log10f(static_cast(floatVolume*9.f+1.f)); #else float correctedVol= log10f(floatVolume*9.f+1.f); #endif