Trying to load a HL BSP - what am I doing wrong?

This topic is 3737 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I can't figure out what I'm doing wrong... I followed the description of the Half Life BSP map format from this website: http://www.geocities.com/cofrdrbob/bspformat.html But I can't even get the header to load correctly! When I compare the value I get from the file header for the 'ident' variable and compare it to what it's supposed to be, it doesn't match. I think maybe I am not loading it correctly somehow? I get the ident number 30, but I should have 1347633750. Have a look at my code and see if I'm doing something wrong: Here is the code for the map class (it only has the header; I haven't added any of the other parts because I've haven't yet made this part work).
struct lump_t
{
int		fileofs, filelen;
int		version;		// default to zero
char	fourCC[4];		// default to ( char )0, ( char )0, ( char )0, ( char )0
};

{
int         ident;            // BSP file identifier
int         version;          // BSP file version
lump_t      lumps[HEADER_LUMPS];    // lump directory array
int         mapRevision;      // the map's revision (iteration, version) number
};

class CHLMap
{
public:
};

And here is the code that loads the map:

//the correct header should have this ident:
//it equals 1347633750 but the number that I get from the file I load is 30

CHLMap map;

FILE* fp = fopen ("fy_iceworld.bsp", "rb");

if(!fp)
return false;

int CorrectIdent = IDBSPHEADER;

{
char message[256];
sprintf(message, "Error: incorrect ident in BSP map file (%d). Ident should be %d.", map->header.ident, CorrectIdent);
MessageBox(NULL, message, "Error", NULL);
}

//... the rest of the loading code would go here

fclose(fp);

The map I am trying to load is fy_iceworld.bsp (which I took from my Counter-Strike 1.6 map folder). You can download it yourself here and try it: http://www.zvdk.nl/maps/cstrike/maps/ So if anyone knows how to do this properly please help... thanks. [Edited by - polyfrag on December 1, 2007 7:42:52 PM]