diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index b30e36997a..f3909d6159 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -24,7 +24,7 @@ "/Library/Frameworks" ], "cStandard": "c11", - "cppStandard": "c++17" + "cppStandard": "c++20" }, { "name": "Linux", diff --git a/CMakeLists.txt b/CMakeLists.txt index 82476ec069..7c551951e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,7 @@ endif () include(CheckCXXCompilerFlag) include(GNUInstallDirs) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}") @@ -277,6 +277,9 @@ if (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244") # C4244: 'conversion_type': conversion from 'type1' to 'type2', possible loss of data set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4068") # C4068: unknown pragma + # Enable char8_t<->char conversion :( + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:char8_t-") + add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_SCL_SECURE_NO_WARNINGS) if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") @@ -331,6 +334,9 @@ else () set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas -Wno-missing-braces -Wno-comment -Wnonnull -Wno-unused-parameter -Wno-attributes") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG=${DEBUG_LEVEL}") + # Enable char8_t<->char conversion :( + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-char8_t -Wno-deprecated-declarations") + if(APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=objc-method-access") endif() diff --git a/openrct2.common.props b/openrct2.common.props index ecb0b4a280..a884253606 100644 --- a/openrct2.common.props +++ b/openrct2.common.props @@ -65,7 +65,7 @@ MultiThreadedDLL true true - /utf-8 /std:c++17 /permissive- /Zc:externConstexpr + /utf-8 /std:c++20 /permissive- /Zc:externConstexpr /Zc:char8_t- true diff --git a/readme.md b/readme.md index bb732bb78c..b71aa9ed44 100644 --- a/readme.md +++ b/readme.md @@ -135,7 +135,7 @@ OpenRCT2 requires original files of RollerCoaster Tycoon 2 to play. It can be bo
Linux prerequisites - - gcc (>= 7.1) or clang (>= 8.0.0) (for C++17 support) + - gcc (>= 8.0) or clang (>= 10.0) (for C++20 support) - sdl2 (only for UI client) - freetype (can be disabled) - fontconfig (can be disabled) diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index e23000c078..d24ffce194 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -1034,18 +1034,28 @@ private: auto footpathPlaceAction = FootpathPlaceAction( footpathLoc, slope, type, gFootpathSelection.Railings, _footpathConstructDirection, constructFlags); - footpathPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + + footpathPlaceAction.SetCallback([footpathLoc](const GameAction* ga, const GameActions::Result* result) { if (result->Error == GameActions::Status::Ok) { - OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position); + Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position); + } + auto* self = static_cast(WindowFindByClass(WindowClass::Footpath)); + if (self == nullptr) + { + return; + } + + if (result->Error == GameActions::Status::Ok) + { if (gFootpathConstructSlope == 0) { - _footpathConstructValidDirections = INVALID_DIRECTION; + self->_footpathConstructValidDirections = INVALID_DIRECTION; } else { - _footpathConstructValidDirections = _footpathConstructDirection; + self->_footpathConstructValidDirections = self->_footpathConstructDirection; } if (gFootpathGroundFlags & ELEMENT_IS_UNDERGROUND) @@ -1062,7 +1072,7 @@ private: gFootpathConstructFromPosition.z += PATH_HEIGHT_STEP; } } - WindowFootpathSetEnabledAndPressedWidgets(); + self->WindowFootpathSetEnabledAndPressedWidgets(); }); GameActions::Execute(&footpathPlaceAction); } diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index c60d455790..1871352059 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -104,11 +104,11 @@ private: return firstStrId; } - bool operator==(const FilterArguments& other) + bool operator==(const FilterArguments& other) const { return std::memcmp(args, other.args, sizeof(args)) == 0; } - bool operator!=(const FilterArguments& other) + bool operator!=(const FilterArguments& other) const { return !(*this == other); } diff --git a/src/openrct2-ui/windows/ObjectLoadError.cpp b/src/openrct2-ui/windows/ObjectLoadError.cpp index cd7669f95d..b3ce56655a 100644 --- a/src/openrct2-ui/windows/ObjectLoadError.cpp +++ b/src/openrct2-ui/windows/ObjectLoadError.cpp @@ -42,11 +42,11 @@ private: size_t Count{}; size_t Total{}; - bool operator==(const DownloadStatusInfo& rhs) + bool operator==(const DownloadStatusInfo& rhs) const { return Name == rhs.Name && Source == rhs.Source && Count == rhs.Count && Total == rhs.Total; } - bool operator!=(const DownloadStatusInfo& rhs) + bool operator!=(const DownloadStatusInfo& rhs) const { return !(*this == rhs); } diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 44b2c8d3b4..93043edaf0 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -3230,9 +3230,10 @@ public: // Draw an overlay if clearance checks are disabled if (gCheatsDisableClearanceChecks) { + auto colour = static_cast(EnumValue(COLOUR_DARK_ORANGE) | EnumValue(COLOUR_FLAG_OUTLINE)); DrawTextBasic( dpi, screenPos + ScreenCoordsXY{ 26, 2 }, STR_OVERLAY_CLEARANCE_CHECKS_DISABLED, {}, - { COLOUR_DARK_ORANGE | COLOUR_FLAG_OUTLINE, TextAlignment::RIGHT }); + { colour, TextAlignment::RIGHT }); } } @@ -3295,9 +3296,8 @@ public: // Draw number of players. auto ft = Formatter(); ft.Add(NetworkGetNumVisiblePlayers()); - DrawTextBasic( - dpi, screenPos + ScreenCoordsXY{ 23, 1 }, STR_COMMA16, ft, - { COLOUR_WHITE | COLOUR_FLAG_OUTLINE, TextAlignment::RIGHT }); + auto colour = static_cast(EnumValue(COLOUR_WHITE) | EnumValue(COLOUR_FLAG_OUTLINE)); + DrawTextBasic(dpi, screenPos + ScreenCoordsXY{ 23, 1 }, STR_COMMA16, ft, { colour, TextAlignment::RIGHT }); } } }; diff --git a/src/openrct2/drawing/Rect.cpp b/src/openrct2/drawing/Rect.cpp index 747731e84d..e9044dd5b3 100644 --- a/src/openrct2/drawing/Rect.cpp +++ b/src/openrct2/drawing/Rect.cpp @@ -30,18 +30,9 @@ void GfxFillRectInset(DrawPixelInfo& dpi, const ScreenRect& rect, int32_t colour const auto leftBottom = ScreenCoordsXY{ rect.GetLeft(), rect.GetBottom() }; const auto rightTop = ScreenCoordsXY{ rect.GetRight(), rect.GetTop() }; const auto rightBottom = ScreenCoordsXY{ rect.GetRight(), rect.GetBottom() }; - if (colour & (COLOUR_FLAG_TRANSLUCENT | COLOUR_FLAG_8)) + if (colour & COLOUR_FLAG_TRANSLUCENT) { - TranslucentWindowPalette palette; - if (colour & COLOUR_FLAG_8) - { - // TODO: This can't be added up - // palette = NOT_TRANSLUCENT(colour); - assert(false); - return; - } - - palette = TranslucentWindowPalettes[BASE_COLOUR(colour)]; + auto palette = TranslucentWindowPalettes[BASE_COLOUR(colour)]; if (flags & INSET_RECT_FLAG_BORDER_NONE) { diff --git a/src/openrct2/interface/Colour.h b/src/openrct2/interface/Colour.h index 2f5d90bfb2..9a47f2a7cb 100644 --- a/src/openrct2/interface/Colour.h +++ b/src/openrct2/interface/Colour.h @@ -212,12 +212,11 @@ constexpr uint8_t COLOUR_NUM_NORMAL = 54; #define TEXT_COLOUR_254 (254) #define TEXT_COLOUR_255 (255) -enum +enum : colour_t { COLOUR_FLAG_OUTLINE = (1 << 5), COLOUR_FLAG_INSET = (1 << 6), // 64, 0x40 COLOUR_FLAG_TRANSLUCENT = (1 << 7), - COLOUR_FLAG_8 = (1 << 8) }; #define TRANSLUCENT(x) ((x) | static_cast(COLOUR_FLAG_TRANSLUCENT))