diff options
-rw-r--r-- | engines/voyeur/files.cpp | 27 | ||||
-rw-r--r-- | engines/voyeur/files.h | 4 | ||||
-rw-r--r-- | engines/voyeur/files_threads.cpp | 23 |
3 files changed, 34 insertions, 20 deletions
diff --git a/engines/voyeur/files.cpp b/engines/voyeur/files.cpp index 3b90e52294..1eefef40b1 100644 --- a/engines/voyeur/files.cpp +++ b/engines/voyeur/files.cpp @@ -525,8 +525,10 @@ void BVoyBoltFile::initSoundMap() { } void BVoyBoltFile::sInitRect() { - _state._curMemberPtr->_data = _state.decompress(NULL, 8, _state._curMemberPtr->_mode); - _state._curMemberPtr->_rectResource = new RectResource(_state, _state._curMemberPtr->_data); + _state._curMemberPtr->_data = _state.decompress(NULL, _state._curMemberPtr->_size, + _state._curMemberPtr->_mode); + _state._curMemberPtr->_rectResource = new RectResource(_state._curMemberPtr->_data, + _state._curMemberPtr->_size); } void BVoyBoltFile::sInitPic() { @@ -692,11 +694,22 @@ bool BoltEntry::hasResource() const { /*------------------------------------------------------------------------*/ -RectResource::RectResource(BoltFilesState &state, const byte *src) { - left = READ_LE_UINT16(src); - top = READ_LE_UINT16(src + 2); - setWidth(READ_LE_UINT16(src + 4)); - setHeight(READ_LE_UINT16(src + 6)); +RectResource::RectResource(const byte *src, int size) { + int count = 1; + if (size != 8) { + count = READ_LE_UINT16(src); + src += 2; + } + + for (int i = 0; i < count; ++i, src += 8) { + _entries.push_back(Common::Rect(READ_LE_UINT16(src), READ_LE_UINT16(src + 2), + READ_LE_UINT16(src + 4), READ_LE_UINT16(src + 6))); + } + + left = _entries[0].left; + top = _entries[0].top; + right = _entries[0].right; + bottom = _entries[0].bottom; } RectResource::RectResource(int x1, int y1, int x2, int y2) { diff --git a/engines/voyeur/files.h b/engines/voyeur/files.h index 4440490e12..48592dae61 100644 --- a/engines/voyeur/files.h +++ b/engines/voyeur/files.h @@ -236,7 +236,9 @@ public: class RectResource: public Common::Rect { public: - RectResource(BoltFilesState &state, const byte *src); + Common::Array<Common::Rect> _entries; +public: + RectResource(const byte *src, int size); RectResource(int xp, int yp, int width, int height); virtual ~RectResource() {} }; diff --git a/engines/voyeur/files_threads.cpp b/engines/voyeur/files_threads.cpp index 43bebf3564..15f2e96125 100644 --- a/engines/voyeur/files_threads.cpp +++ b/engines/voyeur/files_threads.cpp @@ -1053,20 +1053,21 @@ int ThreadResource::doApt() { _vm->_playStamp2 = 151; _vm->_voy._viewBounds = _vm->_bVoy->boltEntry(_vm->_playStamp1)._rectResource; - byte *hotspotsP = _vm->_bVoy->memberAddr(_vm->_playStamp1 + 1); + Common::Array<Common::Rect> &hotspots = _vm->_bVoy->boltEntry( + _vm->_playStamp1 + 1)._rectResource->_entries; _vm->_eventsManager.getMouseInfo(); if (_doAptPosX == -1) { - _doAptPosX = READ_LE_UINT16(hotspotsP + 18) + 16; - _doAptPosY = READ_LE_UINT16(hotspotsP + 20) + 16; + _doAptPosX = hotspots[2].left; + _doAptPosY = hotspots[2].top; _vm->_playStamp2 = 153; } if (_vm->_voy._field470 == 16) { - WRITE_LE_UINT16(hotspotsP + 2, 999); - WRITE_LE_UINT16(hotspotsP + 26, 999); - _doAptPosX = READ_LE_UINT16(hotspotsP + 34) + 28; - _doAptPosY = READ_LE_UINT16(hotspotsP + 36) + 28; + hotspots[0].left = 999; + hotspots[3].left = 999; + _doAptPosX = hotspots[4].left + 28; + _doAptPosY = hotspots[4].top + 28; } _vm->_eventsManager.setMousePos(Common::Point(_doAptPosX, _doAptPosY)); @@ -1097,11 +1098,9 @@ int ThreadResource::doApt() { // Loop through the hotspot list hotspotId = -1; pt = _vm->_eventsManager.getMousePos(); - for (int idx = 0; idx < READ_LE_UINT16(hotspotsP); ++idx) { - if (pt.x > READ_LE_UINT16(hotspotsP + idx * 8 + 2) && - pt.x < READ_LE_UINT16(hotspotsP + idx * 8 + 6) && - pt.y > READ_LE_UINT16(hotspotsP + idx * 8 + 4) && - pt.y < READ_LE_UINT16(hotspotsP + idx * 8 + 8)) { + for (int idx = 0; idx < hotspots.size(); ++idx) { + if (pt.x > hotspots[idx].left && pt.x < hotspots[idx].right && + pt.y > hotspots[idx].top && pt.y < hotspots[idx].bottom) { // Cursor is within hotspot area hotspotId = idx; |