(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
|
@ -25,37 +25,63 @@
|
||||||
*
|
*
|
||||||
* ---
|
* ---
|
||||||
*
|
*
|
||||||
* genitem.h: Definition for generic items
|
* genobj.h: General empire objects.
|
||||||
*
|
*
|
||||||
* Known contributors to this file:
|
* Known contributors to this file:
|
||||||
*
|
* Ron Koenderink, 2006
|
||||||
*/
|
* Markus Armbruster, 2006
|
||||||
/*
|
|
||||||
* 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
|
#ifndef EMPOBJ_H
|
||||||
#define GENITEM_H
|
#define EMPOBJ_H
|
||||||
|
|
||||||
struct genitem {
|
#include "commodity.h"
|
||||||
short ef_type;
|
#include "land.h"
|
||||||
natid own;
|
#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;
|
short uid;
|
||||||
coord x;
|
coord x; /* is valid if EFF_XY is set in table def. */
|
||||||
coord y;
|
coord y; /* is valid if EFF_XY is set in table def. */
|
||||||
signed char type;
|
signed char type;
|
||||||
signed char effic;
|
signed char effic;
|
||||||
signed char mobil;
|
signed char mobil;
|
||||||
unsigned char off;
|
unsigned char off;
|
||||||
short tech;
|
short tech;
|
||||||
char group;
|
char group; /* is valid if EFF_GROUP is set in table def. */
|
||||||
coord opx, opy;
|
coord opx, opy;
|
||||||
short mission;
|
short mission;
|
||||||
short radius;
|
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
|
#endif
|
||||||
|
|
|
@ -72,7 +72,7 @@ struct empfile {
|
||||||
/*
|
/*
|
||||||
* EFF_XY / EFF_OWNER / EFF_GROUP assert that coordinates / owner /
|
* EFF_XY / EFF_OWNER / EFF_GROUP assert that coordinates / owner /
|
||||||
* group of such a table's entries can be safely obtained by
|
* 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_XY bit(0)
|
||||||
#define EFF_OWNER bit(1)
|
#define EFF_OWNER bit(1)
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
#define LAND_MINFIREEFF 40 /* arty must be this effic to fire */
|
#define LAND_MINFIREEFF 40 /* arty must be this effic to fire */
|
||||||
|
|
||||||
struct lndstr {
|
struct lndstr {
|
||||||
/* initial part must match struct genitem */
|
/* initial part must match struct empobj */
|
||||||
short ef_type;
|
short ef_type;
|
||||||
natid lnd_own; /* owner's country num */
|
natid lnd_own; /* owner's country num */
|
||||||
short lnd_uid; /* unit id (land unit) */
|
short lnd_uid; /* unit id (land unit) */
|
||||||
|
@ -62,7 +62,7 @@ struct lndstr {
|
||||||
coord lnd_opx, lnd_opy; /* Op sector coords */
|
coord lnd_opx, lnd_opy; /* Op sector coords */
|
||||||
short lnd_mission; /* mission code */
|
short lnd_mission; /* mission code */
|
||||||
short lnd_radius; /* mission radius */
|
short lnd_radius; /* mission radius */
|
||||||
/* end of part matching struct genitem */
|
/* end of part matching struct empobj */
|
||||||
signed char lnd_flags; /* unit flags (unused) */
|
signed char lnd_flags; /* unit flags (unused) */
|
||||||
short lnd_ship; /* pointer to transporting ship */
|
short lnd_ship; /* pointer to transporting ship */
|
||||||
signed char lnd_harden; /* fortification */
|
signed char lnd_harden; /* fortification */
|
||||||
|
|
|
@ -35,10 +35,10 @@
|
||||||
#define LOST_H
|
#define LOST_H
|
||||||
|
|
||||||
struct loststr {
|
struct loststr {
|
||||||
/* initial part must match struct genitem */
|
/* initial part must match struct empobj */
|
||||||
short ef_type;
|
short ef_type;
|
||||||
natid lost_owner; /* Who lost it */
|
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) */
|
int lost_uid; /* lost ID (assigned, otherwise unused) */
|
||||||
char lost_type; /* Type of thing (ship, plane, nuke, land, sector) */
|
char lost_type; /* Type of thing (ship, plane, nuke, land, sector) */
|
||||||
short lost_id; /* ID of lost thing */
|
short lost_id; /* ID of lost thing */
|
||||||
|
|
|
@ -64,10 +64,10 @@ typedef enum {
|
||||||
* If we had working virtual selectors, we could remove r_cnum and r_realm.
|
* If we had working virtual selectors, we could remove r_cnum and r_realm.
|
||||||
*/
|
*/
|
||||||
struct realmstr {
|
struct realmstr {
|
||||||
/* initial part must match struct genitem */
|
/* initial part must match struct empobj */
|
||||||
short ef_type;
|
short ef_type;
|
||||||
natid r_cnum; /* country number */
|
natid r_cnum; /* country number */
|
||||||
/* end of part matching struct genitem */
|
/* end of part matching struct empobj */
|
||||||
short r_uid; /* realm table index */
|
short r_uid; /* realm table index */
|
||||||
unsigned short r_realm; /* realm number */
|
unsigned short r_realm; /* realm number */
|
||||||
short r_xl, r_xh; /* horizontal bounds */
|
short r_xl, r_xh; /* horizontal bounds */
|
||||||
|
@ -76,10 +76,10 @@ struct realmstr {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct natstr {
|
struct natstr {
|
||||||
/* initial part must match struct genitem */
|
/* initial part must match struct empobj */
|
||||||
short ef_type;
|
short ef_type;
|
||||||
natid nat_cnum; /* our country number */
|
natid nat_cnum; /* our country number */
|
||||||
/* end of part matching struct genitem */
|
/* end of part matching struct empobj */
|
||||||
nat_status nat_stat;
|
nat_status nat_stat;
|
||||||
char nat_cnam[20]; /* country name */
|
char nat_cnam[20]; /* country name */
|
||||||
char nat_pnam[20]; /* representative */
|
char nat_pnam[20]; /* representative */
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#define MIN_DRNUKE_CONST 0.001
|
#define MIN_DRNUKE_CONST 0.001
|
||||||
|
|
||||||
struct nukstr {
|
struct nukstr {
|
||||||
/* initial part must match struct genitem */
|
/* initial part must match struct empobj */
|
||||||
short ef_type;
|
short ef_type;
|
||||||
natid nuk_own;
|
natid nuk_own;
|
||||||
short nuk_uid;
|
short nuk_uid;
|
||||||
|
@ -52,7 +52,7 @@ struct nukstr {
|
||||||
coord nuk_opx, nuk_opy; /* Op sector coords, unused */
|
coord nuk_opx, nuk_opy; /* Op sector coords, unused */
|
||||||
short nuk_mission; /* mission code, unused */
|
short nuk_mission; /* mission code, unused */
|
||||||
short nuk_radius; /* mission radius, 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_ship; /* currently aboard ship (unused) */
|
||||||
short nuk_plane; /* currently aboard plane */
|
short nuk_plane; /* currently aboard plane */
|
||||||
short nuk_land; /* currently aboard land (unused) */
|
short nuk_land; /* currently aboard land (unused) */
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
#define PLANE_MINEFF 10
|
#define PLANE_MINEFF 10
|
||||||
|
|
||||||
struct plnstr {
|
struct plnstr {
|
||||||
/* initial part must match struct genitem */
|
/* initial part must match struct empobj */
|
||||||
short ef_type;
|
short ef_type;
|
||||||
natid pln_own; /* owning country */
|
natid pln_own; /* owning country */
|
||||||
short pln_uid; /* plane unit id */
|
short pln_uid; /* plane unit id */
|
||||||
|
@ -59,7 +59,7 @@ struct plnstr {
|
||||||
coord pln_opy; /* Op sector coords */
|
coord pln_opy; /* Op sector coords */
|
||||||
short pln_mission; /* mission code */
|
short pln_mission; /* mission code */
|
||||||
short pln_radius; /* mission radius */
|
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; /* total distance, not radius */
|
||||||
unsigned char pln_range_max; /* max range for this plane */
|
unsigned char pln_range_max; /* max range for this plane */
|
||||||
short pln_ship; /* pointer to carrier */
|
short pln_ship; /* pointer to carrier */
|
||||||
|
|
|
@ -488,14 +488,14 @@ extern int num_shipsatxy(coord, coord, int, int);
|
||||||
extern int islist(char *);
|
extern int islist(char *);
|
||||||
/* src/lib/subs/mission.c */
|
/* src/lib/subs/mission.c */
|
||||||
extern char *mission_name(short);
|
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 collateral_damage(coord, coord, int, struct emp_qelem *);
|
||||||
extern int mission_pln_equip(struct plist *, struct ichrstr *, int, char);
|
extern int mission_pln_equip(struct plist *, struct ichrstr *, int, char);
|
||||||
extern int ground_interdict(coord, coord, natid, char *);
|
extern int ground_interdict(coord, coord, natid, char *);
|
||||||
extern int unit_interdict(coord, coord, natid, char *, int, int);
|
extern int unit_interdict(coord, coord, natid, char *, int, int);
|
||||||
extern int off_support(coord, coord, natid, natid);
|
extern int off_support(coord, coord, natid, natid);
|
||||||
extern int def_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 int cando(int, int);
|
||||||
extern void show_mission(int, struct nstr_item *);
|
extern void show_mission(int, struct nstr_item *);
|
||||||
extern int air_defense(coord, coord, natid, struct emp_qelem *,
|
extern int air_defense(coord, coord, natid, struct emp_qelem *,
|
||||||
|
|
|
@ -40,13 +40,13 @@
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
|
|
||||||
struct sctstr {
|
struct sctstr {
|
||||||
/* initial part must match struct genitem */
|
/* initial part must match struct empobj */
|
||||||
short ef_type;
|
short ef_type;
|
||||||
natid sct_own; /* owner's country num */
|
natid sct_own; /* owner's country num */
|
||||||
short sct_elev; /* elevation/depth */
|
short sct_elev; /* elevation/depth */
|
||||||
coord sct_x; /* x coord of sector */
|
coord sct_x; /* x coord of sector */
|
||||||
coord sct_y; /* y 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_type; /* sector type */
|
||||||
unsigned char sct_effic; /* 0% to 100% */
|
unsigned char sct_effic; /* 0% to 100% */
|
||||||
short sct_mobil; /* mobility units */
|
short sct_mobil; /* mobility units */
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
#define MAXSHPNAMLEN 24
|
#define MAXSHPNAMLEN 24
|
||||||
|
|
||||||
struct shpstr {
|
struct shpstr {
|
||||||
/* initial part must match struct genitem */
|
/* initial part must match struct empobj */
|
||||||
short ef_type;
|
short ef_type;
|
||||||
natid shp_own; /* owner's country num */
|
natid shp_own; /* owner's country num */
|
||||||
short shp_uid; /* unit id (ship #) */
|
short shp_uid; /* unit id (ship #) */
|
||||||
|
@ -75,7 +75,7 @@ struct shpstr {
|
||||||
coord shp_opx, shp_opy; /* Op sector coords */
|
coord shp_opx, shp_opy; /* Op sector coords */
|
||||||
short shp_mission; /* mission code */
|
short shp_mission; /* mission code */
|
||||||
short shp_radius; /* mission radius */
|
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_nplane; /* number of planes on board */
|
||||||
unsigned char shp_nland; /* number of land units on board */
|
unsigned char shp_nland; /* number of land units on board */
|
||||||
short shp_armor;
|
short shp_armor;
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
#include "ship.h"
|
#include "ship.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "xy.h"
|
#include "xy.h"
|
||||||
#include "genitem.h"
|
#include "empobj.h"
|
||||||
#include "trade.h"
|
#include "trade.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "prototypes.h" /* must come at end, after defines and typedefs */
|
#include "prototypes.h" /* must come at end, after defines and typedefs */
|
||||||
|
|
|
@ -37,12 +37,6 @@
|
||||||
#ifndef TRADE_H
|
#ifndef TRADE_H
|
||||||
#define TRADE_H
|
#define TRADE_H
|
||||||
|
|
||||||
#include "genitem.h"
|
|
||||||
#include "nuke.h"
|
|
||||||
#include "plane.h"
|
|
||||||
#include "land.h"
|
|
||||||
#include "ship.h"
|
|
||||||
|
|
||||||
struct trdstr {
|
struct trdstr {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
natid trd_owner;
|
natid trd_owner;
|
||||||
|
@ -56,19 +50,11 @@ struct trdstr {
|
||||||
coord trd_y;
|
coord trd_y;
|
||||||
};
|
};
|
||||||
|
|
||||||
union trdgenstr {
|
extern int trade_check_ok(struct trdstr *, union empobj_storage *);
|
||||||
struct genitem gen;
|
extern int trade_check_item_ok(union empobj_storage *);
|
||||||
struct nukstr nuk;
|
extern char *trade_nameof(struct trdstr *, union empobj_storage *);
|
||||||
struct plnstr pln;
|
extern int trade_desc(struct trdstr *, union empobj_storage *);
|
||||||
struct lndstr lnd;
|
extern int trade_getitem(struct trdstr *, union empobj_storage *);
|
||||||
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 *);
|
|
||||||
|
|
||||||
#define gettrade(n, p) ef_read(EF_TRADE, (n), (p))
|
#define gettrade(n, p) ef_read(EF_TRADE, (n), (p))
|
||||||
#define puttrade(n, p) ef_write(EF_TRADE, (n), (p))
|
#define puttrade(n, p) ef_write(EF_TRADE, (n), (p))
|
||||||
|
|
|
@ -37,28 +37,18 @@
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "plague.h"
|
#include "plague.h"
|
||||||
#include "xy.h"
|
#include "xy.h"
|
||||||
#include "ship.h"
|
|
||||||
#include "plane.h"
|
|
||||||
#include "land.h"
|
|
||||||
#include "nat.h"
|
|
||||||
#include "nsc.h"
|
#include "nsc.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "sect.h"
|
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
|
#include "empobj.h"
|
||||||
|
|
||||||
union item_u {
|
|
||||||
struct shpstr ship;
|
|
||||||
struct lndstr land;
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
int
|
||||||
fuel(void)
|
fuel(void)
|
||||||
{
|
{
|
||||||
static int shp_or_lnd[] = { EF_SHIP, EF_LAND, EF_BAD };
|
static int shp_or_lnd[] = { EF_SHIP, EF_LAND, EF_BAD };
|
||||||
struct nstr_item ni;
|
struct nstr_item ni;
|
||||||
union item_u item, item2;
|
union empobj_storage item, item2;
|
||||||
int type;
|
int type;
|
||||||
struct mchrstr *mp;
|
struct mchrstr *mp;
|
||||||
struct lchrstr *lcp;
|
struct lchrstr *lcp;
|
||||||
|
|
|
@ -321,7 +321,7 @@ lload(void)
|
||||||
void
|
void
|
||||||
gift(natid givee, natid giver, void *ptr, int type, char *mesg)
|
gift(natid givee, natid giver, void *ptr, int type, char *mesg)
|
||||||
{
|
{
|
||||||
struct genitem *gen = ptr;
|
struct empobj *gen = ptr;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if (giver != givee) {
|
if (giver != givee) {
|
||||||
|
|
|
@ -36,13 +36,7 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "xy.h"
|
#include "xy.h"
|
||||||
#include "treaty.h"
|
|
||||||
#include "nat.h"
|
|
||||||
#include "ship.h"
|
|
||||||
#include "land.h"
|
|
||||||
#include "sect.h"
|
|
||||||
#include "retreat.h"
|
#include "retreat.h"
|
||||||
#include "news.h"
|
|
||||||
#include "nsc.h"
|
#include "nsc.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
|
@ -50,6 +44,7 @@
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
#include "damage.h"
|
#include "damage.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
|
#include "empobj.h"
|
||||||
|
|
||||||
enum targ_type {
|
enum targ_type {
|
||||||
targ_land, targ_ship, targ_sub, targ_unit, targ_bogus
|
targ_land, targ_ship, targ_sub, targ_unit, targ_bogus
|
||||||
|
@ -64,12 +59,6 @@ struct flist {
|
||||||
int victim; /* who I was shooting at */
|
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 void add_to_fired_queue(struct emp_qelem *, struct emp_qelem *);
|
||||||
static int defend(struct emp_qelem *al,
|
static int defend(struct emp_qelem *al,
|
||||||
struct emp_qelem *dl,
|
struct emp_qelem *dl,
|
||||||
|
@ -120,7 +109,7 @@ multifire(void)
|
||||||
char *p;
|
char *p;
|
||||||
int nfiring = 0;
|
int nfiring = 0;
|
||||||
int ndefending = 0;
|
int ndefending = 0;
|
||||||
union item_u item;
|
union empobj_storage item;
|
||||||
struct emp_qelem fired, defended;
|
struct emp_qelem fired, defended;
|
||||||
double odds;
|
double odds;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
|
@ -37,24 +37,13 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "xy.h"
|
#include "xy.h"
|
||||||
#include "sect.h"
|
|
||||||
#include "ship.h"
|
|
||||||
#include "land.h"
|
|
||||||
#include "plane.h"
|
|
||||||
#include "nat.h"
|
|
||||||
#include "nsc.h"
|
#include "nsc.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "mission.h"
|
#include "mission.h"
|
||||||
#include "genitem.h"
|
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
|
#include "empobj.h"
|
||||||
union item_u {
|
|
||||||
struct shpstr ship;
|
|
||||||
struct plnstr plane;
|
|
||||||
struct lndstr land;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* mission <type> <planes/ships/units> <mission type> <op sector> [<radius>]
|
* mission <type> <planes/ships/units> <mission type> <op sector> [<radius>]
|
||||||
|
@ -69,8 +58,8 @@ mission(void)
|
||||||
coord x, y;
|
coord x, y;
|
||||||
int desired_radius, radius;
|
int desired_radius, radius;
|
||||||
struct sctstr opsect;
|
struct sctstr opsect;
|
||||||
union item_u item;
|
union empobj_storage item;
|
||||||
struct genitem *gp;
|
struct empobj *gp;
|
||||||
int num = 0, mobmax, mobused, dist;
|
int num = 0, mobmax, mobused, dist;
|
||||||
struct nstr_item ni;
|
struct nstr_item ni;
|
||||||
char prompt[128];
|
char prompt[128];
|
||||||
|
@ -212,7 +201,7 @@ mission(void)
|
||||||
mobused = ldround(mission_mob_cost * (double)mobmax, 1);
|
mobused = ldround(mission_mob_cost * (double)mobmax, 1);
|
||||||
|
|
||||||
while (nxtitem(&ni, &item)) {
|
while (nxtitem(&ni, &item)) {
|
||||||
gp = (struct genitem *)&item;
|
gp = (struct empobj *)&item;
|
||||||
|
|
||||||
if (!player->owner || gp->own == 0)
|
if (!player->owner || gp->own == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -36,27 +36,17 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "xy.h"
|
#include "xy.h"
|
||||||
#include "sect.h"
|
|
||||||
#include "ship.h"
|
|
||||||
#include "plane.h"
|
|
||||||
#include "land.h"
|
|
||||||
#include "nat.h"
|
|
||||||
#include "nsc.h"
|
#include "nsc.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
|
#include "empobj.h"
|
||||||
union item_u {
|
|
||||||
struct shpstr ship;
|
|
||||||
struct plnstr plane;
|
|
||||||
struct lndstr land;
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
int
|
||||||
scra(void)
|
scra(void)
|
||||||
{
|
{
|
||||||
struct nstr_item ni;
|
struct nstr_item ni;
|
||||||
union item_u item;
|
union empobj_storage item;
|
||||||
int type;
|
int type;
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
struct mchrstr *mp;
|
struct mchrstr *mp;
|
||||||
|
|
|
@ -35,31 +35,20 @@
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "sect.h"
|
|
||||||
#include "news.h"
|
|
||||||
#include "xy.h"
|
#include "xy.h"
|
||||||
#include "ship.h"
|
|
||||||
#include "land.h"
|
|
||||||
#include "plane.h"
|
|
||||||
#include "nat.h"
|
|
||||||
#include "nsc.h"
|
#include "nsc.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
|
#include "empobj.h"
|
||||||
|
|
||||||
static void scuttle_land(struct lndstr *);
|
static void scuttle_land(struct lndstr *);
|
||||||
|
|
||||||
union item_u {
|
|
||||||
struct shpstr ship;
|
|
||||||
struct plnstr plane;
|
|
||||||
struct lndstr land;
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
int
|
||||||
scut(void)
|
scut(void)
|
||||||
{
|
{
|
||||||
struct nstr_item ni;
|
struct nstr_item ni;
|
||||||
union item_u item;
|
union empobj_storage item;
|
||||||
int type;
|
int type;
|
||||||
struct mchrstr *mp;
|
struct mchrstr *mp;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
|
@ -63,7 +63,7 @@ set(void)
|
||||||
struct trdstr trade;
|
struct trdstr trade;
|
||||||
struct nstr_item ni;
|
struct nstr_item ni;
|
||||||
struct nstr_item ni_trade;
|
struct nstr_item ni_trade;
|
||||||
union trdgenstr item;
|
union empobj_storage item;
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
int freeslot;
|
int freeslot;
|
||||||
int foundslot;
|
int foundslot;
|
||||||
|
|
|
@ -38,20 +38,10 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "xy.h"
|
#include "xy.h"
|
||||||
#include "sect.h"
|
|
||||||
#include "nsc.h"
|
|
||||||
#include "nat.h"
|
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
|
#include "empobj.h"
|
||||||
union item_u {
|
|
||||||
struct genitem gen;
|
|
||||||
struct shpstr ship;
|
|
||||||
struct plnstr plane;
|
|
||||||
struct lndstr land;
|
|
||||||
struct nukstr nuke;
|
|
||||||
};
|
|
||||||
|
|
||||||
static int start_stop(int);
|
static int start_stop(int);
|
||||||
static int start_stop_sector(char *, int);
|
static int start_stop_sector(char *, int);
|
||||||
|
@ -59,7 +49,7 @@ static void start_stop_hdr(int);
|
||||||
static void proff(int);
|
static void proff(int);
|
||||||
static int start_stop_unit(int, char *, int);
|
static int start_stop_unit(int, char *, int);
|
||||||
static void start_stop_unit_hdr(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
|
int
|
||||||
start(void)
|
start(void)
|
||||||
|
@ -167,7 +157,7 @@ proff(int off)
|
||||||
static int
|
static int
|
||||||
start_stop_unit(int type, char *arg, int off)
|
start_stop_unit(int type, char *arg, int off)
|
||||||
{
|
{
|
||||||
union item_u unit;
|
union empobj_storage unit;
|
||||||
int nunit;
|
int nunit;
|
||||||
struct nstr_item nstr;
|
struct nstr_item nstr;
|
||||||
|
|
||||||
|
@ -211,7 +201,7 @@ start_stop_unit_hdr(int off)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
unit_type_name(union item_u *unit)
|
unit_type_name(union empobj_storage *unit)
|
||||||
{
|
{
|
||||||
int type = unit->gen.type;
|
int type = unit->gen.type;
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,6 @@
|
||||||
#include "nat.h"
|
#include "nat.h"
|
||||||
#include "land.h"
|
#include "land.h"
|
||||||
#include "plane.h"
|
#include "plane.h"
|
||||||
#include "genitem.h"
|
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
|
|
||||||
static void expose_ship(struct shpstr *s1, struct shpstr *s2);
|
static void expose_ship(struct shpstr *s1, struct shpstr *s2);
|
||||||
|
|
|
@ -71,7 +71,7 @@ trad(void)
|
||||||
struct nstr_item ni;
|
struct nstr_item ni;
|
||||||
struct trdstr trade;
|
struct trdstr trade;
|
||||||
struct trdstr tmpt;
|
struct trdstr tmpt;
|
||||||
union trdgenstr tg;
|
union empobj_storage tg;
|
||||||
int plflags;
|
int plflags;
|
||||||
double canspend;
|
double canspend;
|
||||||
time_t now;
|
time_t now;
|
||||||
|
@ -193,8 +193,8 @@ trad(void)
|
||||||
*/
|
*/
|
||||||
if (((trade.trd_type == EF_PLANE) || (trade.trd_type == EF_NUKE))
|
if (((trade.trd_type == EF_PLANE) || (trade.trd_type == EF_NUKE))
|
||||||
&& ((trade.trd_type == EF_NUKE) ||
|
&& ((trade.trd_type == EF_NUKE) ||
|
||||||
!(tg.pln.pln_flags & PLN_LAUNCHED))) {
|
!(tg.plane.pln_flags & PLN_LAUNCHED))) {
|
||||||
plflags = plchr[(int)tg.pln.pln_type].pl_flags;
|
plflags = plchr[(int)tg.plane.pln_type].pl_flags;
|
||||||
while (1) {
|
while (1) {
|
||||||
p = getstring("Destination sector: ", buf);
|
p = getstring("Destination sector: ", buf);
|
||||||
if (!trade_check_ok(&trade, &tg))
|
if (!trade_check_ok(&trade, &tg))
|
||||||
|
@ -292,7 +292,7 @@ check_trade(void)
|
||||||
struct lndstr land;
|
struct lndstr land;
|
||||||
struct natstr *natp;
|
struct natstr *natp;
|
||||||
struct trdstr trade;
|
struct trdstr trade;
|
||||||
union trdgenstr tg;
|
union empobj_storage tg;
|
||||||
time_t now;
|
time_t now;
|
||||||
double subleft;
|
double subleft;
|
||||||
double monleft;
|
double monleft;
|
||||||
|
@ -380,68 +380,68 @@ check_trade(void)
|
||||||
putnat(natp);
|
putnat(natp);
|
||||||
switch (trade.trd_type) {
|
switch (trade.trd_type) {
|
||||||
case EF_NUKE:
|
case EF_NUKE:
|
||||||
tg.nuk.nuk_x = trade.trd_x;
|
tg.nuke.nuk_x = trade.trd_x;
|
||||||
tg.nuk.nuk_y = trade.trd_y;
|
tg.nuke.nuk_y = trade.trd_y;
|
||||||
makelost(EF_NUKE, tg.nuk.nuk_own, tg.nuk.nuk_uid,
|
makelost(EF_NUKE, tg.nuke.nuk_own, tg.nuke.nuk_uid,
|
||||||
tg.nuk.nuk_x, tg.nuk.nuk_y);
|
tg.nuke.nuk_x, tg.nuke.nuk_y);
|
||||||
tg.nuk.nuk_own = trade.trd_maxbidder;
|
tg.nuke.nuk_own = trade.trd_maxbidder;
|
||||||
makenotlost(EF_NUKE, tg.nuk.nuk_own, tg.nuk.nuk_uid,
|
makenotlost(EF_NUKE, tg.nuke.nuk_own, tg.nuke.nuk_uid,
|
||||||
tg.nuk.nuk_x, tg.nuk.nuk_y);
|
tg.nuke.nuk_x, tg.nuke.nuk_y);
|
||||||
break;
|
break;
|
||||||
case EF_PLANE:
|
case EF_PLANE:
|
||||||
if ((tg.pln.pln_flags & PLN_LAUNCHED) == 0) {
|
if ((tg.plane.pln_flags & PLN_LAUNCHED) == 0) {
|
||||||
tg.pln.pln_x = trade.trd_x;
|
tg.plane.pln_x = trade.trd_x;
|
||||||
tg.pln.pln_y = trade.trd_y;
|
tg.plane.pln_y = trade.trd_y;
|
||||||
}
|
}
|
||||||
makelost(EF_PLANE, tg.pln.pln_own, tg.pln.pln_uid,
|
makelost(EF_PLANE, tg.plane.pln_own, tg.plane.pln_uid,
|
||||||
tg.pln.pln_x, tg.pln.pln_y);
|
tg.plane.pln_x, tg.plane.pln_y);
|
||||||
tg.pln.pln_own = trade.trd_maxbidder;
|
tg.plane.pln_own = trade.trd_maxbidder;
|
||||||
makenotlost(EF_PLANE, tg.pln.pln_own, tg.pln.pln_uid,
|
makenotlost(EF_PLANE, tg.plane.pln_own, tg.plane.pln_uid,
|
||||||
tg.pln.pln_x, tg.pln.pln_y);
|
tg.plane.pln_x, tg.plane.pln_y);
|
||||||
tg.pln.pln_wing = 0;
|
tg.plane.pln_wing = 0;
|
||||||
/* no cheap version of fly */
|
/* no cheap version of fly */
|
||||||
if (opt_MOB_ACCESS) {
|
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 {
|
} else {
|
||||||
tg.pln.pln_mobil = 0;
|
tg.plane.pln_mobil = 0;
|
||||||
}
|
}
|
||||||
tg.pln.pln_mission = 0;
|
tg.plane.pln_mission = 0;
|
||||||
tg.pln.pln_harden = 0;
|
tg.plane.pln_harden = 0;
|
||||||
time(&tg.pln.pln_access);
|
time(&tg.plane.pln_access);
|
||||||
tg.pln.pln_ship = -1;
|
tg.plane.pln_ship = -1;
|
||||||
tg.pln.pln_land = -1;
|
tg.plane.pln_land = -1;
|
||||||
break;
|
break;
|
||||||
case EF_SHIP:
|
case EF_SHIP:
|
||||||
takeover_ship(&tg.shp, trade.trd_maxbidder, 0);
|
takeover_ship(&tg.ship, trade.trd_maxbidder, 0);
|
||||||
break;
|
break;
|
||||||
case EF_LAND:
|
case EF_LAND:
|
||||||
tg.lnd.lnd_x = trade.trd_x;
|
tg.land.lnd_x = trade.trd_x;
|
||||||
tg.lnd.lnd_y = trade.trd_y;
|
tg.land.lnd_y = trade.trd_y;
|
||||||
if (tg.lnd.lnd_ship >= 0) {
|
if (tg.land.lnd_ship >= 0) {
|
||||||
struct shpstr ship;
|
struct shpstr ship;
|
||||||
getship(tg.lnd.lnd_ship, &ship);
|
getship(tg.land.lnd_ship, &ship);
|
||||||
ship.shp_nland--;
|
ship.shp_nland--;
|
||||||
putship(ship.shp_uid, &ship);
|
putship(ship.shp_uid, &ship);
|
||||||
}
|
}
|
||||||
makelost(EF_LAND, tg.lnd.lnd_own, tg.lnd.lnd_uid,
|
makelost(EF_LAND, tg.land.lnd_own, tg.land.lnd_uid,
|
||||||
tg.lnd.lnd_x, tg.lnd.lnd_y);
|
tg.land.lnd_x, tg.land.lnd_y);
|
||||||
tg.lnd.lnd_own = trade.trd_maxbidder;
|
tg.land.lnd_own = trade.trd_maxbidder;
|
||||||
makenotlost(EF_LAND, tg.lnd.lnd_own, tg.lnd.lnd_uid,
|
makenotlost(EF_LAND, tg.land.lnd_own, tg.land.lnd_uid,
|
||||||
tg.lnd.lnd_x, tg.lnd.lnd_y);
|
tg.land.lnd_x, tg.land.lnd_y);
|
||||||
tg.lnd.lnd_army = 0;
|
tg.land.lnd_army = 0;
|
||||||
/* no cheap version of fly */
|
/* no cheap version of fly */
|
||||||
if (opt_MOB_ACCESS) {
|
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 {
|
} else {
|
||||||
tg.lnd.lnd_mobil = 0;
|
tg.land.lnd_mobil = 0;
|
||||||
}
|
}
|
||||||
tg.lnd.lnd_harden = 0;
|
tg.land.lnd_harden = 0;
|
||||||
time(&tg.lnd.lnd_access);
|
time(&tg.land.lnd_access);
|
||||||
tg.lnd.lnd_mission = 0;
|
tg.land.lnd_mission = 0;
|
||||||
/* Drop any land units this unit was carrying */
|
/* 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)) {
|
while (nxtitem(&ni, &land)) {
|
||||||
if (land.lnd_land != tg.lnd.lnd_uid)
|
if (land.lnd_land != tg.land.lnd_uid)
|
||||||
continue;
|
continue;
|
||||||
land.lnd_land = -1;
|
land.lnd_land = -1;
|
||||||
wu(0, land.lnd_own, "unit #%d dropped in %s\n",
|
wu(0, land.lnd_own, "unit #%d dropped in %s\n",
|
||||||
|
@ -450,7 +450,7 @@ check_trade(void)
|
||||||
putland(land.lnd_uid, &land);
|
putland(land.lnd_uid, &land);
|
||||||
}
|
}
|
||||||
/* Drop any planes this unit was carrying */
|
/* 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)) {
|
while (nxtitem(&ni, &plane)) {
|
||||||
if (plane.pln_flags & PLN_LAUNCHED)
|
if (plane.pln_flags & PLN_LAUNCHED)
|
||||||
continue;
|
continue;
|
||||||
|
@ -462,8 +462,8 @@ check_trade(void)
|
||||||
xyas(plane.pln_x, plane.pln_y, plane.pln_own));
|
xyas(plane.pln_x, plane.pln_y, plane.pln_own));
|
||||||
putplane(plane.pln_uid, &plane);
|
putplane(plane.pln_uid, &plane);
|
||||||
}
|
}
|
||||||
tg.lnd.lnd_ship = -1;
|
tg.land.lnd_ship = -1;
|
||||||
tg.lnd.lnd_land = -1;
|
tg.land.lnd_land = -1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logerror("Bad trade type %d in trade\n", trade.trd_type);
|
logerror("Bad trade type %d in trade\n", trade.trd_type);
|
||||||
|
@ -490,7 +490,7 @@ int
|
||||||
ontradingblock(int type, void *ptr)
|
ontradingblock(int type, void *ptr)
|
||||||
{
|
{
|
||||||
struct trdstr trade;
|
struct trdstr trade;
|
||||||
union trdgenstr tg;
|
union empobj_storage tg;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
for (n = 0; gettrade(n, &trade); n++) {
|
for (n = 0; gettrade(n, &trade); n++) {
|
||||||
|
@ -500,7 +500,7 @@ ontradingblock(int type, void *ptr)
|
||||||
continue;
|
continue;
|
||||||
if (trade.trd_type != type)
|
if (trade.trd_type != type)
|
||||||
continue;
|
continue;
|
||||||
if (tg.gen.uid == ((struct genitem *)ptr)->uid)
|
if (tg.gen.uid == ((struct empobj *)ptr)->uid)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -510,7 +510,7 @@ void
|
||||||
trdswitchown(int type, void *ptr, int newown)
|
trdswitchown(int type, void *ptr, int newown)
|
||||||
{
|
{
|
||||||
struct trdstr trade;
|
struct trdstr trade;
|
||||||
union trdgenstr tg;
|
union empobj_storage tg;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
for (n = 0; gettrade(n, &trade); n++) {
|
for (n = 0; gettrade(n, &trade); n++) {
|
||||||
|
@ -520,7 +520,7 @@ trdswitchown(int type, void *ptr, int newown)
|
||||||
continue;
|
continue;
|
||||||
if (trade.trd_type != type)
|
if (trade.trd_type != type)
|
||||||
continue;
|
continue;
|
||||||
if (tg.gen.uid != ((struct genitem *)ptr)->uid)
|
if (tg.gen.uid != ((struct empobj *)ptr)->uid)
|
||||||
continue;
|
continue;
|
||||||
if (trade.trd_owner == trade.trd_maxbidder)
|
if (trade.trd_owner == trade.trd_maxbidder)
|
||||||
trade.trd_maxbidder = newown;
|
trade.trd_maxbidder = newown;
|
||||||
|
|
|
@ -197,7 +197,7 @@ xdftr(int n)
|
||||||
static int
|
static int
|
||||||
xdvisible(int type, void *p)
|
xdvisible(int type, void *p)
|
||||||
{
|
{
|
||||||
struct genitem *gp = p;
|
struct empobj *gp = p;
|
||||||
struct trtstr *tp = p;
|
struct trtstr *tp = p;
|
||||||
struct lonstr *lp = p;
|
struct lonstr *lp = p;
|
||||||
struct natstr *natp;
|
struct natstr *natp;
|
||||||
|
|
|
@ -322,28 +322,28 @@ unit_map(int unit_type, int uid, struct nstr_sect *nsp, char *originp)
|
||||||
struct lndstr origl;
|
struct lndstr origl;
|
||||||
struct plnstr origp;
|
struct plnstr origp;
|
||||||
struct nukstr orign;
|
struct nukstr orign;
|
||||||
struct genitem *gp;
|
struct empobj *gp;
|
||||||
struct range range;
|
struct range range;
|
||||||
|
|
||||||
if (unit_type == EF_LAND) {
|
if (unit_type == EF_LAND) {
|
||||||
if (!getland(uid, &origl) || !player->owner || origl.lnd_own == 0)
|
if (!getland(uid, &origl) || !player->owner || origl.lnd_own == 0)
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
gp = (struct genitem *)&origl;
|
gp = (struct empobj *)&origl;
|
||||||
*originp = *lchr[(int)origl.lnd_type].l_name;
|
*originp = *lchr[(int)origl.lnd_type].l_name;
|
||||||
} else if (unit_type == EF_PLANE) {
|
} else if (unit_type == EF_PLANE) {
|
||||||
if (!getplane(uid, &origp) || !player->owner || origp.pln_own == 0)
|
if (!getplane(uid, &origp) || !player->owner || origp.pln_own == 0)
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
gp = (struct genitem *)&origp;
|
gp = (struct empobj *)&origp;
|
||||||
*originp = *plchr[(int)origp.pln_type].pl_name;
|
*originp = *plchr[(int)origp.pln_type].pl_name;
|
||||||
} else if (unit_type == EF_NUKE) {
|
} else if (unit_type == EF_NUKE) {
|
||||||
if (!getnuke(uid, &orign) || !player->owner || orign.nuk_own == 0)
|
if (!getnuke(uid, &orign) || !player->owner || orign.nuk_own == 0)
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
gp = (struct genitem *)&orign;
|
gp = (struct empobj *)&orign;
|
||||||
*originp = 'n';
|
*originp = 'n';
|
||||||
} else {
|
} else {
|
||||||
if (!getship(uid, &origs) || !player->owner || origs.shp_own == 0)
|
if (!getship(uid, &origs) || !player->owner || origs.shp_own == 0)
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
gp = (struct genitem *)&origs;
|
gp = (struct empobj *)&origs;
|
||||||
*originp = *mchr[(int)origs.shp_type].m_name;
|
*originp = *mchr[(int)origs.shp_type].m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,21 +41,8 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "xy.h"
|
#include "xy.h"
|
||||||
#include "loan.h"
|
|
||||||
#include "nsc.h"
|
#include "nsc.h"
|
||||||
#include "news.h"
|
#include "empobj.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 "product.h"
|
#include "product.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
|
||||||
|
@ -191,20 +178,20 @@ struct castr dchr_ca[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NSC_GENITEM(ef_type, ef_chr) \
|
#define NSC_GENITEM(ef_type, ef_chr) \
|
||||||
{ NSC_SHORT, 0, 0, fldoff(genitem, uid), "uid", ef_type}, \
|
{ NSC_SHORT, 0, 0, fldoff(empobj, uid), "uid", ef_type}, \
|
||||||
{ NSC_NATID, 0, 0, fldoff(genitem, own), "owner", EF_NATION}, \
|
{ NSC_NATID, 0, 0, fldoff(empobj, own), "owner", EF_NATION}, \
|
||||||
{ NSC_XCOORD, 0, 0, fldoff(genitem, x), "xloc", EF_BAD}, \
|
{ NSC_XCOORD, 0, 0, fldoff(empobj, x), "xloc", EF_BAD}, \
|
||||||
{ NSC_YCOORD, 0, 0, fldoff(genitem, y), "yloc", EF_BAD}, \
|
{ NSC_YCOORD, 0, 0, fldoff(empobj, y), "yloc", EF_BAD}, \
|
||||||
{ NSC_CHAR, 0, 0, fldoff(genitem, type), "type", ef_chr}, \
|
{ NSC_CHAR, 0, 0, fldoff(empobj, type), "type", ef_chr}, \
|
||||||
{ NSC_CHAR, 0, 0, fldoff(genitem, effic), "effic", EF_BAD}, \
|
{ NSC_CHAR, 0, 0, fldoff(empobj, effic), "effic", EF_BAD}, \
|
||||||
{ NSC_CHAR , 0, 0, fldoff(genitem, mobil), "mobil", EF_BAD}, \
|
{ NSC_CHAR , 0, 0, fldoff(empobj, mobil), "mobil", EF_BAD}, \
|
||||||
{ NSC_UCHAR , 0, 0, fldoff(genitem, off), "off", EF_BAD}, \
|
{ NSC_UCHAR , 0, 0, fldoff(empobj, off), "off", EF_BAD}, \
|
||||||
{ NSC_SHORT, 0, 0, fldoff(genitem, tech), "tech", EF_BAD}, \
|
{ NSC_SHORT, 0, 0, fldoff(empobj, tech), "tech", EF_BAD}, \
|
||||||
{ NSC_STRINGY, NSC_EXTRA, 1, fldoff(genitem, group), "group", EF_BAD}, \
|
{ NSC_STRINGY, NSC_EXTRA, 1, fldoff(empobj, group), "group", EF_BAD}, \
|
||||||
{ NSC_XCOORD, 0, 0, fldoff(genitem, opx), "opx", EF_BAD}, \
|
{ NSC_XCOORD, 0, 0, fldoff(empobj, opx), "opx", EF_BAD}, \
|
||||||
{ NSC_YCOORD, 0, 0, fldoff(genitem, opy), "opy", EF_BAD}, \
|
{ NSC_YCOORD, 0, 0, fldoff(empobj, opy), "opy", EF_BAD}, \
|
||||||
{ NSC_SHORT, 0, 0, fldoff(genitem, mission), "mission", EF_MISSIONS}, \
|
{ NSC_SHORT, 0, 0, fldoff(empobj, mission), "mission", EF_MISSIONS}, \
|
||||||
{ NSC_SHORT, 0, 0, fldoff(genitem, radius), "radius", EF_BAD}
|
{ NSC_SHORT, 0, 0, fldoff(empobj, radius), "radius", EF_BAD}
|
||||||
|
|
||||||
struct castr ship_ca[] = {
|
struct castr ship_ca[] = {
|
||||||
NSC_GENITEM(EF_SHIP, EF_SHIP_CHR),
|
NSC_GENITEM(EF_SHIP, EF_SHIP_CHR),
|
||||||
|
|
|
@ -37,23 +37,17 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "xy.h"
|
#include "xy.h"
|
||||||
#include "sect.h"
|
|
||||||
#include "ship.h"
|
|
||||||
#include "land.h"
|
|
||||||
#include "plane.h"
|
|
||||||
#include "nat.h"
|
|
||||||
#include "nsc.h"
|
#include "nsc.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "mission.h"
|
#include "mission.h"
|
||||||
#include "genitem.h"
|
|
||||||
#include "news.h"
|
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "damage.h"
|
#include "damage.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
|
#include "empobj.h"
|
||||||
|
|
||||||
struct genlist {
|
struct genlist {
|
||||||
struct emp_qelem queue; /* list of units */
|
struct emp_qelem queue; /* list of units */
|
||||||
|
@ -68,12 +62,6 @@ struct airport {
|
||||||
natid own;
|
natid own;
|
||||||
};
|
};
|
||||||
|
|
||||||
union item_u {
|
|
||||||
struct shpstr ship;
|
|
||||||
struct plnstr plane;
|
|
||||||
struct lndstr land;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void add_airport(struct emp_qelem *, coord, coord);
|
static void add_airport(struct emp_qelem *, coord, coord);
|
||||||
static int air_damage(struct emp_qelem *, coord, coord, int, natid,
|
static int air_damage(struct emp_qelem *, coord, coord, int, natid,
|
||||||
char *, int);
|
char *, int);
|
||||||
|
@ -301,8 +289,8 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
|
||||||
{
|
{
|
||||||
struct nstr_item ni;
|
struct nstr_item ni;
|
||||||
struct genlist *glp;
|
struct genlist *glp;
|
||||||
struct genitem *gp;
|
struct empobj *gp;
|
||||||
union item_u item;
|
union empobj_storage item;
|
||||||
int dist;
|
int dist;
|
||||||
int radius;
|
int radius;
|
||||||
int relat;
|
int relat;
|
||||||
|
@ -310,7 +298,7 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
|
||||||
|
|
||||||
snxtitem_all(&ni, type);
|
snxtitem_all(&ni, type);
|
||||||
while (nxtitem(&ni, &item)) {
|
while (nxtitem(&ni, &item)) {
|
||||||
gp = (struct genitem *)&item;
|
gp = (struct empobj *)&item;
|
||||||
|
|
||||||
if (gp->own == 0)
|
if (gp->own == 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -427,7 +415,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
||||||
struct emp_qelem *newqp;
|
struct emp_qelem *newqp;
|
||||||
struct genlist *glp;
|
struct genlist *glp;
|
||||||
struct plist *plp;
|
struct plist *plp;
|
||||||
struct genitem *gp;
|
struct empobj *gp;
|
||||||
struct lndstr *lp;
|
struct lndstr *lp;
|
||||||
struct shpstr *sp;
|
struct shpstr *sp;
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
|
@ -817,7 +805,7 @@ cando(int mission, int type)
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
nameofitem(struct genitem *gp, int type)
|
nameofitem(struct empobj *gp, int type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EF_SHIP:
|
case EF_SHIP:
|
||||||
|
@ -858,11 +846,11 @@ void
|
||||||
show_mission(int type, struct nstr_item *np)
|
show_mission(int type, struct nstr_item *np)
|
||||||
{
|
{
|
||||||
int first = 1, radius;
|
int first = 1, radius;
|
||||||
union item_u item;
|
union empobj_storage item;
|
||||||
struct genitem *gp;
|
struct empobj *gp;
|
||||||
|
|
||||||
while (nxtitem(np, &item)) {
|
while (nxtitem(np, &item)) {
|
||||||
gp = (struct genitem *)&item;
|
gp = (struct empobj *)&item;
|
||||||
if (!player->owner || gp->own == 0)
|
if (!player->owner || gp->own == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -909,7 +897,7 @@ show_mission(int type, struct nstr_item *np)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
oprange(struct genitem *gp, int type, int *radius)
|
oprange(struct empobj *gp, int type, int *radius)
|
||||||
{
|
{
|
||||||
int range;
|
int range;
|
||||||
struct shpstr ship;
|
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 emp_qelem *qp, interceptors, airp, i, empty, *next;
|
||||||
struct plist *plp;
|
struct plist *plp;
|
||||||
struct genlist *glp;
|
struct genlist *glp;
|
||||||
struct genitem *gp;
|
struct empobj *gp;
|
||||||
struct genlist mi[MAXNOC];
|
struct genlist mi[MAXNOC];
|
||||||
char buf[512];
|
char buf[512];
|
||||||
char *path;
|
char *path;
|
||||||
|
|
|
@ -40,18 +40,17 @@
|
||||||
#include "land.h"
|
#include "land.h"
|
||||||
#include "nsc.h"
|
#include "nsc.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "genitem.h"
|
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
nxtitem(struct nstr_item *np, void *ptr)
|
nxtitem(struct nstr_item *np, void *ptr)
|
||||||
{
|
{
|
||||||
struct genitem *gp;
|
struct empobj *gp;
|
||||||
int selected;
|
int selected;
|
||||||
|
|
||||||
if (np->sel == NS_UNDEF)
|
if (np->sel == NS_UNDEF)
|
||||||
return 0;
|
return 0;
|
||||||
gp = (struct genitem *)ptr;
|
gp = (struct empobj *)ptr;
|
||||||
do {
|
do {
|
||||||
if (np->sel == NS_LIST) {
|
if (np->sel == NS_LIST) {
|
||||||
np->index++;
|
np->index++;
|
||||||
|
|
|
@ -53,39 +53,39 @@
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
|
|
||||||
int
|
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);
|
return check_trade_ok(tp) && trade_check_item_ok(tgp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
trade_check_item_ok(union trdgenstr *tgp)
|
trade_check_item_ok(union empobj_storage *tgp)
|
||||||
{
|
{
|
||||||
if (tgp->gen.ef_type == EF_LAND)
|
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)
|
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)
|
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)
|
if (tgp->gen.ef_type == EF_NUKE)
|
||||||
return check_nuke_ok(&tgp->nuk);
|
return check_nuke_ok(&tgp->nuke);
|
||||||
CANT_REACH();
|
CANT_REACH();
|
||||||
pr("Trade lot went bad!\n");
|
pr("Trade lot went bad!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
trade_nameof(struct trdstr *tp, union trdgenstr *tgp)
|
trade_nameof(struct trdstr *tp, union empobj_storage *tgp)
|
||||||
{
|
{
|
||||||
switch (tp->trd_type) {
|
switch (tp->trd_type) {
|
||||||
case EF_NUKE:
|
case EF_NUKE:
|
||||||
return nchr[(int)tgp->nuk.nuk_type].n_name;
|
return nchr[(int)tgp->nuke.nuk_type].n_name;
|
||||||
case EF_PLANE:
|
case EF_PLANE:
|
||||||
return plchr[(int)tgp->pln.pln_type].pl_name;
|
return plchr[(int)tgp->plane.pln_type].pl_name;
|
||||||
case EF_SHIP:
|
case EF_SHIP:
|
||||||
return mchr[(int)tgp->shp.shp_type].m_name;
|
return mchr[(int)tgp->ship.shp_type].m_name;
|
||||||
case EF_LAND:
|
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 "Bad trade type, get help";
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ trade_nameof(struct trdstr *tp, union trdgenstr *tgp)
|
||||||
* Return 1 on success, 0 on error
|
* Return 1 on success, 0 on error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
trade_desc(struct trdstr *tp, union trdgenstr *tgp)
|
trade_desc(struct trdstr *tp, union empobj_storage *tgp)
|
||||||
{
|
{
|
||||||
i_type it;
|
i_type it;
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
|
@ -110,14 +110,14 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp)
|
||||||
|
|
||||||
switch (tp->trd_type) {
|
switch (tp->trd_type) {
|
||||||
case EF_NUKE:
|
case EF_NUKE:
|
||||||
np = &tgp->nuk;
|
np = &tgp->nuke;
|
||||||
tp->trd_owner = np->nuk_own;
|
tp->trd_owner = np->nuk_own;
|
||||||
pr("(%3d) tech %d %d%% %s #%d",
|
pr("(%3d) tech %d %d%% %s #%d",
|
||||||
tp->trd_owner, np->nuk_tech, np->nuk_effic,
|
tp->trd_owner, np->nuk_tech, np->nuk_effic,
|
||||||
nchr[(int)np->nuk_type].n_name, tp->trd_unitid);
|
nchr[(int)np->nuk_type].n_name, tp->trd_unitid);
|
||||||
break;
|
break;
|
||||||
case EF_SHIP:
|
case EF_SHIP:
|
||||||
sp = &tgp->shp;
|
sp = &tgp->ship;
|
||||||
tp->trd_owner = sp->shp_own;
|
tp->trd_owner = sp->shp_own;
|
||||||
pr("(%3d) tech %d %d%% %s [",
|
pr("(%3d) tech %d %d%% %s [",
|
||||||
tp->trd_owner, sp->shp_tech, sp->shp_effic, prship(sp));
|
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");
|
pr(" at sea");
|
||||||
break;
|
break;
|
||||||
case EF_LAND:
|
case EF_LAND:
|
||||||
lp = &tgp->lnd;
|
lp = &tgp->land;
|
||||||
tp->trd_owner = lp->lnd_own;
|
tp->trd_owner = lp->lnd_own;
|
||||||
pr("(%3d) tech %d %d%% %s [",
|
pr("(%3d) tech %d %d%% %s [",
|
||||||
tp->trd_owner,
|
tp->trd_owner,
|
||||||
|
@ -201,7 +201,7 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp)
|
||||||
getsect(lp->lnd_x, lp->lnd_y, §);
|
getsect(lp->lnd_x, lp->lnd_y, §);
|
||||||
break;
|
break;
|
||||||
case EF_PLANE:
|
case EF_PLANE:
|
||||||
pp = &tgp->pln;
|
pp = &tgp->plane;
|
||||||
tp->trd_owner = pp->pln_own;
|
tp->trd_owner = pp->pln_own;
|
||||||
pr("(%3d) tech %d %d%% %s #%d",
|
pr("(%3d) tech %d %d%% %s #%d",
|
||||||
tp->trd_owner,
|
tp->trd_owner,
|
||||||
|
@ -220,7 +220,7 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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))
|
if (!ef_read(tp->trd_type, tp->trd_unitid, tgp))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include "land.h"
|
#include "land.h"
|
||||||
#include "nsc.h"
|
#include "nsc.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "genitem.h"
|
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "gen.h"
|
#include "gen.h"
|
||||||
|
@ -48,7 +47,7 @@
|
||||||
void *
|
void *
|
||||||
nxtitemp(struct nstr_item *np)
|
nxtitemp(struct nstr_item *np)
|
||||||
{
|
{
|
||||||
struct genitem *gp;
|
struct empobj *gp;
|
||||||
int selected;
|
int selected;
|
||||||
|
|
||||||
if (np->sel == NS_UNDEF)
|
if (np->sel == NS_UNDEF)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue