aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/lure/res.cpp6
-rw-r--r--engines/lure/res_struct.cpp14
-rw-r--r--engines/lure/res_struct.h12
3 files changed, 25 insertions, 7 deletions
diff --git a/engines/lure/res.cpp b/engines/lure/res.cpp
index e58ce87faf..42eac59f26 100644
--- a/engines/lure/res.cpp
+++ b/engines/lure/res.cpp
@@ -168,7 +168,8 @@ void Resources::reloadData() {
while (READ_LE_UINT16(&joinRec->hotspot1Id) != 0xffff) {
RoomExitJoinData *newEntry = new RoomExitJoinData(joinRec);
_exitJoins.push_back(newEntry);
- ++joinRec;
+
+ GET_NEXT(joinRec, RoomExitJoinResource);
}
delete mb;
@@ -178,7 +179,8 @@ void Resources::reloadData() {
while (READ_LE_UINT16(&hsRec->hotspotId) != 0xffff) {
HotspotData *newEntry = new HotspotData(hsRec);
_hotspotData.push_back(newEntry);
- ++hsRec;
+
+ GET_NEXT(hsRec, HotspotResource);
}
delete mb;
diff --git a/engines/lure/res_struct.cpp b/engines/lure/res_struct.cpp
index 076e691d42..51af356a9d 100644
--- a/engines/lure/res_struct.cpp
+++ b/engines/lure/res_struct.cpp
@@ -77,8 +77,9 @@ extern const RoomTranslationRecord roomTranslations[] = {
RoomData::RoomData(RoomResource *rec, MemoryBlock *pathData) {
roomNumber = READ_LE_UINT16(&rec->roomNumber);
hdrFlags = rec->hdrFlags;
- actions = FROM_LE_32(rec->actions) & 0xfffffff;
- flags = (FROM_LE_32(rec->actions) >> 24) & 0xf0;
+
+ actions = READ_LE_UINT32(&rec->actions) & 0xfffffff;
+ flags = (READ_LE_UINT32(&rec->actions) >> 24) & 0xf0;
descId = READ_LE_UINT16(&rec->descId);
sequenceOffset = READ_LE_UINT16(&rec->sequenceOffset);
numLayers = READ_LE_UINT16(&rec->numLayers);
@@ -90,7 +91,7 @@ RoomData::RoomData(RoomResource *rec, MemoryBlock *pathData) {
clippingXStart = READ_LE_UINT16(&rec->clippingXStart);
clippingXEnd = READ_LE_UINT16(&rec->clippingXEnd);
- exitTime = FROM_LE_32(rec->exitTime);
+ exitTime = READ_LE_UINT32(&rec->exitTime);
areaFlag = rec->areaFlag;
walkBounds.left = READ_LE_UINT16(&rec->walkBounds.xs);
walkBounds.right = READ_LE_UINT16(&rec->walkBounds.xe);
@@ -361,7 +362,8 @@ void RoomExitJoinList::loadFromStream(ReadStream *stream) {
HotspotActionData::HotspotActionData(HotspotActionResource *rec) {
action = (Action) rec->action;
- sequenceOffset = READ_LE_UINT16(&rec->sequenceOffset);
+ // FIXME: some compilers may add padding to properly align the second member
+ sequenceOffset = READ_LE_UINT16(((byte *)rec) + 1);
}
uint16 HotspotActionList::getActionOffset(Action action) {
@@ -604,7 +606,9 @@ HotspotActionList::HotspotActionList(uint16 id, byte *data) {
HotspotActionResource *actionRec = (HotspotActionResource *) data;
- for (int actionCtr = 0; actionCtr < numItems; ++actionCtr, ++actionRec) {
+ for (int actionCtr = 0; actionCtr < numItems; ++actionCtr,
+ GET_NEXT(actionRec, HotspotActionResource)) {
+
HotspotActionData *actionEntry = new HotspotActionData(actionRec);
push_back(actionEntry);
}
diff --git a/engines/lure/res_struct.h b/engines/lure/res_struct.h
index b9a9b363bc..d0851d98c7 100644
--- a/engines/lure/res_struct.h
+++ b/engines/lure/res_struct.h
@@ -39,6 +39,18 @@ using namespace Common;
/* */
/*-------------------------------------------------------------------------*/
+/* HACK/FIXME: three structs are misaligned (at least on 4-byte aligned system,
+ should have more troubles with coming 64bit systems), GET_NEXT let us read
+ properly sequence of struct in lure.dat hardcoding size of struct.
+*/
+
+#define GET_NEXT(v, sc) v = (sc *)(((byte *)v) + kSizeOf##sc)
+
+#define kSizeOfRoomExitJoinResource 13
+#define kSizeOfHotspotResource 62
+#define kSizeOfHotspotActionResource 3
+
+
#include "common/pack-start.h" // START STRUCT PACKING
struct VersionStructure {