.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > SDK Programming discussions > Half-Life 1 SDK
Half-Life 1 SDK For developments focused around Half-Life (and its mods) Half-Life

Reply
 
Thread Tools
getting a map size
Old
  (#1)
theturtle
Guest
 
Status:
Posts: n/a
Default getting a map size - 04-10-2004

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
  
Reply With Quote
Re: getting a map size
Old
  (#2)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: getting a map size - 04-10-2004

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 ????
:'(



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com