From f586981cd3d81c419b9e94ee6eae1c97bf4e347e Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 28 Sep 2020 16:50:11 +0300 Subject: [PATCH] Use std::string for TitleSequence names Co-authored-by: Gabriel Guedes --- src/openrct2-ui/title/TitleSequencePlayer.cpp | 2 +- src/openrct2/title/TitleSequence.cpp | 7 +++---- src/openrct2/title/TitleSequence.h | 2 +- src/openrct2/title/TitleSequenceManager.cpp | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/openrct2-ui/title/TitleSequencePlayer.cpp b/src/openrct2-ui/title/TitleSequencePlayer.cpp index 0af76d8575..3ddddc02a1 100644 --- a/src/openrct2-ui/title/TitleSequencePlayer.cpp +++ b/src/openrct2-ui/title/TitleSequencePlayer.cpp @@ -159,7 +159,7 @@ public: { if (!SkipToNextLoadCommand() || _position == entryPosition) { - Console::Error::WriteLine("Unable to load any parks from %s.", _sequence->Name); + Console::Error::WriteLine("Unable to load any parks from %s.", _sequence->Name.c_str()); return false; } } diff --git a/src/openrct2/title/TitleSequence.cpp b/src/openrct2/title/TitleSequence.cpp index 1fc6ed487a..0dfee1a70f 100644 --- a/src/openrct2/title/TitleSequence.cpp +++ b/src/openrct2/title/TitleSequence.cpp @@ -1,4 +1,4 @@ -/***************************************************************************** +/***************************************************************************** * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md @@ -89,7 +89,7 @@ std::unique_ptr LoadTitleSequence(const utf8* path) auto commands = LegacyScriptRead(reinterpret_cast(script.data()), script.size(), saves); auto seq = CreateTitleSequence(); - seq->Name = Path::GetFileNameWithoutExtension(path); + seq->Name = Path::GetFileNameWithoutExtension(std::string(path)); seq->Path = String::Duplicate(path); for (auto* save : saves) { @@ -102,7 +102,6 @@ std::unique_ptr LoadTitleSequence(const utf8* path) void FreeTitleSequence(TitleSequence& seq) { - Memory::Free(seq.Name); Memory::Free(seq.Path); } @@ -527,7 +526,7 @@ static std::string LegacyScriptWrite(const TitleSequence& seq) auto sb = StringBuilder(128); sb.Append("# SCRIPT FOR "); - sb.Append(seq.Name); + sb.Append(seq.Name.c_str()); sb.Append("\n"); for (const auto& command : seq.Commands) { diff --git a/src/openrct2/title/TitleSequence.h b/src/openrct2/title/TitleSequence.h index fdd7c55f7e..565801ca67 100644 --- a/src/openrct2/title/TitleSequence.h +++ b/src/openrct2/title/TitleSequence.h @@ -42,7 +42,7 @@ struct TitleCommand struct TitleSequence { - const utf8* Name = nullptr; + std::string Name; const utf8* Path = nullptr; std::vector Commands; diff --git a/src/openrct2/title/TitleSequenceManager.cpp b/src/openrct2/title/TitleSequenceManager.cpp index 4bab37842c..48d3f81e11 100644 --- a/src/openrct2/title/TitleSequenceManager.cpp +++ b/src/openrct2/title/TitleSequenceManager.cpp @@ -139,7 +139,7 @@ namespace TitleSequenceManager { std::string path = GetNewTitleSequencePath(std::string(name), true); auto seq = CreateTitleSequence(); - seq->Name = String::Duplicate(name); + seq->Name = name; seq->Path = String::Duplicate(path.c_str()); seq->IsZip = true;