/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
- * Ken Stevens, Steve McClure
+ * Copyright (C) 1986-2013, 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,
* 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/>.
*
* ---
*
* nsc.c: Empire selection global structures
*
* Known contributors to this file:
- * Markus Armbruster, 2004-2009
+ * Markus Armbruster, 2004-2013
*/
/*
#include "empobj.h"
#include "file.h"
#include "optlist.h"
+#include "news.h"
#include "nsc.h"
#include "product.h"
#include "unit.h"
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)
#define CURSTR struct pchrstr
{"uid", fldoff(p_uid), NSC_INT, 0, NULL, EF_PRODUCT, 0},
{"name", fldoff(p_name), NSC_STRING, 0, NULL, EF_BAD, 0},
- {"sname", fldoff(p_sname), NSC_STRING, 0, NULL, EF_BAD, NSC_CONST},
+ {"sname", fldoff(p_sname), NSC_STRING, 0, NULL, EF_BAD, 0},
{"ctype", fldoff(p_ctype), NSC_SITYPE(i_type), MAXPRCON, NULL,
EF_ITEM, 0},
{"camt", fldoff(p_camt), NSC_USHORT, MAXPRCON, NULL, EF_BAD, 0},
};
#define NSC_GENITEM(ef_type, ef_chr) \
- {"uid", empobjoff(uid), NSC_INT, 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
{"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 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(m_nchoppers), NSC_UCHAR, 0, NULL, EF_BAD, 0},
{"tech", fldoff(m_tech), NSC_INT, 0, NULL, EF_BAD, 0},
{"cost", fldoff(m_cost), NSC_INT, 0, NULL, EF_BAD, 0},
- {"flags", fldoff(m_flags), NSC_LONG, 0, NULL,
+ {"flags", fldoff(m_flags), NSC_INT, 0, NULL,
EF_SHIP_CHR_FLAGS, NSC_BITS},
{"nplanes", fldoff(m_nplanes), NSC_UCHAR, 0, NULL, EF_BAD, 0},
{"nland", fldoff(m_nland), NSC_UCHAR, 0, NULL, EF_BAD, 0},
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_INT, 0, NULL, EF_BAD, 0},
- {"land", fldoff(pln_land), NSC_INT, 0, NULL, EF_BAD, 0},
{"harden", fldoff(pln_harden), NSC_CHAR, 0, NULL, EF_BAD, 0},
- {"flags", fldoff(pln_flags), NSC_CHAR, 0, NULL,
+ {"ship", fldoff(pln_ship), NSC_INT, 0, NULL, EF_SHIP, 0},
+ {"land", fldoff(pln_land), NSC_INT, 0, NULL, EF_LAND, 0},
+ {"flags", fldoff(pln_flags), NSC_INT, 0, NULL,
EF_PLANE_FLAGS, NSC_BITS},
{"access", fldoff(pln_access), NSC_SHORT, 0, NULL, EF_BAD, 0},
{"theta", fldoff(pln_theta), NSC_FLOAT, 0, NULL, EF_BAD, 0},
#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_INT, 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},
{"rflags", fldoff(lnd_rflags), NSC_INT, 0, NULL,
{"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_INT, 0, NULL, EF_BAD, 0},
+ {"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},
{"dam", fldoff(l_dam), NSC_INT, 0, NULL, EF_BAD, 0},
{"ammo", fldoff(l_ammo), NSC_INT, 0, NULL, EF_BAD, 0},
{"aaf", fldoff(l_aaf), NSC_INT, 0, NULL, EF_BAD, 0},
+ {"flags", fldoff(l_flags), NSC_INT, 0, NULL,
+ EF_LAND_CHR_FLAGS, NSC_BITS},
{"nxlight", fldoff(l_nxlight), NSC_UCHAR, 0, NULL, EF_BAD, 0},
{"nland", fldoff(l_nland), NSC_UCHAR, 0, NULL, EF_BAD, 0},
- {"flags", fldoff(l_flags), NSC_LONG, 0, NULL,
- EF_LAND_CHR_FLAGS, NSC_BITS},
{NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
#undef CURSTR
};
struct castr nuke_ca[] = {
#define CURSTR struct nukstr
NSC_GENITEM(EF_NUKE, EF_NUKE_CHR),
- {"plane", fldoff(nuk_plane), NSC_INT, 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
};
EF_AGREEMENT_STATUS, 0},
{"irate", fldoff(l_irate), NSC_INT, 0, NULL, EF_BAD, 0},
{"ldur", fldoff(l_ldur), NSC_INT, 0, NULL, EF_BAD, 0},
- {"amtpaid", fldoff(l_amtpaid), NSC_LONG, 0, NULL, EF_BAD, 0},
- {"amtdue", fldoff(l_amtdue), NSC_LONG, 0, NULL, EF_BAD, 0},
+ {"amtpaid", fldoff(l_amtpaid), NSC_INT, 0, NULL, EF_BAD, 0},
+ {"amtdue", fldoff(l_amtdue), NSC_INT, 0, NULL, EF_BAD, 0},
{"lastpay", fldoff(l_lastpay), NSC_TIME, 0, NULL, EF_BAD, 0},
{"duedate", fldoff(l_duedate), NSC_TIME, 0, NULL, EF_BAD, 0},
{NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
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'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},
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'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},
+ {"price", fldoff(trd_price), NSC_INT, 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},
/* should let maxbidder access xloc, yloc, but can't express that: */
EF_BAD, NSC_EXTRA},
{"stat", fldoff(nat_stat), NSC_SITYPE(enum nat_status), 0, NULL,
EF_NATION_STATUS, NSC_EXTRA},
+ {"flags", fldoff(nat_flags), NSC_INT, 0, NULL,
+ EF_NATION_FLAGS, NSC_BITS},
{"cname", fldoff(nat_cnam), NSC_STRINGY, 20, NULL, EF_BAD, NSC_EXTRA},
{"passwd", fldoff(nat_pnam), NSC_STRINGY, 20, NULL,
EF_BAD, NSC_DEITY | NSC_EXTRA},
{"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},
- {"money", fldoff(nat_money), NSC_LONG, 0, NULL, EF_BAD, 0},
+ {"milreserve", fldoff(nat_reserve), NSC_INT, 0, NULL, EF_BAD, 0},
+ {"money", fldoff(nat_money), NSC_INT, 0, NULL, EF_BAD, 0},
{"login", fldoff(nat_last_login), NSC_TIME, 0, NULL, EF_BAD, 0},
{"logout", fldoff(nat_last_logout), NSC_TIME, 0, NULL, EF_BAD, 0},
{"newstim", fldoff(nat_newstim), NSC_TIME, 0, NULL, EF_BAD, 0},
EF_BAD, NSC_DEITY | NSC_EXTRA},
{"rejects", fldoff(nat_rejects), NSC_UCHAR, MAXNOC, NULL,
EF_NATION_REJECTS, NSC_EXTRA | NSC_BITS},
- {"flags", fldoff(nat_flags), NSC_LONG, 0, NULL,
- EF_NATION_FLAGS, NSC_BITS},
{NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
#undef CURSTR
};
{"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
};