Jump to content
  • Advertisement
Sign in to follow this  
polyfrag

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

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

If you intended to correct an error in the post then please contact us.

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
};

struct dheader_t
{
      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:
      struct dheader_t header;
};
And here is the code that loads the map:

//the correct header should have this ident:
#define IDBSPHEADER	(('P'<<24)+('S'<<16)+('B'<<8)+'V')
//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;

     fread (&map->header, sizeof (struct dheader_t), 1, fp);
     int CorrectIdent = IDBSPHEADER;
     
     if(map->header.ident != CorrectIdent)
     {
                          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]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!