Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

aas_cfg.c File Reference

#include "qbsp.h"
#include "float.h"
#include "../botlib/aasfile.h"
#include "aas_store.h"
#include "aas_cfg.h"
#include "../botlib/l_precomp.h"
#include "../botlib/l_struct.h"
#include "../botlib/l_libvar.h"

Include dependency graph for aas_cfg.c:

Include dependency graph

Go to the source code of this file.

Defines

#define BBOX_OFS(x)   (int)&(((aas_bbox_t *)0)->x)
#define CFG_OFS(x)   (int)&(((cfg_t *)0)->x)

Functions

void DefaultCfg (void)
int LoadCfgFile (char *filename)
void SetCfgLibVars (void)
char *QDECL va (char *format,...)

Variables

fielddef_t bbox_fields []
structdef_t bbox_struct
cfg_t cfg
fielddef_t cfg_fields []
structdef_t cfg_struct


Define Documentation

#define BBOX_OFS  )     (int)&(((aas_bbox_t *)0)->x)
 

Definition at line 33 of file aas_cfg.c.

#define CFG_OFS  )     (int)&(((cfg_t *)0)->x)
 

Definition at line 34 of file aas_cfg.c.


Function Documentation

void DefaultCfg void   ) 
 

Definition at line 106 of file aas_cfg.c.

References cfg_s::allpresencetypes, cfg_s::bboxes, cfg, cfg_fields, aas_bbox_s::flags, i, aas_bbox_s::maxs, aas_bbox_s::mins, fielddef_s::name, cfg_s::numbboxes, fielddef_s::offset, cfg_s::phys_gravitydirection, cfg_s::phys_maxsteepness, PRESENCE_NORMAL, aas_bbox_s::presencetype, and fielddef_s::type.

Referenced by main().

00107 {
00108     int i;
00109 
00110     // default all float values to infinite
00111     for (i = 0; cfg_fields[i].name; i++)
00112     {
00113         if ((cfg_fields[i].type & FT_TYPE) == FT_FLOAT)
00114             *(float *)( ((char*)&cfg) + cfg_fields[i].offset ) = FLT_MAX;
00115     } //end for
00116     //
00117     cfg.numbboxes = 2;
00118     //bbox 0
00119     cfg.bboxes[0].presencetype = PRESENCE_NORMAL;
00120     cfg.bboxes[0].flags = 0;
00121     cfg.bboxes[0].mins[0] = -15;
00122     cfg.bboxes[0].mins[1] = -15;
00123     cfg.bboxes[0].mins[2] = -24;
00124     cfg.bboxes[0].maxs[0] = 15;
00125     cfg.bboxes[0].maxs[1] = 15;
00126     cfg.bboxes[0].maxs[2] = 32;
00127     //bbox 1
00128     cfg.bboxes[1].presencetype = PRESENCE_CROUCH;
00129     cfg.bboxes[1].flags = 1;
00130     cfg.bboxes[1].mins[0] = -15;
00131     cfg.bboxes[1].mins[1] = -15;
00132     cfg.bboxes[1].mins[2] = -24;
00133     cfg.bboxes[1].maxs[0] = 15;
00134     cfg.bboxes[1].maxs[1] = 15;
00135     cfg.bboxes[1].maxs[2] = 16;
00136     //
00137     cfg.allpresencetypes = PRESENCE_NORMAL|PRESENCE_CROUCH;
00138     cfg.phys_gravitydirection[0]    = 0;
00139     cfg.phys_gravitydirection[1]    = 0;
00140     cfg.phys_gravitydirection[2]    = -1;
00141     cfg.phys_maxsteepness           = 0.7;
00142 } //end of the function DefaultCfg

int LoadCfgFile char *  filename  ) 
 

Definition at line 194 of file aas_cfg.c.

References cfg_s::allpresencetypes, bbox_struct, cfg_s::bboxes, cfg, cfg_struct, cfg_t, FreeSource(), LoadSourceFile(), Log_Print(), memset(), cfg_s::numbboxes, PC_ReadToken(), cfg_s::phys_gravitydirection, aas_bbox_s::presencetype, ReadStructure(), SetCfgLibVars(), source, source_t, SourceError(), SourceWarning(), token_s::string, token, token_t, and VectorLength().

Referenced by main().

00195 {
00196     source_t *source;
00197     token_t token;
00198     int settingsdefined;
00199 
00200     source = LoadSourceFile(filename);
00201     if (!source)
00202     {
00203         Log_Print("couldn't open cfg file %s\n", filename);
00204         return false;
00205     } //end if
00206 
00207     settingsdefined = false;
00208     memset(&cfg, 0, sizeof(cfg_t));
00209 
00210     while(PC_ReadToken(source, &token))
00211     {
00212         if (!stricmp(token.string, "bbox"))
00213         {
00214             if (cfg.numbboxes >= AAS_MAX_BBOXES)
00215             {
00216                 SourceError(source, "too many bounding box volumes defined");
00217             } //end if
00218             if (!ReadStructure(source, &bbox_struct, (char *) &cfg.bboxes[cfg.numbboxes]))
00219             {
00220                 FreeSource(source);
00221                 return false;
00222             } //end if
00223             cfg.allpresencetypes |= cfg.bboxes[cfg.numbboxes].presencetype;
00224             cfg.numbboxes++;
00225         } //end if
00226         else if (!stricmp(token.string, "settings"))
00227         {
00228             if (settingsdefined)
00229             {
00230                 SourceWarning(source, "settings already defined\n");
00231             } //end if
00232             settingsdefined = true;
00233             if (!ReadStructure(source, &cfg_struct, (char *) &cfg))
00234             {
00235                 FreeSource(source);
00236                 return false;
00237             } //end if
00238         } //end else if
00239     } //end while
00240     if (VectorLength(cfg.phys_gravitydirection) < 0.9 || VectorLength(cfg.phys_gravitydirection) > 1.1)
00241     {
00242         SourceError(source, "invalid gravity direction specified");
00243     } //end if
00244     if (cfg.numbboxes <= 0)
00245     {
00246         SourceError(source, "no bounding volumes specified");
00247     } //end if
00248     FreeSource(source);
00249     SetCfgLibVars();
00250     Log_Print("using cfg file %s\n", filename);
00251     return true;
00252 } //end of the function LoadCfgFile

Here is the call graph for this function:

void SetCfgLibVars void   ) 
 

Definition at line 171 of file aas_cfg.c.

References cfg_fields, i, LibVarSet(), name, fielddef_s::name, fielddef_s::offset, fielddef_s::type, va(), and value.

Referenced by LoadCfgFile().

00172 {
00173     int i;
00174     float value;
00175 
00176     for (i = 0; cfg_fields[i].name; i++)
00177     {
00178         if ((cfg_fields[i].type & FT_TYPE) == FT_FLOAT)
00179         {
00180             value = *(float *)(((char*)&cfg) + cfg_fields[i].offset);
00181             if (value != FLT_MAX)
00182             {
00183                 LibVarSet(cfg_fields[i].name, va("%f", value));
00184             } //end if
00185         } //end if
00186     } //end for
00187 } //end of the function SetCfgLibVars

Here is the call graph for this function:

char* QDECL va char *  format,
  ...
 

Definition at line 149 of file aas_cfg.c.

Referenced by _Vector5Add(), _VectorAdd(), _VectorMA(), _VectorSubtract(), AssertCvarRange(), BotEnterChat(), BotVoiceChat(), BotVoiceChatOnly(), CG_BuildSpectatorString(), CG_Draw1stPlace(), CG_Draw2ndPlace(), CG_DrawCapFragLimit(), CG_EntityEvent(), CL_RequestAuthorization(), DriverInfo_MenuDraw(), Item_Multi_HandleKey(), Item_Slider_HandleKey(), Item_YesNo_HandleKey(), Scroll_Slider_ThumbFunc(), UI_DrawGLInfo(), UI_DrawMapTimeToBeat(), UI_DrawNetFilter(), UI_DrawNetSource(), UI_DrawServerRefreshDate(), UI_DrawTeamName(), UI_DrawTier(), UI_SPLevelMenu_SetMenuArena(), UI_StartServerRefresh(), VectorMA(), VectorMidpoint(), and VectorRotate().

00150 {
00151     va_list     argptr;
00152     static char     string[2][32000];   // in case va is called by nested functions
00153     static int      index = 0;
00154     char    *buf;
00155 
00156     buf = string[index & 1];
00157     index++;
00158 
00159     va_start (argptr, format);
00160     vsprintf (buf, format,argptr);
00161     va_end (argptr);
00162 
00163     return buf;
00164 } //end of the function va


Variable Documentation

fielddef_t bbox_fields[]
 

Initial value:

{
    {"presencetype", BBOX_OFS(presencetype), FT_INT},
    {"flags", BBOX_OFS(flags), FT_INT},
    {"mins", BBOX_OFS(mins), FT_FLOAT|FT_ARRAY, 3},
    {"maxs", BBOX_OFS(maxs), FT_FLOAT|FT_ARRAY, 3},
    {NULL, 0, 0, 0}
}

Definition at line 37 of file aas_cfg.c.

structdef_t bbox_struct
 

Initial value:

{
    sizeof(aas_bbox_t), bbox_fields
}

Definition at line 87 of file aas_cfg.c.

Referenced by LoadCfgFile().

cfg_t cfg
 

Definition at line 97 of file aas_cfg.c.

Referenced by AAS_CreateArea(), AAS_CreateMapBrushes(), AAS_FindBestAreaSplitPlane(), AAS_GapFace(), AAS_GroundFace(), AAS_StoreBoundingBoxes(), DefaultCfg(), LeafNode(), and LoadCfgFile().

fielddef_t cfg_fields[]
 

Initial value:

{
    {"phys_gravitydirection", CFG_OFS(phys_gravitydirection), FT_FLOAT|FT_ARRAY, 3},
    {"phys_friction", CFG_OFS(phys_friction), FT_FLOAT},
    {"phys_stopspeed", CFG_OFS(phys_stopspeed), FT_FLOAT},
    {"phys_gravity", CFG_OFS(phys_gravity), FT_FLOAT},
    {"phys_waterfriction", CFG_OFS(phys_waterfriction), FT_FLOAT},
    {"phys_watergravity", CFG_OFS(phys_watergravity), FT_FLOAT},
    {"phys_maxvelocity", CFG_OFS(phys_maxvelocity), FT_FLOAT},
    {"phys_maxwalkvelocity", CFG_OFS(phys_maxwalkvelocity), FT_FLOAT},
    {"phys_maxcrouchvelocity", CFG_OFS(phys_maxcrouchvelocity), FT_FLOAT},
    {"phys_maxswimvelocity", CFG_OFS(phys_maxswimvelocity), FT_FLOAT},
    {"phys_walkaccelerate", CFG_OFS(phys_walkaccelerate), FT_FLOAT},
    {"phys_airaccelerate", CFG_OFS(phys_airaccelerate), FT_FLOAT},
    {"phys_swimaccelerate", CFG_OFS(phys_swimaccelerate), FT_FLOAT},
    {"phys_maxstep", CFG_OFS(phys_maxstep), FT_FLOAT},
    {"phys_maxsteepness", CFG_OFS(phys_maxsteepness), FT_FLOAT},
    {"phys_maxwaterjump", CFG_OFS(phys_maxwaterjump), FT_FLOAT},
    {"phys_maxbarrier", CFG_OFS(phys_maxbarrier), FT_FLOAT},
    {"phys_jumpvel", CFG_OFS(phys_jumpvel), FT_FLOAT},
    {"phys_falldelta5", CFG_OFS(phys_falldelta5), FT_FLOAT},
    {"phys_falldelta10", CFG_OFS(phys_falldelta10), FT_FLOAT},
    {"rs_waterjump", CFG_OFS(rs_waterjump), FT_FLOAT},
    {"rs_teleport", CFG_OFS(rs_teleport), FT_FLOAT},
    {"rs_barrierjump", CFG_OFS(rs_barrierjump), FT_FLOAT},
    {"rs_startcrouch", CFG_OFS(rs_startcrouch), FT_FLOAT},
    {"rs_startgrapple", CFG_OFS(rs_startgrapple), FT_FLOAT},
    {"rs_startwalkoffledge", CFG_OFS(rs_startwalkoffledge), FT_FLOAT},
    {"rs_startjump", CFG_OFS(rs_startjump), FT_FLOAT},
    {"rs_rocketjump", CFG_OFS(rs_rocketjump), FT_FLOAT},
    {"rs_bfgjump", CFG_OFS(rs_bfgjump), FT_FLOAT},
    {"rs_jumppad", CFG_OFS(rs_jumppad), FT_FLOAT},
    {"rs_aircontrolledjumppad", CFG_OFS(rs_aircontrolledjumppad), FT_FLOAT},
    {"rs_funcbob", CFG_OFS(rs_funcbob), FT_FLOAT},
    {"rs_startelevator", CFG_OFS(rs_startelevator), FT_FLOAT},
    {"rs_falldamage5", CFG_OFS(rs_falldamage5), FT_FLOAT},
    {"rs_falldamage10", CFG_OFS(rs_falldamage10), FT_FLOAT},
    {"rs_maxjumpfallheight", CFG_OFS(rs_maxjumpfallheight), FT_FLOAT},
    {NULL, 0, 0, 0}
}

Definition at line 46 of file aas_cfg.c.

Referenced by DefaultCfg(), and SetCfgLibVars().

structdef_t cfg_struct
 

Initial value:

{
    sizeof(cfg_t), cfg_fields
}

Definition at line 91 of file aas_cfg.c.

Referenced by LoadCfgFile().


Generated on Thu Aug 25 12:44:45 2005 for Quake III Arena by  doxygen 1.3.9.1