AGS: Common: replaced couple of smart ptr arrays with std::vector

From upstream c1afae64fe348c64ee4a8c8888349ae267241395
This commit is contained in:
Walter Agazzi 2023-02-27 22:13:43 +01:00 committed by Thierry Crozat
parent 26375b823b
commit f58c4d9bdb
4 changed files with 8 additions and 10 deletions

View File

@ -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;

View File

@ -535,7 +535,7 @@ public:
int _said_text = 0;
int _longestline = 0;
// Old dialog support
std::vector< std::shared_ptr<unsigned char> > _old_dialog_scripts;
std::vector<std::vector<uint8_t>> _old_dialog_scripts;
std::vector<String> _old_speech_lines;
/**@}*/

View File

@ -266,7 +266,7 @@ void ReadViews(GameSetupStruct &game, std::vector<ViewStruct> &views, Stream *in
}
void ReadDialogs(std::vector<DialogTopic> &dialog,
std::vector< std::shared_ptr<unsigned char> > &old_dialog_scripts,
std::vector<std::vector<uint8_t>> &old_dialog_scripts,
std::vector<String> &old_dialog_src,
std::vector<String> &old_speech_lines,
Stream *in, GameDataVersion data_ver, int dlg_count) {
@ -282,8 +282,8 @@ void ReadDialogs(std::vector<DialogTopic> &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<unsigned char>(new unsigned char[dialog[i].codesize], Common::ArrayDeleter<unsigned char>()));
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();
}

View File

@ -120,12 +120,12 @@ struct LoadedGameEntities {
// Original sprite data (when it was read into const-sized arrays)
size_t SpriteCount;
Common::Array<byte> SpriteFlags;
std::vector<uint8_t> SpriteFlags; // SPF_* flags
// Old dialog support
// legacy compiled dialog script of its own format,
// requires separate interpreting
std::vector< std::shared_ptr<unsigned char> > OldDialogScripts;
std::vector<std::vector<uint8_t>> OldDialogScripts;
// probably, actual dialog script sources kept within some older games
std::vector<String> OldDialogSources;
// speech texts displayed during dialog