]> git.pond.sub.org Git - empserver/blobdiff - src/lib/global/nsc.c
COPYING duplicates information from README. Remove. Move GPL from
[empserver] / src / lib / global / nsc.c
index 7082cb982c79ac73eddb44edd033b5de2c507275..16ee98f1dc422da5498fe50b4842f43c20b031b3 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2005, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -19,9 +19,9 @@
  *
  *  ---
  *
- *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- *  related information and legal notices. It is expected that any future
- *  projects/authors will amend these files as needed.
+ *  See files README, COPYING and CREDITS in the root of the source
+ *  tree for related information and legal notices.  It is expected
+ *  that future projects/authors will amend these files as needed.
  *
  *  ---
  *
@@ -32,6 +32,8 @@
  *  
  */
 
+#include <config.h>
+
 #include <stddef.h>
 #include "misc.h"
 #include "xy.h"
@@ -86,6 +88,8 @@ struct castr ichr_ca[] = {
     {NSC_INT, 0, 0, offsetof(struct ichrstr, i_sell), "sell", EF_BAD},
     {NSC_INT, 0, 0, offsetof(struct ichrstr, i_lbs), "lbs", EF_BAD},
     {NSC_INT, 0, NUMPKG, offsetof(struct ichrstr, i_pkg), "pkg", EF_BAD},
+    {NSC_INT, 0, 0, offsetof(struct ichrstr, i_melt_denom), "melt_denom",
+     EF_BAD},
     {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
 };
 
@@ -102,7 +106,7 @@ struct castr pchr_ca[] = {
      EF_ITEM},
     {NSC_INT, 0, 0, offsetof(struct pchrstr, p_level), "level", EF_LEVEL},
     {NSC_INT, 0, 0, offsetof(struct pchrstr, p_cost), "cost", EF_BAD},
-    {NSC_INT, 0, 0, offsetof(struct pchrstr, p_nrndx), "nrndx", EF_BAD},
+    {NSC_INT, 0, 0, offsetof(struct pchrstr, p_nrndx), "nrndx", EF_RESOURCES},
     {NSC_INT, 0, 0, offsetof(struct pchrstr, p_nrdep), "nrdep", EF_BAD},
     {NSC_INT, 0, 0, offsetof(struct pchrstr, p_nlndx), "nlndx", EF_BAD},
     {NSC_INT, 0, 0, offsetof(struct pchrstr, p_nlmin), "nlmin", EF_BAD},
@@ -163,7 +167,8 @@ struct castr dchr_ca[] = {
     {NSC_INT, NSC_CONST, 0, offsetof(struct dchrstr, d_mnem), "mnem", EF_BAD},
     {NSC_INT, 0, 0, offsetof(struct dchrstr, d_prd), "prd", EF_PRODUCT},
     {NSC_INT, 0, 0, offsetof(struct dchrstr, d_mcst), "mcst", EF_BAD},
-    {NSC_INT, 0, 0, offsetof(struct dchrstr, d_flg), "flg", EF_BAD},
+    {NSC_SITYPE(d_navigation), 0, 0, offsetof(struct dchrstr, d_nav), "nav",
+     EF_SECTOR_NAVIGATION},
     {NSC_SITYPE(i_packing), 0, 0, offsetof(struct dchrstr, d_pkg), "pkg",
      EF_PACKING},
     {NSC_FLOAT, 0, 0, offsetof(struct dchrstr, d_ostr), "ostr", EF_BAD},
@@ -236,7 +241,7 @@ struct castr ship_ca[] = {
 
 struct castr mchr_ca[] = {
     {NSC_STRING, 0, 0, offsetof(struct mchrstr, m_name), "name", EF_BAD},
-    {NSC_USHORT, 0, I_MAX+1, offsetof(struct mchrstr, m_item), "item", EF_BAD},
+    NSC_IVEC(offsetof(struct mchrstr, m_item), ""),
     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_lcm), "lcm", EF_BAD},
     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_hcm), "hcm", EF_BAD},
     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_armor), "armor", EF_BAD},
@@ -339,7 +344,7 @@ struct castr land_ca[] = {
 
 struct castr lchr_ca[] = {
     {NSC_STRING, 0, 0, offsetof(struct lchrstr, l_name), "name", EF_BAD},
-    {NSC_USHORT, 0, I_MAX+1, offsetof(struct mchrstr, m_item), "item", EF_BAD},
+    NSC_IVEC(offsetof(struct lchrstr, l_item), ""),
     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_lcm), "lcm", EF_BAD},
     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_hcm), "hcm", EF_BAD},
     {NSC_INT, 0, 0, offsetof(struct lchrstr, l_gun), "gun", EF_BAD},
@@ -373,7 +378,7 @@ struct castr nuke_ca[] = {
     {NSC_XCOORD, 0, 0, fldoff(nukstr, nuk_x), "xloc", EF_BAD},
     {NSC_YCOORD, 0, 0, fldoff(nukstr, nuk_y), "yloc", EF_BAD},
     {NSC_CHAR, 0, 0, fldoff(nukstr, nuk_n), "number", EF_BAD},
-    {NSC_SHORT, 0, N_MAXNUKE, fldoff(nukstr, nuk_types), "types", EF_NUKE_CHR},
+    {NSC_SHORT, 0, N_MAXNUKE, fldoff(nukstr, nuk_types), "types", EF_BAD},
     {NSC_TIME, NSC_EXTRA, 0, fldoff(nukstr, nuk_timestamp), "timestamp",
      EF_BAD},
     {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
@@ -450,6 +455,7 @@ struct castr commodity_ca[] = {
     {NSC_NATID, 0, 0, fldoff(comstr, com_owner), "owner", EF_NATION},
     {NSC_SITYPE(i_type), 0, 0, fldoff(comstr, com_type), "type", EF_ITEM},
     {NSC_INT, 0, 0, fldoff(comstr, com_amount), "amount", EF_BAD},
+    {NSC_FLOAT, 0, 0, fldoff(comstr, com_price), "price", EF_BAD},
     {NSC_INT, 0, 0, fldoff(comstr, com_maxbidder), "maxbidder", EF_NATION},
     {NSC_TIME, 0, 0, fldoff(comstr, com_markettime), "markettime", EF_BAD},
     /* could let maxbidder access these, but we can't express that yet: */
@@ -458,7 +464,6 @@ struct castr commodity_ca[] = {
     /* could let the owner access these, but we can't express that yet: */
     {NSC_XCOORD, NSC_DEITY, 0, fldoff(comstr, sell_x), "xsell", EF_BAD},
     {NSC_YCOORD, NSC_DEITY, 0, fldoff(comstr, sell_y), "ysell", EF_BAD},
-    {NSC_FLOAT, 0, 0, fldoff(comstr, com_price), "price", EF_BAD},
     {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
 };
 
@@ -470,7 +475,7 @@ struct castr trade_ca[] = {
     {NSC_LONG, 0, 0, fldoff(trdstr, trd_price), "price", EF_BAD},
     {NSC_INT, 0, 0, fldoff(trdstr, trd_maxbidder), "maxbidder", EF_NATION},
     {NSC_TIME, 0, 0, fldoff(trdstr, trd_markettime), "markettime", EF_BAD},
-    /* could let the owner access these, but we can't express that yet: */
+    /* could let the maxbidder access these, but we can't express that yet: */
     {NSC_XCOORD, NSC_DEITY, 0, fldoff(trdstr, trd_x), "xloc", EF_BAD},
     {NSC_YCOORD, NSC_DEITY, 0, fldoff(trdstr, trd_y), "yloc", EF_BAD},
     {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
@@ -478,18 +483,18 @@ struct castr trade_ca[] = {
 
 struct castr nat_ca[] = {
     {NSC_NATID, 0, 0, fldoff(natstr, nat_cnum), "cnum", EF_NATION},
-    {NSC_CHAR, NSC_BITS, 0, fldoff(natstr, nat_stat), "stat", EF_BAD},
+    {NSC_SITYPE(nat_status), 0, 0, fldoff(natstr, nat_stat), "stat",
+     EF_NATION_STATUS},
     {NSC_STRINGY, 0, 20, fldoff(natstr, nat_cnam), "cname", EF_BAD},
     {NSC_STRINGY, NSC_DEITY, 20, fldoff(natstr, nat_pnam), "passwd", EF_BAD},
     {NSC_STRINGY, 0, 32, fldoff(natstr, nat_hostaddr), "ip", EF_BAD},
     {NSC_STRINGY, 0, 512, fldoff(natstr, nat_hostname), "hostname", EF_BAD},
     {NSC_STRINGY, 0, 32, fldoff(natstr, nat_userid), "userid", EF_BAD},
-    {NSC_XCOORD, 0, 0, fldoff(natstr, nat_xstart), "xstart", EF_BAD},
-    {NSC_YCOORD, 0, 0, fldoff(natstr, nat_ystart), "ystart", EF_BAD},
     {NSC_XCOORD, 0, 0, fldoff(natstr, nat_xcap), "xcap", EF_BAD},
     {NSC_YCOORD, 0, 0, fldoff(natstr, nat_ycap), "ycap", EF_BAD},
     {NSC_XCOORD, NSC_DEITY, 0, fldoff(natstr, nat_xorg), "xorg", EF_BAD},
     {NSC_YCOORD, NSC_DEITY, 0, fldoff(natstr, nat_yorg), "yorg", EF_BAD},
+    {NSC_CHAR, 0, 0, fldoff(natstr, nat_dayno), "dayno", EF_BAD},
     {NSC_CHAR, 0, 0, fldoff(natstr, nat_update), "update", EF_BAD},
     {NSC_UCHAR, 0, 0, fldoff(natstr, nat_missed), "missed", EF_BAD},
     {NSC_USHORT, 0, 0, fldoff(natstr, nat_tgms), "tgms", EF_BAD},
@@ -508,16 +513,35 @@ struct castr nat_ca[] = {
      EF_BAD},
     {NSC_FLOAT, 0, 0, fldoff(natstr, nat_level[NAT_HLEV]), "happiness",
      EF_BAD},
-    /* FIXME nat_b[], nat_rejects[], nat_priorities[] */
-    {NSC_UCHAR, NSC_DEITY, MAXNOC, fldoff(natstr, nat_contact), "contacts",
-     EF_BAD},
     {NSC_SHORT, 0, MAXNOC, fldoff(natstr, nat_relate), "relations",
      EF_NATION_RELATIONS},
-    {NSC_LONG, NSC_BITS, 0, fldoff(natstr, nat_flags),"flags",
+    {NSC_UCHAR, NSC_DEITY, MAXNOC, fldoff(natstr, nat_contact), "contacts",
+     EF_BAD},
+    /* FIXME nat_rejects[], nat_priorities[] */
+    {NSC_LONG, NSC_BITS, 0, fldoff(natstr, nat_flags), "flags",
      EF_NATION_FLAGS},
     {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
 };
 
+struct castr cou_ca[] = {
+    {NSC_NATID, 0, 0, fldoff(natstr, nat_cnum), "cnum", EF_NATION},
+    {NSC_CHAR, 0, 0, fldoff(natstr, nat_stat), "stat",
+     EF_NATION_STATUS},
+    {NSC_STRINGY, 0, 20, fldoff(natstr, nat_cnam), "cname", EF_BAD},
+    {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
+};
+
+struct castr realm_ca[] = {
+    {NSC_SHORT, 0, 0, fldoff(realmstr, r_uid), "uid", EF_REALM},
+    {NSC_NATID, 0, 0, fldoff(realmstr, r_cnum), "cnum", EF_NATION},
+    {NSC_USHORT, 0, 0, fldoff(realmstr, r_realm), "realm", EF_BAD},
+    {NSC_SHORT, 0, 0, fldoff(realmstr, r_xl), "xl", EF_BAD},
+    {NSC_SHORT, 0, 0, fldoff(realmstr, r_xh), "xh", EF_BAD},
+    {NSC_SHORT, 0, 0, fldoff(realmstr, r_yl), "yl", EF_BAD},
+    {NSC_SHORT, 0, 0, fldoff(realmstr, r_yh), "yh", EF_BAD},
+    {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
+};
+
 struct castr intrchr_ca[] = {
     {NSC_STRING, NSC_CONST, 0, offsetof(struct sctintrins, in_name), "name",
      EF_BAD},
@@ -560,21 +584,18 @@ struct symbol ship_chr_flags[] = {
     {M_MINE, "mine"},
     {M_SWEEP, "sweep"},
     {M_SUB, "sub"},
-    {M_SPY, "spy"},
     {M_LAND, "land"},
     {M_SUBT, "sub-torp"},
     {M_TRADE, "trade"},
     {M_SEMILAND, "semi-land"},
-    {M_XLIGHT, "xlight"},
-    {M_CHOPPER, "chopper"},
     {M_OILER, "oiler"},
     {M_SUPPLY, "supply"},
+    {M_CANAL, "canal"},
     {M_ANTIMISSILE, "anti-missile"},
     {0, NULL}
 };
 
 struct symbol land_chr_flags[] = {
-    {L_XLIGHT, "xlight"},
     {L_ENGINEER, "engineer"},
     {L_SUPPLY, "supply"},
     {L_SECURITY, "security"},
@@ -657,6 +678,7 @@ struct symbol meta_type[]  = {
 };
 
 struct symbol missions[] = {
+    {MI_NONE, "none"},
     {MI_INTERDICT, "interdiction"},
     {MI_SUPPORT, "support"},
     {MI_RESERVE, "reserve"},
@@ -686,6 +708,15 @@ struct symbol retreat_flags[] = {
     {0, NULL}
 };
 
+struct symbol nation_status[] = {
+    {STAT_UNUSED, "unused"},
+    {STAT_NEW, "new"},
+    {STAT_VIS, "visitor"},
+    {STAT_SANCT, "sanctuary"},
+    {STAT_ACTIVE, "active"},
+    {STAT_GOD, "deity"}
+};
+
 struct symbol nation_flags[] = {
     {NF_INFORM, "inform"},
     {NF_FLASH, "flash"},
@@ -740,3 +771,22 @@ struct symbol packing[] = {
     {BPKG, "bank"},
     {0, NULL}
 };
+
+struct symbol resources[] = {
+    /* names should match resource selector names in sect_ca[] */
+    {0, "none"},
+    {offsetof(struct sctstr, sct_min), "min"},
+    {offsetof(struct sctstr, sct_gmin), "gold"},
+    {offsetof(struct sctstr, sct_fertil), "fert"},
+    {offsetof(struct sctstr, sct_oil), "ocontent"},
+    {offsetof(struct sctstr, sct_uran), "uran"},
+    {0, NULL}
+};
+
+struct symbol sector_navigation[] = { /* for d_nav */
+    {NAV_NONE, "land"},
+    {NAVOK, "sea"},
+    {NAV_02, "harbor"},
+    {NAV_60, "bridge"},
+    {0, NULL}
+};