![]() |
Compiler wierdness
After a few days of on/off work I have for the most part figured out the half-life sprite file format.
It would have been done faster except I kept missing the fact that even the first frame has a frame header instead of using the sprite header, anyway... Here is what I have so far... Code:
// Should be at the start of the file, identifies this as a sprite But the problem I had was with the main sprite header ( hl_sprheader_t ). What would happen is I added an unsigned short to the end of it because there are 2 still unknown bytes before the palette. However, MSVC decided that it would make the short into 4 bytes. That really threw everything off since the first 2 bytes of the palette were getting read into the header. I guessed and found a solution with #pragma pack but it still doesn't feel right, can someone explain what is going on and if it will happen on a different compiler aswell? |
Re: Compiler wierdness
(If I'm reading right...possible not considering I don't have my glasses on, am tired, and hungry) - I ran across a similar problem documented by Epic (for loading of their psk and psa files). For msvc at any rate, pragma was used, as by default it packs structs to 4byte sizes (i.e it'll pad data in the struct to the closest 4bytes). Not sure on what gcc does.
Another method I've used to ensure padding doesn't affect it is a little long-winded, but works. Simply read it all in a byte array, and use a few array offsets & memcpy. Takes a tad longer, more code, more complex, etc, but gives more precise control. |
Re: Compiler wierdness
there is a "struct member alignment" or something like that in the project options, not sure if it's problem with that.
|
Re: Compiler wierdness
I see, but that has to be the dumbest thing I've had to deal with in a while.
What about someone expecting their struct to be say 42 bytes and the compiler makes it 44 instead, it drove me nuts because I thought I screwed up while figuring out the headers. But some odd idea had me printf out the result of sizeof( hl_sprheader_t ) to check the size so I could look at it in the hex editor. 2 More quick things... 1. Since I more or less figured out the file format, am I free from valve's sdk license? ( never looked at the hlsdk for this, only created sprites in a hex editor ) 2. Everything written more than 1 byte at a time has to be swapped if running on a machine with a different endianness? And if so, how do you tell which it was created on? Thanks for the help so far. |
Re: Compiler wierdness
"1. Since I more or less figured out the file format, am I free from valve's sdk license? ( never looked at the hlsdk for this, only created sprites in a hex editor )"
If no significant part of your code is based on Valve's code, then I don't think Valve's license apply to your code. The file format itself AFAIK is not restricted. |
Re: Compiler wierdness
I have absolutely no clue.
Perhaps you should ask this in the HLCoders mailing list ? |
Re: Compiler wierdness
I doubt they'd help someone who took time to figure out their file format just to get around licensing.
Besides, they don't respond/act on emails anyway. I emailed them a hlds bug about a week ago and it still exists and I never got a reply. |
All times are GMT +2. The time now is 21:21. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.