Page 1 of 1

Byte Offsets?

Posted: Fri Jan 09, 2009 11:07 am
by Silicone_Milk
I have an idea that concerns lightmaps and I want to be able to extract them after I've compiled the .d3dbsp (Call of Duty 4's version of the .bsp file. It has 34 lumps)

So, I picked up where I left off a year or two ago with the cod .bsp format but this time focused on .d3dbsp.

I'm a little confused though because the very beginning of the file

Code: Select all

49 42 53 50 16 00 00 00 22 00 00 00 00 00 00 00 88 02 00 00 01 00 00 00 00 00 30 00 2C 00 00 00 7A 00 00 00 2D 00 00 00 30 03 00 00 02 00 00 00 90 A2 00 00 03 00 00 00 60 12 00 00 04 00 00 00 60 15 00 00 05 00 00 00 78 20 00 00 06 00 00 00 0F 04 00 00 07 00 00 00 4F 08 00 00 08 00 00 00 78 01 00 00 09 00 00 00 20 01 00 00 0A 00 00 00 18 1B 00 00 0B 00 00 00 50 01 00 00 18 00 00 00 0C 00 00 00 19 00 00 00 70 00 00 00 1B 00 00 00 94 08 00 00 1C 00 00 00 E8 05 00 00 1D 00 00 00 D4 02 00 00 1F 00 00 00 18 06 00 00 20 00 00 00 70 05 00 00 21 00 00 00 58 00 00 00 22 00 00 00 B0 05 00 00 23 00 00 00 6C 00 00 00 24 00 00 00 C0 01 00 00 25 00 00 00 30 00 00 00 27 00 00 00 DD 08 00 00 2B 00 00 00 00 01 00 00 34 00 00 00 02 00 00 00 2F 00 00 00 20 01 00 00 30 00 00 00 18 1B 00 00 31 00 00 00 50 01 00 00 33 00 00 00 0C 00 00 00 29 00 00 00 10 01 08 00 
is the header (49 42 53 50 16 00 00 00 22 00 00 00) followed by the direntry of 34 offset/length pairs which tell you how to find each lump of the bsp.

I've determined that 011C is the location of the beginning of the very first lump.

But what gives? That offset isn't listed anywhere in the direntry array above it!

Even reading in reverse order (which I found I had to do to make the length size of the first lump match to what the direntry claimed it to be) I can't find that offset. (EDIT: Realized it's because it's little-endian)

Do the offsets not start from the beginning of the file?

00 00 00 00 88 02 00 00 when read backwards is a 648 byte block of data with an offset of.... 0. Yet the lump starts at 011C which is byte # 284. Not even close to 0.

Thoughts?

Re: Byte Offsets?

Posted: Mon Jan 12, 2009 5:50 am
by Silicone_Milk
Funny story:
Infinity Ward changed the format so lumps disappear if there's no data to be stored in it.

This means these aren't offsets/lengths. They're Lump Type/Length

The offset is found by starting from the first lump and moving along the file by the lump's size. Repeat for next lump to get the next offset.

Have a few lumps defined now.