From 871516a9697db1914d703f0abb48a2f084452b0c Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sat, 6 Aug 2016 18:07:54 +0200 Subject: MOHAWK: Move the effect list to RivenCard --- engines/mohawk/riven_card.cpp | 33 ++++++++++++++++++++++++++++++++- engines/mohawk/riven_card.h | 11 +++++++++++ engines/mohawk/riven_scripts.cpp | 18 +----------------- 3 files changed, 44 insertions(+), 18 deletions(-) (limited to 'engines/mohawk') diff --git a/engines/mohawk/riven_card.cpp b/engines/mohawk/riven_card.cpp index 158c72f080..cdf9cf1a3e 100644 --- a/engines/mohawk/riven_card.cpp +++ b/engines/mohawk/riven_card.cpp @@ -37,6 +37,7 @@ RivenCard::RivenCard(MohawkEngine_Riven *vm, uint16 id) : loadCardPictureList(id); loadCardSoundList(id); loadCardHotspotEnableList(id); + loadCardWaterEffectList(id); } RivenCard::~RivenCard() { @@ -269,7 +270,7 @@ RivenHotspot *RivenCard::getHotspotByBlstId(const uint16 blstId) const { } void RivenCard::loadCardHotspotEnableList(uint16 id) { - Common::SeekableReadStream* blst = _vm->getResource(ID_BLST, id); + Common::SeekableReadStream *blst = _vm->getResource(ID_BLST, id); uint16 recordCount = blst->readUint16BE(); _hotspotEnableList.resize(recordCount); @@ -295,6 +296,36 @@ void RivenCard::activateHotspotEnableRecord(uint16 index) { } } +void RivenCard::loadCardWaterEffectList(uint16 id) { + Common::SeekableReadStream *flst = _vm->getResource(ID_FLST, id); + + uint16 recordCount = flst->readUint16BE(); + _waterEffectList.resize(recordCount); + + for (uint16 i = 0; i < recordCount; i++) { + WaterEffectRecord &record = _waterEffectList[i]; + record.index = flst->readUint16BE(); + record.sfxeId = flst->readUint16BE(); + record.u0 = flst->readUint16BE(); + + if (record.u0 != 0) { + warning("FLST u0 non-zero"); + } + } + + delete flst; +} + +void RivenCard::activateWaterEffect(uint16 index) { + for (uint16 i = 0; i < _waterEffectList.size(); i++) { + const WaterEffectRecord &record = _waterEffectList[i]; + if (record.index == index) { + _vm->_gfx->scheduleWaterEffect(record.sfxeId); + break; + } + } +} + RivenHotspot::RivenHotspot(MohawkEngine_Riven *vm, Common::ReadStream *stream) : _vm(vm) { loadFromStream(stream); diff --git a/engines/mohawk/riven_card.h b/engines/mohawk/riven_card.h index 6648d2640c..007a26d7b6 100644 --- a/engines/mohawk/riven_card.h +++ b/engines/mohawk/riven_card.h @@ -97,12 +97,16 @@ public: /** Activate a hotspot using a hotspot enable list entry */ void activateHotspotEnableRecord(uint16 index); + /** Activate a water effect list entry */ + void activateWaterEffect(uint16 index); + private: void loadCardResource(uint16 id); void loadHotspots(uint16 id); void loadCardPictureList(uint16 id); void loadCardSoundList(uint16 id); void loadCardHotspotEnableList(uint16 id); + void loadCardWaterEffectList(uint16 id); void defaultLoadScript(); @@ -112,6 +116,12 @@ private: uint16 hotspotId; }; + struct WaterEffectRecord { + uint16 index; + uint16 sfxeId; + uint16 u0; + }; + MohawkEngine_Riven *_vm; // General card data @@ -126,6 +136,7 @@ private: Common::Array _pictureList; Common::Array _soundList; Common::Array _hotspotEnableList; + Common::Array _waterEffectList; }; /** diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp index 2f3780d5c2..e951043aa5 100644 --- a/engines/mohawk/riven_scripts.cpp +++ b/engines/mohawk/riven_scripts.cpp @@ -596,23 +596,7 @@ void RivenSimpleCommand::activateBLST(uint16 op, uint16 argc, uint16 *argv) { // Command 44: activate FLST record (information on which SFXE resource this card should use) void RivenSimpleCommand::activateFLST(uint16 op, uint16 argc, uint16 *argv) { - Common::SeekableReadStream* flst = _vm->getResource(ID_FLST, _vm->getCurCard()->getId()); - uint16 recordCount = flst->readUint16BE(); - - for (uint16 i = 0; i < recordCount; i++) { - uint16 index = flst->readUint16BE(); - uint16 sfxeID = flst->readUint16BE(); - - if (flst->readUint16BE() != 0) - warning("FLST u0 non-zero"); - - if (index == argv[0]) { - _vm->_gfx->scheduleWaterEffect(sfxeID); - break; - } - } - - delete flst; + _vm->getCurCard()->activateWaterEffect(argv[0]); } // Command 45: do zip mode -- cgit v1.2.3