Pierre-Marie Baty |
04-10-2004 18:56 |
Re: getting a map size
yep
The map size is the size of the bounding box of the first entity (worldspawn) in the BSP file.
PHP Code:
void LookDownOnTheWorld (void) { // this function loads and interprets the map BSP file at server boot start. It opens the map // file named filename, reads its contents, parses through the different BSP lumps and fills // the map BSP data structure "map", so that we can access to much more geometric info about // the virtual world than the engine would lets us know normally. The BSP loading code comes // with heavy simplification and major rewriting from Zoner's Half-Life tools source code. char bsp_file_path[256]; char *mfile; int bsp_file_size; // do some cleanup first FreeMapData (); memset (&bsp_file, 0, sizeof (bsp_file)); memset (&map, 0, sizeof (map)); // load the bsp file and get its actual size (can't fail to do this, the map already booted) sprintf (bsp_file_path, "maps/%s.bsp", server.map_name); // build BSP file path mfile = (char *) LOAD_FILE_FOR_ME (bsp_file_path, &bsp_file_size); // load bsp file // read the MODELS, VERTEXES, PLANES, FACES, SURFEDGES and EDGES lumps of the BSP file memcpy (bsp_file.dmodels, mfile + ((bsp_dheader_t *) mfile)->lumps[LUMP_MODELS].fileofs, ((bsp_dheader_t *) mfile)->lumps[LUMP_MODELS].filelen); memcpy (bsp_file.dvertexes, mfile + ((bsp_dheader_t *) mfile)->lumps[LUMP_VERTEXES].fileofs, ((bsp_dheader_t *) mfile)->lumps[LUMP_VERTEXES].filelen); memcpy (bsp_file.dplanes, mfile + ((bsp_dheader_t *) mfile)->lumps[LUMP_PLANES].fileofs, ((bsp_dheader_t *) mfile)->lumps[LUMP_PLANES].filelen); memcpy (bsp_file.dfaces, mfile + ((bsp_dheader_t *) mfile)->lumps[LUMP_FACES].fileofs, ((bsp_dheader_t *) mfile)->lumps[LUMP_FACES].filelen); memcpy (bsp_file.dsurfedges, mfile + ((bsp_dheader_t *) mfile)->lumps[LUMP_SURFEDGES].fileofs, ((bsp_dheader_t *) mfile)->lumps[LUMP_SURFEDGES].filelen); memcpy (bsp_file.dedges, mfile + ((bsp_dheader_t *) mfile)->lumps[LUMP_EDGES].fileofs, ((bsp_dheader_t *) mfile)->lumps[LUMP_EDGES].filelen); FREE_FILE (mfile); // everything is loaded, free the BSP file // get a quick access to the world's bounding box map.v_worldmins = bsp_file.dmodels[0].mins; map.v_worldmaxs = bsp_file.dmodels[0].maxs; [...]
WHAT THE HELL DID THE ADMINS DO TO MY [ CODE ] TAGS ????
:'(
|