MOHAWK: Move the effect list to RivenCard

This commit is contained in:
Bastien Bouclet 2016-08-06 18:07:54 +02:00 committed by Eugene Sandulenko
parent c1e0b8684b
commit 871516a969
3 changed files with 44 additions and 18 deletions

View File

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

View File

@ -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<Picture> _pictureList;
Common::Array<SLSTRecord> _soundList;
Common::Array<HotspotEnableRecord> _hotspotEnableList;
Common::Array<WaterEffectRecord> _waterEffectList;
};
/**

View File

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