Misc. improvements

- Fix MSVC compilation
- Improve some repetitive code
This commit is contained in:
Alayan 2024-05-22 23:24:50 +02:00
parent 2923a86cd6
commit c086a6774d
No known key found for this signature in database
3 changed files with 12 additions and 29 deletions

View File

@ -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 $<$<CONFIG:Debug>: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

View File

@ -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<CaptureTheFlag*>(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<s32> rect(core::position2d<s32>(0, 0),
red->getSize());
const core::rect<s32> 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<s32> rect(core::position2d<s32>(0, 0),
blue->getSize());
const core::rect<s32> 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<s32> rect(core::position2d<s32>(0, 0), flag->getSize());
const core::rect<s32> pos1(x - 20, y - 10, x + w - 20, y + w - 30);
draw2DImage(flag, pos1, rect, NULL, NULL, true);
}
const core::rect<s32> pos(x, y, x+w, y+w);

View File

@ -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.
*/