UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
entitiesdef.h File Reference

Handles definition of entities, parsing them from entities.ufo. More...

Go to the source code of this file.

Data Structures

union  int_float_u
 
struct  entityKeyRange_s
 
struct  entityKeyDef_s
 
struct  entityDef_s
 

Macros

#define ED_MAX_DEFS   64
 
#define ED_ERROR   -1
 
#define ED_OK   1
 
#define ED_OPTIONAL   (1<<0)
 
#define ED_MANDATORY   (1<<1)
 
#define ED_ABSTRACT   (1<<2)
 
#define ED_TYPE_FLOAT   (1<<3)
 
#define ED_TYPE_INT   (1<<4)
 
#define ED_TYPE_STRING   (1<<5)
 
#define ED_DEFAULT   (1<<6)
 
#define ED_MODE_TYPE   (1<<7)
 
#define ED_RANGE   (1<<8)
 
#define ED_INSIST_POSITIVE   (1<<9)
 
#define ED_TYPE_BOOL   (1<<10)
 
#define ED_CONCRETE   (ED_OPTIONAL | ED_MANDATORY)
 
#define ED_KEY_TYPE   (ED_TYPE_FLOAT | ED_TYPE_INT | ED_TYPE_STRING | ED_TYPE_BOOL)
 

Typedefs

typedef union int_float_u int_float_tu
 
typedef struct entityKeyRange_s entityKeyRange_t
 
typedef struct entityKeyDef_s entityKeyDef_t
 
typedef struct entityDef_s entityDef_t
 

Functions

int ED_GetIntVector (const entityKeyDef_t *kd, int v[], const int n)
 parses a value from the definition More...
 
int ED_Check (const char *classname, const char *key, const char *value)
 tests if a value string matches the type for this key. Also checks the value against the range, if one was defined. More...
 
int ED_CheckKey (const entityKeyDef_t *kd, const char *value)
 as ED_Check, but where the entity and key are known, so takes different arguments. More...
 
const entityDef_tED_GetEntityDef (const char *classname)
 searches for the parsed entity def by classname More...
 
const entityKeyDef_tED_GetKeyDef (const char *classname, const char *keyname, const int abstract)
 searches for the parsed key def More...
 
const entityKeyDef_tED_GetKeyDefEntity (const entityDef_t *ed, const char *keyname, const int abstract)
 searches for the parsed key def, when the entity def is known More...
 
int ED_Parse (const char *data_p)
 
const char * ED_GetLastError (void)
 
void ED_Free (void)
 

Variables

int numEntityDefs
 
entityDef_t entityDefs [ED_MAX_DEFS+1]
 

Detailed Description

Handles definition of entities, parsing them from entities.ufo.

Definition in file entitiesdef.h.

Macro Definition Documentation

#define ED_ABSTRACT   (1<<2)

flag and parse mode, radiant use exclusively, should not be in .map file as a key

Definition at line 37 of file entitiesdef.h.

Referenced by ED_Block2Constant(), ED_Constant2Block(), ED_FindKeyDefInArray(), ED_GetKeyDefEntity(), ED_PairParsed(), and ED_ParseEntities().

#define ED_CONCRETE   (ED_OPTIONAL | ED_MANDATORY)

flags indicating that this is a real key for use in a map file

Definition at line 47 of file entitiesdef.h.

#define ED_DEFAULT   (1<<6)

Definition at line 41 of file entitiesdef.h.

Referenced by ED_Block2Constant(), ED_Constant2Block(), and ED_PairParsed().

#define ED_ERROR   -1
#define ED_INSIST_POSITIVE   (1<<9)

the type insists that the values are unsigned

Definition at line 44 of file entitiesdef.h.

Referenced by ED_CheckNumericType(), ED_ParseType(), and ED_ProcessRanges().

#define ED_KEY_TYPE   (ED_TYPE_FLOAT | ED_TYPE_INT | ED_TYPE_STRING | ED_TYPE_BOOL)

Definition at line 48 of file entitiesdef.h.

Referenced by ED_CheckKey(), and ED_ProcessRanges().

#define ED_MANDATORY   (1<<1)

flag and parse mode. for entityKeyDef_t flags. entities of this type are not valid without this key. also a parse mode

Definition at line 36 of file entitiesdef.h.

Referenced by CheckEntities(), ED_Block2Constant(), ED_Constant2Block(), ED_PairParsed(), and ED_ParseEntities().

#define ED_MAX_DEFS   64

Definition at line 30 of file entitiesdef.h.

Referenced by ED_ParseEntities().

#define ED_MODE_TYPE   (1<<7)

flag parse mode indicating that a type is being parsed

Definition at line 42 of file entitiesdef.h.

Referenced by ED_Block2Constant(), ED_Constant2Block(), and ED_PairParsed().

#define ED_OPTIONAL   (1<<0)

flag and parse mode

Definition at line 35 of file entitiesdef.h.

Referenced by ED_Block2Constant(), ED_Constant2Block(), and ED_PairParsed().

#define ED_RANGE   (1<<8)

Definition at line 43 of file entitiesdef.h.

Referenced by ED_Block2Constant(), ED_Constant2Block(), and ED_PairParsed().

#define ED_TYPE_BOOL   (1<<10)
#define ED_TYPE_FLOAT   (1<<3)
#define ED_TYPE_STRING   (1<<5)

Typedef Documentation

typedef struct entityDef_s entityDef_t
typedef union int_float_u int_float_tu

Function Documentation

int ED_Check ( const char *  classname,
const char *  key,
const char *  value 
)

tests if a value string matches the type for this key. Also checks the value against the range, if one was defined.

Returns
ED_OK or ED_ERROR
See also
ED_GetLastError
Note
abstract (radiant) keys may not have types. keys used here must be declared in entities.ufo in an optional or mandatory block.

Definition at line 357 of file entitiesdef.cpp.

References ED_CheckKey(), ED_ERROR, and ED_GetKeyDef().

int ED_CheckKey ( const entityKeyDef_t kd,
const char *  value 
)

as ED_Check, but where the entity and key are known, so takes different arguments.

Returns
ED_ERROR or ED_OK
See also
ED_GetLastError

Definition at line 372 of file entitiesdef.cpp.

References ED_CheckNumericType(), ED_KEY_TYPE, ED_OK, ED_RETURN_ERROR, ED_TEST_RETURN_ERROR, ED_TYPE_BOOL, ED_TYPE_FLOAT, ED_TYPE_INT, ED_TYPE_STRING, and entityKeyDef_s::flags.

Referenced by CheckEntities(), ED_Check(), and ED_CheckDefaultTypes().

const entityDef_t* ED_GetEntityDef ( const char *  classname)

searches for the parsed entity def by classname

Returns
nullptr if the entity def is not found. call ED_GetLastError to get a relevant message.

Definition at line 815 of file entitiesdef.cpp.

References entityDef_s::classname, lastErr, entityDef_s::numKeyDefs, and Q_streq.

Referenced by CheckEntities(), ED_GetKeyDef(), and ED_ParseEntities().

int ED_GetIntVector ( const entityKeyDef_t kd,
int  v[],
const int  n 
)

parses a value from the definition

Parameters
kdthe key definition to parse from
[out]vthe array of int to put the answer in it must have enough space for n elements.
nthe number of elements expected in the vector
Returns
ED_ERROR or ED_OK
See also
ED_GetLastError.

Definition at line 208 of file entitiesdef.cpp.

References entityKeyDef_s::desc, ED_GetIntVectorFromString(), ED_OK, and ED_PASS_ERROR.

Referenced by Check_InfoStartAligned().

const entityKeyDef_t* ED_GetKeyDef ( const char *  classname,
const char *  keyname,
const int  abstract 
)

searches for the parsed key def

Parameters
classnameThe name, eg. "func_door"
keynameThe key we are looking for
abstractsend abstract to find an abstract key with this name
Returns
nullptr if the entity def or key def is not found. call ED_GetLastError to get a relevant message.

Definition at line 775 of file entitiesdef.cpp.

References ED_GetEntityDef(), and ED_GetKeyDefEntity().

Referenced by ED_Check().

const entityKeyDef_t* ED_GetKeyDefEntity ( const entityDef_t ed,
const char *  keyname,
const int  abstract 
)

searches for the parsed key def, when the entity def is known

Parameters
edThe list of keys for the entity
keynameThe key we are looking for
abstractsend a nonzero value if the abstract (radiant - not in any block) version of the key is required
Returns
nullptr if the entity def or key def is not found. call ED_GetLastError to get a relevant message.

Definition at line 789 of file entitiesdef.cpp.

References entityDef_s::classname, ED_ABSTRACT, entityKeyDef_s::flags, entityDef_s::keyDefs, lastErr, entityKeyDef_s::name, and Q_streq.

Referenced by Check_InfoStartAligned(), CheckEntities(), and ED_GetKeyDef().

const char* ED_GetLastError ( void  )

Definition at line 763 of file entitiesdef.cpp.

References lastErr.

Referenced by Check_InfoStartAligned(), Check_InitEntityDefs(), and CheckEntities().

int ED_Parse ( const char *  data_p)

parses entity definitions from entities.ufo

Returns
ED_OK or ED_ERR
See also
ED_GetLastErr

Definition at line 738 of file entitiesdef.cpp.

References ED_CheckDefaultTypes(), ED_OK, ED_ParseEntities(), ED_PASS_ERROR, ED_ProcessRanges(), ED_TEST_RETURN_ERROR, lastErr, numEntityDefs, and OBJZERO.

Referenced by Check_InitEntityDefs(), and TEST_F().

Variable Documentation

entityDef_t entityDefs[ED_MAX_DEFS+1]

Definition at line 46 of file entitiesdef.cpp.

Referenced by Check_Stats(), and TEST_F().

int numEntityDefs