]> git.pond.sub.org Git - empserver/blobdiff - src/lib/common/filetable.c
Update copyright notice
[empserver] / src / lib / common / filetable.c
index 792e62ab935578c0fada96e227a9fcc48ed21239..fd9fd39e423449bde15d47c78079e36222444c2c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2014, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2020, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
  *  filetable.c: Empire game data file descriptions.
  *
  *  Known contributors to this file:
- *     Markus Armbruster, 2005-2013
+ *     Markus Armbruster, 2005-2016
  */
 
 #include <config.h>
 
+#include <assert.h>
 #include <stddef.h>
+#include <string.h>
 #include "commodity.h"
-#include "file.h"
 #include "game.h"
 #include "land.h"
 #include "loan.h"
@@ -51,8 +52,6 @@
 #include "ship.h"
 #include "server.h"
 #include "trade.h"
-#include "treaty.h"
-#include "version.h"
 #include "xy.h"
 
 static void sct_oninit(void *);
@@ -60,6 +59,7 @@ static void pln_oninit(void *);
 static void lnd_oninit(void *);
 static void nuk_oninit(void *);
 static void nat_oninit(void *);
+static void contact_oninit(void *);
 static void realm_oninit(void *);
 static void game_oninit(void *);
 static void pchr_oninit(void *);
@@ -68,7 +68,9 @@ static void plchr_oninit(void *);
 static void lchr_oninit(void *);
 static void nchr_oninit(void *);
 
-/* Number of elements in ARRAY.  */
+static char dummy_cache;
+
+/* Number of elements in ARRAY. */
 #define SZ(array) (sizeof(array) / sizeof((array)[0]))
 
 /* Initializers for members flags... */
@@ -154,9 +156,6 @@ struct empfile empfile[] = {
     {EF_NEWS, "news", NULL, "news", news_ca, EF_BAD,
      UNMAPPED_CACHE(struct nwsstr, -1, 0),
      NULL, NULL, NULL, NULL},
-    {EF_TREATY, "treaty", NULL, "treaty", treaty_ca, EF_BAD,
-     UNMAPPED_CACHE(struct trtstr, -1, EFF_TYPED),
-     NULL, NULL, NULL, NULL},
     {EF_TRADE, "trade", "trade lot", "trade", trade_ca, EF_BAD,
      UNMAPPED_CACHE(struct trdstr, -1, EFF_TYPED | EFF_OWNER),
      NULL, NULL, NULL, NULL},
@@ -166,6 +165,15 @@ struct empfile empfile[] = {
     {EF_NATION, "nat", "nation", "nation", nat_ca, EF_BAD,
      UNMAPPED_CACHE(struct natstr, MAXNOC, EFF_TYPED | EFF_OWNER),
      nat_oninit, NULL, NULL, NULL},
+    {EF_RELAT, "relat", NULL, "relat", relat_ca, EF_BAD,
+     UNMAPPED_CACHE(struct relatstr, MAXNOC, EFF_TYPED),
+     NULL, NULL, NULL, NULL},
+    {EF_CONTACT, "contact", NULL, "contact", contact_ca, EF_BAD,
+     UNMAPPED_CACHE(struct contactstr, MAXNOC, EFF_TYPED),
+     contact_oninit, NULL, NULL, NULL},
+    {EF_REJECT, "reject", NULL, "reject", reject_ca, EF_BAD,
+     UNMAPPED_CACHE(struct rejectstr, MAXNOC, EFF_TYPED),
+     NULL, NULL, NULL, NULL},
     {EF_LOAN, "loan", NULL, "loan", loan_ca, EF_BAD,
      UNMAPPED_CACHE(struct lonstr, -1, EFF_TYPED),
      NULL, NULL, NULL, NULL},
@@ -229,7 +237,7 @@ struct empfile empfile[] = {
      ARRAY_TABLE(empfile, EF_MAX, EFF_CFG),
      NULL, NULL, NULL, NULL},
     {EF_VERSION, "version", NULL, NULL, NULL, EF_BAD,
-     sizeof(PACKAGE_STRING), -1, EFF_STATIC, version, 1, 0, 1, 1, -1,
+     0, -1, EFF_MEM | EFF_STATIC, &dummy_cache, 1, 0, 1, 1, -1,
      NULL, NULL, NULL, NULL},
     {EF_META, "meta", NULL, NULL, mdchr_ca, EF_BAD,
      PTR_CACHE(mdchr_ca, EFF_CFG),
@@ -264,8 +272,8 @@ struct empfile empfile[] = {
     SYMTAB(EF_RESOURCES, "resources", resources),
     SYMTAB(EF_RETREAT_FLAGS, "retreat-flags", retreat_flags),
     SYMTAB(EF_SECTOR_NAVIGATION, "sector-navigation", sector_navigation),
+    SYMTAB(EF_SECTOR_CHR_FLAGS, "sect-chr-flags", sect_chr_flags),
     SYMTAB(EF_SHIP_CHR_FLAGS, "ship-chr-flags", ship_chr_flags),
-    SYMTAB(EF_TREATY_FLAGS, "treaty-flags", treaty_flags),
 
     /* Views */
     {EF_COUNTRY, "country", NULL, NULL, cou_ca, EF_NATION,
@@ -286,6 +294,7 @@ sct_oninit(void *ptr)
     sp->sct_dist_x = sp->sct_x;
     sp->sct_dist_y = sp->sct_y;
     sp->sct_newtype = sp->sct_type = SCT_WATER;
+    sp->sct_work = 100;
     sp->sct_coastal = 1;
 }
 
@@ -321,6 +330,17 @@ nat_oninit(void *ptr)
     np->nat_cnum = np->nat_uid;
 }
 
+static void
+contact_oninit(void *ptr)
+{
+    struct contactstr *cp = ptr;
+
+    if (opt_HIDDEN)
+       cp->con_contact[cp->con_uid] = 1;
+    else
+       memset(cp->con_contact, 1, sizeof(cp->con_contact));
+}
+
 static void
 realm_oninit(void *ptr)
 {
@@ -399,6 +419,11 @@ empfile_init(void)
 void
 empfile_fixup(void)
 {
+    struct empfile *ep;
+
     empfile[EF_SECTOR].nent = WORLD_SZ();
     empfile[EF_MAP].size = empfile[EF_BMAP].size = WORLD_SZ();
+
+    for (ep = empfile; ep->uid >= 0; ep++)
+       assert(!ep->cadef || ep->size <= EF_WITH_CADEF_MAX_ENTRY_SIZE);
 }