2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2007, 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 files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future projects/authors will amend these files as needed.
28 * file.c: Empire game data file descriptions.
30 * Known contributors to this file:
31 * Markus Armbruster, 2005-2007
37 #include "commodity.h"
56 /* Number of elements in ARRAY. */
57 #define SZ(array) (sizeof(array) / sizeof((array)[0]))
59 /* Initializers for members flags... */
61 #define UNMAPPED_CACHE(type, flags) \
62 sizeof(type), (flags), NULL, 0, 0, 0, 0, -1, NULL, NULL, NULL
64 * Mapped cache, array with known size.
65 * Members cids, fids are not set.
67 #define ARRAY_CACHE(array, flags) \
68 sizeof(*(array)), (flags), (char *)(array), \
69 SZ((array)), 0, 0, 0, -1, NULL, NULL, NULL
71 * Mapped cache, array with unknown size.
72 * Members csize, cids, fids are not set.
74 #define PTR_CACHE(ptr, flags) \
75 sizeof(*(ptr)), (flags), (char *)(ptr), \
76 0, 0, 0, 0, -1, NULL, NULL, NULL
79 * The array's last element is the sentinel.
81 #define ARRAY_TABLE(array, flags) \
82 sizeof(*(array)), (flags), (char *)(array), \
83 SZ((array)), 0, SZ((array)) - 1, SZ((array)) - 1, -1, NULL, NULL, NULL
85 /* Common configuration table flags */
86 #define EFF_CFG (EFF_RDONLY | EFF_MEM | EFF_STATIC)
88 struct empfile empfile[] = {
90 * How this initializer works:
92 * Members uid, name, file, size, cadef, and the EFF_IMMUTABLE
93 * bits of flags get their final value.
94 * If flags & EFF_STATIC, the cache is mapped here, and members
95 * cache, csize get their final value.
96 * Members baseid, cids, fids and the EFF_MEM|EFF_RDONLY bits of
97 * flags are initialized according the initial cache contents.
98 * Member fd is initialized to -1.
99 * Members init, postread, prewrite get initialized to NULL, but
100 * that can be changed by users.
102 * Whatever of the above can't be done here must be done in
107 * Keep in mind that player command arguments are matched against
108 * values of member name: no whitespace there, please.
111 /* Dynamic game data */
112 {EF_SECTOR, "sect", "sector", sect_ca,
113 UNMAPPED_CACHE(struct sctstr, EFF_XY | EFF_OWNER)},
114 {EF_SHIP, "ship", "ship", ship_ca,
115 UNMAPPED_CACHE(struct shpstr, EFF_XY | EFF_OWNER | EFF_GROUP)},
116 {EF_PLANE, "plane", "plane", plane_ca,
117 UNMAPPED_CACHE(struct plnstr, EFF_XY | EFF_OWNER | EFF_GROUP)},
118 {EF_LAND, "land", "land", land_ca,
119 UNMAPPED_CACHE(struct lndstr, EFF_XY | EFF_OWNER | EFF_GROUP)},
120 {EF_NUKE, "nuke", "nuke", nuke_ca,
121 UNMAPPED_CACHE(struct nukstr, EFF_XY | EFF_OWNER)},
122 {EF_NEWS, "news", "news", news_ca,
123 UNMAPPED_CACHE(struct nwsstr, 0)},
124 {EF_TREATY, "treaty", "treaty", treaty_ca,
125 UNMAPPED_CACHE(struct trtstr, 0)},
126 {EF_TRADE, "trade", "trade", trade_ca,
127 UNMAPPED_CACHE(struct trdstr, 0)},
128 {EF_POWER, "pow", "power", NULL,
129 UNMAPPED_CACHE(struct powstr, 0)},
130 {EF_NATION, "nat", "nation", nat_ca,
131 UNMAPPED_CACHE(struct natstr, EFF_OWNER)},
132 {EF_LOAN, "loan", "loan", loan_ca,
133 UNMAPPED_CACHE(struct lonstr, 0)},
134 {EF_MAP, "map", "map", NULL,
135 0, 0, NULL, 0, 0, 0, 0, -1, NULL, NULL, NULL},
136 {EF_BMAP, "bmap", "bmap", NULL,
137 0, 0, NULL, 0, 0, 0, 0, -1, NULL, NULL, NULL},
138 {EF_COMM, "commodity", "commodity", commodity_ca,
139 UNMAPPED_CACHE(struct comstr, 0)},
140 {EF_LOST, "lost", "lostitems", lost_ca,
141 UNMAPPED_CACHE(struct loststr, EFF_OWNER)},
142 {EF_REALM, "realm", "realms", realm_ca,
143 UNMAPPED_CACHE(struct realmstr, EFF_OWNER)},
144 {EF_GAME, "game", "game", game_ca,
145 UNMAPPED_CACHE(struct gamestr, 0)},
147 /* Static game data (configuration) */
148 {EF_ITEM, "item", "item.config", ichr_ca,
149 ARRAY_CACHE(ichr, EFF_CFG)},
150 {EF_PRODUCT, "product", "product.config", pchr_ca,
151 ARRAY_CACHE(pchr, EFF_CFG)},
152 {EF_SECTOR_CHR, "sect-chr", "sect.config", dchr_ca,
153 ARRAY_CACHE(dchr, EFF_CFG)},
154 {EF_SHIP_CHR, "ship-chr", "ship.config", mchr_ca,
155 ARRAY_CACHE(mchr, EFF_CFG)},
156 {EF_PLANE_CHR, "plane-chr", "plane.config", plchr_ca,
157 ARRAY_CACHE(plchr, EFF_CFG)},
158 {EF_LAND_CHR, "land-chr", "land.config", lchr_ca,
159 ARRAY_CACHE(lchr, EFF_CFG)},
160 {EF_NUKE_CHR, "nuke-chr", "nuke.config", nchr_ca,
161 ARRAY_CACHE(nchr, EFF_CFG)},
162 {EF_NEWS_CHR, "news-chr", NULL, rpt_ca,
163 ARRAY_TABLE(rpt, EFF_CFG)},
164 {EF_INFRASTRUCTURE, "infrastructure", "infra.config", intrchr_ca,
165 ARRAY_CACHE(intrchr, EFF_CFG)},
166 {EF_UPDATES, "updates", NULL, update_ca,
167 ARRAY_TABLE(update_time, EFF_CFG)},
168 {EF_TABLE, "table", NULL, empfile_ca,
169 ARRAY_TABLE(empfile, EFF_CFG)},
170 {EF_META, "meta", NULL, mdchr_ca,
171 PTR_CACHE(mdchr_ca, EFF_CFG)},
174 #define SYMTAB(type, name, tab) \
175 {(type), (name), NULL, symbol_ca, PTR_CACHE((tab), EFF_CFG)}
176 SYMTAB(EF_AGREEMENT_STATUS, "agreement-status", agreement_statuses),
177 SYMTAB(EF_LAND_CHR_FLAGS, "land-chr-flags", land_chr_flags),
178 SYMTAB(EF_LEVEL, "level", level),
179 SYMTAB(EF_META_FLAGS, "meta-flags", meta_flags),
180 SYMTAB(EF_META_TYPE, "meta-type", meta_type),
181 SYMTAB(EF_MISSIONS, "missions", missions),
182 SYMTAB(EF_NATION_FLAGS, "nation-flags", nation_flags),
183 SYMTAB(EF_NATION_REJECTS, "nation-rejects", nation_rejects),
184 SYMTAB(EF_NATION_RELATIONS, "nation-relationships", nation_relations),
185 SYMTAB(EF_NATION_STATUS, "nation-status", nation_status),
186 SYMTAB(EF_NUKE_CHR_FLAGS, "nuke-chr-flags", nuke_chr_flags),
187 SYMTAB(EF_PACKING, "packing", packing),
188 SYMTAB(EF_PAGE_HEADINGS, "page-headings", page_headings),
189 SYMTAB(EF_PLAGUE_STAGES, "plague-stages", plague_stages),
190 SYMTAB(EF_PLANE_CHR_FLAGS, "plane-chr-flags", plane_chr_flags),
191 SYMTAB(EF_PLANE_FLAGS, "plane-flags", plane_flags),
192 SYMTAB(EF_RESOURCES, "resources", resources),
193 SYMTAB(EF_RETREAT_FLAGS, "retreat-flags", retreat_flags),
194 SYMTAB(EF_SECTOR_NAVIGATION, "sector-navigation", sector_navigation),
195 SYMTAB(EF_SHIP_CHR_FLAGS, "ship-chr-flags", ship_chr_flags),
196 SYMTAB(EF_TREATY_FLAGS, "treaty-flags", treaty_flags),
199 {EF_COUNTRY, "country", NULL, cou_ca, UNMAPPED_CACHE(struct natstr, 0)},
202 {EF_BAD, NULL, NULL, NULL, 0, 0, NULL, 0, 0, 0, 0, -1, NULL, NULL, NULL},