Codechange: Store GameStrings as shared_ptr. (#13905)

Uses shared_ptr/weak_ptr as LanguageScanner needs access without ownership.
This commit is contained in:
Peter Nelson
2025-03-28 17:44:43 +00:00
committed by GitHub
parent d95422561b
commit a361841848
2 changed files with 14 additions and 14 deletions
+3 -5
View File
@@ -113,7 +113,7 @@ struct GSDTChunkHandler : ChunkHandler {
}
};
extern GameStrings *_current_data;
extern std::shared_ptr<GameStrings> _current_data;
static std::string _game_saveload_string;
static uint32_t _game_saveload_strings;
@@ -159,8 +159,7 @@ struct GSTRChunkHandler : ChunkHandler {
{
const std::vector<SaveLoad> slt = SlCompatTableHeader(_game_language_desc, _game_language_sl_compat);
delete _current_data;
_current_data = new GameStrings();
_current_data = std::make_shared<GameStrings>();
while (SlIterateArray() != -1) {
LanguageStrings ls;
@@ -170,8 +169,7 @@ struct GSTRChunkHandler : ChunkHandler {
/* If there were no strings in the savegame, set GameStrings to nullptr */
if (_current_data->raw_strings.empty()) {
delete _current_data;
_current_data = nullptr;
_current_data.reset();
return;
}