/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2016, 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
#include <config.h>
+#include <limits.h>
#include <stdlib.h>
#include "empobj.h"
#include "optlist.h"
#include "nsc.h"
#include "product.h"
#include "unit.h"
+#include "version.h"
static void *nsc_ver(struct valstr *, struct natstr *, void *);
static void *nsc_ver_maxnoc(struct valstr *, struct natstr *, void *);
+static void *nsc_ver_version(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 *);
{"action", fldoff(nws_vrb), NSC_UCHAR, 0, NULL, EF_NEWS_CHR, 0,
CA_DUMP},
{"victim", fldoff(nws_vno), NSC_NATID, 0, NULL, EF_NATION, 0, CA_DUMP},
- {"times", fldoff(nws_ntm), NSC_CHAR, 0, NULL, EF_BAD, 0, CA_DUMP},
+ {"times", fldoff(nws_ntm), NSC_USHORT, 0, NULL, EF_BAD, 0, CA_DUMP},
{"duration", fldoff(nws_duration), NSC_SHORT, 0, NULL, EF_BAD, 0,
CA_DUMP},
{"time", fldoff(nws_when), NSC_TIME, 0, NULL, EF_BAD, 0, CA_DUMP},
EF_BAD, NSC_DEITY, CA_DUMP_NONE},
{"ip", fldoff(nat_hostaddr), NSC_STRINGY, 46, NULL, EF_BAD, 0,
CA_DUMP},
- {"hostname", 0, NSC_STRINGY, 0, NULL, EF_BAD, 0, CA_DUMP}, /* deprecated */
{"userid", fldoff(nat_userid), NSC_STRINGY, 32, NULL, EF_BAD, 0,
CA_DUMP},
{"xcap", fldoff(nat_xcap), NSC_XCOORD, 0, NULL, EF_BAD, 0, CA_DUMP},
EF_BAD, 0, CA_DUMP},
{"happiness", fldoff(nat_level[NAT_HLEV]), NSC_FLOAT, 0, NULL,
EF_BAD, 0, CA_DUMP},
- {"relations", fldoff(nat_relate), NSC_UCHAR, MAXNOC, NULL,
- EF_NATION_RELATIONS, NSC_HIDDEN, CA_DUMP_NONE},
- /* mortals know there's contact (relations show), but not how strong */
- {"contacts", fldoff(nat_contact), NSC_UCHAR, MAXNOC, NULL,
- EF_BAD, NSC_DEITY, CA_DUMP_NONE},
- {"rejects", fldoff(nat_rejects), NSC_UCHAR, MAXNOC, NULL,
- EF_NATION_REJECTS, NSC_BITS, CA_DUMP_NONE},
{NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0, CA_DUMP}
#undef CURSTR
};
struct castr nat_ca[sizeof(cou_ca) / sizeof(*cou_ca)];
/* initialized by nsc_init() */
+struct castr relat_ca[] = {
+#define CURSTR struct relatstr
+ {"uid", fldoff(rel_uid), NSC_INT, 0, NULL, EF_RELAT, 0, CA_DUMP},
+ {"timestamp", fldoff(rel_timestamp), NSC_TIME, 0, NULL,
+ EF_BAD, 0, CA_DUMP_NONE},
+ {"relations", fldoff(rel_relate), NSC_UCHAR, MAXNOC, NULL,
+ EF_NATION_RELATIONS, NSC_HIDDEN, CA_DUMP},
+ {NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0, CA_DUMP}
+#undef CURSTR
+};
+
+struct castr contact_ca[] = {
+#define CURSTR struct contactstr
+ {"uid", fldoff(con_uid), NSC_INT, 0, NULL, EF_CONTACT, 0, CA_DUMP},
+ {"timestamp", fldoff(con_timestamp), NSC_TIME, 0, NULL,
+ EF_BAD, 0, CA_DUMP_NONE},
+ /* mortals know there's contact (relations show), but not how strong */
+ {"contacts", fldoff(con_contact), NSC_UCHAR, MAXNOC, NULL,
+ EF_BAD, NSC_DEITY, CA_DUMP},
+ {NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0, CA_DUMP}
+#undef CURSTR
+};
+
+struct castr reject_ca[] = {
+#define CURSTR struct rejectstr
+ {"uid", fldoff(rej_uid), NSC_INT, 0, NULL, EF_REJECT, 0, CA_DUMP},
+ {"timestamp", fldoff(rej_timestamp), NSC_TIME, 0, NULL,
+ EF_BAD, 0, CA_DUMP_NONE},
+ {"rejects", fldoff(rej_rejects), NSC_UCHAR, MAXNOC, NULL,
+ EF_NATION_REJECTS, NSC_BITS, CA_DUMP},
+ {NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0, CA_DUMP}
+#undef CURSTR
+};
+
struct castr realm_ca[] = {
#define CURSTR struct realmstr
/* uid is encoded in cnum, realm */
/* no need for uid as long as it's not referenced from other tables */
{"name", fldoff(in_name), NSC_STRING, 0, NULL, EF_BAD, 0,
CA_DUMP_CONST},
- {"lcms", fldoff(in_lcms), NSC_UCHAR, 0, NULL, EF_BAD, 0, CA_DUMP},
- {"hcms", fldoff(in_hcms), NSC_UCHAR, 0, NULL, EF_BAD, 0, CA_DUMP},
- {"dcost", fldoff(in_dcost), NSC_UCHAR, 0, NULL, EF_BAD, 0, CA_DUMP},
- {"mcost", fldoff(in_mcost), NSC_UCHAR, 0, NULL, EF_BAD, 0, CA_DUMP},
+ NSC_MVEC(fldoff(in_mat), CA_DUMP_ONLY, CA_DUMP_ONLY, CA_DUMP_ONLY),
+ {"bmobil", fldoff(in_bmobil), NSC_SHORT, 0, NULL, EF_BAD, 0, CA_DUMP},
+ {"cost", fldoff(in_cost), NSC_INT, 0, NULL, EF_BAD, 0, CA_DUMP},
{"enable", fldoff(in_enable), NSC_UCHAR, 0, NULL, EF_BAD, 0, CA_DUMP},
{NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0, CA_DUMP}
#undef CURSTR
struct castr symbol_ca[] = {
#define CURSTR struct symbol
/*
- * value is is const because it has to match what is compiled into
+ * value is const because it has to match what is compiled into
* the server. name is const because clients key on it.
*/
{"value", fldoff(value), NSC_INT, 0, NULL, EF_BAD, 0, CA_DUMP_CONST},
nsc_init(void)
{
static struct castr version_ca0 = {
- "version", 0, NSC_STRINGY, sizeof(PACKAGE_STRING), NULL, EF_BAD, 0,
- CA_DUMP
+ "version", 0, NSC_STRING, 0, nsc_ver_version, EF_BAD, 0, CA_DUMP
};
static struct castr version_ca1 = {
"maxnoc", 0, NSC_LONG, 0, nsc_ver_maxnoc, EF_BAD, 0, CA_DUMP
return NULL;
}
+static void *
+nsc_ver_version(struct valstr *val, struct natstr *np, void *ptr)
+{
+ val->val_as.str.base = version;
+ val->val_as.str.maxsz = INT_MAX; /* really SIZE_MAX, but that's C99 */
+ return NULL;
+}
+
static void *
nsc_sct_terr(struct valstr *val, struct natstr *np, void *ptr)
{