UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
entitiesdef.h
Go to the documentation of this file.
1 
6 /*
7 All original material Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 Copyright (C) 1997-2001 Id Software, Inc.
10 
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 as published by the Free Software Foundation; either version 2
14 of the License, or (at your option) any later version.
15 
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 
20 See the GNU General Public License for more details.
21 
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 
26 */
27 
28 #pragma once
29 
30 # define ED_MAX_DEFS 64
31 
32 # define ED_ERROR -1
33 # define ED_OK 1
34 
35 # define ED_OPTIONAL (1<<0)
36 # define ED_MANDATORY (1<<1)
37 # define ED_ABSTRACT (1<<2)
38 # define ED_TYPE_FLOAT (1<<3)
39 # define ED_TYPE_INT (1<<4)
40 # define ED_TYPE_STRING (1<<5)
41 # define ED_DEFAULT (1<<6)
42 # define ED_MODE_TYPE (1<<7)
43 # define ED_RANGE (1<<8)
44 # define ED_INSIST_POSITIVE (1<<9)
45 # define ED_TYPE_BOOL (1<<10)
46 
47 # define ED_CONCRETE (ED_OPTIONAL | ED_MANDATORY)
48 # define ED_KEY_TYPE (ED_TYPE_FLOAT | ED_TYPE_INT | ED_TYPE_STRING | ED_TYPE_BOOL)
49 
50 typedef union int_float_u {
51  int i;
52  float f;
53 } int_float_tu;
54 
55 typedef struct entityKeyRange_s {
56  char* str;
57  int* iArr;
58  float* fArr;
60  int continuous;
62 
63 typedef struct entityKeyDef_s {
64  char* name;
65  char* desc;
66  char* defaultVal;
67  int flags;
68  int vLen;
70  int numRanges;
72 
73 typedef struct entityDef_s {
74  char* classname;
77 } entityDef_t;
78 
79 int ED_GetIntVector(const entityKeyDef_t* kd, int v[], const int n);
80 int ED_Check(const char* classname, const char* key, const char* value);
81 int ED_CheckKey(const entityKeyDef_t* kd, const char* value);
82 const entityDef_t* ED_GetEntityDef(const char* classname);
83 const entityKeyDef_t* ED_GetKeyDef(const char* classname, const char* keyname, const int abstract);
84 const entityKeyDef_t* ED_GetKeyDefEntity(const entityDef_t* ed, const char* keyname, const int abstract);
85 int ED_Parse(const char* data_p);
86 const char* ED_GetLastError(void);
87 void ED_Free(void);
88 
89 extern int numEntityDefs;
union int_float_u int_float_tu
int ED_GetIntVector(const entityKeyDef_t *kd, int v[], const int n)
parses a value from the definition
char * defaultVal
Definition: entitiesdef.h:66
int ED_Parse(const char *data_p)
int numEntityDefs
Definition: entitiesdef.cpp:45
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...
const entityKeyDef_t * ED_GetKeyDef(const char *classname, const char *keyname, const int abstract)
searches for the parsed key def
void ED_Free(void)
unsigned int key
Definition: cl_input.cpp:68
struct entityDef_s entityDef_t
int numKeyDefs
Definition: entitiesdef.h:76
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
entityDef_t entityDefs[ED_MAX_DEFS+1]
Definition: entitiesdef.cpp:46
const char * ED_GetLastError(void)
struct entityKeyRange_s entityKeyRange_t
char * classname
Definition: entitiesdef.h:74
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.
struct entityKeyDef_s entityKeyDef_t
const entityDef_t * ED_GetEntityDef(const char *classname)
searches for the parsed entity def by classname
QGL_EXTERN int GLboolean GLfloat * v
Definition: r_gl.h:120
entityKeyRange_t ** ranges
Definition: entitiesdef.h:69
#define ED_MAX_DEFS
Definition: entitiesdef.h:30
entityKeyDef_t * keyDefs
Definition: entitiesdef.h:75