diff --git a/src/openrct2/core/Optional.hpp b/src/openrct2/core/Optional.hpp deleted file mode 100644 index 66c67028fb..0000000000 --- a/src/openrct2/core/Optional.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers - * - * For a complete list of all authors, please refer to contributors.md - * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 - * - * OpenRCT2 is licensed under the GNU General Public License version 3. - *****************************************************************************/ - -#pragma once - -#ifdef __has_include -# if __has_include() -# include -# elif __has_include() -# include -# else -# error Missing -# endif -#else -# error __has_include is not defined -#endif - -// `optional` and friends will be available in NS `::opt` -#if __has_include() -namespace opt = std; -#elif __has_include() -namespace opt = std::experimental; -#endif diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index d00fea053a..c3691f6bd3 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -17,7 +17,6 @@ #include "../audio/audio.h" #include "../core/Console.hpp" #include "../core/Imaging.h" -#include "../core/Optional.hpp" #include "../drawing/Drawing.h" #include "../drawing/X8DrawingEngine.h" #include "../localisation/Localisation.h" @@ -33,6 +32,7 @@ #include #include #include +#include #include using namespace std::literals::string_literals; @@ -135,7 +135,7 @@ static std::string screenshot_get_formatted_date_time() return formatted; } -static opt::optional screenshot_get_next_path() +static std::optional screenshot_get_next_path() { auto screenshotDirectory = screenshot_get_directory(); if (!platform_ensure_directory_exists(screenshotDirectory.c_str())) @@ -173,7 +173,7 @@ std::string screenshot_dump_png(rct_drawpixelinfo* dpi) // Get a free screenshot path auto path = screenshot_get_next_path(); - if (path == opt::nullopt) + if (path == std::nullopt) { return ""; } @@ -193,7 +193,7 @@ std::string screenshot_dump_png_32bpp(int32_t width, int32_t height, const void* { auto path = screenshot_get_next_path(); - if (path == opt::nullopt) + if (path == std::nullopt) { return ""; } @@ -398,7 +398,7 @@ void screenshot_giant() try { auto path = screenshot_get_next_path(); - if (path == opt::nullopt) + if (path == std::nullopt) { throw std::runtime_error("Giant screenshot failed, unable to find a suitable destination path."); } diff --git a/src/openrct2/interface/Viewport.h b/src/openrct2/interface/Viewport.h index 62e2dadc81..1ab5025973 100644 --- a/src/openrct2/interface/Viewport.h +++ b/src/openrct2/interface/Viewport.h @@ -10,10 +10,10 @@ #ifndef _VIEWPORT_H_ #define _VIEWPORT_H_ -#include "../core/Optional.hpp" #include "../world/Location.hpp" #include "Window.h" +#include #include struct paint_session; diff --git a/src/openrct2/management/Research.h b/src/openrct2/management/Research.h index 9a677f4cf0..6ff0f1f4f2 100644 --- a/src/openrct2/management/Research.h +++ b/src/openrct2/management/Research.h @@ -10,10 +10,11 @@ #pragma once #include "../common.h" -#include "../core/Optional.hpp" #include "../object/ObjectLimits.h" #include "../ride/Ride.h" +#include + struct rct_ride_entry; struct ResearchItem diff --git a/src/openrct2/network/ServerList.cpp b/src/openrct2/network/ServerList.cpp index 7bc8c18e75..951254b572 100644 --- a/src/openrct2/network/ServerList.cpp +++ b/src/openrct2/network/ServerList.cpp @@ -26,6 +26,7 @@ # include # include +# include using namespace OpenRCT2; @@ -75,7 +76,7 @@ bool ServerListEntry::IsVersionValid() const return version.empty() || version == network_get_version(); } -opt::optional ServerListEntry::FromJson(const json_t* server) +std::optional ServerListEntry::FromJson(const json_t* server) { auto port = json_object_get(server, "port"); auto name = json_object_get(server, "name"); diff --git a/src/openrct2/network/ServerList.h b/src/openrct2/network/ServerList.h index b0cb5e1bc2..75bff4eddd 100644 --- a/src/openrct2/network/ServerList.h +++ b/src/openrct2/network/ServerList.h @@ -10,9 +10,9 @@ #pragma once #include "../common.h" -#include "../core/Optional.hpp" #include +#include #include #include #include @@ -35,7 +35,7 @@ struct ServerListEntry int32_t CompareTo(const ServerListEntry& other) const; bool IsVersionValid() const; - static opt::optional FromJson(const json_t* root); + static std::optional FromJson(const json_t* root); }; class ServerList diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index ca607cad82..10807ba097 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -11,7 +11,6 @@ #define _PEEP_H_ #include "../common.h" -#include "../core/Optional.hpp" #include "../management/Finance.h" #include "../rct12/RCT12.h" #include "../ride/Ride.h" @@ -20,6 +19,7 @@ #include "../world/SpriteBase.h" #include +#include #define PEEP_MAX_THOUGHTS 5 #define PEEP_THOUGHT_ITEM_NONE 255 diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index ac6f1db38f..44bd24d74d 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -50,6 +50,7 @@ #include #include #include +#include S6Exporter::S6Exporter() { @@ -457,7 +458,7 @@ void S6Exporter::ExportParkName() { auto& park = OpenRCT2::GetContext()->GetGameState()->GetPark(); auto stringId = AllocateUserString(park.Name); - if (stringId != opt::nullopt) + if (stringId != std::nullopt) { _s6.park_name = *stringId; _s6.park_name_args = 0; @@ -517,7 +518,7 @@ void S6Exporter::ExportRide(rct2_ride* dst, const Ride* src) { // Custom name, allocate user string for ride auto stringId = AllocateUserString(src->custom_name); - if (stringId != opt::nullopt) + if (stringId != std::nullopt) { dst->name = *stringId; dst->name_arguments = 0; @@ -1067,7 +1068,7 @@ void S6Exporter::ExportSpritePeep(RCT2SpritePeep* dst, const Peep* src) if (src->name != nullptr) { auto stringId = AllocateUserString(src->name); - if (stringId != opt::nullopt) + if (stringId != std::nullopt) { dst->name_string_idx = *stringId; generateName = false; @@ -1338,7 +1339,7 @@ void S6Exporter::ExportBanner(RCT12Banner& dst, const Banner& src) } auto stringId = AllocateUserString(bannerText); - if (stringId != opt::nullopt) + if (stringId != std::nullopt) { dst.string_idx = *stringId; } @@ -1551,7 +1552,7 @@ void S6Exporter::ExportTileElement(RCT12TileElement* dst, TileElement* src) } } -opt::optional S6Exporter::AllocateUserString(const std::string_view& value) +std::optional S6Exporter::AllocateUserString(const std::string_view& value) { auto nextId = _userStrings.size(); if (nextId < RCT12_MAX_USER_STRINGS) diff --git a/src/openrct2/rct2/S6Exporter.h b/src/openrct2/rct2/S6Exporter.h index a37dd18fe8..ef831ec8a3 100644 --- a/src/openrct2/rct2/S6Exporter.h +++ b/src/openrct2/rct2/S6Exporter.h @@ -10,10 +10,10 @@ #pragma once #include "../common.h" -#include "../core/Optional.hpp" #include "../object/ObjectList.h" #include "../scenario/Scenario.h" +#include #include #include #include @@ -72,6 +72,6 @@ private: void ExportTileElements(); void ExportTileElement(RCT12TileElement* dst, TileElement* src); - opt::optional AllocateUserString(const std::string_view& value); + std::optional AllocateUserString(const std::string_view& value); void ExportUserStrings(); }; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 8b56ae0855..9890924ca1 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -25,7 +25,6 @@ #include "../common.h" #include "../config/Config.h" #include "../core/Guard.hpp" -#include "../core/Optional.hpp" #include "../interface/Window.h" #include "../localisation/Date.h" #include "../localisation/Localisation.h" @@ -70,6 +69,7 @@ #include #include #include +#include using namespace OpenRCT2; @@ -6594,9 +6594,9 @@ uint64_t ride_entry_get_supported_track_pieces(const rct_ride_entry* rideEntry) return supportedPieces; } -static opt::optional ride_get_smallest_station_length(Ride* ride) +static std::optional ride_get_smallest_station_length(Ride* ride) { - opt::optional result; + std::optional result; for (const auto& station : ride->stations) { if (!station.Start.isNull())