mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 19:13:07 +01:00
Add const ref, remove excess .c_str(), push_* -> emplace_* and rewrite constructors
This commit is contained in:
committed by
Hielke Morsink
parent
cdc1a912d3
commit
0045aed7f9
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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, {});
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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++)
|
||||
{
|
||||
|
||||
@@ -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<std::string> pluginPaths;
|
||||
for (auto& plugin : _plugins)
|
||||
{
|
||||
pluginPaths.push_back(std::string(plugin->GetPath()));
|
||||
pluginPaths.emplace_back(plugin->GetPath());
|
||||
StopPlugin(plugin);
|
||||
}
|
||||
for (auto& plugin : _plugins)
|
||||
|
||||
Reference in New Issue
Block a user