--- /dev/null
+/*
+ * 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
+
/*
* 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)
+++ /dev/null
-/*
- * 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
#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) */
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 */
#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 */
* 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 */
};
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 */
#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;
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) */
#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 */
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 */
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 *,
#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 */
#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 #) */
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;
#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 */
#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;
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))
#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;
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) {
#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"
#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
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,
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];
#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>]
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];
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;
#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;
#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;
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;
#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);
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)
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;
}
static char *
-unit_type_name(union item_u *unit)
+unit_type_name(union empobj_storage *unit)
{
int type = unit->gen.type;
#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);
struct nstr_item ni;
struct trdstr trade;
struct trdstr tmpt;
- union trdgenstr tg;
+ union empobj_storage tg;
int plflags;
double canspend;
time_t now;
*/
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))
struct lndstr land;
struct natstr *natp;
struct trdstr trade;
- union trdgenstr tg;
+ union empobj_storage tg;
time_t now;
double subleft;
double monleft;
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",
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;
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);
ontradingblock(int type, void *ptr)
{
struct trdstr trade;
- union trdgenstr tg;
+ union empobj_storage tg;
int n;
for (n = 0; gettrade(n, &trade); n++) {
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;
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++) {
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;
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;
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;
}
#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"
};
#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),
#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 */
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);
{
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;
snxtitem_all(&ni, type);
while (nxtitem(&ni, &item)) {
- gp = (struct genitem *)&item;
+ gp = (struct empobj *)&item;
if (gp->own == 0)
continue;
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;
}
char *
-nameofitem(struct genitem *gp, int type)
+nameofitem(struct empobj *gp, int type)
{
switch (type) {
case EF_SHIP:
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;
}
int
-oprange(struct genitem *gp, int type, int *radius)
+oprange(struct empobj *gp, int type, int *radius)
{
int range;
struct shpstr ship;
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;
#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++;
#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";
}
* 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;
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));
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,
getsect(lp->lnd_x, lp->lnd_y, §);
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,
}
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;
#include "land.h"
#include "nsc.h"
#include "file.h"
-#include "genitem.h"
#include "player.h"
#include "update.h"
#include "gen.h"
void *
nxtitemp(struct nstr_item *np)
{
- struct genitem *gp;
+ struct empobj *gp;
int selected;
if (np->sel == NS_UNDEF)