* file.c: Empire game data file descriptions.
*
* Known contributors to this file:
- * Markus Armbruster, 2005-2007
+ * Markus Armbruster, 2005-2008
*/
#include <config.h>
#include "server.h"
#include "trade.h"
#include "treaty.h"
+#include "version.h"
#include "xy.h"
/* Number of elements in ARRAY. */
/* Initializers for members flags... */
/* Unmapped cache */
#define UNMAPPED_CACHE(type, flags) \
- sizeof(type), (flags), NULL, 0, 0, 0, 0, -1, NULL, NULL, NULL
+ sizeof(type), (flags), NULL, 0, 0, 0, 0, -1, NULL, NULL
/*
* Mapped cache, array with known size.
* Members cids, fids are not set.
*/
#define ARRAY_CACHE(array, flags) \
sizeof(*(array)), (flags), (char *)(array), \
- SZ((array)), 0, 0, 0, -1, NULL, NULL, NULL
+ SZ((array)), 0, 0, 0, -1, NULL, NULL
/*
* Mapped cache, array with unknown size.
* Members csize, cids, fids are not set.
*/
#define PTR_CACHE(ptr, flags) \
sizeof(*(ptr)), (flags), (char *)(ptr), \
- 0, 0, 0, 0, -1, NULL, NULL, NULL
+ 0, 0, 0, 0, -1, NULL, NULL
/*
* Array-backed table.
* The array's last element is the sentinel.
*/
#define ARRAY_TABLE(array, flags) \
sizeof(*(array)), (flags), (char *)(array), \
- SZ((array)), 0, SZ((array)) - 1, SZ((array)) - 1, -1, NULL, NULL, NULL
+ SZ((array)), 0, SZ((array)) - 1, SZ((array)) - 1, -1, NULL, NULL
/* Common configuration table flags */
-#define EFF_CFG (EFF_RDONLY | EFF_MEM | EFF_STATIC)
+#define EFF_CFG (EFF_PRIVATE | EFF_MEM | EFF_STATIC | EFF_SENTINEL)
struct empfile empfile[] = {
/*
* bits of flags get their final value.
* If flags & EFF_STATIC, the cache is mapped here, and members
* cache, csize get their final value.
- * Members baseid, cids, fids and the EFF_MEM|EFF_RDONLY bits of
+ * Members baseid, cids, fids and the EFF_MEM|EFF_PRIVATE bits of
* flags are initialized according the initial cache contents.
* Member fd is initialized to -1.
* Members init, postread, prewrite get initialized to NULL, but
* that can be changed by users.
*
* Whatever of the above can't be done here must be done in
- * empfile_init() or empfile_fixup().
+ * empfile_init() or empfile_fixup(). Except cadef may be set in
+ * nsc_init() instead.
*/
/*
* Fixed up by empfile_fixup().
*/
{EF_SECTOR, "sect", "sector", sect_ca,
- UNMAPPED_CACHE(struct sctstr, EFF_XY | EFF_OWNER)},
+ UNMAPPED_CACHE(struct sctstr, EFF_TYPED | EFF_XY | EFF_OWNER)},
{EF_SHIP, "ship", "ship", ship_ca,
- UNMAPPED_CACHE(struct shpstr, EFF_XY | EFF_OWNER | EFF_GROUP)},
+ UNMAPPED_CACHE(struct shpstr,
+ EFF_TYPED | EFF_XY | EFF_OWNER | EFF_GROUP)},
{EF_PLANE, "plane", "plane", plane_ca,
- UNMAPPED_CACHE(struct plnstr, EFF_XY | EFF_OWNER | EFF_GROUP)},
+ UNMAPPED_CACHE(struct plnstr,
+ EFF_TYPED | EFF_XY | EFF_OWNER | EFF_GROUP)},
{EF_LAND, "land", "land", land_ca,
- UNMAPPED_CACHE(struct lndstr, EFF_XY | EFF_OWNER | EFF_GROUP)},
+ UNMAPPED_CACHE(struct lndstr,
+ EFF_TYPED | EFF_XY | EFF_OWNER | EFF_GROUP)},
{EF_NUKE, "nuke", "nuke", nuke_ca,
- UNMAPPED_CACHE(struct nukstr, EFF_XY | EFF_OWNER)},
+ UNMAPPED_CACHE(struct nukstr, EFF_TYPED | EFF_XY | EFF_OWNER)},
{EF_NEWS, "news", "news", news_ca,
- UNMAPPED_CACHE(struct nwsstr, 0)},
+ UNMAPPED_CACHE(struct nwsstr, EFF_TYPED)},
{EF_TREATY, "treaty", "treaty", treaty_ca,
- UNMAPPED_CACHE(struct trtstr, 0)},
+ UNMAPPED_CACHE(struct trtstr, EFF_TYPED)},
{EF_TRADE, "trade", "trade", trade_ca,
- UNMAPPED_CACHE(struct trdstr, 0)},
+ UNMAPPED_CACHE(struct trdstr, EFF_TYPED | EFF_OWNER)},
{EF_POWER, "pow", "power", NULL,
UNMAPPED_CACHE(struct powstr, 0)},
{EF_NATION, "nat", "nation", nat_ca,
- UNMAPPED_CACHE(struct natstr, EFF_OWNER)},
+ UNMAPPED_CACHE(struct natstr, EFF_TYPED | EFF_OWNER)},
{EF_LOAN, "loan", "loan", loan_ca,
- UNMAPPED_CACHE(struct lonstr, 0)},
+ UNMAPPED_CACHE(struct lonstr, EFF_TYPED)},
{EF_MAP, "map", "map", NULL,
- 0, 0, NULL, 0, 0, 0, 0, -1, NULL, NULL, NULL},
+ 0, 0, NULL, 0, 0, 0, 0, -1, NULL, NULL},
{EF_BMAP, "bmap", "bmap", NULL,
- 0, 0, NULL, 0, 0, 0, 0, -1, NULL, NULL, NULL},
+ 0, 0, NULL, 0, 0, 0, 0, -1, NULL, NULL},
{EF_COMM, "commodity", "commodity", commodity_ca,
- UNMAPPED_CACHE(struct comstr, 0)},
+ UNMAPPED_CACHE(struct comstr, EFF_TYPED | EFF_OWNER)},
{EF_LOST, "lost", "lostitems", lost_ca,
- UNMAPPED_CACHE(struct loststr, EFF_OWNER)},
+ UNMAPPED_CACHE(struct loststr, EFF_TYPED | EFF_OWNER)},
{EF_REALM, "realm", "realms", realm_ca,
- UNMAPPED_CACHE(struct realmstr, EFF_OWNER)},
+ UNMAPPED_CACHE(struct realmstr, EFF_TYPED | EFF_OWNER)},
{EF_GAME, "game", "game", game_ca,
- UNMAPPED_CACHE(struct gamestr, 0)},
+ UNMAPPED_CACHE(struct gamestr, EFF_TYPED)},
/*
* Static game data (configuration)
- *
- * These are all empty tables, except for EF_NEWS_CHR and EF_META.
- * Use read_builtin_tables() to fill them. EF_META gets bogus
- * size, cids and fids here. Fixed up by empfile_init().
+ */
+ /*
+ * Characteristics tables. Characteristics with a null file
+ * member are compiled in. The others are empty; use
+ * read_builtin_tables() to fill them.
*/
{EF_ITEM, "item", "item.config", ichr_ca,
ARRAY_CACHE(ichr, EFF_CFG)},
ARRAY_TABLE(rpt, EFF_CFG)},
{EF_INFRASTRUCTURE, "infrastructure", "infra.config", intrchr_ca,
ARRAY_CACHE(intrchr, EFF_CFG)},
+ /*
+ * Update schedule table. Use read_schedule() to fill.
+ */
{EF_UPDATES, "updates", NULL, update_ca,
ARRAY_TABLE(update_time, EFF_CFG)},
+ /*
+ * Special tables. EF_META gets bogus size, cids and fids here.
+ * Fixed up by empfile_init(). EF_VERSION's cadef is set by
+ * nsc_init().
+ */
{EF_TABLE, "table", NULL, empfile_ca,
ARRAY_TABLE(empfile, EFF_CFG)},
+ {EF_VERSION, "version", NULL, NULL,
+ sizeof(PACKAGE_STRING), EFF_STATIC, version, 1, 0, 1, 1, -1,
+ NULL, NULL},
{EF_META, "meta", NULL, mdchr_ca,
PTR_CACHE(mdchr_ca, EFF_CFG)},
/*
* Symbol tables
*
- * These get bogus size, cids and fids here. Fixed up by
+ * These get bogus csize, cids and fids here. Fixed up by
* empfile_init().
*/
#define SYMTAB(type, name, tab) \
SYMTAB(EF_TREATY_FLAGS, "treaty-flags", treaty_flags),
/* Views */
- {EF_COUNTRY, "country", NULL, cou_ca, UNMAPPED_CACHE(struct natstr, 0)},
+ {EF_COUNTRY, "country", NULL, cou_ca,
+ UNMAPPED_CACHE(struct natstr, EFF_TYPED | EFF_OWNER)},
/* Sentinel */
- {EF_BAD, NULL, NULL, NULL, 0, 0, NULL, 0, 0, 0, 0, -1, NULL, NULL, NULL},
+ {EF_BAD, NULL, NULL, NULL, 0, 0, NULL, 0, 0, 0, 0, -1, NULL, NULL},
};
static void