Debian Codegraph @

code/botlib/l_struct.h

raw
1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake III Arena source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake III Arena source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
21 */
22
23 /*****************************************************************************
24 * name: l_struct.h
25 *
26 * desc: structure reading/writing
27 *
28 * $Archive: /source/code/botlib/l_struct.h $
29 *
30 *****************************************************************************/
31
32
33 #define MAX_STRINGFIELD 80
34 //field types
35 #define FT_CHAR 1 // char
36 #define FT_INT 2 // int
37 #define FT_FLOAT 3 // float
38 #define FT_STRING 4 // char [MAX_STRINGFIELD]
39 #define FT_STRUCT 6 // struct (sub structure)
40 //type only mask
41 #define FT_TYPE 0x00FF // only type, clear subtype
42 //sub types
43 #define FT_ARRAY 0x0100 // array of type
44 #define FT_BOUNDED 0x0200 // bounded value
45 #define FT_UNSIGNED 0x0400
46
47 //structure field definition
48 typedef struct fielddef_s
49 {
50 char *name; //name of the field
51 int offset; //offset in the structure
52 int type; //type of the field
53 //type specific fields
54 int maxarray; //maximum array size
55 float floatmin, floatmax; //float min and max
56 struct structdef_s *substruct; //sub structure
57 } fielddef_t;
58
59 //structure definition
60 typedef struct structdef_s
61 {
62 int size;
63 fielddef_t *fields;
64 } structdef_t;
65
66 //read a structure from a script
67 int ReadStructure(source_t *source, structdef_t *def, char *structure);
68 //write a structure to a file
69 int WriteStructure(FILE *fp, structdef_t *def, char *structure);
70 //writes indents
71 int WriteIndent(FILE *fp, int indent);
72 //writes a float without traling zeros
73 int WriteFloat(FILE *fp, float value);
74
75