From c086a6774dba68583953d2e5e3f3e8805c5a9444 Mon Sep 17 00:00:00 2001 From: Alayan <25536748+Alayan-stk-2@users.noreply.github.com> Date: Wed, 22 May 2024 23:24:50 +0200 Subject: [PATCH] Misc. improvements - Fix MSVC compilation - Improve some repetitive code --- CMakeLists.txt | 7 ++---- src/states_screens/race_gui_base.cpp | 32 ++++++++-------------------- src/tracks/track.cpp | 2 +- 3 files changed, 12 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64fcec66f..d85449a5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,10 +9,6 @@ add_definitions( -DSUPERTUXKART_VERSION="${PROJECT_VERSION}" ) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") include(CMakeDependentOption) -if(MSVC) - cmake_policy(SET CMP0043 OLD) -endif() - include(BuildTypeSTKRelease) if(NOT CMAKE_BUILD_TYPE) message(STATUS "No build type selected, default to STKRelease") @@ -523,7 +519,8 @@ endif() if(MSVC) # VS will automatically add NDEBUG for release mode, but only _DEBUG in debug mode. # Since STK uses DEBUG, this is added for debug compilation only: - set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS $<$:DEBUG>) + cmake_policy(SET CMP0043 OLD) + set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG) else() # All non VS generators used create only a single compile mode, so # compile flags can be simplye be added diff --git a/src/states_screens/race_gui_base.cpp b/src/states_screens/race_gui_base.cpp index b1c59e0ae..bb3a19adc 100644 --- a/src/states_screens/race_gui_base.cpp +++ b/src/states_screens/race_gui_base.cpp @@ -1034,35 +1034,21 @@ void RaceGUIBase::drawPlayerIcon(AbstractKart *kart, int x, int y, int w, bool is_local) { #ifndef SERVER_ONLY - video::ITexture *icon = - kart->getKartProperties()->getIconMaterial()->getTexture(); + video::ITexture *icon = kart->getKartProperties()->getIconMaterial()->getTexture(); CaptureTheFlag* ctf = dynamic_cast(World::getWorld()); unsigned int kart_id = kart->getWorldKartId(); // CTF - if (ctf) + if (ctf && (ctf->getRedHolder() == (int)kart_id || + ctf->getBlueHolder() == (int)kart_id)) { - if (ctf->getRedHolder() == (int)kart_id) - { - video::ITexture* red = - irr_driver->getTexture(FileManager::GUI_ICON, "red_flag.png"); - const core::rect rect(core::position2d(0, 0), - red->getSize()); - const core::rect pos1 - (x - 20, y - 10, x + w - 20, y + w - 30); - draw2DImage(red, pos1, rect, NULL, NULL, true); - } - else if (ctf->getBlueHolder() == (int)kart_id) - { - video::ITexture* blue = - irr_driver->getTexture(FileManager::GUI_ICON, "blue_flag.png"); - const core::rect rect(core::position2d(0, 0), - blue->getSize()); - const core::rect pos1 - (x - 20, y - 10, x + w - 20, y + w - 30); - draw2DImage(blue, pos1, rect, NULL, NULL, true); - } + video::ITexture* flag = irr_driver->getTexture(FileManager::GUI_ICON, + (ctf->getRedHolder() == (int)kart_id) ? "red_flag.png" : "blue_flag.png"); + + const core::rect rect(core::position2d(0, 0), flag->getSize()); + const core::rect pos1(x - 20, y - 10, x + w - 20, y + w - 30); + draw2DImage(flag, pos1, rect, NULL, NULL, true); } const core::rect pos(x, y, x+w, y+w); diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index ce13b321e..e2219c508 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -936,7 +936,7 @@ void Track::createPhysicsModel(unsigned int main_track_count, // ----------------------------------------------------------------------------- -/** Convert the graohics track into its physics equivalents. +/** Convert the graphics track into its physics equivalents. * \param mesh The mesh to convert. * \param node The scene node. */