aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mohawk/riven_card.cpp28
-rw-r--r--engines/mohawk/riven_card.h11
-rw-r--r--engines/mohawk/riven_scripts.cpp22
3 files changed, 42 insertions, 19 deletions
diff --git a/engines/mohawk/riven_card.cpp b/engines/mohawk/riven_card.cpp
index 39a818c6a9..158c72f080 100644
--- a/engines/mohawk/riven_card.cpp
+++ b/engines/mohawk/riven_card.cpp
@@ -36,6 +36,7 @@ RivenCard::RivenCard(MohawkEngine_Riven *vm, uint16 id) :
loadHotspots(id);
loadCardPictureList(id);
loadCardSoundList(id);
+ loadCardHotspotEnableList(id);
}
RivenCard::~RivenCard() {
@@ -267,6 +268,33 @@ RivenHotspot *RivenCard::getHotspotByBlstId(const uint16 blstId) const {
return nullptr;
}
+void RivenCard::loadCardHotspotEnableList(uint16 id) {
+ Common::SeekableReadStream* blst = _vm->getResource(ID_BLST, id);
+
+ uint16 recordCount = blst->readUint16BE();
+ _hotspotEnableList.resize(recordCount);
+
+ for (uint16 i = 0; i < recordCount; i++) {
+ HotspotEnableRecord &record = _hotspotEnableList[i];
+ record.index = blst->readUint16BE();
+ record.enabled = blst->readUint16BE();
+ record.hotspotId = blst->readUint16BE();
+ }
+
+ delete blst;
+}
+
+void RivenCard::activateHotspotEnableRecord(uint16 index) {
+ for (uint16 i = 0; i < _hotspotEnableList.size(); i++) {
+ const HotspotEnableRecord &record = _hotspotEnableList[i];
+ if (record.index == index) {
+ RivenHotspot *hotspot = getHotspotByBlstId(record.hotspotId);
+ hotspot->enable(record.enabled == 1);
+ 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 10b77275ab..6648d2640c 100644
--- a/engines/mohawk/riven_card.h
+++ b/engines/mohawk/riven_card.h
@@ -94,14 +94,24 @@ public:
/** Get all the hotspots in the card. To be used for debugging features only */
Common::Array<RivenHotspot *> getHotspots() const;
+ /** Activate a hotspot using a hotspot enable list entry */
+ void activateHotspotEnableRecord(uint16 index);
+
private:
void loadCardResource(uint16 id);
void loadHotspots(uint16 id);
void loadCardPictureList(uint16 id);
void loadCardSoundList(uint16 id);
+ void loadCardHotspotEnableList(uint16 id);
void defaultLoadScript();
+ struct HotspotEnableRecord {
+ uint16 index;
+ uint16 enabled;
+ uint16 hotspotId;
+ };
+
MohawkEngine_Riven *_vm;
// General card data
@@ -115,6 +125,7 @@ private:
// Resource lists
Common::Array<Picture> _pictureList;
Common::Array<SLSTRecord> _soundList;
+ Common::Array<HotspotEnableRecord> _hotspotEnableList;
};
/**
diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp
index 0595c77919..2f3780d5c2 100644
--- a/engines/mohawk/riven_scripts.cpp
+++ b/engines/mohawk/riven_scripts.cpp
@@ -576,8 +576,8 @@ void RivenSimpleCommand::activateSLST(uint16 op, uint16 argc, uint16 *argv) {
return;
_vm->_activatedSLST = true;
- SLSTRecord picture = _vm->getCurCard()->getSound(argv[0]);
- _vm->_sound->playSLST(picture);
+ SLSTRecord slstRecord = _vm->getCurCard()->getSound(argv[0]);
+ _vm->_sound->playSLST(slstRecord);
}
// Command 41: activate MLST record and play
@@ -588,23 +588,7 @@ void RivenSimpleCommand::activateMLSTAndPlay(uint16 op, uint16 argc, uint16 *arg
// Command 43: activate BLST record (card hotspot enabling lists)
void RivenSimpleCommand::activateBLST(uint16 op, uint16 argc, uint16 *argv) {
- Common::SeekableReadStream* blst = _vm->getResource(ID_BLST, _vm->getCurCard()->getId());
- uint16 recordCount = blst->readUint16BE();
-
- for (uint16 i = 0; i < recordCount; i++) {
- uint16 index = blst->readUint16BE(); // record index
- uint16 enabled = blst->readUint16BE();
- uint16 hotspotID = blst->readUint16BE();
-
- if (argv[0] == index) {
- RivenHotspot *hotspot = _vm->getCurCard()->getHotspotByBlstId(hotspotID);
- if (hotspot) {
- hotspot->enable(enabled == 1);
- }
- }
- }
-
- delete blst;
+ _vm->getCurCard()->activateHotspotEnableRecord(argv[0]);
// Recheck our current hotspot because it may have now changed
_vm->updateCurrentHotspot();