.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Half-Life 1 SDK (http://forums.bots-united.com/forumdisplay.php?f=33)
-   -   getting a map size (http://forums.bots-united.com/showthread.php?t=2749)

theturtle 04-10-2004 16:35

getting a map size
 
hello all

i'd like to get the size of a map (in counter strike, but i don't think it is mod specific...).
that is to say i'd like to code (or use somebody's code) to make something like that :
Code:

int map_height = getCurrentMapHeight();
Code:

int map_width = getCurrentMapWidth();
does someone has an idea on how to do this ? or do someone has a piece of code which does it ?
thanks

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_file0sizeof (bsp_file));
   
memset (&map0sizeof (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.dmodelsmfile + ((bsp_dheader_t *) mfile)->lumps[LUMP_MODELS].fileofs, ((bsp_dheader_t *) mfile)->lumps[LUMP_MODELS].filelen);
   
memcpy (bsp_file.dvertexesmfile + ((bsp_dheader_t *) mfile)->lumps[LUMP_VERTEXES].fileofs, ((bsp_dheader_t *) mfile)->lumps[LUMP_VERTEXES].filelen);
   
memcpy (bsp_file.dplanesmfile + ((bsp_dheader_t *) mfile)->lumps[LUMP_PLANES].fileofs, ((bsp_dheader_t *) mfile)->lumps[LUMP_PLANES].filelen);
   
memcpy (bsp_file.dfacesmfile + ((bsp_dheader_t *) mfile)->lumps[LUMP_FACES].fileofs, ((bsp_dheader_t *) mfile)->lumps[LUMP_FACES].filelen);
   
memcpy (bsp_file.dsurfedgesmfile + ((bsp_dheader_t *) mfile)->lumps[LUMP_SURFEDGES].fileofs, ((bsp_dheader_t *) mfile)->lumps[LUMP_SURFEDGES].filelen);
   
memcpy (bsp_file.dedgesmfile + ((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 ????
:'(


All times are GMT +2. The time now is 04:08.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.