Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
HollowedEmpire

WAD pointers (solved)

Recommended Posts

I need just a bit of light shined on this for me. I'm trying to figure out how to use these 'pointers' in the directory section of the wads. I done some searching but I haven't gotten much details on it.

Maybe it's more obvious then I'm making it, but what exactly what must one do using the value the 'pointer' has to reach the starting point of the data its pointing at? I've never dealt with pointers in files before.

Share this post


Link to post

Wait, are you trying to write some new wad editing utility? If you just want to make a level you don't have to deal with any of that.

Share this post


Link to post

Well... not exactly.

I'm basically loading the maps in my own game I'm creating. I have it reading everything fine from the wad... only hard coded to certain byte positions. So now I'm trying to have it read the directory and get the positions the right way. (And so I can read more than just that particular wad! Haha!)

Share this post


Link to post

You mean the starting offset? It's just the location in the file where the lump starts.

Otherwise I'm not sure I understand.

Share this post


Link to post

Yeah! Except how do I use that value to get there? If I try directly jumping to that point by using it as a byte offset, it's incorrect.

According to XWE, the starting offset (in bytes) for E1M1 is 67494. However, when I read the values directly from the directory, the pointer says E1M1 starts at 2470!

The pointer to the table in the header was something I also couldn't read. The table starts at (in bytes, using a hex editor) 4,175,568. However the pointer in the header says it's at 79056!

To work around my confusion with it, I ended up getting the file size and subtracting the number of lumps multiplied by 16 to find where the table starts. But of course I still have these pointers throughout the table so that trick hardly helps out. Haha!

So all I've gotten so far is that these pointers have something more to them than just byte offsets...

But again, despite that I get the feeling I'll be like "Oh my god, really?" when I realize what these values stand for! It's probably something super simple right?

Share this post


Link to post

You must be reading them wrong. They are plain 4 byte signed integers.

Share this post


Link to post

That's what I was thinking for a while... but then I realized that would be very odd, because everything except these pointers are read in correctly! Things, Linedefs, Sidedefs... everything is correct (when I use the byte offsets from XWE to read them in that is.)!

If I use my trick to get to the directory, the names and size of the entry are also read in correctly as well, just the pointer is wrong...

And I'm currently reading them in as a 4-byte signed number too.

Also, now that I just checked, looking at the a value in a hex editor seems to show A6 07 01 00 is the value.

Share this post


Link to post
HollowedEmpire said:

That's what I was thinking for a while... but then I realized that would be very odd, because everything except these pointers are read in correctly! Things, Linedefs, Sidedefs... everything is correct (when I use the byte offsets from XWE to read them in that is.)!

If I use my trick to get to the directory, the names and size of the entry are also read in correctly as well, just the pointer is wrong...

And I'm currently reading them in as a 4-byte signed number too.

Also, now that I just checked, looking at the a value in a hex editor seems to show A6 07 01 00 is the value.

Are you getting your byte ordering confused? A6 07 01 00 in little endian is 67,494. What platform/language are you working with?

Share this post


Link to post

Ahhh! Yes the bit order! Haha! I completely overlooked that! I'll go investing and find out of that's it, though I'm pretty sure it is.

And I'm actually using Game Maker currently. I had to write a function for reading in set bytes of data, but I never even thought about the byte ordering.

Sheer dumb luck as brought me the level in visual order it seems! Though I guess this is also why I started having some weird issues with Nodes...

Thanks for that!

*EDIT

I got it solved. Turns out, I was just being retarded! Everyone laugh with me! Haha!

When I read in the bytes, this is was I was doing:

value+=byte[j]*(j*256);

When I SHOULD have been doing this:

value+=byte[j]*(power(256, j));

(j is a loop variable, which loops the number of bytes to be read, and value is the "total" the bytes make up together)

So I had everything right the whole time, It was a case of of math skills failing as usual. Luckily everything in the level was at a small enough level where it wasn't affected by that error.

Sorry for wasting a topic on this! But hopefully you can at least get a laugh out of it too. Haha!

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×