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

l_libvar.c File Reference

#include "../game/q_shared.h"
#include "l_memory.h"
#include "l_libvar.h"

Include dependency graph for l_libvar.c:

Include dependency graph

Go to the source code of this file.

Functions

libvar_tLibVar (char *var_name, char *value)
libvar_tLibVarAlloc (char *var_name)
qboolean LibVarChanged (char *var_name)
void LibVarDeAlloc (libvar_t *v)
void LibVarDeAllocAll (void)
libvar_tLibVarGet (char *var_name)
char * LibVarGetString (char *var_name)
float LibVarGetValue (char *var_name)
void LibVarSet (char *var_name, char *value)
void LibVarSetNotModified (char *var_name)
char * LibVarString (char *var_name, char *value)
float LibVarStringValue (char *string)
float LibVarValue (char *var_name, char *value)

Variables

libvar_tlibvarlist


Function Documentation

libvar_t* LibVar char *  var_name,
char *  value
 

Definition at line 189 of file l_libvar.c.

References GetMemory(), libvar_t, LibVarAlloc(), LibVarGet(), LibVarStringValue(), libvar_s::modified, strcpy(), libvar_s::string, strlen(), v, value, and libvar_s::value.

Referenced by AAS_Setup(), BotSetupGoalAI(), BotSetupMoveAI(), LibVarString(), and LibVarValue().

00190 {
00191     libvar_t *v;
00192     v = LibVarGet(var_name);
00193     if (v) return v;
00194     //create new variable
00195     v = LibVarAlloc(var_name);
00196     //variable string
00197     v->string = (char *) GetMemory(strlen(value) + 1);
00198     strcpy(v->string, value);
00199     //the value
00200     v->value = LibVarStringValue(v->string);
00201     //variable is modified
00202     v->modified = qtrue;
00203     //
00204     return v;
00205 } //end of the function LibVar

Here is the call graph for this function:

libvar_t* LibVarAlloc char *  var_name  ) 
 

Definition at line 83 of file l_libvar.c.

References Com_Memset(), GetMemory(), libvar_t, libvarlist, libvar_s::name, libvar_s::next, strcpy(), strlen(), and v.

Referenced by LibVar(), and LibVarSet().

00084 {
00085     libvar_t *v;
00086 
00087     v = (libvar_t *) GetMemory(sizeof(libvar_t) + strlen(var_name) + 1);
00088     Com_Memset(v, 0, sizeof(libvar_t));
00089     v->name = (char *) v + sizeof(libvar_t);
00090     strcpy(v->name, var_name);
00091     //add the variable in the list
00092     v->next = libvarlist;
00093     libvarlist = v;
00094     return v;
00095 } //end of the function LibVarAlloc

Here is the call graph for this function:

qboolean LibVarChanged char *  var_name  ) 
 

Definition at line 265 of file l_libvar.c.

References libvar_t, LibVarGet(), libvar_s::modified, qboolean, and v.

00266 {
00267     libvar_t *v;
00268 
00269     v = LibVarGet(var_name);
00270     if (v)
00271     {
00272         return v->modified;
00273     } //end if
00274     else
00275     {
00276         return qfalse;
00277     } //end else
00278 } //end of the function LibVarChanged

Here is the call graph for this function:

void LibVarDeAlloc libvar_t v  ) 
 

Definition at line 102 of file l_libvar.c.

References FreeMemory(), libvar_t, libvar_s::string, and v.

Referenced by LibVarDeAllocAll().

00103 {
00104     if (v->string) FreeMemory(v->string);
00105     FreeMemory(v);
00106 } //end of the function LibVarDeAlloc

Here is the call graph for this function:

void LibVarDeAllocAll void   ) 
 

Definition at line 113 of file l_libvar.c.

References libvar_t, LibVarDeAlloc(), libvarlist, libvar_s::next, and v.

Referenced by Export_BotLibShutdown().

00114 {
00115     libvar_t *v;
00116 
00117     for (v = libvarlist; v; v = libvarlist)
00118     {
00119         libvarlist = libvarlist->next;
00120         LibVarDeAlloc(v);
00121     } //end for
00122     libvarlist = NULL;
00123 } //end of the function LibVarDeAllocAll

Here is the call graph for this function:

libvar_t* LibVarGet char *  var_name  ) 
 

Definition at line 130 of file l_libvar.c.

References libvar_t, libvar_s::name, libvar_s::next, Q_stricmp(), and v.

Referenced by LibVar(), LibVarChanged(), LibVarGetString(), LibVarGetValue(), LibVarSet(), and LibVarSetNotModified().

00131 {
00132     libvar_t *v;
00133 
00134     for (v = libvarlist; v; v = v->next)
00135     {
00136         if (!Q_stricmp(v->name, var_name))
00137         {
00138             return v;
00139         } //end if
00140     } //end for
00141     return NULL;
00142 } //end of the function LibVarGet

Here is the call graph for this function:

char* LibVarGetString char *  var_name  ) 
 

Definition at line 149 of file l_libvar.c.

References libvar_t, LibVarGet(), libvar_s::string, and v.

Referenced by AAS_LoadAASFile(), and Export_BotLibVarGet().

00150 {
00151     libvar_t *v;
00152 
00153     v = LibVarGet(var_name);
00154     if (v)
00155     {
00156         return v->string;
00157     } //end if
00158     else
00159     {
00160         return "";
00161     } //end else
00162 } //end of the function LibVarGetString

Here is the call graph for this function:

float LibVarGetValue char *  var_name  ) 
 

Definition at line 169 of file l_libvar.c.

References libvar_t, LibVarGet(), v, and libvar_s::value.

Referenced by AAS_ContinueInit(), AAS_InitClustering(), AAS_InitReachability(), AAS_StartFrame(), BotEnterChat(), BotExportTest(), BotFreeCharacter(), BotFreeChatState(), BotLoadCharacterSkill(), BotLoadChatFile(), BotNumInitialChats(), BotReplyChat(), Export_BotLibSetup(), FreeWeightConfig(), and ReadWeightConfig().

00170 {
00171     libvar_t *v;
00172 
00173     v = LibVarGet(var_name);
00174     if (v)
00175     {
00176         return v->value;
00177     } //end if
00178     else
00179     {
00180         return 0;
00181     } //end else
00182 } //end of the function LibVarGetValue

Here is the call graph for this function:

void LibVarSet char *  var_name,
char *  value
 

Definition at line 238 of file l_libvar.c.

References FreeMemory(), GetMemory(), libvar_t, LibVarAlloc(), LibVarGet(), LibVarStringValue(), libvar_s::modified, strcpy(), libvar_s::string, strlen(), v, value, and libvar_s::value.

Referenced by AAS_StartFrame(), Export_BotLibVarSet(), LoadItemConfig(), LoadWeaponConfig(), and SetCfgLibVars().

00239 {
00240     libvar_t *v;
00241 
00242     v = LibVarGet(var_name);
00243     if (v)
00244     {
00245         FreeMemory(v->string);
00246     } //end if
00247     else
00248     {
00249         v = LibVarAlloc(var_name);
00250     } //end else
00251     //variable string
00252     v->string = (char *) GetMemory(strlen(value) + 1);
00253     strcpy(v->string, value);
00254     //the value
00255     v->value = LibVarStringValue(v->string);
00256     //variable is modified
00257     v->modified = qtrue;
00258 } //end of the function LibVarSet

Here is the call graph for this function:

void LibVarSetNotModified char *  var_name  ) 
 

Definition at line 285 of file l_libvar.c.

References libvar_t, LibVarGet(), libvar_s::modified, and v.

00286 {
00287     libvar_t *v;
00288 
00289     v = LibVarGet(var_name);
00290     if (v)
00291     {
00292         v->modified = qfalse;
00293     } //end if
00294 } //end of the function LibVarSetNotModified

Here is the call graph for this function:

char* LibVarString char *  var_name,
char *  value
 

Definition at line 212 of file l_libvar.c.

References LibVar(), libvar_t, libvar_s::string, v, and value.

Referenced by BotSetupChatAI(), BotSetupGoalAI(), and BotSetupWeaponAI().

00213 {
00214     libvar_t *v;
00215 
00216     v = LibVar(var_name, value);
00217     return v->string;
00218 } //end of the function LibVarString

Here is the call graph for this function:

float LibVarStringValue char *  string  ) 
 

Definition at line 45 of file l_libvar.c.

References string(), and value.

Referenced by LibVar(), and LibVarSet().

00046 {
00047     int dotfound = 0;
00048     float value = 0;
00049 
00050     while(*string)
00051     {
00052         if (*string < '0' || *string > '9')
00053         {
00054             if (dotfound || *string != '.')
00055             {
00056                 return 0;
00057             } //end if
00058             else
00059             {
00060                 dotfound = 10;
00061                 string++;
00062             } //end if
00063         } //end if
00064         if (dotfound)
00065         {
00066             value = value + (float) (*string - '0') / (float) dotfound;
00067             dotfound *= 10;
00068         } //end if
00069         else
00070         {
00071             value = value * 10.0 + (float) (*string - '0');
00072         } //end else
00073         string++;
00074     } //end while
00075     return value;
00076 } //end of the function LibVarStringValue

Here is the call graph for this function:

float LibVarValue char *  var_name,
char *  value
 

Definition at line 225 of file l_libvar.c.

References LibVar(), libvar_t, v, value, and libvar_s::value.

Referenced by AAS_BestReachableFromJumpPadArea(), AAS_ContinueInit(), AAS_InitAASLinkHeap(), AAS_InitRouting(), AAS_InitSettings(), AAS_Reachability_JumpPad(), AAS_Setup(), BotSetupChatAI(), BotSetupGoalAI(), Export_BotLibSetup(), InitConsoleMessageHeap(), InitLevelItemHeap(), LoadItemConfig(), LoadWeaponConfig(), and Log_Open().

00226 {
00227     libvar_t *v;
00228 
00229     v = LibVar(var_name, value);
00230     return v->value;
00231 } //end of the function LibVarValue

Here is the call graph for this function:


Variable Documentation

libvar_t* libvarlist
 

Definition at line 37 of file l_libvar.c.

Referenced by LibVarAlloc(), and LibVarDeAllocAll().


Generated on Thu Aug 25 12:42:48 2005 for Quake III Arena by  doxygen 1.3.9.1