From 51db0d3445b18c6eb25e62fb5fc6dba2dfaec1b3 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 7 Mar 2020 16:57:06 +0000 Subject: [PATCH] Fix build on ARM, considering real number being float in this case. Fixing editor build too. --- CMakeLists.txt | 6 ++++++ src/actplayer.cpp | 16 ++++++++-------- src/editor.cpp | 5 +++-- src/monster_insectoid.cpp | 4 ++-- src/sound.cpp | 10 +++++----- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e62e94f06..129d7c5a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,6 +95,12 @@ if( NOT WIN32 ) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -malign-double") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -malign-double") endif() + if (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "arm") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fsingle-precision-constant") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsingle-precision-constant") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fsingle-precision-constant") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fsingle-precision-constant") + endif() set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -rdynamic -Wl,-rpath=$ORIGIN") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11 -rdynamic -Wl,-rpath=$ORIGIN") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wl,-rpath=$ORIGIN -Wno-write-strings") diff --git a/src/actplayer.cpp b/src/actplayer.cpp index 8b9d0947b..3ba820b14 100644 --- a/src/actplayer.cpp +++ b/src/actplayer.cpp @@ -3391,14 +3391,14 @@ void actPlayer(Entity* my) DEX = std::min(DEX - 3, -2); slowSpeedPenalty = 2.0; } - real_t speedFactor = std::min((DEX * 0.1 + 15.5 - slowSpeedPenalty) * weightratio, 18.0); + real_t speedFactor = std::min(static_cast((DEX * 0.1 + 15.5 - slowSpeedPenalty) * weightratio), 18.0); if ( DEX <= 5 ) { - speedFactor = std::min((DEX + 10) * weightratio, 18.0); + speedFactor = std::min(static_cast((DEX + 10) * weightratio), 18.0); } else if ( DEX <= 15 ) { - speedFactor = std::min((DEX * 0.2 + 14 - slowSpeedPenalty) * weightratio, 18.0); + speedFactor = std::min(static_cast((DEX * 0.2 + 14 - slowSpeedPenalty) * weightratio), 18.0); } /*if ( ticks % 50 == 0 ) { @@ -5183,11 +5183,11 @@ void actPlayer(Entity* my) { if ( insectoidLevitating[PLAYER_NUM] ) { - entity->fskill[0] += std::min(std::max(0.2, dist * PLAYERWALKSPEED), 2.f * PLAYERWALKSPEED); // move proportional to move speed + entity->fskill[0] += std::min(std::max(0.2, static_cast(dist * PLAYERWALKSPEED)), static_cast(2.0 * PLAYERWALKSPEED)); // move proportional to move speed } else { - entity->fskill[0] += std::min(dist * PLAYERWALKSPEED, 2.f * PLAYERWALKSPEED); // move proportional to move speed + entity->fskill[0] += std::min(static_cast(dist * PLAYERWALKSPEED), static_cast(2.0 * PLAYERWALKSPEED)); // move proportional to move speed } } else if ( PLAYER_ATTACK != 0 ) @@ -5213,11 +5213,11 @@ void actPlayer(Entity* my) { if ( insectoidLevitating[PLAYER_NUM] ) { - entity->fskill[0] -= std::min(std::max(0.15, dist * PLAYERWALKSPEED), 2.f * PLAYERWALKSPEED); + entity->fskill[0] -= std::min(std::max(0.15, static_cast(dist * PLAYERWALKSPEED)), static_cast(2.0 * PLAYERWALKSPEED)); // move proportional to move speed } else { - entity->fskill[0] -= std::min(dist * PLAYERWALKSPEED, 2.f * PLAYERWALKSPEED); + entity->fskill[0] -= std::min(static_cast(dist * PLAYERWALKSPEED), static_cast(2.0 * PLAYERWALKSPEED)); // move proportional to move speed } } else if ( PLAYER_ATTACK != 0 ) @@ -6619,4 +6619,4 @@ void playerAnimateSpider(Entity* my) break; } } -} \ No newline at end of file +} diff --git a/src/editor.cpp b/src/editor.cpp index e397a4866..911496c9d 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -287,6 +287,7 @@ void closeNetworkInterfaces() -------------------------------------------------------------------------------*/ view_t camera_vel; +view_t &camera = cameras[0]; void mainLogic(void) { @@ -4522,7 +4523,7 @@ int main(int argc, char** argv) color = SDL_MapRGB(mainsurface->format, 0, 255, 0); char tmpStr[32] = ""; strcpy(tmpStr, spriteProperties[i]); //reset - strcat(tmpStr, " Tiles to power in facing direction"); + strcat(tmpStr, " Tiles to power in facing dir."); printTextFormattedColor(font8x8_bmp, pad_x3, pad_y2, color, tmpStr); } } @@ -7413,4 +7414,4 @@ void reselectEntityGroup() int generateDungeon(char* levelset, Uint32 seed, std::tuple mapParameters) { return 0; // dummy function -} \ No newline at end of file +} diff --git a/src/monster_insectoid.cpp b/src/monster_insectoid.cpp index c359b068c..a65cc5fcc 100644 --- a/src/monster_insectoid.cpp +++ b/src/monster_insectoid.cpp @@ -1483,7 +1483,7 @@ void insectoidMoveBodyparts(Entity* my, Stat* myStats, double dist) { if ( moving ) { - entity->fskill[0] += std::min(dist * INSECTOIDWALKSPEED, 2.f * INSECTOIDWALKSPEED); // move proportional to move speed + entity->fskill[0] += std::min(static_cast(dist * INSECTOIDWALKSPEED), static_cast(2.0 * INSECTOIDWALKSPEED)); // move proportional to move speed } else if ( my->monsterAttack != 0 ) { @@ -1504,7 +1504,7 @@ void insectoidMoveBodyparts(Entity* my, Stat* myStats, double dist) { if ( moving ) { - entity->fskill[0] -= std::min(dist * INSECTOIDWALKSPEED, 2.f * INSECTOIDWALKSPEED); + entity->fskill[0] -= std::min(static_cast(dist * INSECTOIDWALKSPEED), static_cast(2.0 * INSECTOIDWALKSPEED)); } else if ( my->monsterAttack != 0 ) { diff --git a/src/sound.cpp b/src/sound.cpp index 861547d22..ab6918b37 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -587,9 +587,9 @@ void sound_update() } FMOD_VECTOR position; - position.x = -camera.y; - position.y = -camera.z / 32; - position.z = -camera.x; + position.x = -cameras[0].y; + position.y = -cameras[0].z / 32; + position.z = -cameras[0].x; /*double cosroll = cos(0); double cosyaw = cos(camera.ang); @@ -603,9 +603,9 @@ void sound_update() double rz = cosroll*cospitch;*/ float vector[6]; - vector[0] = 1 * sin(camera.ang); + vector[0] = 1 * sin(cameras[0].ang); vector[1] = 0; - vector[2] = 1 * cos(camera.ang); + vector[2] = 1 * cos(cameras[0].ang); /*forward.x = rx; forward.y = ry; forward.z = rz;*/