(nxtitemp, trade_getitem, trade_desc, trade_check_item_ok, nxtitem,
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.
This commit is contained in:
parent
9e75e5e009
commit
79ee88f7c6
29 changed files with 191 additions and 270 deletions
|
|
@ -37,28 +37,18 @@
|
|||
#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;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -36,13 +36,7 @@
|
|||
#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];
|
||||
|
|
|
|||
|
|
@ -37,24 +37,13 @@
|
|||
#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;
|
||||
|
|
|
|||
|
|
@ -36,27 +36,17 @@
|
|||
#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;
|
||||
|
|
|
|||
|
|
@ -35,31 +35,20 @@
|
|||
|
||||
#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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -38,20 +38,10 @@
|
|||
#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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue