diff --git a/contributors.md b/contributors.md index be04a6a6ba..21a6293c65 100644 --- a/contributors.md +++ b/contributors.md @@ -112,6 +112,7 @@ The following people are not part of the development team, but have been contrib * Patrick Martinez (martip23) * Andy Ford (AndyTWF) * Matthew Beaudin (mattbeaudin) +* Øystein Dale (oystedal) ## Toolchain * (Balletie) - macOS diff --git a/src/openrct2/config/IniReader.cpp b/src/openrct2/config/IniReader.cpp index 112f37a595..5dc2233c47 100644 --- a/src/openrct2/config/IniReader.cpp +++ b/src/openrct2/config/IniReader.cpp @@ -354,7 +354,7 @@ private: sb.Append(&c, 1); } } - return std::string(sb.GetString()); + return sb.GetStdString(); } std::string GetLine(size_t index) diff --git a/src/openrct2/core/StringBuilder.hpp b/src/openrct2/core/StringBuilder.hpp index 4d072fb424..b993f21820 100644 --- a/src/openrct2/core/StringBuilder.hpp +++ b/src/openrct2/core/StringBuilder.hpp @@ -10,6 +10,7 @@ #pragma once #include +#include #include "../common.h" #include "Math.hpp" @@ -132,6 +133,14 @@ public: return result; } + /** + * Returns the current string buffer as a standard string. + */ + std::string GetStdString() const + { + return std::string(_buffer, _length); + } + /** * Gets the current state of the StringBuilder. Warning: this represents the StringBuilder's current working buffer and will * be deallocated when the StringBuilder is destructed. diff --git a/src/openrct2/localisation/LanguagePack.cpp b/src/openrct2/localisation/LanguagePack.cpp index 49183186a6..a8e079277a 100644 --- a/src/openrct2/localisation/LanguagePack.cpp +++ b/src/openrct2/localisation/LanguagePack.cpp @@ -389,7 +389,7 @@ private: } if (sb.GetLength() == 8) { - _currentGroup = sb.GetString(); + _currentGroup = sb.GetStdString(); _currentObjectOverride = GetObjectOverride(_currentGroup); _currentScenarioOverride = nullptr; if (_currentObjectOverride == nullptr) @@ -432,7 +432,7 @@ private: if (closedCorrectly) { - _currentGroup = sb.GetString(); + _currentGroup = sb.GetStdString(); _currentObjectOverride = nullptr; _currentScenarioOverride = GetScenarioOverride(_currentGroup); if (_currentScenarioOverride == nullptr) diff --git a/src/openrct2/object/ObjectRepository.cpp b/src/openrct2/object/ObjectRepository.cpp index 0412128b96..66e032c095 100644 --- a/src/openrct2/object/ObjectRepository.cpp +++ b/src/openrct2/object/ObjectRepository.cpp @@ -156,8 +156,8 @@ protected: ObjectRepositoryItem item; item.ObjectEntry = stream->ReadValue(); - item.Path = stream->ReadString(); - item.Name = stream->ReadString(); + item.Path = stream->ReadStdString(); + item.Name = stream->ReadStdString(); switch (object_entry_get_type(&item.ObjectEntry)) { case OBJECT_TYPE_RIDE: