diff --git a/contributors.md b/contributors.md index db7f1bd1a6..ef6ceb7565 100644 --- a/contributors.md +++ b/contributors.md @@ -77,6 +77,7 @@ Includes all git commit authors. Aliases are GitHub user names. * Jake Breen (Haekb) * Marco Benzi Tobar (Lisergishnu) * Richard Jenkins (rwjuk) +* (ceeac) ## Toolchain * (Balletie) - macOS diff --git a/src/openrct2/core/Path.cpp b/src/openrct2/core/Path.cpp index 0b3f9f5c96..849b78a50d 100644 --- a/src/openrct2/core/Path.cpp +++ b/src/openrct2/core/Path.cpp @@ -44,7 +44,10 @@ namespace Path std::string GetDirectory(const std::string &path) { - return GetDirectory(path.c_str()); + const utf8* directory = GetDirectory(path.c_str()); + std::string result(directory); + Memory::Free(directory); + return result; } utf8 * GetDirectory(const utf8 * path) diff --git a/src/openrct2/title/TitleSequence.cpp b/src/openrct2/title/TitleSequence.cpp index 786235e98b..0c82dae072 100644 --- a/src/openrct2/title/TitleSequence.cpp +++ b/src/openrct2/title/TitleSequence.cpp @@ -54,7 +54,7 @@ extern "C" TitleSequence * LoadTitleSequence(const utf8 * path) { size_t scriptLength; - char * script; + utf8 * script; std::vector saves; bool isZip; @@ -70,7 +70,7 @@ extern "C" return nullptr; } - script = (char *)zip->GetFileData("script.txt", &scriptLength); + script = (utf8 *)zip->GetFileData("script.txt", &scriptLength); if (script == nullptr) { Console::Error::WriteLine("Unable to open script.txt in '%s'", path); @@ -88,7 +88,7 @@ extern "C" utf8 scriptPath[MAX_PATH]; String::Set(scriptPath, sizeof(scriptPath), path); Path::Append(scriptPath, sizeof(scriptPath), "script.txt"); - script = (char *)ReadScriptFile(scriptPath, &scriptLength); + script = (utf8 *)ReadScriptFile(scriptPath, &scriptLength); if (script == nullptr) { Console::Error::WriteLine("Unable to open '%s'", scriptPath); @@ -100,6 +100,7 @@ extern "C" } std::vector commands = LegacyScriptRead(script, scriptLength, saves); + Memory::Free(script); TitleSequence * seq = CreateTitleSequence(); seq->Name = Path::GetFileNameWithoutExtension(path); @@ -165,6 +166,7 @@ extern "C" { Memory::Free(handle->HintPath); delete ((IStream *)handle->Stream); + Memory::Free(handle); } } diff --git a/src/openrct2/title/TitleSequence.h b/src/openrct2/title/TitleSequence.h index 259d2354fd..6c1ed64858 100644 --- a/src/openrct2/title/TitleSequence.h +++ b/src/openrct2/title/TitleSequence.h @@ -88,6 +88,11 @@ extern "C" void FreeTitleSequence(TitleSequence * seq); TitleSequenceParkHandle * TitleSequenceGetParkHandle(TitleSequence * seq, size_t index); + + /** + * Close a title sequence park handle. + * The pointer to the handle is invalid after calling this function. + */ void TitleSequenceCloseParkHandle(TitleSequenceParkHandle * handle); bool TileSequenceSave(TitleSequence * seq); bool TileSequenceAddPark(TitleSequence * seq, const utf8 * path, const utf8 * name); diff --git a/src/openrct2/title/TitleSequenceManager.cpp b/src/openrct2/title/TitleSequenceManager.cpp index d5efdadb8f..7d32825cb3 100644 --- a/src/openrct2/title/TitleSequenceManager.cpp +++ b/src/openrct2/title/TitleSequenceManager.cpp @@ -267,7 +267,7 @@ namespace TitleSequenceManager if (item.PredefinedIndex != PREDEFINED_INDEX_CUSTOM) { rct_string_id stringId = PredefinedSequences[item.PredefinedIndex].StringId; - item.Name = String::Duplicate(language_get_string(stringId)); + item.Name = language_get_string(stringId); } item.IsZip = isZip; _items.push_back(item);