]> git.pond.sub.org Git - empserver/blobdiff - src/lib/common/nsc.c
Provide proper ca_table for carrier unit# selectors
[empserver] / src / lib / common / nsc.c
index 733e2c5d863acb5f935d288d8589cf68f2cb64a0..257b2c056073b1e14a3da8440a1286a2ac378c5c 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
@@ -26,9 +25,9 @@
  *  ---
  *
  *  nsc.c: Empire selection global structures
- * 
+ *
  *  Known contributors to this file:
- *     Markus Armbruster, 2004-2008
+ *     Markus Armbruster, 2004-2010
  */
 
 /*
 #include "empobj.h"
 #include "file.h"
 #include "optlist.h"
+#include "news.h"
 #include "nsc.h"
 #include "product.h"
+#include "unit.h"
 
 static void *nsc_ver(struct valstr *, struct natstr *, void *);
 static void *nsc_ver_maxnoc(struct valstr *, struct natstr *, void *);
 static void *nsc_sct_terr(struct valstr *, struct natstr *, void *);
+static void *nsc_sct_track(struct valstr *, struct natstr *, void *);
+static void *nsc_cargo_nplane(struct valstr *, struct natstr *, void *);
+static void *nsc_cargo_nchopper(struct valstr *, struct natstr *, void *);
+static void *nsc_cargo_nxlight(struct valstr *, struct natstr *, void *);
+static void *nsc_cargo_nland(struct valstr *, struct natstr *, void *);
 static void *nsc_pln_att(struct valstr *, struct natstr *, void *);
 static void *nsc_pln_def(struct valstr *, struct natstr *, void *);
 static void *nsc_pln_nuketype(struct valstr *, struct natstr *, void *);
@@ -61,8 +67,9 @@ static void *nsc_lnd_acc(struct valstr *, struct natstr *, void *);
 static void *nsc_lnd_dam(struct valstr *, struct natstr *, void *);
 static void *nsc_lnd_aaf(struct valstr *, struct natstr *, void *);
 static void *nsc_lchr(struct valstr *, struct natstr *, void *);
+static void *nsc_nws_timestamp(struct valstr *, struct natstr *, void *);
 
-/* Ugly hack to improve legibility by avoid long lines */
+/* Ugly hacks to avoid illegibly long lines */
 #define fldoff(fld) offsetof(CURSTR, fld)
 #define empobjoff(fld) offsetof(struct empobj, fld)
 
@@ -124,7 +131,7 @@ struct castr pchr_ca[] = {
 struct castr sect_ca[] = {
 #define CURSTR struct sctstr
     /* uid needs to be NSC_DEITY because it discloses true origin */
-    {"uid", fldoff(sct_uid), NSC_SHORT, 0, NULL,
+    {"uid", fldoff(sct_uid), NSC_INT, 0, NULL,
      EF_SECTOR, NSC_DEITY | NSC_EXTRA},
     {"timestamp", fldoff(sct_timestamp), NSC_TIME, 0, NULL,
      EF_BAD, NSC_EXTRA},
@@ -132,8 +139,9 @@ struct castr sect_ca[] = {
     {"xloc", fldoff(sct_x), NSC_XCOORD, 0, NULL, EF_BAD, NSC_CONST},
     {"yloc", fldoff(sct_y), NSC_YCOORD, 0, NULL, EF_BAD, NSC_CONST},
     {"des", fldoff(sct_type), NSC_CHAR, 0, NULL, EF_SECTOR_CHR, 0},
-    {"effic", fldoff(sct_effic), NSC_UCHAR, 0, NULL, EF_BAD, 0},
-    {"mobil", fldoff(sct_mobil), NSC_SHORT, 0, NULL, EF_BAD, 0},
+    {"effic", fldoff(sct_effic), NSC_CHAR, 0, NULL, EF_BAD, 0},
+    {"mobil", fldoff(sct_mobil), NSC_CHAR, 0, NULL, EF_BAD, 0},
+    {"off", fldoff(sct_off), NSC_UCHAR, 0, NULL, EF_BAD, 0},
     {"loyal", fldoff(sct_loyal), NSC_UCHAR, 0, NULL, EF_BAD, NSC_DEITY},
     {"terr", 0, NSC_UCHAR, 0, nsc_sct_terr, EF_BAD, NSC_EXTRA},
     {"terr0", fldoff(sct_terr), NSC_UCHAR, 0, NULL, EF_BAD, 0},
@@ -154,7 +162,7 @@ struct castr sect_ca[] = {
     {"ocontent", fldoff(sct_oil), NSC_UCHAR, 0, NULL, EF_BAD, 0},
     {"uran", fldoff(sct_uran), NSC_UCHAR, 0, NULL, EF_BAD, 0},
     {"oldown", fldoff(sct_oldown), NSC_NATID, 0, NULL, EF_NATION, 0},
-    {"off", fldoff(sct_off), NSC_UCHAR, 0, NULL, EF_BAD, 0},
+    {"track", 0, NSC_LONG, 0, nsc_sct_track, EF_BAD, NSC_EXTRA},
     NSC_IVEC(fldoff(sct_item), ""),
     NSC_IVEC(fldoff(sct_dist), "_dist"),
     NSC_IVEC(fldoff(sct_del), "_del"),
@@ -180,6 +188,7 @@ struct castr dchr_ca[] = {
     {"uid", fldoff(d_uid), NSC_UCHAR, 0, NULL, EF_SECTOR_CHR, 0},
     {"name", fldoff(d_name), NSC_STRING, 0, NULL, EF_BAD, 0},
     {"mnem", fldoff(d_mnem), NSC_STRINGY, 1, NULL, EF_BAD, NSC_CONST},
+    {"terrain", fldoff(d_terrain), NSC_UCHAR, 0, NULL, EF_SECTOR_CHR, 0},
     {"prd", fldoff(d_prd), NSC_INT, 0, NULL, EF_PRODUCT, 0},
     {"peffic", fldoff(d_peffic), NSC_INT, 0, NULL, EF_BAD, 0},
     {"mob0", fldoff(d_mob0), NSC_FLOAT, 0, NULL, EF_BAD, 0},
@@ -195,34 +204,33 @@ struct castr dchr_ca[] = {
     {"build", fldoff(d_build), NSC_INT, 0, NULL, EF_BAD, 0},
     {"lcms", fldoff(d_lcms), NSC_INT, 0, NULL, EF_BAD, 0},
     {"hcms", fldoff(d_hcms), NSC_INT, 0, NULL, EF_BAD, 0},
+    {"maint", fldoff(d_maint), NSC_INT, 0, NULL, EF_BAD, 0},
     {"maxpop", fldoff(d_maxpop), NSC_INT, 0, NULL, EF_BAD, 0},
     {NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
 #undef CURSTR
 };
 
 #define NSC_GENITEM(ef_type, ef_chr)                                   \
-    {"uid", empobjoff(uid),  NSC_SHORT, 0, NULL, ef_type, 0},          \
+    {"uid", empobjoff(uid), NSC_INT, 0, NULL, ef_type, 0},             \
     {"timestamp", empobjoff(timestamp), NSC_TIME, 0, NULL, EF_BAD, NSC_EXTRA}, \
-    {"owner", empobjoff(own),  NSC_NATID, 0, NULL, EF_NATION, 0},      \
-    {"xloc", empobjoff(x),  NSC_XCOORD, 0, NULL, EF_BAD, 0},           \
-    {"yloc", empobjoff(y),  NSC_YCOORD, 0, NULL, EF_BAD, 0},           \
-    {"type", empobjoff(type),  NSC_CHAR, 0, NULL, ef_chr, 0},          \
-    {"effic", empobjoff(effic),  NSC_CHAR, 0, NULL, EF_BAD, 0},                \
-    {"mobil", empobjoff(mobil),  NSC_CHAR , 0, NULL, EF_BAD, 0},       \
-    {"off", empobjoff(off),  NSC_UCHAR , 0, NULL, EF_BAD, 0},          \
-    {"tech", empobjoff(tech),  NSC_SHORT, 0, NULL, EF_BAD, 0},         \
-    {"group", empobjoff(group),  NSC_STRINGY, 1, NULL, EF_BAD, NSC_EXTRA}, \
-    {"opx", empobjoff(opx),  NSC_XCOORD, 0, NULL, EF_BAD, 0},          \
-    {"opy", empobjoff(opy),  NSC_YCOORD, 0, NULL, EF_BAD, 0},          \
-    {"mission", empobjoff(mission),  NSC_SHORT, 0, NULL, EF_MISSIONS, 0}, \
-    {"radius", empobjoff(radius),  NSC_SHORT, 0, NULL, EF_BAD, 0}
+    {"owner", empobjoff(own), NSC_NATID, 0, NULL, EF_NATION, 0},       \
+    {"xloc", empobjoff(x), NSC_XCOORD, 0, NULL, EF_BAD, 0},            \
+    {"yloc", empobjoff(y), NSC_YCOORD, 0, NULL, EF_BAD, 0},            \
+    {"type", empobjoff(type), NSC_CHAR, 0, NULL, ef_chr, 0},           \
+    {"effic", empobjoff(effic), NSC_CHAR, 0, NULL, EF_BAD, 0},         \
+    {"mobil", empobjoff(mobil), NSC_CHAR , 0, NULL, EF_BAD, 0},                \
+    {"off", empobjoff(off), NSC_UCHAR , 0, NULL, EF_BAD, 0},           \
+    {"tech", empobjoff(tech), NSC_SHORT, 0, NULL, EF_BAD, 0},          \
+    {"group", empobjoff(group), NSC_STRINGY, 1, NULL, EF_BAD, NSC_EXTRA}, \
+    {"opx", empobjoff(opx), NSC_XCOORD, 0, NULL, EF_BAD, 0},           \
+    {"opy", empobjoff(opy), NSC_YCOORD, 0, NULL, EF_BAD, 0},           \
+    {"mission", empobjoff(mission), NSC_SHORT, 0, NULL, EF_MISSIONS, 0}, \
+    {"radius", empobjoff(radius), NSC_SHORT, 0, NULL, EF_BAD, 0}
 
 struct castr ship_ca[] = {
 #define CURSTR struct shpstr
     NSC_GENITEM(EF_SHIP, EF_SHIP_CHR),
     {"fleet", fldoff(shp_fleet), NSC_STRINGY, 1, NULL, EF_BAD, 0},
-    {"nplane", fldoff(shp_nplane), NSC_UCHAR, 0, NULL, EF_BAD, NSC_EXTRA},
-    {"nland", fldoff(shp_nland), NSC_UCHAR, 0, NULL, EF_BAD, NSC_EXTRA},
     {"xstart", fldoff(shp_destx[0]), NSC_XCOORD, 0, NULL, EF_BAD, 0},
     {"xend", fldoff(shp_destx[1]), NSC_XCOORD, 0, NULL, EF_BAD, 0},
     {"ystart", fldoff(shp_desty[0]), NSC_YCOORD, 0, NULL, EF_BAD, 0},
@@ -241,13 +249,10 @@ struct castr ship_ca[] = {
     {"access", fldoff(shp_access), NSC_SHORT, 0, NULL, EF_BAD, 0},
     {"mquota", fldoff(shp_mobquota), NSC_UCHAR, 0, NULL, EF_BAD, 0},
     {"path", fldoff(shp_path), NSC_STRINGY, MAXSHPPATH, NULL, EF_BAD, 0},
-    {"follow", fldoff(shp_follow), NSC_SHORT, 0, NULL, EF_BAD, 0},
+    /* follow can point to dead ship; avoid ca_table for now */
+    {"follow", fldoff(shp_follow), NSC_INT, 0, NULL, EF_BAD, 0},
     {"name", fldoff(shp_name), NSC_STRINGY, MAXSHPNAMLEN, NULL,
      EF_BAD, 0},
-    {"nchoppers", fldoff(shp_nchoppers), NSC_UCHAR, 0, NULL,
-     EF_BAD, NSC_EXTRA},
-    {"nxlight", fldoff(shp_nxlight), NSC_UCHAR, 0, NULL,
-     EF_BAD, NSC_EXTRA},
     /* should let builder access xbuilt, ybuilt, but can't express that: */
     {"xbuilt", fldoff(shp_orig_x), NSC_XCOORD, 0, NULL,
      EF_BAD, NSC_DEITY},
@@ -258,6 +263,10 @@ struct castr ship_ca[] = {
     {"rflags", fldoff(shp_rflags), NSC_INT, 0, NULL,
      EF_RETREAT_FLAGS, NSC_BITS},
     {"rpath", fldoff(shp_rpath), NSC_STRINGY, RET_LEN, NULL, EF_BAD, 0},
+    {"nplane", 0, NSC_LONG, 0, nsc_cargo_nplane, EF_BAD, NSC_EXTRA},
+    {"nchoppers", 0, NSC_LONG, 0, nsc_cargo_nchopper, EF_BAD, NSC_EXTRA},
+    {"nxlight", 0, NSC_LONG, 0, nsc_cargo_nxlight, EF_BAD, NSC_EXTRA},
+    {"nland", 0, NSC_LONG, 0, nsc_cargo_nland, EF_BAD, NSC_EXTRA},
     {NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
 #undef CURSTR
 };
@@ -292,8 +301,8 @@ struct castr plane_ca[] = {
     NSC_GENITEM(EF_PLANE, EF_PLANE_CHR),
     {"wing", fldoff(pln_wing), NSC_STRINGY, 1, NULL, EF_BAD, 0},
     {"range", fldoff(pln_range), NSC_UCHAR, 0, NULL, EF_BAD, 0},
-    {"ship", fldoff(pln_ship), NSC_SHORT, 0, NULL, EF_BAD, 0},
-    {"land", fldoff(pln_land), NSC_SHORT, 0, NULL, EF_BAD, 0},
+    {"ship", fldoff(pln_ship), NSC_INT, 0, NULL, EF_SHIP, 0},
+    {"land", fldoff(pln_land), NSC_INT, 0, NULL, EF_LAND, 0},
     {"harden", fldoff(pln_harden), NSC_CHAR, 0, NULL, EF_BAD, 0},
     {"flags", fldoff(pln_flags), NSC_CHAR, 0, NULL,
      EF_PLANE_FLAGS, NSC_BITS},
@@ -332,21 +341,17 @@ struct castr land_ca[] = {
 #define CURSTR struct lndstr
     NSC_GENITEM(EF_LAND, EF_LAND_CHR),
     {"army", fldoff(lnd_army), NSC_STRINGY, 1, NULL, EF_BAD, 0},
-    {"ship", fldoff(lnd_ship), NSC_SHORT, 0, NULL, EF_BAD, 0},
+    {"ship", fldoff(lnd_ship), NSC_INT, 0, NULL, EF_SHIP, 0},
     {"harden", fldoff(lnd_harden), NSC_CHAR, 0, NULL, EF_BAD, 0},
     {"retreat", fldoff(lnd_retreat), NSC_SHORT, 0, NULL, EF_BAD, 0},
-    {"nxlight", fldoff(lnd_nxlight), NSC_UCHAR, 0, NULL,
-     EF_BAD, NSC_EXTRA},
     {"rflags", fldoff(lnd_rflags), NSC_INT, 0, NULL,
      EF_RETREAT_FLAGS, NSC_BITS},
     {"rpath", fldoff(lnd_rpath), NSC_STRINGY, RET_LEN, NULL, EF_BAD, 0},
-    {"react", fldoff(lnd_rad_max), NSC_UCHAR, 0, NULL, EF_BAD, 0},
     NSC_IVEC(fldoff(lnd_item), ""),
     {"pstage", fldoff(lnd_pstage), NSC_SHORT, 0, NULL,
      EF_PLAGUE_STAGES, NSC_DEITY},
     {"ptime", fldoff(lnd_ptime), NSC_SHORT, 0, NULL, EF_BAD, NSC_DEITY},
-    {"land", fldoff(lnd_land), NSC_SHORT, 0, NULL, EF_BAD, 0},
-    {"nland", fldoff(lnd_nland), NSC_UCHAR, 0, NULL, EF_BAD, NSC_EXTRA},
+    {"land", fldoff(lnd_land), NSC_INT, 0, NULL, EF_LAND, 0},
     {"access", fldoff(lnd_access), NSC_SHORT, 0, NULL, EF_BAD, 0},
     {"att", 0, NSC_DOUBLE, 0, nsc_lnd_att, EF_BAD, NSC_EXTRA},
     {"def", 0, NSC_DOUBLE, 0, nsc_lnd_def, EF_BAD, NSC_EXTRA},
@@ -357,6 +362,8 @@ struct castr land_ca[] = {
     {"acc", 0, NSC_LONG, 0, nsc_lnd_acc, EF_BAD, NSC_EXTRA},
     {"dam", 0, NSC_LONG, 0, nsc_lnd_dam, EF_BAD, NSC_EXTRA},
     {"aaf", 0, NSC_LONG, 0, nsc_lnd_aaf, EF_BAD, NSC_EXTRA},
+    {"nland", 0, NSC_LONG, 0, nsc_cargo_nland, EF_BAD, NSC_EXTRA},
+    {"nxlight", 0, NSC_LONG, 0, nsc_cargo_nxlight, EF_BAD, NSC_EXTRA},
 #undef CURSTR
 #define CURSTR struct lchrstr
     {"spy", fldoff(l_spy), NSC_INT, 0, nsc_lchr, EF_BAD, NSC_EXTRA},
@@ -400,7 +407,7 @@ struct castr lchr_ca[] = {
 struct castr nuke_ca[] = {
 #define CURSTR struct nukstr
     NSC_GENITEM(EF_NUKE, EF_NUKE_CHR),
-    {"plane", fldoff(nuk_plane), NSC_SHORT, 0, NULL, EF_BAD, 0},
+    {"plane", fldoff(nuk_plane), NSC_INT, 0, NULL, EF_PLANE, 0},
     {NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
 #undef CURSTR
 };
@@ -426,7 +433,7 @@ struct castr nchr_ca[] = {
 
 struct castr treaty_ca[] = {
 #define CURSTR struct trtstr
-    {"uid", fldoff(trt_uid), NSC_SHORT, 0, NULL, EF_TREATY, 0},
+    {"uid", fldoff(trt_uid), NSC_INT, 0, NULL, EF_TREATY, 0},
     {"timestamp", fldoff(trt_timestamp), NSC_TIME, 0, NULL,
      EF_BAD, NSC_EXTRA},
     {"cna", fldoff(trt_cna), NSC_NATID, 0, NULL, EF_NATION, 0},
@@ -444,7 +451,7 @@ struct castr treaty_ca[] = {
 
 struct castr loan_ca[] = {
 #define CURSTR struct lonstr
-    {"uid", fldoff(l_uid), NSC_SHORT, 0, NULL, EF_LOAN, 0},
+    {"uid", fldoff(l_uid), NSC_INT, 0, NULL, EF_LOAN, 0},
     {"timestamp", fldoff(l_timestamp), NSC_TIME, 0, NULL,
      EF_BAD, NSC_EXTRA},
     {"loaner", fldoff(l_loner), NSC_NATID, 0, NULL, EF_NATION, 0},
@@ -463,13 +470,12 @@ struct castr loan_ca[] = {
 
 struct castr news_ca[] = {
 #define CURSTR struct nwsstr
-    /* no need for uid as long as it's not referenced from other tables */
-    {"timestamp", fldoff(nws_timestamp), NSC_TIME, 0, NULL,
-     EF_BAD, NSC_EXTRA},
+    {"timestamp", 0, NSC_LONG, 0, nsc_nws_timestamp, EF_BAD, NSC_EXTRA},
     {"actor", fldoff(nws_ano), NSC_NATID, 0, NULL, EF_NATION, 0},
     {"action", fldoff(nws_vrb), NSC_UCHAR, 0, NULL, EF_NEWS_CHR, 0},
     {"victim", fldoff(nws_vno), NSC_NATID, 0, NULL, EF_NATION, 0},
     {"times", fldoff(nws_ntm), NSC_CHAR, 0, NULL, EF_BAD, 0},
+    {"duration", fldoff(nws_duration), NSC_SHORT, 0, NULL, EF_BAD, 0},
     {"time", fldoff(nws_when), NSC_TIME, 0, NULL, EF_BAD, 0},
     {NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
 #undef CURSTR
@@ -477,12 +483,13 @@ struct castr news_ca[] = {
 
 struct castr lost_ca[] = {
 #define CURSTR struct loststr
-   /* no need for uid as long as it's not referenced from other tables */
+    /* no need for uid as long as it's not referenced from other tables */
     {"timestamp", fldoff(lost_timestamp), NSC_TIME, 0, NULL,
      EF_BAD, 0},
     {"owner", fldoff(lost_owner), NSC_NATID, 0, NULL, EF_NATION, 0},
     {"type", fldoff(lost_type), NSC_CHAR, 0, NULL, EF_TABLE, 0},
-    {"id", fldoff(lost_id), NSC_SHORT, 0, NULL, EF_BAD, 0},
+    /* id's ca_table given by type, but can't express that: */
+    {"id", fldoff(lost_id), NSC_INT, 0, NULL, EF_BAD, 0},
     {"x", fldoff(lost_x), NSC_XCOORD, 0, NULL, EF_BAD, 0},
     {"y", fldoff(lost_y), NSC_YCOORD, 0, NULL, EF_BAD, 0},
     {NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
@@ -491,7 +498,7 @@ struct castr lost_ca[] = {
 
 struct castr commodity_ca[] = {
 #define CURSTR struct comstr
-    {"uid", fldoff(com_uid), NSC_SHORT, 0, NULL, EF_COMM, 0},
+    {"uid", fldoff(com_uid), NSC_INT, 0, NULL, EF_COMM, 0},
     {"timestamp", fldoff(com_timestamp), NSC_TIME, 0, NULL,
      EF_BAD, NSC_EXTRA},
     {"owner", fldoff(com_owner), NSC_NATID, 0, NULL, EF_NATION, 0},
@@ -512,12 +519,13 @@ struct castr commodity_ca[] = {
 
 struct castr trade_ca[] = {
 #define CURSTR struct trdstr
-    {"uid", fldoff(trd_uid), NSC_SHORT, 0, NULL, EF_TRADE, 0},
+    {"uid", fldoff(trd_uid), NSC_INT, 0, NULL, EF_TRADE, 0},
     {"timestamp", fldoff(trd_timestamp), NSC_TIME, 0, NULL,
      EF_BAD, NSC_EXTRA},
     {"owner", fldoff(trd_owner), NSC_NATID, 0, NULL, EF_NATION, 0},
     {"type", fldoff(trd_type), NSC_CHAR, 0, NULL, EF_TABLE, 0},
-    {"unitid", fldoff(trd_unitid), NSC_SHORT, 0, NULL, EF_BAD, 0},
+    /* unitid's ca_table given by type, but can't express that: */
+    {"unitid", fldoff(trd_unitid), NSC_INT, 0, NULL, EF_BAD, 0},
     {"price", fldoff(trd_price), NSC_LONG, 0, NULL, EF_BAD, 0},
     {"maxbidder", fldoff(trd_maxbidder), NSC_INT, 0, NULL, EF_NATION, 0},
     {"markettime", fldoff(trd_markettime), NSC_TIME, 0, NULL, EF_BAD, 0},
@@ -558,11 +566,10 @@ struct castr cou_ca[] = {
      EF_BAD, NSC_DEITY | NSC_EXTRA},
     {"yorg", fldoff(nat_yorg), NSC_YCOORD, 0, NULL,
      EF_BAD, NSC_DEITY | NSC_EXTRA},
-    {"dayno", fldoff(nat_dayno), NSC_CHAR, 0, NULL, EF_BAD, 0},
     {"update", fldoff(nat_update), NSC_CHAR, 0, NULL, EF_BAD, 0},
     {"tgms", fldoff(nat_tgms), NSC_USHORT, 0, NULL, EF_BAD, 0},
     {"ann", fldoff(nat_ann), NSC_USHORT, 0, NULL, EF_BAD, 0},
-    {"minused", fldoff(nat_minused), NSC_USHORT, 0, NULL, EF_BAD, 0},
+    {"timeused", fldoff(nat_timeused), NSC_INT, 0, NULL, EF_BAD, 0},
     {"btu", fldoff(nat_btu), NSC_SHORT, 0, NULL, EF_BAD, 0},
     {"access", fldoff(nat_access), NSC_SHORT, 0, NULL, EF_BAD, 0},
     {"milreserve", fldoff(nat_reserve), NSC_LONG, 0, NULL, EF_BAD, 0},
@@ -616,6 +623,7 @@ struct castr game_ca[] = {
      EF_BAD, NSC_EXTRA},
     {"upd_disable", fldoff(game_upd_disable), NSC_CHAR, 0, NULL,
      EF_BAD, 0},
+    {"down", fldoff(game_down), NSC_CHAR, 0, NULL, EF_BAD, 0},
     {"turn", fldoff(game_turn), NSC_SHORT, 0, NULL, EF_BAD, 0},
     {"tick", fldoff(game_tick), NSC_SHORT, 0, NULL, EF_BAD, NSC_DEITY},
     {"rt", fldoff(game_rt), NSC_TIME, 0, NULL, EF_BAD, NSC_DEITY},
@@ -682,7 +690,7 @@ struct castr mdchr_ca[] = {
     {"flags", fldoff(ca_flags), NSC_UCHAR, 0, NULL,
      EF_META_FLAGS, NSC_CONST | NSC_BITS},
     {"len", fldoff(ca_len), NSC_USHORT, 0, NULL, EF_BAD, NSC_CONST},
-    {"table", fldoff(ca_table), NSC_INT, 0, NULL, EF_BAD, NSC_CONST},
+    {"table", fldoff(ca_table), NSC_INT, 0, NULL, EF_TABLE, NSC_CONST},
     {NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
 #undef CURSTR
 };
@@ -769,6 +777,55 @@ nsc_sct_terr(struct valstr *val, struct natstr *np, void *ptr)
     return ptr;
 }
 
+static void *
+nsc_sct_track(struct valstr *val, struct natstr *np, void *ptr)
+{
+    val->val_as.lng = sct_rail_track(ptr);
+    return NULL;
+}
+
+static void *
+nsc_cargo_nplane(struct valstr *val, struct natstr *np, void *ptr)
+{
+    struct empobj *obj = ptr;
+    int n, nch, nxl;
+
+    n = unit_nplane(obj->ef_type, obj->uid, &nch, &nxl, NULL);
+    val->val_as.lng = n - nch - nxl;
+    return NULL;
+}
+
+static void *
+nsc_cargo_nchopper(struct valstr *val, struct natstr *np, void *ptr)
+{
+    struct empobj *obj = ptr;
+    int n;
+
+    unit_nplane(obj->ef_type, obj->uid, &n, NULL, NULL);
+    val->val_as.lng = n;
+    return NULL;
+}
+
+static void *
+nsc_cargo_nxlight(struct valstr *val, struct natstr *np, void *ptr)
+{
+    struct empobj *obj = ptr;
+    int n;
+
+    unit_nplane(obj->ef_type, obj->uid, NULL, &n, NULL);
+    val->val_as.lng = n;
+    return NULL;
+}
+
+static void *
+nsc_cargo_nland(struct valstr *val, struct natstr *np, void *ptr)
+{
+    struct empobj *obj = ptr;
+
+    val->val_as.lng = unit_cargo_count(obj->ef_type, obj->uid, EF_LAND);
+    return NULL;
+}
+
 static void *
 nsc_pln_def(struct valstr *val, struct natstr *np, void *ptr)
 {
@@ -860,3 +917,12 @@ nsc_lchr(struct valstr *val, struct natstr *np, void *ptr)
     val->val_as.sym.get = NULL;
     return lchr + ((struct lndstr *)ptr)->lnd_type;
 }
+
+static void *
+nsc_nws_timestamp(struct valstr *val, struct natstr *natp, void *ptr)
+{
+    struct nwsstr *np = ptr;
+
+    val->val_as.lng = np->nws_when + np->nws_duration;
+    return NULL;
+}