Posted by BitShifter on February 27, 2000 at 10:06:35:
In reply to: NumWords for Room is wrong... posted by Jean Luc Picard on February 27, 2000 at 03:11:23:
: Is the documentation simply wrong, or what is up? It's not just a couple of bytes that it's off. We're talking about a ~1K difference. Or am I simply reading it wrong?
Nope, it's not. I made that mistake too when I was doing my LevelAnalyser. After the numberOf Rooms, you have a fixed size (16 bytes for TR3) RoomInfo then a NumData (number of bitu16s to follow) These are the vertices for *that* room. Calculating the offset from that number will not bring you to the end of the room, it will bring you to the start of the next block of data: NumRectangles.
To make sure you get to the exact end of the room, you have to "walk" that structure (which is variable in size), going from NumThis to NumThat and calculating the Offsets as you go along.
It might help if instead of thinking in term of C structures, which are fixed in size (like types), you were to think in term of "chunks" of data, with the number of repeat of types at the start of the chunk (a chunk is a repeated structure). Read the NumOfWhatever and add to the current offset to get to the next NumOfWhatsNext.
It worked for me.