diff --git a/src/openrct2-ui/interface/InGameConsole.cpp b/src/openrct2-ui/interface/InGameConsole.cpp index eb9fcfc26f..ebf6852c20 100644 --- a/src/openrct2-ui/interface/InGameConsole.cpp +++ b/src/openrct2-ui/interface/InGameConsole.cpp @@ -224,7 +224,7 @@ void InGameConsole::WriteLine(const std::string& input, FormatToken colourFormat { splitPos = input.find('\n', stringOffset); line = input.substr(stringOffset, splitPos - stringOffset); - _consoleLines.push_back(colourCodepoint + line); + _consoleLines.emplace_back(colourCodepoint + line); stringOffset = splitPos + 1; } diff --git a/src/openrct2-ui/title/TitleSequencePlayer.cpp b/src/openrct2-ui/title/TitleSequencePlayer.cpp index fe4c314004..9101fb6aef 100644 --- a/src/openrct2-ui/title/TitleSequencePlayer.cpp +++ b/src/openrct2-ui/title/TitleSequencePlayer.cpp @@ -85,7 +85,7 @@ public: } auto seqItem = TitleSequenceManager::GetItem(titleSequenceId); - auto sequence = LoadTitleSequence(seqItem->Path.c_str()); + auto sequence = LoadTitleSequence(seqItem->Path); if (sequence == nullptr) { return false; @@ -418,7 +418,6 @@ private: } else { - std::string extension = Path::GetExtension(hintPath); bool isScenario = ParkImporter::ExtensionIsScenario(hintPath); auto parkImporter = ParkImporter::Create(hintPath); auto result = parkImporter->LoadFromStream(stream, isScenario); diff --git a/src/openrct2-ui/windows/Changelog.cpp b/src/openrct2-ui/windows/Changelog.cpp index 524ece3bfe..f95c09df9e 100644 --- a/src/openrct2-ui/windows/Changelog.cpp +++ b/src/openrct2-ui/windows/Changelog.cpp @@ -289,7 +289,7 @@ private: { std::string::size_type pos = 0; std::string::size_type prev = 0; - while ((pos = text.find("\n", prev)) != std::string::npos) + while ((pos = text.find('\n', prev)) != std::string::npos) { _changelogLines.push_back(text.substr(prev, pos - prev)); prev = pos + 1; diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index aca5c3e5ed..8ac22a7988 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -926,7 +926,7 @@ static void WindowLoadsavePopulateList( newListItem.time_formatted = Platform::FormatTime(newListItem.date_modified); // Mark if file is the currently loaded game - newListItem.loaded = newListItem.path.compare(gCurrentLoadedPath.c_str()) == 0; + newListItem.loaded = newListItem.path.compare(gCurrentLoadedPath) == 0; // Remove the extension (but only the first extension token) if (!showExtension) diff --git a/src/openrct2-ui/windows/ServerList.cpp b/src/openrct2-ui/windows/ServerList.cpp index 2be7336f67..e3aaf03af6 100644 --- a/src/openrct2-ui/windows/ServerList.cpp +++ b/src/openrct2-ui/windows/ServerList.cpp @@ -518,7 +518,7 @@ static void JoinServer(std::string address) address = address.substr(beginBracketIndex + 1, endBracketIndex - beginBracketIndex - 1); } - if (!network_begin_client(address.c_str(), port)) + if (!network_begin_client(address, port)) { context_show_error(STR_UNABLE_TO_CONNECT_TO_SERVER, STR_NONE, {}); } diff --git a/src/openrct2-ui/windows/ServerStart.cpp b/src/openrct2-ui/windows/ServerStart.cpp index b0d7e89d35..268dac3de3 100644 --- a/src/openrct2-ui/windows/ServerStart.cpp +++ b/src/openrct2-ui/windows/ServerStart.cpp @@ -131,7 +131,7 @@ static void WindowServerStartScenarioselectCallback(const utf8* path) game_notify_map_change(); if (GetContext()->LoadParkFromFile(path, false, true)) { - network_begin_server(gConfigNetwork.default_port, gConfigNetwork.listen_address.c_str()); + network_begin_server(gConfigNetwork.default_port, gConfigNetwork.listen_address); } } @@ -141,7 +141,7 @@ static void WindowServerStartLoadsaveCallback(int32_t result, const utf8* path) { game_notify_map_change(); context_load_park_from_file(path); - network_begin_server(gConfigNetwork.default_port, gConfigNetwork.listen_address.c_str()); + network_begin_server(gConfigNetwork.default_port, gConfigNetwork.listen_address); } } diff --git a/src/openrct2/actions/GameActionResult.cpp b/src/openrct2/actions/GameActionResult.cpp index f24d674a4f..3659a6b772 100644 --- a/src/openrct2/actions/GameActionResult.cpp +++ b/src/openrct2/actions/GameActionResult.cpp @@ -5,10 +5,10 @@ namespace GameActions { Result::Result(GameActions::Status error, rct_string_id title, rct_string_id message, uint8_t* args /*= nullptr*/) + : Error(error) + , ErrorTitle(title) + , ErrorMessage(message) { - Error = error; - ErrorTitle = title; - ErrorMessage = message; if (args != nullptr) { std::copy_n(args, ErrorMessageArgs.size(), ErrorMessageArgs.begin()); diff --git a/src/openrct2/actions/WaterLowerAction.cpp b/src/openrct2/actions/WaterLowerAction.cpp index c3839bb2fe..aa087b0687 100644 --- a/src/openrct2/actions/WaterLowerAction.cpp +++ b/src/openrct2/actions/WaterLowerAction.cpp @@ -122,7 +122,7 @@ GameActions::Result WaterLowerAction::QueryExecute(bool isExecuting) const return res; } -uint8_t WaterLowerAction::GetLowestHeight(MapRange validRange) const +uint8_t WaterLowerAction::GetLowestHeight(const MapRange& validRange) const { // The lowest height to lower the water to is the highest water level in the selection uint8_t minHeight{ 0 }; diff --git a/src/openrct2/actions/WaterLowerAction.h b/src/openrct2/actions/WaterLowerAction.h index ac5058b1db..0f0b885cb8 100644 --- a/src/openrct2/actions/WaterLowerAction.h +++ b/src/openrct2/actions/WaterLowerAction.h @@ -28,5 +28,5 @@ public: private: GameActions::Result QueryExecute(bool isExecuting) const; - uint8_t GetLowestHeight(MapRange validRange) const; + uint8_t GetLowestHeight(const MapRange& validRange) const; }; diff --git a/src/openrct2/actions/WaterRaiseAction.cpp b/src/openrct2/actions/WaterRaiseAction.cpp index ae3b7b0ab7..2272df4a5a 100644 --- a/src/openrct2/actions/WaterRaiseAction.cpp +++ b/src/openrct2/actions/WaterRaiseAction.cpp @@ -128,7 +128,7 @@ GameActions::Result WaterRaiseAction::QueryExecute(bool isExecuting) const return res; } -uint16_t WaterRaiseAction::GetHighestHeight(MapRange validRange) const +uint16_t WaterRaiseAction::GetHighestHeight(const MapRange& validRange) const { // The highest height to raise the water to is the lowest water level in the selection uint16_t maxHeight = 255 * COORDS_Z_STEP; diff --git a/src/openrct2/actions/WaterRaiseAction.h b/src/openrct2/actions/WaterRaiseAction.h index 6c5fbc899a..f1b3b335ce 100644 --- a/src/openrct2/actions/WaterRaiseAction.h +++ b/src/openrct2/actions/WaterRaiseAction.h @@ -28,5 +28,5 @@ public: private: GameActions::Result QueryExecute(bool isExecuting) const; - uint16_t GetHighestHeight(MapRange validRange) const; + uint16_t GetHighestHeight(const MapRange& validRange) const; }; diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index 2dbf478fc2..8e4982f02e 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -739,7 +739,7 @@ namespace Config desc.Filters.emplace_back(language_get_string(STR_ALL_FILES), "*"); const auto userHomePath = Platform::GetFolderPath(SPECIAL_FOLDER::USER_HOME); - desc.InitialDirectory = userHomePath.c_str(); + desc.InitialDirectory = userHomePath; return ContextOpenCommonFileDialog(installerPath, desc, 4096); } diff --git a/src/openrct2/config/IniReader.cpp b/src/openrct2/config/IniReader.cpp index ca070248e6..4dbc09a06d 100644 --- a/src/openrct2/config/IniReader.cpp +++ b/src/openrct2/config/IniReader.cpp @@ -287,7 +287,7 @@ private: } } - void ParseSectionValues(LineRange range) + void ParseSectionValues(const LineRange& range) { for (size_t i = range.Start + 1; i <= range.End; i++) { diff --git a/src/openrct2/scripting/ScriptEngine.cpp b/src/openrct2/scripting/ScriptEngine.cpp index aa4e2b431c..52b8987b51 100644 --- a/src/openrct2/scripting/ScriptEngine.cpp +++ b/src/openrct2/scripting/ScriptEngine.cpp @@ -457,7 +457,7 @@ void ScriptEngine::RefreshPlugins() { if (plugin->HasPath()) { - plugins.push_back(std::string(plugin->GetPath())); + plugins.emplace_back(plugin->GetPath()); } } @@ -580,7 +580,7 @@ void ScriptEngine::StopUnloadRegisterAllPlugins() std::vector pluginPaths; for (auto& plugin : _plugins) { - pluginPaths.push_back(std::string(plugin->GetPath())); + pluginPaths.emplace_back(plugin->GetPath()); StopPlugin(plugin); } for (auto& plugin : _plugins)