From f58c4d9bdb24a1176b78e8e8734ca5fa1e292c04 Mon Sep 17 00:00:00 2001 From: Walter Agazzi Date: Mon, 27 Feb 2023 22:13:43 +0100 Subject: [PATCH] AGS: Common: replaced couple of smart ptr arrays with std::vector From upstream c1afae64fe348c64ee4a8c8888349ae267241395 --- engines/ags/engine/ac/dialog.cpp | 2 +- engines/ags/globals.h | 2 +- engines/ags/shared/game/main_game_file.cpp | 10 ++++------ engines/ags/shared/game/main_game_file.h | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/engines/ags/engine/ac/dialog.cpp b/engines/ags/engine/ac/dialog.cpp index fa10284709f..1223bdc745a 100644 --- a/engines/ags/engine/ac/dialog.cpp +++ b/engines/ags/engine/ac/dialog.cpp @@ -182,7 +182,7 @@ int run_dialog_script(int dialogID, int offse, int optionIndex) { if (offse == -1) return result; - unsigned char *script = _G(old_dialog_scripts)[dialogID].get() + offse; + unsigned char *script = _G(old_dialog_scripts)[dialogID].data() + offse; unsigned short param1 = 0; unsigned short param2 = 0; diff --git a/engines/ags/globals.h b/engines/ags/globals.h index 80498217e70..62fe79cd659 100644 --- a/engines/ags/globals.h +++ b/engines/ags/globals.h @@ -535,7 +535,7 @@ public: int _said_text = 0; int _longestline = 0; // Old dialog support - std::vector< std::shared_ptr > _old_dialog_scripts; + std::vector> _old_dialog_scripts; std::vector _old_speech_lines; /**@}*/ diff --git a/engines/ags/shared/game/main_game_file.cpp b/engines/ags/shared/game/main_game_file.cpp index 187336ea71b..3419a5bba37 100644 --- a/engines/ags/shared/game/main_game_file.cpp +++ b/engines/ags/shared/game/main_game_file.cpp @@ -266,7 +266,7 @@ void ReadViews(GameSetupStruct &game, std::vector &views, Stream *in } void ReadDialogs(std::vector &dialog, - std::vector< std::shared_ptr > &old_dialog_scripts, + std::vector> &old_dialog_scripts, std::vector &old_dialog_src, std::vector &old_speech_lines, Stream *in, GameDataVersion data_ver, int dlg_count) { @@ -282,8 +282,8 @@ void ReadDialogs(std::vector &dialog, old_dialog_src.resize(dlg_count); for (int i = 0; i < dlg_count; ++i) { // NOTE: originally this was read into dialog[i].optionscripts - old_dialog_scripts[i].reset(Common::SharedPtr(new unsigned char[dialog[i].codesize], Common::ArrayDeleter())); - in->Read(old_dialog_scripts[i].get(), dialog[i].codesize); + old_dialog_scripts[i].resize(dialog[i].codesize); + in->Read(old_dialog_scripts[i].data(), dialog[i].codesize); // Encrypted text script int script_text_len = in->ReadInt32(); @@ -685,10 +685,8 @@ HGameFileError ReadSpriteFlags(LoadedGameEntities &ents, Stream *in, GameDataVer return new MainGameFileError(kMGFErr_TooManySprites, String::FromFormat("Count: %zu, max: %zu", sprcount, (size_t)SpriteCache::MAX_SPRITE_INDEX + 1)); ents.SpriteCount = sprcount; - ents.SpriteFlags.clear(); ents.SpriteFlags.resize(sprcount); - - in->Read(&ents.SpriteFlags[0], sprcount); + in->Read(ents.SpriteFlags.data(), sprcount); return HGameFileError::None(); } diff --git a/engines/ags/shared/game/main_game_file.h b/engines/ags/shared/game/main_game_file.h index 3b8cc59742d..5dced939921 100644 --- a/engines/ags/shared/game/main_game_file.h +++ b/engines/ags/shared/game/main_game_file.h @@ -120,12 +120,12 @@ struct LoadedGameEntities { // Original sprite data (when it was read into const-sized arrays) size_t SpriteCount; - Common::Array SpriteFlags; + std::vector SpriteFlags; // SPF_* flags // Old dialog support // legacy compiled dialog script of its own format, // requires separate interpreting - std::vector< std::shared_ptr > OldDialogScripts; + std::vector> OldDialogScripts; // probably, actual dialog script sources kept within some older games std::vector OldDialogSources; // speech texts displayed during dialog