2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2005, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * file.h: Describes Empire tables (`files' for historical reasons)
30 * Known contributors to this file:
31 * Markus Armbruster, 2005
40 int ef_uid; /* Table ID */
41 char *name; /* Empire name (e.g., "treaty") */
42 char *file; /* if backed by file, file name relative to
44 int flags; /* EFF_XY, ... */
45 int size; /* size of a table entry */
46 void (*init)(int, char *); /* called after entry creation, unless null */
47 int (*postread)(int, char *); /* called after read, unless null */
48 int (*prewrite)(int, char *); /* called before write, unless null */
49 int fd; /* file descriptor, -1 if not open */
50 int baseid; /* id of first entry in cache */
51 int cids; /* # entries in cache */
52 int csize; /* cache size, in entries */
53 char *cache; /* pointer to cache */
54 int fids; /* # entries in table */
55 struct castr *cadef; /* table column selectors (column meta-data) */
59 * struct empfile flags
62 * EFF_XY / EFF_OWNER / EFF_GROUP assert that coordinates / owner /
63 * group of such a table's entries can be safely obtained by
64 * dereferencing entry address cast to struct genitem *.
67 #define EFF_OWNER bit(1)
68 #define EFF_GROUP bit(2)
69 /* Table is entirely in memory */
70 #define EFF_MEM bit(3)
71 /* Table is read-only */
72 #define EFF_RDONLY bit(4)
73 /* Create table file, clobbering any existing file */
74 #define EFF_CREATE bit(5)
75 /* Table is allocated statically */
76 #define EFF_STATIC bit(6)
78 /* Flags that may be passed to ef_open() */
79 #define EFF_OPEN (EFF_MEM | EFF_RDONLY | EFF_CREATE)
83 * These are really table IDs. Some tables are backed by files, some
84 * are compiled into the server.
85 * Historically, only table IDs 0..EF_MAX-1 existed. All the
86 * functions operating on table IDs still reject the new indexes >=
87 * EF_MAX. This needs to be rectified, carefully checking existing
88 * code, which could rely on unspoken assumptions about these tables.
92 /* Dynamic game data tables: 0..EF_MAX-1 */
109 /* Static game data (configuration): EF_MAX.. */
110 #define EF_SECTOR_CHR 15
111 #define EF_SHIP_CHR 16
112 #define EF_PLANE_CHR 17
113 #define EF_LAND_CHR 18
114 #define EF_NUKE_CHR 19
115 #if 0 /* doesn't exist yet */
118 #define EF_TREATY_CHR 20
120 #define EF_INFRASTRUCTURE 22
121 #define EF_PRODUCT 23
123 #define EF_SHIP_CHR_FLAGS 25
124 #define EF_PLANE_CHR_FLAGS 26
125 #define EF_LAND_CHR_FLAGS 27
126 #define EF_NUKE_CHR_FLAGS 28
128 #define EF_META_TYPE 30
129 #define EF_META_FLAGS 31
133 void (*init) (int, char *);
134 int (*postread) (int, char *);
135 int (*prewrite) (int, char *);
138 extern struct castr *ef_cadef(int);
139 extern int ef_read(int, int, void *);
140 extern void *ef_ptr(int, int);
141 extern char *ef_nameof(int);
142 extern time_t ef_mtime(int);
143 extern int ef_open(int, int);
144 extern int ef_check(int);
145 extern int ef_close(int);
146 extern int ef_flush(int);
147 extern int ef_write(int, int, void *);
148 extern int ef_extend(int, int);
149 extern int ef_ensure_space(int, int, int);
150 extern int ef_nelem(int);
151 extern int ef_flags(int);
152 extern int ef_byname(char *);
154 extern struct empfile empfile[];
156 #endif /* _FILE_H_ */