]> git.pond.sub.org Git - empserver/commitdiff
(nxtitemp, trade_getitem, trade_desc, trade_check_item_ok, nxtitem,
authorRon Koenderink <rkoenderink@yahoo.ca>
Fri, 7 Jul 2006 15:15:43 +0000 (15:15 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Fri, 7 Jul 2006 15:15:43 +0000 (15:15 +0000)
oprange, show_mission, nameofitem, build_mission_list_type,
unit_map, xdvisible, trdswitchown, ontradingblock, trad, check_trade,
unit_type_name, start_stop_unit, scut, scra, mission, multifire,
perform_mission, fuel, NSC_GENITEM): Replace struct genitem with
struct empobj.  Remove genitem.h and create a new file empobj.h.
Replace multiple instances of unions of ef_type structures with
one standard union empobj_storage which is a superset of the individual
instances.

30 files changed:
include/empobj.h [new file with mode: 0644]
include/file.h
include/genitem.h [deleted file]
include/land.h
include/lost.h
include/nat.h
include/nuke.h
include/plane.h
include/prototypes.h
include/sect.h
include/ship.h
include/subs.h
include/trade.h
src/lib/commands/fuel.c
src/lib/commands/load.c
src/lib/commands/mfir.c
src/lib/commands/miss.c
src/lib/commands/scra.c
src/lib/commands/scut.c
src/lib/commands/set.c
src/lib/commands/stop.c
src/lib/commands/tend.c
src/lib/commands/trad.c
src/lib/commands/xdump.c
src/lib/common/maps.c
src/lib/global/nsc.c
src/lib/subs/mission.c
src/lib/subs/nxtitem.c
src/lib/subs/trdsub.c
src/lib/update/nxtitemp.c

diff --git a/include/empobj.h b/include/empobj.h
new file mode 100644 (file)
index 0000000..a6812b9
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ *  Empire - A multi-player, client/server Internet based war game.
+ *  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
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  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
+ *
+ *  ---
+ *
+ *  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.
+ *
+ *  ---
+ *
+ *  genobj.h: General empire objects.
+ * 
+ *  Known contributors to this file:
+ *     Ron Koenderink, 2006
+ *     Markus Armbruster, 2006
+ */
+
+#ifndef EMPOBJ_H
+#define EMPOBJ_H
+
+#include "commodity.h"
+#include "land.h"
+#include "loan.h"
+#include "lost.h"
+#include "plane.h"
+#include "nat.h"
+#include "news.h"
+#include "nuke.h"
+#include "sect.h"
+#include "ship.h"
+#include "trade.h"
+#include "treaty.h"
+
+struct empobj {
+    short ef_type;     /* is always valid */
+    natid own;         /* is valid if EFF_OWNER   is set in table def. */
+    short uid;
+    coord x;           /* is valid if EFF_XY      is set in table def. */
+    coord y;           /* is valid if EFF_XY      is set in table def. */
+    signed char type;
+    signed char effic;
+    signed char mobil;
+    unsigned char off;
+    short tech;        
+    char group;                /* is valid if EFF_GROUP   is set in table def. */
+    coord opx, opy;
+    short mission;
+    short radius;
+};
+
+union empobj_storage {
+    short ef_type;
+    struct empobj gen;
+    struct comstr comm;
+    struct lndstr land;
+    struct lonstr loan;
+    struct loststr lost;
+    struct natstr nat; 
+    struct nwsstr news;
+    struct nukstr nuke;
+    struct plnstr plane;
+    struct realmstr realm;
+    struct sctstr sect;
+    struct shpstr ship;
+    struct trdstr trade;
+    struct trtstr treaty;
+};
+
+#endif
+
index 0e0e2b5fe159db3592a7ac757a97831689458a00..fa16f7cf823bb3d4b2cbe7186a72f8cd1229c698 100644 (file)
@@ -72,7 +72,7 @@ struct empfile {
 /*
  * EFF_XY / EFF_OWNER / EFF_GROUP assert that coordinates / owner /
  * group of such a table's entries can be safely obtained by
- * dereferencing entry address cast to struct genitem *.
+ * dereferencing entry address cast to struct empobj *.
  */
 #define EFF_XY         bit(0)
 #define EFF_OWNER      bit(1)
diff --git a/include/genitem.h b/include/genitem.h
deleted file mode 100644 (file)
index a0892b8..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- *  Empire - A multi-player, client/server Internet based war game.
- *  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
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  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
- *
- *  ---
- *
- *  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.
- *
- *  ---
- *
- *  genitem.h: Definition for generic items
- * 
- *  Known contributors to this file:
- * 
- */
-/*
- * XXX cheap hack; this depends on the fact
- * that units are all the same starting from the top.
- * If you change the units, DON'T CHANGE the tops to
- * be non-identical. Also, if you change types of
- * parts of the tops, be sure to change this file!
- */
-
-#ifndef GENITEM_H
-#define GENITEM_H
-
-struct genitem {
-    short ef_type;
-    natid own;
-    short uid;
-    coord x;
-    coord y;
-    signed char type;
-    signed char effic;
-    signed char mobil;
-    unsigned char off;
-    short tech;
-    char group;
-    coord opx, opy;
-    short mission;
-    short radius;
-};
-
-#endif
index 6d2fc0e44c07887081f17f903ab6cdac6dc03ac5..93b9305990ab1c75ea11ed6051686f27718c193e 100644 (file)
@@ -47,7 +47,7 @@
 #define LAND_MINFIREEFF 40     /* arty must be this effic to fire */
 
 struct lndstr {
-    /* initial part must match struct genitem */
+    /* initial part must match struct empobj */
     short ef_type;
     natid lnd_own;             /* owner's country num */
     short lnd_uid;             /* unit id (land unit) */
@@ -62,7 +62,7 @@ struct lndstr {
     coord lnd_opx, lnd_opy;    /* Op sector coords */
     short lnd_mission;         /* mission code */
     short lnd_radius;          /* mission radius */
-    /* end of part matching struct genitem */
+    /* end of part matching struct empobj */
     signed char lnd_flags;     /* unit flags (unused) */
     short lnd_ship;            /* pointer to transporting ship */
     signed char lnd_harden;    /* fortification */
index 71b876197a3afb51682c855149cac078d404ec16..2572dce220800b6dad75ea37116df045947b11b2 100644 (file)
 #define LOST_H
 
 struct loststr {
-    /* initial part must match struct genitem */
+    /* initial part must match struct empobj */
     short ef_type;
     natid lost_owner;          /* Who lost it */
-    /* end of part matching struct genitem */
+    /* end of part matching struct empobj */
     int lost_uid;              /* lost ID (assigned, otherwise unused) */
     char lost_type;            /* Type of thing (ship, plane, nuke, land, sector) */
     short lost_id;             /* ID of lost thing */
index 2b44568fec0d1bd573ea75f6e1ebab4101dc9b17..4edddd83a761bcec97b03935f098226c86c7cc4e 100644 (file)
@@ -64,10 +64,10 @@ typedef enum {
  * If we had working virtual selectors, we could remove r_cnum and r_realm.
  */
 struct realmstr {
-    /* initial part must match struct genitem */
+    /* initial part must match struct empobj */
     short ef_type;
     natid r_cnum;              /* country number */
-    /* end of part matching struct genitem */
+    /* end of part matching struct empobj */
     short r_uid;               /* realm table index */
     unsigned short r_realm;    /* realm number */
     short r_xl, r_xh;          /* horizontal bounds */
@@ -76,10 +76,10 @@ struct realmstr {
 };
 
 struct natstr {
-    /* initial part must match struct genitem */
+    /* initial part must match struct empobj */
     short ef_type;
     natid nat_cnum;            /* our country number */
-    /* end of part matching struct genitem */
+    /* end of part matching struct empobj */
     nat_status nat_stat;
     char nat_cnam[20];         /* country name */
     char nat_pnam[20];         /* representative */
index 9abed3d113da4112c54a65f1abb607977bc76373..a64cedaeacdc0a83a2e4203125e66ae6b3e6829c 100644 (file)
@@ -38,7 +38,7 @@
 #define        MIN_DRNUKE_CONST        0.001
 
 struct nukstr {
-    /* initial part must match struct genitem */
+    /* initial part must match struct empobj */
     short ef_type;
     natid nuk_own;
     short nuk_uid;
@@ -52,7 +52,7 @@ struct nukstr {
     coord nuk_opx, nuk_opy;    /* Op sector coords, unused */
     short nuk_mission;         /* mission code, unused */
     short nuk_radius;          /* mission radius, unused */
-    /* end of part matching struct genitem */
+    /* end of part matching struct empobj */
     short nuk_ship;            /* currently aboard ship (unused) */
     short nuk_plane;           /* currently aboard plane */
     short nuk_land;            /* currently aboard land (unused) */
index 76b32b00f5bf3d68798c60b5dcf7bc8850f4e327..beee78d6ed6849bb1fc83ec6a72d043cce6f1efb 100644 (file)
@@ -43,7 +43,7 @@
 #define        PLANE_MINEFF    10
 
 struct plnstr {
-    /* initial part must match struct genitem */
+    /* initial part must match struct empobj */
     short ef_type;
     natid pln_own;             /* owning country */
     short pln_uid;             /* plane unit id */
@@ -59,7 +59,7 @@ struct plnstr {
     coord pln_opy;             /* Op sector coords */
     short pln_mission;         /* mission code */
     short pln_radius;          /* mission radius */
-    /* end of part matching struct genitem */
+    /* end of part matching struct empobj */
     unsigned char pln_range;   /* total distance, not radius */
     unsigned char pln_range_max; /* max range for this plane */
     short pln_ship;            /* pointer to carrier */
index 296d44d33cab72afbf57abe5a86e37e6705f847b..d2c856c958b9361b2620437b5b2097b38ac6dc39 100644 (file)
@@ -488,14 +488,14 @@ extern int num_shipsatxy(coord, coord, int, int);
 extern int islist(char *);
 /* src/lib/subs/mission.c */
 extern char *mission_name(short);
-extern char *nameofitem(struct genitem *, int);
+extern char *nameofitem(struct empobj *, int);
 extern int collateral_damage(coord, coord, int, struct emp_qelem *);
 extern int mission_pln_equip(struct plist *, struct ichrstr *, int, char);
 extern int ground_interdict(coord, coord, natid, char *);
 extern int unit_interdict(coord, coord, natid, char *, int, int);
 extern int off_support(coord, coord, natid, natid);
 extern int def_support(coord, coord, natid, natid);
-extern int oprange(struct genitem *, int, int *);
+extern int oprange(struct empobj *, int, int *);
 extern int cando(int, int);
 extern void show_mission(int, struct nstr_item *);
 extern int air_defense(coord, coord, natid, struct emp_qelem *,
index 637d40ac9a12bda0c9144c6e5221d860c57eb855..ce3c5a0315e15589179996955c011b4982e5d1f9 100644 (file)
 #include "item.h"
 
 struct sctstr {
-    /* initial part must match struct genitem */
+    /* initial part must match struct empobj */
     short ef_type;
     natid sct_own;             /* owner's country num */
     short sct_elev;            /* elevation/depth */
     coord sct_x;               /* x coord of sector */
     coord sct_y;               /* y coord of sector */
-    /* end of part matching struct genitem */
+    /* end of part matching struct empobj */
     unsigned char sct_type;    /* sector type */
     unsigned char sct_effic;   /* 0% to 100% */
     short sct_mobil;           /* mobility units */
index 16f8220eae00f438cf6e59b0a91a9db9dc56a380..e58cd0d0221f4a6f69a3b62b40d89d5d46da5a6d 100644 (file)
@@ -60,7 +60,7 @@
 #define        MAXSHPNAMLEN    24
 
 struct shpstr {
-    /* initial part must match struct genitem */
+    /* initial part must match struct empobj */
     short ef_type;
     natid shp_own;             /* owner's country num */
     short shp_uid;             /* unit id (ship #) */
@@ -75,7 +75,7 @@ struct shpstr {
     coord shp_opx, shp_opy;    /* Op sector coords */
     short shp_mission;         /* mission code */
     short shp_radius;          /* mission radius */
-    /* end of part matching struct genitem */
+    /* end of part matching struct empobj */
     unsigned char shp_nplane;  /* number of planes on board */
     unsigned char shp_nland;   /* number of land units on board */
     short shp_armor;
index f5612711a8261b7b1c9d12ddba4149bb773c06e9..384fa69d14a5fe696d5d311ca5a79817ff5b37a0 100644 (file)
@@ -47,7 +47,7 @@
 #include "ship.h"
 #include "queue.h"
 #include "xy.h"
-#include "genitem.h"
+#include "empobj.h"
 #include "trade.h"
 #include "player.h"
 #include "prototypes.h"                /* must come at end, after defines and typedefs */
index 1fb0e5a1b2db740f99d6e2913453fe4ef87424d8..fc3d7cf013622e67c87f37767ec7ae8f4ceeaaf5 100644 (file)
 #ifndef TRADE_H
 #define TRADE_H
 
-#include "genitem.h"
-#include "nuke.h"
-#include "plane.h"
-#include "land.h"
-#include "ship.h"
-
 struct trdstr {
     short ef_type;
     natid trd_owner;
@@ -56,19 +50,11 @@ struct trdstr {
     coord trd_y;
 };
 
-union trdgenstr {
-    struct genitem gen;
-    struct nukstr nuk;
-    struct plnstr pln;
-    struct lndstr lnd;
-    struct shpstr shp;
-};
-
-extern int trade_check_ok(struct trdstr *, union trdgenstr *);
-extern int trade_check_item_ok(union trdgenstr *);
-extern char *trade_nameof(struct trdstr *, union trdgenstr *);
-extern int trade_desc(struct trdstr *, union trdgenstr *);
-extern int trade_getitem(struct trdstr *, union trdgenstr *);
+extern int trade_check_ok(struct trdstr *, union empobj_storage *);
+extern int trade_check_item_ok(union empobj_storage *);
+extern char *trade_nameof(struct trdstr *, union empobj_storage *);
+extern int trade_desc(struct trdstr *, union empobj_storage *);
+extern int trade_getitem(struct trdstr *, union empobj_storage *);
 
 #define gettrade(n, p) ef_read(EF_TRADE, (n), (p))
 #define puttrade(n, p) ef_write(EF_TRADE, (n), (p))
index a1cdaf85595ce1e4c1f9aeb0d29e766a14202a29..0bead0df0a8b323f705a29eec226831e017fd8a3 100644 (file)
 #include "player.h"
 #include "plague.h"
 #include "xy.h"
-#include "ship.h"
-#include "plane.h"
-#include "land.h"
-#include "nat.h"
 #include "nsc.h"
 #include "file.h"
-#include "sect.h"
 #include "optlist.h"
 #include "commands.h"
-
-
-union item_u {
-    struct shpstr ship;
-    struct lndstr land;
-};
+#include "empobj.h"
 
 int
 fuel(void)
 {
     static int shp_or_lnd[] = { EF_SHIP, EF_LAND, EF_BAD };
     struct nstr_item ni;
-    union item_u item, item2;
+    union empobj_storage item, item2;
     int type;
     struct mchrstr *mp;
     struct lchrstr *lcp;
index 54a3380953f6c71063be949f2224fc2b49491ac9..cf22981b4679690a0bc0244f4a09ea2abf97fff1 100644 (file)
@@ -321,7 +321,7 @@ lload(void)
 void
 gift(natid givee, natid giver, void *ptr, int type, char *mesg)
 {
-    struct genitem *gen = ptr;
+    struct empobj *gen = ptr;
     char *p;
 
     if (giver != givee) {
index 8348f800a29a7077337784ab1da792cf849ddb4c..11aeb9c8a867dbfa0b5cff80b253876525218dbe 100644 (file)
 #include "misc.h"
 #include "player.h"
 #include "xy.h"
-#include "treaty.h"
-#include "nat.h"
-#include "ship.h"
-#include "land.h"
-#include "sect.h"
 #include "retreat.h"
-#include "news.h"
 #include "nsc.h"
 #include "file.h"
 #include "queue.h"
@@ -50,6 +44,7 @@
 #include "optlist.h"
 #include "damage.h"
 #include "commands.h"
+#include "empobj.h"
 
 enum targ_type {
     targ_land, targ_ship, targ_sub, targ_unit, targ_bogus
@@ -64,12 +59,6 @@ struct flist {
     int victim;                        /* who I was shooting at */
 };
 
-union item_u {
-    struct shpstr ship;
-    struct sctstr sect;
-    struct lndstr land;
-};
-
 static void add_to_fired_queue(struct emp_qelem *, struct emp_qelem *);
 static int defend(struct emp_qelem *al,
                  struct emp_qelem *dl,
@@ -120,7 +109,7 @@ multifire(void)
     char *p;
     int nfiring = 0;
     int ndefending = 0;
-    union item_u item;
+    union empobj_storage item;
     struct emp_qelem fired, defended;
     double odds;
     char buf[1024];
index e2fd200cddea421eea2713886687c6110ca234f4..6d6d70fb05f64921a493fe0b113570a13f7d0d93 100644 (file)
 #include "misc.h"
 #include "player.h"
 #include "xy.h"
-#include "sect.h"
-#include "ship.h"
-#include "land.h"
-#include "plane.h"
-#include "nat.h"
 #include "nsc.h"
 #include "file.h"
 #include "path.h"
 #include "mission.h"
-#include "genitem.h"
 #include "commands.h"
 #include "optlist.h"
-
-union item_u {
-    struct shpstr ship;
-    struct plnstr plane;
-    struct lndstr land;
-};
+#include "empobj.h"
 
 /*
  *  mission <type> <planes/ships/units> <mission type> <op sector> [<radius>]
@@ -69,8 +58,8 @@ mission(void)
     coord x, y;
     int desired_radius, radius;
     struct sctstr opsect;
-    union item_u item;
-    struct genitem *gp;
+    union empobj_storage item;
+    struct empobj *gp;
     int num = 0, mobmax, mobused, dist;
     struct nstr_item ni;
     char prompt[128];
@@ -212,7 +201,7 @@ mission(void)
     mobused = ldround(mission_mob_cost * (double)mobmax, 1);
 
     while (nxtitem(&ni, &item)) {
-       gp = (struct genitem *)&item;
+       gp = (struct empobj *)&item;
 
        if (!player->owner || gp->own == 0)
            continue;
index 9e69e54ad079b549f1e6db80103d6aef987cb46a..1bd9aa150d34d0a4f832cf85fda4df0e8aac3dc0 100644 (file)
 #include "misc.h"
 #include "player.h"
 #include "xy.h"
-#include "sect.h"
-#include "ship.h"
-#include "plane.h"
-#include "land.h"
-#include "nat.h"
 #include "nsc.h"
 #include "file.h"
 #include "commands.h"
 #include "optlist.h"
-
-union item_u {
-    struct shpstr ship;
-    struct plnstr plane;
-    struct lndstr land;
-};
+#include "empobj.h"
 
 int
 scra(void)
 {
     struct nstr_item ni;
-    union item_u item;
+    union empobj_storage item;
     int type;
     struct sctstr sect;
     struct mchrstr *mp;
index 3e0d9bd85196c333b305f1dbf6390ed496222772..32c7878326974468db3f7a694fcef3f9dfd593af 100644 (file)
 
 #include "misc.h"
 #include "player.h"
-#include "sect.h"
-#include "news.h"
 #include "xy.h"
-#include "ship.h"
-#include "land.h"
-#include "plane.h"
-#include "nat.h"
 #include "nsc.h"
 #include "file.h"
 #include "commands.h"
 #include "optlist.h"
+#include "empobj.h"
 
 static void scuttle_land(struct lndstr *);
 
-union item_u {
-    struct shpstr ship;
-    struct plnstr plane;
-    struct lndstr land;
-};
-
 int
 scut(void)
 {
     struct nstr_item ni;
-    union item_u item;
+    union empobj_storage item;
     int type;
     struct mchrstr *mp;
     char *p;
index 03cbf538e4d59b3d6df5e5becb540cde9fd56c47..404e9282189a1bd4f8551fef0c9e8f767d5dba69 100644 (file)
@@ -63,7 +63,7 @@ set(void)
     struct trdstr trade;
     struct nstr_item ni;
     struct nstr_item ni_trade;
-    union trdgenstr item;
+    union empobj_storage item;
     struct sctstr sect;
     int freeslot;
     int foundslot;
index f246389c7813575eda6f4a5c23a44dc4f1b141de..a21871ed9cfc7e2948e7bc6ab997ea62f73d2b72 100644 (file)
 #include "misc.h"
 #include "player.h"
 #include "xy.h"
-#include "sect.h"
-#include "nsc.h"
-#include "nat.h"
 #include "path.h"
 #include "file.h"
 #include "commands.h"
-
-union item_u {
-    struct genitem gen;
-    struct shpstr ship;
-    struct plnstr plane;
-    struct lndstr land;
-    struct nukstr nuke;
-};
+#include "empobj.h"
 
 static int start_stop(int);
 static int start_stop_sector(char *, int);
@@ -59,7 +49,7 @@ static void start_stop_hdr(int);
 static void proff(int);
 static int start_stop_unit(int, char *, int);
 static void start_stop_unit_hdr(int);
-static char *unit_type_name(union item_u *);
+static char *unit_type_name(union empobj_storage *);
 
 int
 start(void)
@@ -167,7 +157,7 @@ proff(int off)
 static int
 start_stop_unit(int type, char *arg, int off)
 {
-    union item_u unit;
+    union empobj_storage unit;
     int nunit;
     struct nstr_item nstr;
 
@@ -211,7 +201,7 @@ start_stop_unit_hdr(int off)
 }
 
 static char *
-unit_type_name(union item_u *unit)
+unit_type_name(union empobj_storage *unit)
 {
     int type = unit->gen.type;
 
index 87f4c78bfe761d28b54f2ac7e71063b8adfacd79..4f2d7c1eb8a223835fb8cdcefbe829b2bde1c0e3 100644 (file)
@@ -47,7 +47,6 @@
 #include "nat.h"
 #include "land.h"
 #include "plane.h"
-#include "genitem.h"
 #include "commands.h"
 
 static void expose_ship(struct shpstr *s1, struct shpstr *s2);
index fc77d80e15622b3e5b66e3f1487a55a7ad1137a6..75773d06e154278622feaf1c0b969eb9ae154b4c 100644 (file)
@@ -71,7 +71,7 @@ trad(void)
     struct nstr_item ni;
     struct trdstr trade;
     struct trdstr tmpt;
-    union trdgenstr tg;
+    union empobj_storage tg;
     int plflags;
     double canspend;
     time_t now;
@@ -193,8 +193,8 @@ trad(void)
      */
     if (((trade.trd_type == EF_PLANE) || (trade.trd_type == EF_NUKE))
        && ((trade.trd_type == EF_NUKE) ||
-           !(tg.pln.pln_flags & PLN_LAUNCHED))) {
-       plflags = plchr[(int)tg.pln.pln_type].pl_flags;
+           !(tg.plane.pln_flags & PLN_LAUNCHED))) {
+       plflags = plchr[(int)tg.plane.pln_type].pl_flags;
        while (1) {
            p = getstring("Destination sector: ", buf);
            if (!trade_check_ok(&trade, &tg))
@@ -292,7 +292,7 @@ check_trade(void)
     struct lndstr land;
     struct natstr *natp;
     struct trdstr trade;
-    union trdgenstr tg;
+    union empobj_storage tg;
     time_t now;
     double subleft;
     double monleft;
@@ -380,68 +380,68 @@ check_trade(void)
        putnat(natp);
        switch (trade.trd_type) {
        case EF_NUKE:
-           tg.nuk.nuk_x = trade.trd_x;
-           tg.nuk.nuk_y = trade.trd_y;
-           makelost(EF_NUKE, tg.nuk.nuk_own, tg.nuk.nuk_uid,
-                    tg.nuk.nuk_x, tg.nuk.nuk_y);
-           tg.nuk.nuk_own = trade.trd_maxbidder;
-           makenotlost(EF_NUKE, tg.nuk.nuk_own, tg.nuk.nuk_uid,
-                       tg.nuk.nuk_x, tg.nuk.nuk_y);
+           tg.nuke.nuk_x = trade.trd_x;
+           tg.nuke.nuk_y = trade.trd_y;
+           makelost(EF_NUKE, tg.nuke.nuk_own, tg.nuke.nuk_uid,
+                    tg.nuke.nuk_x, tg.nuke.nuk_y);
+           tg.nuke.nuk_own = trade.trd_maxbidder;
+           makenotlost(EF_NUKE, tg.nuke.nuk_own, tg.nuke.nuk_uid,
+                       tg.nuke.nuk_x, tg.nuke.nuk_y);
            break;
        case EF_PLANE:
-           if ((tg.pln.pln_flags & PLN_LAUNCHED) == 0) {
-               tg.pln.pln_x = trade.trd_x;
-               tg.pln.pln_y = trade.trd_y;
+           if ((tg.plane.pln_flags & PLN_LAUNCHED) == 0) {
+               tg.plane.pln_x = trade.trd_x;
+               tg.plane.pln_y = trade.trd_y;
            }
-           makelost(EF_PLANE, tg.pln.pln_own, tg.pln.pln_uid,
-                    tg.pln.pln_x, tg.pln.pln_y);
-           tg.pln.pln_own = trade.trd_maxbidder;
-           makenotlost(EF_PLANE, tg.pln.pln_own, tg.pln.pln_uid,
-                       tg.pln.pln_x, tg.pln.pln_y);
-           tg.pln.pln_wing = 0;
+           makelost(EF_PLANE, tg.plane.pln_own, tg.plane.pln_uid,
+                    tg.plane.pln_x, tg.plane.pln_y);
+           tg.plane.pln_own = trade.trd_maxbidder;
+           makenotlost(EF_PLANE, tg.plane.pln_own, tg.plane.pln_uid,
+                       tg.plane.pln_x, tg.plane.pln_y);
+           tg.plane.pln_wing = 0;
            /* no cheap version of fly */
            if (opt_MOB_ACCESS) {
-               tg.pln.pln_mobil = -(etu_per_update / sect_mob_neg_factor);
+               tg.plane.pln_mobil = -(etu_per_update / sect_mob_neg_factor);
            } else {
-               tg.pln.pln_mobil = 0;
+               tg.plane.pln_mobil = 0;
            }
-           tg.pln.pln_mission = 0;
-           tg.pln.pln_harden = 0;
-           time(&tg.pln.pln_access);
-           tg.pln.pln_ship = -1;
-           tg.pln.pln_land = -1;
+           tg.plane.pln_mission = 0;
+           tg.plane.pln_harden = 0;
+           time(&tg.plane.pln_access);
+           tg.plane.pln_ship = -1;
+           tg.plane.pln_land = -1;
            break;
        case EF_SHIP:
-           takeover_ship(&tg.shp, trade.trd_maxbidder, 0);
+           takeover_ship(&tg.ship, trade.trd_maxbidder, 0);
            break;
        case EF_LAND:
-           tg.lnd.lnd_x = trade.trd_x;
-           tg.lnd.lnd_y = trade.trd_y;
-           if (tg.lnd.lnd_ship >= 0) {
+           tg.land.lnd_x = trade.trd_x;
+           tg.land.lnd_y = trade.trd_y;
+           if (tg.land.lnd_ship >= 0) {
                struct shpstr ship;
-               getship(tg.lnd.lnd_ship, &ship);
+               getship(tg.land.lnd_ship, &ship);
                ship.shp_nland--;
                putship(ship.shp_uid, &ship);
            }
-           makelost(EF_LAND, tg.lnd.lnd_own, tg.lnd.lnd_uid,
-                    tg.lnd.lnd_x, tg.lnd.lnd_y);
-           tg.lnd.lnd_own = trade.trd_maxbidder;
-           makenotlost(EF_LAND, tg.lnd.lnd_own, tg.lnd.lnd_uid,
-                       tg.lnd.lnd_x, tg.lnd.lnd_y);
-           tg.lnd.lnd_army = 0;
+           makelost(EF_LAND, tg.land.lnd_own, tg.land.lnd_uid,
+                    tg.land.lnd_x, tg.land.lnd_y);
+           tg.land.lnd_own = trade.trd_maxbidder;
+           makenotlost(EF_LAND, tg.land.lnd_own, tg.land.lnd_uid,
+                       tg.land.lnd_x, tg.land.lnd_y);
+           tg.land.lnd_army = 0;
            /* no cheap version of fly */
            if (opt_MOB_ACCESS) {
-               tg.lnd.lnd_mobil = -(etu_per_update / sect_mob_neg_factor);
+               tg.land.lnd_mobil = -(etu_per_update / sect_mob_neg_factor);
            } else {
-               tg.lnd.lnd_mobil = 0;
+               tg.land.lnd_mobil = 0;
            }
-           tg.lnd.lnd_harden = 0;
-           time(&tg.lnd.lnd_access);
-           tg.lnd.lnd_mission = 0;
+           tg.land.lnd_harden = 0;
+           time(&tg.land.lnd_access);
+           tg.land.lnd_mission = 0;
            /* Drop any land units this unit was carrying */
-           snxtitem_xy(&ni, EF_LAND, tg.lnd.lnd_x, tg.lnd.lnd_y);
+           snxtitem_xy(&ni, EF_LAND, tg.land.lnd_x, tg.land.lnd_y);
            while (nxtitem(&ni, &land)) {
-               if (land.lnd_land != tg.lnd.lnd_uid)
+               if (land.lnd_land != tg.land.lnd_uid)
                    continue;
                land.lnd_land = -1;
                wu(0, land.lnd_own, "unit #%d dropped in %s\n",
@@ -450,7 +450,7 @@ check_trade(void)
                putland(land.lnd_uid, &land);
            }
            /* Drop any planes this unit was carrying */
-           snxtitem_xy(&ni, EF_PLANE, tg.lnd.lnd_x, tg.lnd.lnd_y);
+           snxtitem_xy(&ni, EF_PLANE, tg.land.lnd_x, tg.land.lnd_y);
            while (nxtitem(&ni, &plane)) {
                if (plane.pln_flags & PLN_LAUNCHED)
                    continue;
@@ -462,8 +462,8 @@ check_trade(void)
                   xyas(plane.pln_x, plane.pln_y, plane.pln_own));
                putplane(plane.pln_uid, &plane);
            }
-           tg.lnd.lnd_ship = -1;
-           tg.lnd.lnd_land = -1;
+           tg.land.lnd_ship = -1;
+           tg.land.lnd_land = -1;
            break;
        default:
            logerror("Bad trade type %d in trade\n", trade.trd_type);
@@ -490,7 +490,7 @@ int
 ontradingblock(int type, void *ptr)
 {
     struct trdstr trade;
-    union trdgenstr tg;
+    union empobj_storage tg;
     int n;
 
     for (n = 0; gettrade(n, &trade); n++) {
@@ -500,7 +500,7 @@ ontradingblock(int type, void *ptr)
            continue;
        if (trade.trd_type != type)
            continue;
-       if (tg.gen.uid == ((struct genitem *)ptr)->uid)
+       if (tg.gen.uid == ((struct empobj *)ptr)->uid)
            return 1;
     }
     return 0;
@@ -510,7 +510,7 @@ void
 trdswitchown(int type, void *ptr, int newown)
 {
     struct trdstr trade;
-    union trdgenstr tg;
+    union empobj_storage tg;
     int n;
 
     for (n = 0; gettrade(n, &trade); n++) {
@@ -520,7 +520,7 @@ trdswitchown(int type, void *ptr, int newown)
            continue;
        if (trade.trd_type != type)
            continue;
-       if (tg.gen.uid != ((struct genitem *)ptr)->uid)
+       if (tg.gen.uid != ((struct empobj *)ptr)->uid)
            continue;
        if (trade.trd_owner == trade.trd_maxbidder)
            trade.trd_maxbidder = newown;
index 956260e2e427e0a685c41bae1205b0106ee874e5..d7647818f1f9ebe0a4c53ccb3f941379fa213ac5 100644 (file)
@@ -197,7 +197,7 @@ xdftr(int n)
 static int
 xdvisible(int type, void *p)
 {
-    struct genitem *gp = p;
+    struct empobj *gp = p;
     struct trtstr *tp = p;
     struct lonstr *lp = p;
     struct natstr *natp;
index 458f0e7a9b5cfb5a47a42bf8383ec2663c5423f8..5c9c5c2b682e46117451722dbf7a9720f5950a03 100644 (file)
@@ -322,28 +322,28 @@ unit_map(int unit_type, int uid, struct nstr_sect *nsp, char *originp)
     struct lndstr origl;
     struct plnstr origp;
     struct nukstr orign;
-    struct genitem *gp;
+    struct empobj *gp;
     struct range range;
 
     if (unit_type == EF_LAND) {
        if (!getland(uid, &origl) || !player->owner || origl.lnd_own == 0)
            return RET_FAIL;
-       gp = (struct genitem *)&origl;
+       gp = (struct empobj *)&origl;
        *originp = *lchr[(int)origl.lnd_type].l_name;
     } else if (unit_type == EF_PLANE) {
        if (!getplane(uid, &origp) || !player->owner || origp.pln_own == 0)
            return RET_FAIL;
-       gp = (struct genitem *)&origp;
+       gp = (struct empobj *)&origp;
        *originp = *plchr[(int)origp.pln_type].pl_name;
     } else if (unit_type == EF_NUKE) {
        if (!getnuke(uid, &orign) || !player->owner || orign.nuk_own == 0)
            return RET_FAIL;
-       gp = (struct genitem *)&orign;
+       gp = (struct empobj *)&orign;
        *originp = 'n';
     } else {
        if (!getship(uid, &origs) || !player->owner || origs.shp_own == 0)
            return RET_FAIL;
-       gp = (struct genitem *)&origs;
+       gp = (struct empobj *)&origs;
        *originp = *mchr[(int)origs.shp_type].m_name;
     }
 
index e976bf73fe8c6c48a86e6bdf9c051f4e2849f7c3..e0bff68a23dcc920e0f969f352aaef0788617148 100644 (file)
 #include <stddef.h>
 #include "misc.h"
 #include "xy.h"
-#include "loan.h"
 #include "nsc.h"
-#include "news.h"
-#include "nuke.h"
-#include "plane.h"
-#include "ship.h"
-#include "land.h"
-#include "sect.h"
-#include "trade.h"
-#include "treaty.h"
-#include "genitem.h"
-#include "nat.h"
-#include "map.h"
-#include "commodity.h"
-#include "lost.h"
+#include "empobj.h"
 #include "product.h"
 #include "file.h"
 
@@ -191,20 +178,20 @@ struct castr dchr_ca[] = {
 };
 
 #define NSC_GENITEM(ef_type, ef_chr)                                   \
-{ NSC_SHORT, 0, 0, fldoff(genitem, uid), "uid", ef_type},              \
-{ NSC_NATID, 0, 0, fldoff(genitem, own), "owner", EF_NATION},          \
-{ NSC_XCOORD, 0, 0, fldoff(genitem, x), "xloc", EF_BAD},               \
-{ NSC_YCOORD, 0, 0, fldoff(genitem, y), "yloc", EF_BAD},               \
-{ NSC_CHAR, 0, 0, fldoff(genitem, type), "type", ef_chr},              \
-{ NSC_CHAR, 0, 0, fldoff(genitem, effic), "effic", EF_BAD},            \
-{ NSC_CHAR , 0, 0, fldoff(genitem, mobil), "mobil", EF_BAD},           \
-{ NSC_UCHAR , 0, 0, fldoff(genitem, off), "off", EF_BAD},              \
-{ NSC_SHORT, 0, 0, fldoff(genitem, tech), "tech", EF_BAD},             \
-{ NSC_STRINGY, NSC_EXTRA, 1, fldoff(genitem, group), "group", EF_BAD}, \
-{ NSC_XCOORD, 0, 0, fldoff(genitem, opx), "opx", EF_BAD},              \
-{ NSC_YCOORD, 0, 0, fldoff(genitem, opy), "opy", EF_BAD},              \
-{ NSC_SHORT, 0, 0, fldoff(genitem, mission), "mission", EF_MISSIONS},  \
-{ NSC_SHORT, 0, 0, fldoff(genitem, radius), "radius", EF_BAD}
+{ NSC_SHORT, 0, 0, fldoff(empobj, uid), "uid", ef_type},               \
+{ NSC_NATID, 0, 0, fldoff(empobj, own), "owner", EF_NATION},           \
+{ NSC_XCOORD, 0, 0, fldoff(empobj, x), "xloc", EF_BAD},                \
+{ NSC_YCOORD, 0, 0, fldoff(empobj, y), "yloc", EF_BAD},                \
+{ NSC_CHAR, 0, 0, fldoff(empobj, type), "type", ef_chr},               \
+{ NSC_CHAR, 0, 0, fldoff(empobj, effic), "effic", EF_BAD},             \
+{ NSC_CHAR , 0, 0, fldoff(empobj, mobil), "mobil", EF_BAD},            \
+{ NSC_UCHAR , 0, 0, fldoff(empobj, off), "off", EF_BAD},               \
+{ NSC_SHORT, 0, 0, fldoff(empobj, tech), "tech", EF_BAD},              \
+{ NSC_STRINGY, NSC_EXTRA, 1, fldoff(empobj, group), "group", EF_BAD},  \
+{ NSC_XCOORD, 0, 0, fldoff(empobj, opx), "opx", EF_BAD},               \
+{ NSC_YCOORD, 0, 0, fldoff(empobj, opy), "opy", EF_BAD},               \
+{ NSC_SHORT, 0, 0, fldoff(empobj, mission), "mission", EF_MISSIONS},   \
+{ NSC_SHORT, 0, 0, fldoff(empobj, radius), "radius", EF_BAD}
 
 struct castr ship_ca[] = {
     NSC_GENITEM(EF_SHIP, EF_SHIP_CHR),
index 3982b982d8996e4f90e53b4e86bbdbb18677218b..5776d5a30f7102b866c64ccdb0ef5fc9e1aa6010 100644 (file)
 #include "misc.h"
 #include "player.h"
 #include "xy.h"
-#include "sect.h"
-#include "ship.h"
-#include "land.h"
-#include "plane.h"
-#include "nat.h"
 #include "nsc.h"
 #include "file.h"
 #include "path.h"
 #include "mission.h"
-#include "genitem.h"
-#include "news.h"
 #include "item.h"
 #include <fcntl.h>
 #include "damage.h"
 #include "queue.h"
 #include "prototypes.h"
 #include "optlist.h"
+#include "empobj.h"
 
 struct genlist {
     struct emp_qelem queue;    /* list of units */
@@ -68,12 +62,6 @@ struct airport {
     natid own;
 };
 
-union item_u {
-    struct shpstr ship;
-    struct plnstr plane;
-    struct lndstr land;
-};
-
 static void add_airport(struct emp_qelem *, coord, coord);
 static int air_damage(struct emp_qelem *, coord, coord, int, natid,
                      char *, int);
@@ -301,8 +289,8 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
 {
     struct nstr_item ni;
     struct genlist *glp;
-    struct genitem *gp;
-    union item_u item;
+    struct empobj *gp;
+    union empobj_storage item;
     int dist;
     int radius;
     int relat;
@@ -310,7 +298,7 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
 
     snxtitem_all(&ni, type);
     while (nxtitem(&ni, &item)) {
-       gp = (struct genitem *)&item;
+       gp = (struct empobj *)&item;
 
        if (gp->own == 0)
            continue;
@@ -427,7 +415,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
     struct emp_qelem *newqp;
     struct genlist *glp;
     struct plist *plp;
-    struct genitem *gp;
+    struct empobj *gp;
     struct lndstr *lp;
     struct shpstr *sp;
     struct sctstr sect;
@@ -817,7 +805,7 @@ cando(int mission, int type)
 }
 
 char *
-nameofitem(struct genitem *gp, int type)
+nameofitem(struct empobj *gp, int type)
 {
     switch (type) {
     case EF_SHIP:
@@ -858,11 +846,11 @@ void
 show_mission(int type, struct nstr_item *np)
 {
     int first = 1, radius;
-    union item_u item;
-    struct genitem *gp;
+    union empobj_storage item;
+    struct empobj *gp;
 
     while (nxtitem(np, &item)) {
-       gp = (struct genitem *)&item;
+       gp = (struct empobj *)&item;
        if (!player->owner || gp->own == 0)
            continue;
 
@@ -909,7 +897,7 @@ show_mission(int type, struct nstr_item *np)
 }
 
 int
-oprange(struct genitem *gp, int type, int *radius)
+oprange(struct empobj *gp, int type, int *radius)
 {
     int range;
     struct shpstr ship;
@@ -1462,7 +1450,7 @@ air_defense(coord x, coord y, natid victim, struct emp_qelem *bomb_list,
     struct emp_qelem *qp, interceptors, airp, i, empty, *next;
     struct plist *plp;
     struct genlist *glp;
-    struct genitem *gp;
+    struct empobj *gp;
     struct genlist mi[MAXNOC];
     char buf[512];
     char *path;
index ad347d9454583ac91cdf6bb40151970158ac817a..0e0517cfe8f21e6f2880b405563e1aad4fdca489 100644 (file)
 #include "land.h"
 #include "nsc.h"
 #include "file.h"
-#include "genitem.h"
 #include "prototypes.h"
 
 int
 nxtitem(struct nstr_item *np, void *ptr)
 {
-    struct genitem *gp;
+    struct empobj *gp;
     int selected;
 
     if (np->sel == NS_UNDEF)
        return 0;
-    gp = (struct genitem *)ptr;
+    gp = (struct empobj *)ptr;
     do {
        if (np->sel == NS_LIST) {
            np->index++;
index bfa3f059c8f320cb924287fb225aae593535881c..96aa2d902d8f375c17ff87daf72d2b1afb5254c1 100644 (file)
 #include "optlist.h"
 
 int
-trade_check_ok(struct trdstr *tp, union trdgenstr *tgp)
+trade_check_ok(struct trdstr *tp, union empobj_storage *tgp)
 {
     return check_trade_ok(tp) && trade_check_item_ok(tgp);
 }
 
 int
-trade_check_item_ok(union trdgenstr *tgp)
+trade_check_item_ok(union empobj_storage *tgp)
 {
     if (tgp->gen.ef_type == EF_LAND)
-       return check_land_ok(&tgp->lnd);
+       return check_land_ok(&tgp->land);
     if (tgp->gen.ef_type == EF_PLANE)
-       return check_plane_ok(&tgp->pln);
+       return check_plane_ok(&tgp->plane);
     if (tgp->gen.ef_type == EF_SHIP)
-       return check_ship_ok(&tgp->shp);
+       return check_ship_ok(&tgp->ship);
     if (tgp->gen.ef_type == EF_NUKE)
-       return check_nuke_ok(&tgp->nuk);
+       return check_nuke_ok(&tgp->nuke);
     CANT_REACH();
     pr("Trade lot went bad!\n");
     return 0;
 }
 
 char *
-trade_nameof(struct trdstr *tp, union trdgenstr *tgp)
+trade_nameof(struct trdstr *tp, union empobj_storage *tgp)
 {
     switch (tp->trd_type) {
     case EF_NUKE:
-       return nchr[(int)tgp->nuk.nuk_type].n_name;
+       return nchr[(int)tgp->nuke.nuk_type].n_name;
     case EF_PLANE:
-       return plchr[(int)tgp->pln.pln_type].pl_name;
+       return plchr[(int)tgp->plane.pln_type].pl_name;
     case EF_SHIP:
-       return mchr[(int)tgp->shp.shp_type].m_name;
+       return mchr[(int)tgp->ship.shp_type].m_name;
     case EF_LAND:
-       return lchr[(int)tgp->lnd.lnd_type].l_name;
+       return lchr[(int)tgp->land.lnd_type].l_name;
     }
     return "Bad trade type, get help";
 }
@@ -96,7 +96,7 @@ trade_nameof(struct trdstr *tp, union trdgenstr *tgp)
  * Return 1 on success, 0 on error
  */
 int
-trade_desc(struct trdstr *tp, union trdgenstr *tgp)
+trade_desc(struct trdstr *tp, union empobj_storage *tgp)
 {
     i_type it;
     struct sctstr sect;
@@ -110,14 +110,14 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp)
 
     switch (tp->trd_type) {
     case EF_NUKE:
-       np = &tgp->nuk;
+       np = &tgp->nuke;
        tp->trd_owner = np->nuk_own;
        pr("(%3d)  tech %d %d%% %s #%d",
           tp->trd_owner, np->nuk_tech, np->nuk_effic,
           nchr[(int)np->nuk_type].n_name, tp->trd_unitid);
        break;
     case EF_SHIP:
-       sp = &tgp->shp;
+       sp = &tgp->ship;
        tp->trd_owner = sp->shp_own;
        pr("(%3d)  tech %d %d%% %s [",
           tp->trd_owner, sp->shp_tech, sp->shp_effic, prship(sp));
@@ -174,7 +174,7 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp)
            pr(" at sea");
        break;
     case EF_LAND:
-       lp = &tgp->lnd;
+       lp = &tgp->land;
        tp->trd_owner = lp->lnd_own;
        pr("(%3d)  tech %d %d%% %s [",
           tp->trd_owner,
@@ -201,7 +201,7 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp)
        getsect(lp->lnd_x, lp->lnd_y, &sect);
        break;
     case EF_PLANE:
-       pp = &tgp->pln;
+       pp = &tgp->plane;
        tp->trd_owner = pp->pln_own;
        pr("(%3d)  tech %d %d%% %s #%d",
           tp->trd_owner,
@@ -220,7 +220,7 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp)
 }
 
 int
-trade_getitem(struct trdstr *tp, union trdgenstr *tgp)
+trade_getitem(struct trdstr *tp, union empobj_storage *tgp)
 {
     if (!ef_read(tp->trd_type, tp->trd_unitid, tgp))
        return 0;
index cce620dae18f67777f7e17d087d505298fb99fe6..2d9896c872f5947858a8e4bcca538274760968ca 100644 (file)
@@ -39,7 +39,6 @@
 #include "land.h"
 #include "nsc.h"
 #include "file.h"
-#include "genitem.h"
 #include "player.h"
 #include "update.h"
 #include "gen.h"
@@ -48,7 +47,7 @@
 void *
 nxtitemp(struct nstr_item *np)
 {
-    struct genitem *gp;
+    struct empobj *gp;
     int selected;
 
     if (np->sel == NS_UNDEF)