diff options
author | Bastien Bouclet | 2016-02-06 16:42:49 +0100 |
---|---|---|
committer | Bastien Bouclet | 2016-02-07 15:27:03 +0100 |
commit | a3064b9027569c44a24d84b4e4a6da4abcdadee5 (patch) | |
tree | eff73e6760fa5f2563d8f22b7aefde5a5680463d /engines | |
parent | 32f1ee73addb717b22dbf6db8a0da493627abd82 (diff) | |
download | scummvm-rg350-a3064b9027569c44a24d84b4e4a6da4abcdadee5.tar.gz scummvm-rg350-a3064b9027569c44a24d84b4e4a6da4abcdadee5.tar.bz2 scummvm-rg350-a3064b9027569c44a24d84b4e4a6da4abcdadee5.zip |
MOHAWK: Turn MystView::scriptResources into a Common::Array
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mohawk/myst.cpp | 94 | ||||
-rw-r--r-- | engines/mohawk/myst.h | 4 |
2 files changed, 47 insertions, 51 deletions
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index 9ad27578e8..f42822f2a7 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -90,9 +90,6 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription _cursorHints = nullptr; _prevStack = nullptr; - - _view.scriptResCount = 0; - _view.scriptResources = nullptr; } MohawkEngine_Myst::~MohawkEngine_Myst() { @@ -771,49 +768,50 @@ void MohawkEngine_Myst::loadCard() { } // Resources that scripts can call upon - _view.scriptResCount = viewStream->readUint16LE(); - debugC(kDebugView, "Script Resource Count: %d", _view.scriptResCount); - if (_view.scriptResCount != 0) { - _view.scriptResources = new MystView::ScriptResource[_view.scriptResCount]; - for (uint16 i = 0; i < _view.scriptResCount; i++) { - debugC(kDebugView, "\tResource %d:", i); - _view.scriptResources[i].type = viewStream->readUint16LE(); - debugC(kDebugView, "\t\t Type: %d", _view.scriptResources[i].type); - - switch (_view.scriptResources[i].type) { - case 1: - debugC(kDebugView, "\t\t\t\t= Image"); - break; - case 2: - debugC(kDebugView, "\t\t\t\t= Sound"); - break; - case 3: - debugC(kDebugView, "\t\t\t\t= Resource List"); - break; - default: - debugC(kDebugView, "\t\t\t\t= Unknown"); - break; - } + uint16 scriptResCount = viewStream->readUint16LE(); + debugC(kDebugView, "Script Resource Count: %d", scriptResCount); + for (uint16 i = 0; i < scriptResCount; i++) { + MystView::ScriptResource scriptResource; + + debugC(kDebugView, "\tResource %d:", i); + scriptResource.type = viewStream->readUint16LE(); + debugC(kDebugView, "\t\t Type: %d", scriptResource.type); + + switch (scriptResource.type) { + case 1: + debugC(kDebugView, "\t\t\t\t= Image"); + break; + case 2: + debugC(kDebugView, "\t\t\t\t= Sound"); + break; + case 3: + debugC(kDebugView, "\t\t\t\t= Resource List"); + break; + default: + debugC(kDebugView, "\t\t\t\t= Unknown"); + break; + } - if (_view.scriptResources[i].type == 3) { - _view.scriptResources[i].var = viewStream->readUint16LE(); - debugC(kDebugView, "\t\t Var: %d", _view.scriptResources[i].var); - _view.scriptResources[i].count = viewStream->readUint16LE(); - debugC(kDebugView, "\t\t Resource List Count: %d", _view.scriptResources[i].count); - _view.scriptResources[i].u0 = viewStream->readUint16LE(); - debugC(kDebugView, "\t\t u0: %d", _view.scriptResources[i].u0); - _view.scriptResources[i].resource_list = new int16[_view.scriptResources[i].count]; - - for (uint16 j = 0; j < _view.scriptResources[i].count; j++) { - _view.scriptResources[i].resource_list[j] = viewStream->readSint16LE(); - debugC(kDebugView, "\t\t Resource List %d: %d", j, _view.scriptResources[i].resource_list[j]); - } - } else { - _view.scriptResources[i].resource_list = nullptr; - _view.scriptResources[i].id = viewStream->readUint16LE(); - debugC(kDebugView, "\t\t Id: %d", _view.scriptResources[i].id); + if (scriptResource.type == 3) { + scriptResource.var = viewStream->readUint16LE(); + debugC(kDebugView, "\t\t Var: %d", scriptResource.var); + scriptResource.count = viewStream->readUint16LE(); + debugC(kDebugView, "\t\t Resource List Count: %d", scriptResource.count); + scriptResource.u0 = viewStream->readUint16LE(); + debugC(kDebugView, "\t\t u0: %d", scriptResource.u0); + scriptResource.resource_list = new int16[scriptResource.count]; + + for (uint16 j = 0; j < scriptResource.count; j++) { + scriptResource.resource_list[j] = viewStream->readSint16LE(); + debugC(kDebugView, "\t\t Resource List %d: %d", j, scriptResource.resource_list[j]); } + } else { + scriptResource.resource_list = nullptr; + scriptResource.id = viewStream->readUint16LE(); + debugC(kDebugView, "\t\t Id: %d", scriptResource.id); } + + _view.scriptResources.push_back(scriptResource); } // Identifiers for other resources. 0 if non existent. There is always an RLST. @@ -854,8 +852,8 @@ void MohawkEngine_Myst::loadCard() { } // Precache Script Resources - if (_view.scriptResCount != 0) { - for (uint16 i = 0; i < _view.scriptResCount; i++) { + if (_view.scriptResources.size() != 0) { + for (uint16 i = 0; i < _view.scriptResources.size(); i++) { switch (_view.scriptResources[i].type) { case 1: cachePreload(cacheImageType, _view.scriptResources[i].id); @@ -878,12 +876,10 @@ void MohawkEngine_Myst::unloadCard() { _view.conditionalImages.clear(); _view.soundList.clear(); - for (uint16 i = 0; i < _view.scriptResCount; i++) + for (uint16 i = 0; i < _view.scriptResources.size(); i++) delete[] _view.scriptResources[i].resource_list; - delete[] _view.scriptResources; - _view.scriptResources = nullptr; - _view.scriptResCount = 0; + _view.scriptResources.clear(); } void MohawkEngine_Myst::runInitScript() { diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h index 8d68092287..1e5ddd85da 100644 --- a/engines/mohawk/myst.h +++ b/engines/mohawk/myst.h @@ -132,7 +132,6 @@ struct MystView { Common::Array<MystSoundItem> soundList; // Script Resources - uint16 scriptResCount; struct ScriptResource { uint16 type; uint16 id; // Not used by type 3 @@ -141,7 +140,8 @@ struct MystView { uint16 count; // Used by type 3 only uint16 u0; // Used by type 3 only int16 *resource_list; // Used by type 3 only - } *scriptResources; + }; + Common::Array<ScriptResource> scriptResources; // Resource ID's uint16 rlst; |