extern struct lchrstr lchr[LND_TYPE_MAX + 2];
-struct llist {
- struct emp_qelem queue; /* list of units */
- coord x, y; /* x,y it came from */
- struct lchrstr *lcp; /* pointer to desc of land unit */
- struct lndstr land; /* struct land unit */
- int eff;
- double mobil;
- int supplied;
-};
-
enum {
LND_AIROPS_EFF = 50 /* min. efficiency for air ops */
};
extern double attack_val(int, struct lndstr *);
extern double defense_val(struct lndstr *);
-extern void lnd_print(struct llist *, char *);
-extern void lnd_delete(struct llist *, char *);
-extern int lnd_take_casualty(int, struct llist *, int);
+extern void lnd_print(struct ulist *, char *);
+extern void lnd_delete(struct ulist *, char *);
+extern int lnd_take_casualty(int, struct ulist *, int);
extern void lnd_submil(struct lndstr *, int);
extern void lnd_takemob(struct emp_qelem *, double);
extern int lnd_spyval(struct lndstr *);
extern struct mchrstr mchr[SHP_TYPE_MAX + 2];
-struct mlist {
- struct emp_qelem queue; /* list of ships */
- struct mchrstr *mcp; /* pointer to desc of ship */
- struct shpstr ship; /* struct ship */
- double mobil; /* how much mobility the ship has left */
-};
-
#define SHP_DEF(b, t) (t ? (b * (logx(t, 40.0) < 1.0 ? 1.0 : \
logx(t, 40.0))) : b)
#define SHP_SPD(b, t) (t ? (b * (logx(t, 35.0) < 1.0 ? 1.0 : \
--- /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.
+ *
+ * ---
+ *
+ * unit.h: Generalize unit data structures and functions.
+ *
+ * Known contributors to this file:
+ * Ron Koenderink, 2006
+ * Markus Armbruster, 2006
+ */
+
+struct ulist {
+ struct emp_qelem queue; /* list of units */
+ double mobil; /* how much mobility the unit has left */
+ struct empobj_chr *chrp; /* pointer to characteristics unit */
+ union empobj_storage unit; /* unit */
+ coord x, y; /* x,y it came from LAND only */
+ int eff; /* LAND only */
+ int supplied; /* LAND only */
+};
+
+
#include "combat.h"
#include "commands.h"
-#include "land.h"
#include "mission.h"
#include "path.h"
-#include "ship.h"
+#include "empobj.h"
+#include "unit.h"
int
assa(void)
int n;
int ourtotal;
struct emp_qelem *qp, *next;
- struct llist *llp;
+ struct ulist *llp;
int rel;
att_combat_init(off, EF_SHIP);
}
for (qp = olist.q_forw; qp != &olist; qp = next) {
next = qp->q_forw;
- llp = (struct llist *)qp;
- if (lchr[(int)llp->land.lnd_type].l_flags & L_SPY)
+ llp = (struct ulist *)qp;
+ if (lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY)
continue;
ourtotal++;
}
for (qp = olist.q_forw; qp != &olist; qp = next) {
next = qp->q_forw;
- llp = (struct llist *)qp;
+ llp = (struct ulist *)qp;
rel = getrel(getnatp(def->own), player->cnum);
if (chance(0.10) || rel == ALLIED || !def->own) {
- pr("%s made it on shore safely.\n", prland(&llp->land));
- llp->land.lnd_x = def->x;
- llp->land.lnd_y = def->y;
- llp->land.lnd_ship = -1;
- putland(llp->land.lnd_uid, &llp->land);
+ pr("%s made it on shore safely.\n", prland(&llp->unit.land));
+ llp->unit.land.lnd_x = def->x;
+ llp->unit.land.lnd_y = def->y;
+ llp->unit.land.lnd_ship = -1;
+ putland(llp->unit.land.lnd_uid, &llp->unit.land);
} else {
- pr("%s was spotted", prland(&llp->land));
+ pr("%s was spotted", prland(&llp->unit.land));
if (rel == HOSTILE || rel == AT_WAR || rel == SITZKRIEG ||
rel == MOBILIZATION) {
wu(0, def->own, "%s spy shot and killed in %s.\n",
cname(player->cnum), xyas(def->x, def->y,
def->own));
pr(" and was killed in the attempt.\n");
- llp->land.lnd_effic = 0;
- putland(llp->land.lnd_uid, &llp->land);
+ llp->unit.land.lnd_effic = 0;
+ putland(llp->unit.land.lnd_uid, &llp->unit.land);
lnd_delete(llp, "");
} else {
wu(0, def->own, "%s spy spotted in %s.\n",
cname(player->cnum), xyas(def->x, def->y,
def->own));
pr(" but made it ok.\n");
- llp->land.lnd_x = def->x;
- llp->land.lnd_y = def->y;
- llp->land.lnd_ship = -1;
- putland(llp->land.lnd_uid, &llp->land);
+ llp->unit.land.lnd_x = def->x;
+ llp->unit.land.lnd_y = def->y;
+ llp->unit.land.lnd_ship = -1;
+ putland(llp->unit.land.lnd_uid, &llp->unit.land);
}
}
}
#include <ctype.h>
#include "commands.h"
#include "file.h"
-#include "land.h"
#include "map.h"
#include "path.h"
+#include "empobj.h"
+#include "unit.h"
static int set_leader(struct emp_qelem *list, struct lndstr **leaderp);
static void switch_leader(struct emp_qelem *list, int land_uid);
static int
set_leader(struct emp_qelem *list, struct lndstr **leaderp)
{
- struct llist *llp = (struct llist *)(list->q_back);
+ struct ulist *llp = (struct ulist *)(list->q_back);
if (!*leaderp)
pr("Leader is ");
- else if ((*leaderp)->lnd_uid != llp->land.lnd_uid)
+ else if ((*leaderp)->lnd_uid != llp->unit.land.lnd_uid)
pr("Changing leader to ");
else
return 0;
- *leaderp = &llp->land;
- pr("%s\n", prland(&llp->land));
+ *leaderp = &llp->unit.land;
+ pr("%s\n", prland(&llp->unit.land));
return 1;
}
switch_leader(struct emp_qelem *list, int land_uid)
{
struct emp_qelem *qp, *save;
- struct llist *llp;
+ struct ulist *llp;
if (QEMPTY(list))
return;
emp_remque(qp);
emp_insque(qp, list);
qp = list->q_back;
- llp = (struct llist *)qp;
- if (llp->land.lnd_uid == land_uid || land_uid == -1)
+ llp = (struct ulist *)qp;
+ if (llp->unit.land.lnd_uid == land_uid || land_uid == -1)
break;
} while (list->q_back != save);
}
#include "map.h"
#include "optlist.h"
#include "path.h"
-#include "ship.h"
+#include "empobj.h"
+#include "unit.h"
static int set_flagship(struct emp_qelem *list, struct shpstr **flagshipp);
static void switch_flagship(struct emp_qelem *list, int ship_uid);
static int
set_flagship(struct emp_qelem *list, struct shpstr **flagshipp)
{
- struct mlist *mlp = (struct mlist *)(list->q_back);
+ struct ulist *mlp = (struct ulist *)(list->q_back);
if (!*flagshipp)
pr("Flagship is ");
- else if ((*flagshipp)->shp_uid != mlp->ship.shp_uid)
+ else if ((*flagshipp)->shp_uid != mlp->unit.ship.shp_uid)
pr("Changing flagship to ");
else
return 0;
- *flagshipp = &mlp->ship;
- pr("%s\n", prship(&mlp->ship));
+ *flagshipp = &mlp->unit.ship;
+ pr("%s\n", prship(&mlp->unit.ship));
return 1;
}
switch_flagship(struct emp_qelem *list, int ship_uid)
{
struct emp_qelem *qp, *save;
- struct mlist *mlp;
+ struct ulist *mlp;
if (QEMPTY(list))
return;
emp_remque(qp);
emp_insque(qp, list);
qp = list->q_back;
- mlp = (struct mlist *)qp;
- if (mlp->ship.shp_uid == ship_uid || ship_uid == -1)
+ mlp = (struct ulist *)qp;
+ if (mlp->unit.ship.shp_uid == ship_uid || ship_uid == -1)
break;
} while (list->q_back != save);
}
#include <math.h>
#include "combat.h"
#include "file.h"
-#include "item.h"
-#include "land.h"
-#include "lost.h"
#include "map.h"
#include "misc.h"
#include "mission.h"
-#include "nat.h"
-#include "news.h"
#include "nsc.h"
#include "optlist.h"
#include "path.h"
#include "plague.h"
#include "player.h"
#include "prototypes.h"
-#include "sect.h"
-#include "ship.h"
-#include "treaty.h"
#include "xy.h"
+#include "empobj.h"
+#include "unit.h"
#define CASUALTY_LUMP 1 /* How big casualty chunks should be */
static void ask_olist(int combat_mode, struct combat *off,
struct combat *def, struct emp_qelem *olist,
char *land_answer, int *a_spyp, int *a_engineerp);
-static void take_move_in_mob(int combat_mode, struct llist *llp,
+static void take_move_in_mob(int combat_mode, struct ulist *llp,
struct combat *off, struct combat *def);
static void move_in_land(int combat_mode, struct combat *off,
struct emp_qelem *olist, struct combat *def);
struct combat *off, struct combat *def);
static int get_land(int combat_mode, struct combat *def, int uid,
- struct llist *llp, int victim_land);
+ struct ulist *llp, int victim_land);
char *att_mode[] = {
/* must match combat types in combat.h */
struct nstr_item ni;
struct lndstr land;
double mobcost;
- struct llist *llp;
+ struct ulist *llp;
struct lchrstr *lcp;
double att_val;
int count = 0;
land_answer[(int)land.lnd_army] != 'Y')
continue;
}
- if (!(llp = malloc(sizeof(struct llist)))) {
+ if (!(llp = malloc(sizeof(struct ulist)))) {
logerror("Malloc failed in attack!\n");
abort_attack();
return;
}
- memset(llp, 0, sizeof(struct llist));
+ memset(llp, 0, sizeof(struct ulist));
emp_insque(&llp->queue, olist);
llp->mobil = mobcost;
if (!get_land(combat_mode, def, land.lnd_uid, llp, 0))
continue;
if (lnd_spyval(&land) > *a_spyp)
*a_spyp = lnd_spyval(&land);
- if (llp->lcp->l_flags & L_ENGINEER)
+ if (((struct lchrstr *)llp->chrp)->l_flags & L_ENGINEER)
++*a_engineerp;
if (def->type == EF_SHIP && ++count >= maxland)
break;
{
int d_spy = 0;
struct emp_qelem *qp;
- struct llist *llp;
+ struct ulist *llp;
int dtotal;
int old_dtotal;
att_reacting_units(def, dlist, a_spy, &d_spy, ototal);
for (qp = olist->q_forw; qp != olist; qp = qp->q_forw) {
- llp = (struct llist *)qp;
- intelligence_report(def->own, &llp->land, d_spy,
+ llp = (struct ulist *)qp;
+ intelligence_report(def->own, &llp->unit.land, d_spy,
"Scouts report attacking unit:");
}
int *d_spyp)
{
struct nstr_item ni;
- struct llist *llp;
+ struct ulist *llp;
struct lndstr land;
/* In here is where you need to take out spies and trains from the defending
"Scouts report defending unit:");
continue;
}
- if (!(llp = malloc(sizeof(struct llist)))) {
+ if (!(llp = malloc(sizeof(struct ulist)))) {
logerror("Malloc failed in attack!\n");
abort_attack();
return;
}
- memset(llp, 0, sizeof(struct llist));
+ memset(llp, 0, sizeof(struct ulist));
emp_insque(&llp->queue, list);
llp->supplied = has_supply(&land);
if (!get_land(A_DEFEND, def, land.lnd_uid, llp, 1))
{
double ototal = 0.0;
struct emp_qelem *qp, *next;
- struct llist *llp;
+ struct ulist *llp;
int n, w;
/*
for (qp = olist->q_forw; qp != olist; qp = next) {
next = qp->q_forw;
- llp = (struct llist *)qp;
- if (check && !get_land(combat_mode, 0, llp->land.lnd_uid, llp, 0))
+ llp = (struct ulist *)qp;
+ if (check && !get_land(combat_mode, 0, llp->unit.land.lnd_uid, llp, 0))
continue;
if (combat_mode == A_ATTACK) {
w = -1;
for (n = 0; n <= off->last; ++n) {
if (off[n].type == EF_BAD)
continue;
- if ((off[n].x == llp->land.lnd_x) &&
- (off[n].y == llp->land.lnd_y))
+ if ((off[n].x == llp->unit.land.lnd_x) &&
+ (off[n].y == llp->unit.land.lnd_y))
w = n;
}
if (w < 0) {
lnd_delete(llp, "is in a sector not owned by you");
continue;
}
- ototal += attack_val(combat_mode, &llp->land) *
+ ototal += attack_val(combat_mode, &llp->unit.land) *
att_combat_eff(off + w);
} else {
- ototal += attack_val(combat_mode, &llp->land);
+ ototal += attack_val(combat_mode, &llp->unit.land);
}
}
ototal *= osupport;
{
double dtotal = 0.0, eff = 1.0, d_unit;
struct emp_qelem *qp, *next;
- struct llist *llp;
+ struct ulist *llp;
if (check && att_get_combat(def, 1) < 0)
return 0;
for (qp = list->q_forw; qp != list; qp = next) {
next = qp->q_forw;
- llp = (struct llist *)qp;
- if (check && !get_land(A_DEFEND, def, llp->land.lnd_uid, llp, 1))
+ llp = (struct ulist *)qp;
+ if (check && !get_land(A_DEFEND, def, llp->unit.land.lnd_uid, llp, 1))
continue;
- d_unit = defense_val(&llp->land);
+ d_unit = defense_val(&llp->unit.land);
if (!llp->supplied)
d_unit /= 2.0;
dtotal += d_unit * eff;
*/
static int
-get_land(int combat_mode, struct combat *def, int uid, struct llist *llp,
+get_land(int combat_mode, struct combat *def, int uid, struct ulist *llp,
int victim_land)
{
- struct lndstr *lp = &llp->land;
+ struct lndstr *lp = &llp->unit.land;
char buf[512];
getland(uid, lp);
- if (!llp->lcp) { /* first time */
- llp->x = llp->land.lnd_x;
- llp->y = llp->land.lnd_y;
- llp->lcp = &lchr[(int)llp->land.lnd_type];
+ if (!llp->chrp) { /* first time */
+ llp->x = llp->unit.land.lnd_x;
+ llp->y = llp->unit.land.lnd_y;
+ llp->chrp = (struct empobj_chr *)&lchr[(int)llp->unit.land.lnd_type];
} else { /* not first time */
if (lp->lnd_effic < LAND_MINEFF) {
sprintf(buf, "was destroyed and is no longer a part of the %s",
}
}
}
- llp->eff = llp->land.lnd_effic;
+ llp->eff = llp->unit.land.lnd_effic;
return 1;
}
kill_land(struct emp_qelem *list)
{
struct emp_qelem *qp, *next;
- struct llist *llp;
+ struct ulist *llp;
for (qp = list->q_forw; qp != list; qp = next) {
next = qp->q_forw;
- llp = (struct llist *)qp;
- if (llp->land.lnd_ship >= 0) {
- llp->land.lnd_effic = 0;
+ llp = (struct ulist *)qp;
+ if (llp->unit.land.lnd_ship >= 0) {
+ llp->unit.land.lnd_effic = 0;
lnd_delete(llp, "cannot return to the ship, and dies!");
}
}
att_infect_units(struct emp_qelem *list, int plague)
{
struct emp_qelem *qp, *next;
- struct llist *llp;
+ struct ulist *llp;
if (!plague)
return;
for (qp = list->q_forw; qp != list; qp = next) {
next = qp->q_forw;
- llp = (struct llist *)qp;
- if (llp->land.lnd_pstage == PLG_HEALTHY)
- llp->land.lnd_pstage = PLG_EXPOSED;
+ llp = (struct ulist *)qp;
+ if (llp->unit.land.lnd_pstage == PLG_HEALTHY)
+ llp->unit.land.lnd_pstage = PLG_EXPOSED;
}
}
put_land(struct emp_qelem *list)
{
struct emp_qelem *qp, *next;
- struct llist *llp;
+ struct ulist *llp;
for (qp = list->q_forw; qp != list; qp = next) {
next = qp->q_forw;
- llp = (struct llist *)qp;
- llp->land.lnd_mission = 0;
- llp->land.lnd_harden = 0;
- llp->land.lnd_mobil -= (int)llp->mobil;
+ llp = (struct ulist *)qp;
+ llp->unit.land.lnd_mission = 0;
+ llp->unit.land.lnd_harden = 0;
+ llp->unit.land.lnd_mobil -= (int)llp->mobil;
llp->mobil = 0.0;
- putland(llp->land.lnd_uid, &llp->land);
- if (llp->land.lnd_own != player->cnum) {
+ putland(llp->unit.land.lnd_uid, &llp->unit.land);
+ if (llp->unit.land.lnd_own != player->cnum) {
emp_remque((struct emp_qelem *)llp);
free(llp);
} else
- get_land(A_ATTACK, 0, llp->land.lnd_uid, llp, 0);
+ get_land(A_ATTACK, 0, llp->unit.land.lnd_uid, llp, 0);
}
}
struct nstr_item ni;
struct lndstr land;
struct sctstr sect, dsect;
- struct llist *llp;
+ struct ulist *llp;
int dtotal;
double new_land = 0;
double mobcost;
wu(0, land.lnd_own, "%s reacts to %s.\n",
prland(&land), xyas(land.lnd_x, land.lnd_y, land.lnd_own));
- llp = malloc(sizeof(struct llist));
+ llp = malloc(sizeof(struct ulist));
- memset(llp, 0, sizeof(struct llist));
+ memset(llp, 0, sizeof(struct ulist));
llp->supplied = 1;
llp->x = origx;
llp->y = origy;
- llp->lcp = &lchr[(int)land.lnd_type];
- llp->land = land;
+ llp->chrp = (struct empobj_chr *)&lchr[(int)land.lnd_type];
+ llp->unit.land = land;
emp_insque(&llp->queue, list);
if (lnd_spyval(&land) > *d_spyp)
*d_spyp = lnd_spyval(&land);
int n;
int bodies = 0;
struct emp_qelem *qp;
- struct llist *llp;
+ struct ulist *llp;
for (n = 0; n <= off->last; ++n)
bodies += off[n].troops;
for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
- llp = (struct llist *)qp;
- bodies += llp->land.lnd_item[I_MILIT];
+ llp = (struct ulist *)qp;
+ bodies += llp->unit.land.lnd_item[I_MILIT];
}
return bodies;
}
int biggest_troops = 0, index = -1;
int n, tot_troops = 0, biggest_mil, cas;
struct emp_qelem *qp, *biggest;
- struct llist *llp;
+ struct ulist *llp;
for (n = 0; n <= off->last; ++n) {
if (off[n].type != EF_BAD) {
biggest = NULL;
biggest_mil = -1;
for (qp = olist->q_forw; qp != olist; qp = qp->q_forw) {
- llp = (struct llist *)qp;
+ llp = (struct ulist *)qp;
- if (llp->land.lnd_item[I_MILIT] > biggest_mil) {
- biggest_mil = llp->land.lnd_item[I_MILIT];
+ if (llp->unit.land.lnd_item[I_MILIT] > biggest_mil) {
+ biggest_mil = llp->unit.land.lnd_item[I_MILIT];
biggest = qp;
}
}
if (biggest == NULL)
return CASUALTY_LUMP - to_take;
- llp = (struct llist *)biggest;
+ llp = (struct ulist *)biggest;
cas = lnd_take_casualty(combat_mode, llp, to_take);
return CASUALTY_LUMP - (to_take - cas);
}
send_reacting_units_home(struct emp_qelem *list)
{
struct emp_qelem *qp, *next;
- struct llist *llp;
+ struct ulist *llp;
char buf[1024];
for (qp = list->q_forw; qp != list; qp = next) {
next = qp->q_forw;
- llp = (struct llist *)qp;
- if ((llp->land.lnd_x != llp->x) || (llp->land.lnd_y != llp->y)) {
+ llp = (struct ulist *)qp;
+ if ((llp->unit.land.lnd_x != llp->x) ||
+ (llp->unit.land.lnd_y != llp->y)) {
sprintf(buf, "returns to %s",
- xyas(llp->x, llp->y, llp->land.lnd_own));
- llp->land.lnd_x = llp->x;
- llp->land.lnd_y = llp->y;
+ xyas(llp->x, llp->y, llp->unit.land.lnd_own));
+ llp->unit.land.lnd_x = llp->x;
+ llp->unit.land.lnd_y = llp->y;
lnd_delete(llp, buf);
}
}
{
int n;
int occuppied = 0;
- struct llist *llp, *delete_me = 0;
+ struct ulist *llp, *delete_me = 0;
char buf[1024];
struct sctstr sect;
struct shpstr ship;
pr_com(2, def, def->own));
return 0;
} else {
- llp = (struct llist *)list->q_forw;
- llp->land.lnd_x = def->x;
- llp->land.lnd_y = def->y;
+ llp = (struct ulist *)list->q_forw;
+ llp->unit.land.lnd_x = def->x;
+ llp->unit.land.lnd_y = def->y;
take_move_in_mob(combat_mode, llp, off, def);
if (def->type == EF_SHIP) {
- llp->land.lnd_ship = def->shp_uid;
+ llp->unit.land.lnd_ship = def->shp_uid;
sprintf(buf, "boards %s", prcom(0, def));
delete_me = llp;
} else {
- llp->land.lnd_ship = -1;
+ llp->unit.land.lnd_ship = -1;
sprintf(buf, "moves in to occupy %s",
xyas(def->x, def->y, player->cnum));
lnd_delete(llp, buf);
{
int n;
struct emp_qelem *qp, *next;
- struct llist *llp;
+ struct ulist *llp;
char buf[512];
char prompt[512];
char land_answer[256];
memset(land_answer, 0, sizeof(land_answer));
for (qp = olist->q_forw; qp != olist; qp = next) {
next = qp->q_forw;
- llp = (struct llist *)qp;
- answerp = &land_answer[(int)llp->land.lnd_army];
+ llp = (struct ulist *)qp;
+ answerp = &land_answer[(int)llp->unit.land.lnd_army];
if (player->aborted || att_get_combat(def, 0) < 0)
*answerp = 'N';
if (*answerp == 'Y')
continue;
if (*answerp != 'N') {
- if (!get_land(A_ATTACK, def, llp->land.lnd_uid, llp, 0))
+ if (!get_land(A_ATTACK, def, llp->unit.land.lnd_uid, llp, 0))
continue;
sprintf(prompt, "Move in with %s (%c %d%%) [ynYNq?] ",
- prland(&llp->land),
- llp->land.lnd_army ? llp->land.lnd_army : '~',
- llp->land.lnd_effic);
- *answerp = att_prompt(prompt, llp->land.lnd_army);
+ prland(&llp->unit.land),
+ llp->unit.land.lnd_army ? llp->unit.land.lnd_army : '~',
+ llp->unit.land.lnd_effic);
+ *answerp = att_prompt(prompt, llp->unit.land.lnd_army);
if (player->aborted || att_get_combat(def, 0) < 0)
*answerp = 'N';
- if (!get_land(A_ATTACK, def, llp->land.lnd_uid, llp, 0))
+ if (!get_land(A_ATTACK, def, llp->unit.land.lnd_uid, llp, 0))
continue;
}
if (*answerp == 'y' || *answerp == 'Y')
continue;
sprintf(buf, "stays in %s",
- xyas(llp->land.lnd_x, llp->land.lnd_y, player->cnum));
+ xyas(llp->unit.land.lnd_x, llp->unit.land.lnd_y,
+ player->cnum));
lnd_delete(llp, buf);
}
if (QEMPTY(olist))
if (att_get_combat(def, 0) < 0) {
for (qp = olist->q_forw; qp != olist; qp = next) {
next = qp->q_forw;
- llp = (struct llist *)qp;
- if (!get_land(A_ATTACK, def, llp->land.lnd_uid, llp, 0))
+ llp = (struct ulist *)qp;
+ if (!get_land(A_ATTACK, def, llp->unit.land.lnd_uid, llp, 0))
continue;
sprintf(buf, "stays in %s",
- xyas(llp->land.lnd_x, llp->land.lnd_y, player->cnum));
+ xyas(llp->unit.land.lnd_x, llp->unit.land.lnd_y,
+ player->cnum));
lnd_delete(llp, buf);
}
return;
struct combat *def)
{
struct emp_qelem *qp, *next;
- struct llist *llp;
+ struct ulist *llp;
char buf[512];
if (QEMPTY(olist))
return;
for (qp = olist->q_forw; qp != olist; qp = next) {
next = qp->q_forw;
- llp = (struct llist *)qp;
- if (!get_land(combat_mode, def, llp->land.lnd_uid, llp, 0))
+ llp = (struct ulist *)qp;
+ if (!get_land(combat_mode, def, llp->unit.land.lnd_uid, llp, 0))
continue;
take_move_in_mob(combat_mode, llp, off, def);
- llp->land.lnd_x = def->x;
- llp->land.lnd_y = def->y;
+ llp->unit.land.lnd_x = def->x;
+ llp->unit.land.lnd_y = def->y;
if (def->type == EF_SHIP)
- llp->land.lnd_ship = def->shp_uid;
+ llp->unit.land.lnd_ship = def->shp_uid;
else
- llp->land.lnd_ship = -1;
+ llp->unit.land.lnd_ship = -1;
}
if (QEMPTY(olist))
return;
return;
for (qp = olist->q_forw; qp != olist; qp = next) {
next = qp->q_forw;
- llp = (struct llist *)qp;
+ llp = (struct ulist *)qp;
lnd_print(llp, buf);
}
if (QEMPTY(olist))
/* Charge land units for moving into a sector or onto a ship */
static void
-take_move_in_mob(int combat_mode, struct llist *llp, struct combat *off,
+take_move_in_mob(int combat_mode, struct ulist *llp, struct combat *off,
struct combat *def)
{
int mobcost;
switch (combat_mode) {
case A_ATTACK:
- mobcost = lnd_pathcost(&llp->land,
+ mobcost = lnd_pathcost(&llp->unit.land,
att_mobcost(off->own, def,
- lnd_mobtype(&llp->land)));
- new = llp->land.lnd_mobil - mobcost;
+ lnd_mobtype(&llp->unit.land)));
+ new = llp->unit.land.lnd_mobil - mobcost;
if (new < -127)
new = -127;
- llp->land.lnd_mobil = new;
+ llp->unit.land.lnd_mobil = new;
break;
case A_ASSAULT:
if (off->shp_mcp->m_flags & M_LAND) {
- if (llp->lcp->l_flags & L_MARINE)
- llp->land.lnd_mobil -=
+ if (((struct lchrstr *)llp->chrp)->l_flags & L_MARINE)
+ llp->unit.land.lnd_mobil -=
(float)etu_per_update * land_mob_scale * 0.5;
else
- llp->land.lnd_mobil -= (float)etu_per_update * land_mob_scale;
+ llp->unit.land.lnd_mobil -= (float)etu_per_update *
+ land_mob_scale;
} else {
- if (llp->lcp->l_flags & L_MARINE)
- llp->land.lnd_mobil = 0;
+ if (((struct lchrstr *)llp->chrp)->l_flags & L_MARINE)
+ llp->unit.land.lnd_mobil = 0;
else
- llp->land.lnd_mobil = -(float)etu_per_update * land_mob_scale;
+ llp->unit.land.lnd_mobil = -(float)etu_per_update *
+ land_mob_scale;
}
break;
case A_BOARD:
/* I arbitrarily chose the numbers 10 and 40 below -KHS */
- if (llp->lcp->l_flags & L_MARINE)
- llp->land.lnd_mobil -= 10;
+ if (((struct lchrstr *)llp->chrp)->l_flags & L_MARINE)
+ llp->unit.land.lnd_mobil -= 10;
else
- llp->land.lnd_mobil -= 40;
+ llp->unit.land.lnd_mobil -= 40;
break;
}
- llp->land.lnd_harden = 0;
+ llp->unit.land.lnd_harden = 0;
}
static void
#include "combat.h"
#include "damage.h"
#include "file.h"
-#include "land.h"
#include "misc.h"
#include "mission.h"
-#include "nat.h"
-#include "news.h"
#include "nsc.h"
#include "optlist.h"
#include "path.h"
-#include "plane.h"
#include "player.h"
#include "prototypes.h"
-#include "sect.h"
-#include "ship.h"
#include "xy.h"
+#include "empobj.h"
+#include "unit.h"
-static void lnd_mess(char *, struct llist *);
+static void lnd_mess(char *, struct ulist *);
static int lnd_hit_mine(struct lndstr *, struct lchrstr *);
double
}
void
-lnd_print(struct llist *llp, char *s)
+lnd_print(struct ulist *llp, char *s)
{
- if (llp->land.lnd_own == player->cnum)
- pr("%s %s\n", prland(&llp->land), s);
+ if (llp->unit.land.lnd_own == player->cnum)
+ pr("%s %s\n", prland(&llp->unit.land), s);
else
- wu(0, llp->land.lnd_own, "%s %s\n", prland(&llp->land), s);
+ wu(0, llp->unit.land.lnd_own, "%s %s\n", prland(&llp->unit.land), s);
}
void
-lnd_delete(struct llist *llp, char *s)
+lnd_delete(struct ulist *llp, char *s)
{
if (s)
lnd_print(llp, s);
- putland(llp->land.lnd_uid, &llp->land);
+ putland(llp->unit.land.lnd_uid, &llp->unit.land);
emp_remque((struct emp_qelem *)llp);
free(llp);
}
int
-lnd_take_casualty(int combat_mode, struct llist *llp, int cas)
+lnd_take_casualty(int combat_mode, struct ulist *llp, int cas)
/* attacking or assaulting or paratrooping? */
/* number of casualties to take */
{
signed char orig;
int mob;
- taken = llp->land.lnd_item[I_MILIT];
+ taken = llp->unit.land.lnd_item[I_MILIT];
/* Spies always die */
- if (llp->lcp->l_flags & L_SPY) {
+ if (((struct lchrstr *)llp->chrp)->l_flags & L_SPY) {
eff_eq = 100;
- llp->land.lnd_effic = 0;
+ llp->unit.land.lnd_effic = 0;
} else {
- eff_eq = ldround(cas * 100.0 / llp->lcp->l_mil, 1);
- llp->land.lnd_effic -= eff_eq;
- lnd_submil(&llp->land, cas);
+ eff_eq = ldround(cas * 100.0 /
+ ((struct lchrstr *)llp->chrp)->l_mil, 1);
+ llp->unit.land.lnd_effic -= eff_eq;
+ lnd_submil(&llp->unit.land, cas);
}
- if (llp->land.lnd_effic < LAND_MINEFF) {
+ if (llp->unit.land.lnd_effic < LAND_MINEFF) {
sprintf(buf, "dies %s %s!",
combat_mode ? att_mode[combat_mode] : "defending",
- xyas(llp->land.lnd_x, llp->land.lnd_y, llp->land.lnd_own));
+ xyas(llp->unit.land.lnd_x, llp->unit.land.lnd_y,
+ llp->unit.land.lnd_own));
lnd_delete(llp, buf);
/* Since we killed the unit, we killed all the mil on it */
return taken;
} else {
/* Ok, now, how many did we take off? (sould be the diff) */
- taken = taken - llp->land.lnd_item[I_MILIT];
+ taken = taken - llp->unit.land.lnd_item[I_MILIT];
}
- if (llp->land.lnd_effic >= llp->land.lnd_retreat)
+ if (llp->unit.land.lnd_effic >= llp->unit.land.lnd_retreat)
return taken;
/* we're being boarded */
- if (llp->land.lnd_ship >= 0 && combat_mode == A_DEFEND)
+ if (llp->unit.land.lnd_ship >= 0 && combat_mode == A_DEFEND)
return taken;
/* we're being boarded */
- if (llp->land.lnd_land >= 0 && combat_mode == A_DEFEND)
+ if (llp->unit.land.lnd_land >= 0 && combat_mode == A_DEFEND)
return taken;
/* Have to make a retreat check */
- ret_chance = llp->land.lnd_retreat - llp->land.lnd_effic;
+ ret_chance = llp->unit.land.lnd_retreat - llp->unit.land.lnd_effic;
if (roll(100) < ret_chance) {
pr("\n");
lnd_print(llp, "fails morale check!");
- llp->land.lnd_mission = 0;
- llp->land.lnd_harden = 0;
- if (llp->land.lnd_ship >= 0 || llp->land.lnd_land >= 0)
+ llp->unit.land.lnd_mission = 0;
+ llp->unit.land.lnd_harden = 0;
+ if (llp->unit.land.lnd_ship >= 0 || llp->unit.land.lnd_land >= 0)
nowhere_to_go = 1;
else if (combat_mode == A_DEFEND) {
/*
biggest = -1;
nowned = 0;
for (n = 1; n <= 6; ++n) {
- ret_x = llp->land.lnd_x + diroff[n][0];
- ret_y = llp->land.lnd_y + diroff[n][1];
+ ret_x = llp->unit.land.lnd_x + diroff[n][0];
+ ret_y = llp->unit.land.lnd_y + diroff[n][1];
getsect(ret_x, ret_y, §);
- if (sect.sct_own != llp->land.lnd_own)
+ if (sect.sct_own != llp->unit.land.lnd_own)
continue;
if (sect.sct_type == SCT_MOUNT)
continue;
- mobcost = lnd_mobcost(&llp->land, &rsect);
+ mobcost = lnd_mobcost(&llp->unit.land, &rsect);
if (mobcost < 0)
continue;
++nowned;
nowhere_to_go = 1;
else {
/* retreat to bx,by */
- llp->land.lnd_x = bx;
- llp->land.lnd_y = by;
+ llp->unit.land.lnd_x = bx;
+ llp->unit.land.lnd_y = by;
/* FIXME landmines */
getsect(bx, by, &rsect);
- mob = llp->land.lnd_mobil - (int)bmcost;
+ mob = llp->unit.land.lnd_mobil - (int)bmcost;
if (mob < -127)
mob = -127;
- orig = llp->land.lnd_mobil;
- llp->land.lnd_mobil = (signed char)mob;
- if (llp->land.lnd_mobil > orig)
- llp->land.lnd_mobil = -127;
+ orig = llp->unit.land.lnd_mobil;
+ llp->unit.land.lnd_mobil = (signed char)mob;
+ if (llp->unit.land.lnd_mobil > orig)
+ llp->unit.land.lnd_mobil = -127;
sprintf(buf, "retreats at %d%% efficiency to %s!",
- llp->land.lnd_effic,
- xyas(bx, by, llp->land.lnd_own));
+ llp->unit.land.lnd_effic,
+ xyas(bx, by, llp->unit.land.lnd_own));
lnd_delete(llp, buf);
}
} else { /* attacking from a sector */
sprintf(buf, "leaves the battlefield at %d%% efficiency",
- llp->land.lnd_effic);
- if ((llp->land.lnd_mobil - (int)llp->mobil) < -127)
- llp->land.lnd_mobil = -127;
+ llp->unit.land.lnd_effic);
+ if ((llp->unit.land.lnd_mobil - (int)llp->mobil) < -127)
+ llp->unit.land.lnd_mobil = -127;
else
- llp->land.lnd_mobil -= (int)llp->mobil;
+ llp->unit.land.lnd_mobil -= (int)llp->mobil;
llp->mobil = 0.0;
lnd_delete(llp, buf);
}
}
if (nowhere_to_go) {
/* nowhere to go.. take more casualties */
- llp->land.lnd_effic -= 10;
- lnd_submil(&llp->land, llp->lcp->l_mil / 10);
- if (llp->land.lnd_effic < LAND_MINEFF)
+ llp->unit.land.lnd_effic -= 10;
+ lnd_submil(&llp->unit.land, ((struct lchrstr *)llp->chrp)->l_mil / 10);
+ if (llp->unit.land.lnd_effic < LAND_MINEFF)
lnd_delete(llp, "has nowhere to retreat, and dies!");
else
lnd_print(llp,
lnd_takemob(struct emp_qelem *list, double loss)
{
struct emp_qelem *qp, *next;
- struct llist *llp;
+ struct ulist *llp;
int new;
int mcost = ldround(combat_mob * loss, 1);
for (qp = list->q_forw; qp != list; qp = next) {
next = qp->q_forw;
- llp = (struct llist *)qp;
+ llp = (struct ulist *)qp;
/*
if (chance(loss))
- use_supply(&llp->land);
- if (llp->land.lnd_mission == MI_RESERVE)
- new = llp->land.lnd_mobil - mcost/2;
+ use_supply(&llp->unit.land);
+ if (llp->unit.land.lnd_mission == MI_RESERVE)
+ new = llp->unit.land.lnd_mobil - mcost/2;
else
*/
- new = llp->land.lnd_mobil - mcost;
+ new = llp->unit.land.lnd_mobil - mcost;
if (new < -127)
new = -127;
- llp->land.lnd_mobil = (signed char)new;
+ llp->unit.land.lnd_mobil = (signed char)new;
}
}
{
struct lndstr land;
struct lchrstr *lcp;
- struct llist *llp;
+ struct ulist *llp;
int this_mot;
int mobtype = MOB_MOVE; /* indeterminate */
land.lnd_harden = 0;
memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath));
putland(land.lnd_uid, &land);
- llp = malloc(sizeof(struct llist));
- llp->lcp = lcp;
- llp->land = land;
+ llp = malloc(sizeof(struct ulist));
+ llp->chrp = (struct empobj_chr *)lcp;
+ llp->unit.land = land;
llp->mobil = land.lnd_mobil;
emp_insque(&llp->queue, list);
}
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct llist *llp;
+ struct ulist *llp;
struct sctstr sect;
struct lndstr land;
coord allx;
*togetherp = 1;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- llp = (struct llist *)qp;
- getland(llp->land.lnd_uid, &land);
+ llp = (struct ulist *)qp;
+ getland(llp->unit.land.lnd_uid, &land);
if (land.lnd_own != actor) {
mpr(actor, "%s was disbanded at %s\n",
prland(&land), xyas(land.lnd_x, land.lnd_y, land.lnd_own));
lnd_mess("was sucked into the sky by a strange looking spaceland", llp); /* heh -KHS */
continue;
}
- if (!(lchr[(int)llp->land.lnd_type].l_flags & L_SPY) &&
- !(lchr[(int)llp->land.lnd_type].l_flags & L_TRAIN) &&
- llp->land.lnd_item[I_MILIT] == 0) {
+ if (!(lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY) &&
+ !(lchr[(int)llp->unit.land.lnd_type].l_flags & L_TRAIN) &&
+ llp->unit.land.lnd_item[I_MILIT] == 0) {
lnd_mess("has no mil on it to guide it", llp);
continue;
}
rel = getrel(getnatp(sect.sct_own), player->cnum);
if (sect.sct_own != land.lnd_own && rel != ALLIED &&
- !(lchr[(int)llp->land.lnd_type].l_flags & L_SPY) &&
+ !(lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY) &&
sect.sct_own) {
sprintf(mess, "has been kidnapped by %s", cname(sect.sct_own));
lnd_mess(mess, llp);
*minmobp = llp->mobil;
if (llp->mobil > *maxmobp)
*maxmobp = llp->mobil;
- llp->land = land;
+ llp->unit.land = land;
}
}
{
struct emp_qelem *qp;
struct emp_qelem *newqp;
- struct llist *llp;
+ struct ulist *llp;
qp = list->q_back;
while (qp != list) {
- llp = (struct llist *)qp;
+ llp = (struct ulist *)qp;
if (actor) {
- mpr(actor, "%s stopped at %s\n", prland(&llp->land),
- xyas(llp->land.lnd_x, llp->land.lnd_y, llp->land.lnd_own));
+ mpr(actor, "%s stopped at %s\n", prland(&llp->unit.land),
+ xyas(llp->unit.land.lnd_x, llp->unit.land.lnd_y,
+ llp->unit.land.lnd_own));
if (llp->mobil < -127)
llp->mobil = -127;
- llp->land.lnd_mobil = llp->mobil;
+ llp->unit.land.lnd_mobil = llp->mobil;
}
- putland(llp->land.lnd_uid, &llp->land);
+ putland(llp->unit.land.lnd_uid, &llp->unit.land);
newqp = qp->q_back;
emp_remque(qp);
free(qp);
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct llist *llp;
+ struct ulist *llp;
struct sctstr sect;
int mines, m, max, sshells, lshells;
for (qp = land_list->q_back; qp != land_list; qp = next) {
next = qp->q_back;
- llp = (struct llist *)qp;
- if (!(llp->lcp->l_flags & L_ENGINEER)) {
+ llp = (struct ulist *)qp;
+ if (!(((struct lchrstr *)llp->chrp)->l_flags & L_ENGINEER)) {
if (verbose)
- mpr(actor, "%s is not an engineer!\n", prland(&llp->land));
+ mpr(actor, "%s is not an engineer!\n",
+ prland(&llp->unit.land));
continue;
}
if (takemob && llp->mobil < 0.0) {
lnd_mess("is out of mobility", llp);
continue;
}
- getsect(llp->land.lnd_x, llp->land.lnd_y, §);
- if (sect.sct_oldown == llp->land.lnd_own) {
+ getsect(llp->unit.land.lnd_x, llp->unit.land.lnd_y, §);
+ if (sect.sct_oldown == llp->unit.land.lnd_own) {
if (verbose)
mpr(actor,
"%s is in a sector completely owned by you. Don't bother digging up mines there!\n",
- prland(&llp->land));
+ prland(&llp->unit.land));
continue;
}
if (sect.sct_type == SCT_BSPAN) {
if (verbose)
mpr(actor, "%s is on a bridge. No mines there!\n",
- prland(&llp->land));
+ prland(&llp->unit.land));
continue;
}
if (takemob) {
- llp->mobil -= lnd_pathcost(&llp->land, 0.2);
- llp->land.lnd_mobil = (int)llp->mobil;
- llp->land.lnd_harden = 0;
+ llp->mobil -= lnd_pathcost(&llp->unit.land, 0.2);
+ llp->unit.land.lnd_mobil = (int)llp->mobil;
+ llp->unit.land.lnd_harden = 0;
}
- putland(llp->land.lnd_uid, &llp->land);
+ putland(llp->unit.land.lnd_uid, &llp->unit.land);
if (!(mines = sect.sct_mines))
continue;
- max = llp->lcp->l_item[I_SHELL];
- lshells = llp->land.lnd_item[I_SHELL];
+ max = ((struct lchrstr *)llp->chrp)->l_item[I_SHELL];
+ lshells = llp->unit.land.lnd_item[I_SHELL];
sshells = sect.sct_item[I_SHELL];
for (m = 0; mines > 0 && m < max * 2; m++) {
- if (chance(0.5 * llp->lcp->l_att)) {
+ if (chance(0.5 * ((struct lchrstr *)llp->chrp)->l_att)) {
mpr(actor, "Sweep...\n");
mines--;
if (lshells < max)
}
}
sect.sct_mines = mines;
- llp->land.lnd_item[I_SHELL] = lshells;
+ llp->unit.land.lnd_item[I_SHELL] = lshells;
sect.sct_item[I_SHELL] = sshells;
- putland(llp->land.lnd_uid, &llp->land);
+ putland(llp->unit.land.lnd_uid, &llp->unit.land);
putsect(§);
}
}
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct llist *llp;
+ struct ulist *llp;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- llp = (struct llist *)qp;
- if (llp->lcp->l_flags & L_ENGINEER)
+ llp = (struct ulist *)qp;
+ if (((struct lchrstr *)llp->chrp)->l_flags & L_ENGINEER)
return 1;
}
return 0;
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct llist *llp;
+ struct ulist *llp;
struct sctstr sect;
int stopping = 0;
int with_eng = contains_engineer(land_list);
for (qp = land_list->q_back; qp != land_list; qp = next) {
next = qp->q_back;
- llp = (struct llist *)qp;
- getsect(llp->land.lnd_x, llp->land.lnd_y, §);
- if (sect.sct_oldown == llp->land.lnd_own)
+ llp = (struct ulist *)qp;
+ getsect(llp->unit.land.lnd_x, llp->unit.land.lnd_y, §);
+ if (sect.sct_oldown == llp->unit.land.lnd_own)
continue;
if (sect.sct_type == SCT_BSPAN)
continue;
if (!sect.sct_mines)
continue;
if (chance(DMINE_LHITCHANCE(sect.sct_mines) / (1 + 2 * with_eng))) {
- lnd_hit_mine(&llp->land, llp->lcp);
+ lnd_hit_mine(&llp->unit.land, ((struct lchrstr *)llp->chrp));
sect.sct_mines--;
putsect(§);
- putland(llp->land.lnd_uid, &llp->land);
- if (!llp->land.lnd_own) {
+ putland(llp->unit.land.lnd_uid, &llp->unit.land);
+ if (!llp->unit.land.lnd_own) {
stopping = 1;
emp_remque(qp);
free(qp);
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct llist *llp;
+ struct ulist *llp;
struct lndstr *lnd;
pr("lnd# land type x,y a eff sh gun xl mu tech retr fuel\n");
for (qp = land_list->q_back; qp != land_list; qp = next) {
next = qp->q_back;
- llp = (struct llist *)qp;
- lnd = &llp->land;
+ llp = (struct ulist *)qp;
+ lnd = &llp->unit.land;
pr("%4d ", lnd->lnd_uid);
- pr("%-16.16s ", llp->lcp->l_name);
- prxy("%4d,%-4d ", lnd->lnd_x, lnd->lnd_y, llp->land.lnd_own);
+ pr("%-16.16s ", ((struct lchrstr *)llp->chrp)->l_name);
+ prxy("%4d,%-4d ", lnd->lnd_x, lnd->lnd_y, llp->unit.land.lnd_own);
pr("%1.1s", &lnd->lnd_army);
pr("%4d%%", lnd->lnd_effic);
pr("%4d", lnd->lnd_item[I_SHELL]);
}
static void
-lnd_mess(char *str, struct llist *llp)
+lnd_mess(char *str, struct ulist *llp)
{
- mpr(llp->land.lnd_own, "%s %s & stays in %s\n",
- prland(&llp->land),
- str, xyas(llp->land.lnd_x, llp->land.lnd_y, llp->land.lnd_own));
+ mpr(llp->unit.land.lnd_own, "%s %s & stays in %s\n",
+ prland(&llp->unit.land),
+ str, xyas(llp->unit.land.lnd_x, llp->unit.land.lnd_y,
+ llp->unit.land.lnd_own));
if (llp->mobil < -127)
llp->mobil = -127;
- llp->land.lnd_mobil = llp->mobil;
- putland(llp->land.lnd_uid, &llp->land);
+ llp->unit.land.lnd_mobil = llp->mobil;
+ putland(llp->unit.land.lnd_uid, &llp->unit.land);
emp_remque((struct emp_qelem *)llp);
free(llp);
}
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct llist *llp;
+ struct ulist *llp;
int count = 0;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- llp = (struct llist *)qp;
+ llp = (struct ulist *)qp;
++count;
}
return count;
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct llist *llp;
+ struct ulist *llp;
int dam;
int count;
dam = ldround((double)totdam / count, 1);
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- llp = (struct llist *)qp;
+ llp = (struct ulist *)qp;
/* have to get it again because of collateral damage */
- getland(llp->land.lnd_uid, &llp->land);
- landdamage(&llp->land, dam);
- putland(llp->land.lnd_uid, &llp->land);
- if (!llp->land.lnd_own) {
+ getland(llp->unit.land.lnd_uid, &llp->unit.land);
+ landdamage(&llp->unit.land, dam);
+ putland(llp->unit.land.lnd_uid, &llp->unit.land);
+ if (!llp->unit.land.lnd_own) {
emp_remque(qp);
free(qp);
}
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct llist *llp;
+ struct ulist *llp;
int hard;
int easiest = 9876; /* things start great for victim */
int count = 0;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- llp = (struct llist *)qp;
- hard = lnd_hardtarget(&llp->land);
+ llp = (struct ulist *)qp;
+ hard = lnd_hardtarget(&llp->unit.land);
if (hard < easiest)
easiest = hard; /* things get worse for victim */
++count;
struct emp_qelem *qp;
struct emp_qelem *qp2;
struct emp_qelem *next;
- struct llist *llp;
+ struct ulist *llp;
struct emp_qelem cur, done;
coord dx;
coord dy;
dy = diroff[dir][1];
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- llp = (struct llist *)qp;
- getsect(llp->land.lnd_x, llp->land.lnd_y, &osect);
+ llp = (struct ulist *)qp;
+ getsect(llp->unit.land.lnd_x, llp->unit.land.lnd_y, &osect);
oldown = osect.sct_own;
- newx = xnorm(llp->land.lnd_x + dx);
- newy = ynorm(llp->land.lnd_y + dy);
+ newx = xnorm(llp->unit.land.lnd_x + dx);
+ newy = ynorm(llp->unit.land.lnd_y + dy);
getsect(newx, newy, §);
rel = getrel(getnatp(sect.sct_own), player->cnum);
if ((sect.sct_own != actor && rel != ALLIED &&
- !(lchr[(int)llp->land.lnd_type].l_flags & L_SPY) &&
+ !(lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY) &&
sect.sct_own) || (sect.sct_type == SCT_WATER ||
sect.sct_type == SCT_SANCT ||
sect.sct_type == SCT_WASTE)) {
}
}
if ((!intrchr[INT_RAIL].in_enable || sect.sct_rail == 0)
- && lnd_mobtype(&llp->land) == MOB_RAIL) {
+ && lnd_mobtype(&llp->unit.land) == MOB_RAIL) {
if (together) {
pr("no rail system in %s\n", xyas(newx, newy, actor));
return 1;
}
/* Note we check would_abandon first because we don't want
to always have to do these checks */
- if (would_abandon(&osect, I_CIVIL, 0, &llp->land)) {
+ if (would_abandon(&osect, I_CIVIL, 0, &llp->unit.land)) {
stop = 0;
- if (!want_to_abandon(&osect, I_CIVIL, 0, &llp->land)) {
+ if (!want_to_abandon(&osect, I_CIVIL, 0, &llp->unit.land)) {
stop = 1;
}
/* now check stuff */
if (!check_sect_ok(&osect))
return 1;
for (qp2 = list->q_back; qp2 != list; qp2 = qp2->q_back) {
- if (!check_land_ok(&((struct llist *)qp2)->land))
+ if (!check_land_ok(&((struct ulist *)qp2)->unit.land))
return 1;
}
if (stop) {
lnd_mess("is out of mobility", llp);
continue;
}
- llp->land.lnd_x = newx;
- llp->land.lnd_y = newy;
- llp->mobil -= lnd_mobcost(&llp->land, §);
- llp->land.lnd_mobil = (int)llp->mobil;
- llp->land.lnd_harden = 0;
- putland(llp->land.lnd_uid, &llp->land);
+ llp->unit.land.lnd_x = newx;
+ llp->unit.land.lnd_y = newy;
+ llp->mobil -= lnd_mobcost(&llp->unit.land, §);
+ llp->unit.land.lnd_mobil = (int)llp->mobil;
+ llp->unit.land.lnd_harden = 0;
+ putland(llp->unit.land.lnd_uid, &llp->unit.land);
putsect(&osect);
getsect(osect.sct_x, osect.sct_y, &osect);
if (osect.sct_own != oldown && oldown == player->cnum) {
}
if (rel != ALLIED && sect.sct_own != actor && sect.sct_own) { /* must be a spy */
/* Always a 10% chance of getting caught. */
- if (chance(LND_SPY_DETECT_CHANCE(llp->land.lnd_effic))) {
+ if (chance(LND_SPY_DETECT_CHANCE(llp->unit.land.lnd_effic))) {
if (rel == NEUTRAL || rel == FRIENDLY) {
wu(0, sect.sct_own,
"%s unit spotted in %s\n", cname(player->cnum),
xyas(sect.sct_x, sect.sct_y, sect.sct_own));
- setrel(sect.sct_own, llp->land.lnd_own, HOSTILE);
+ setrel(sect.sct_own, llp->unit.land.lnd_own, HOSTILE);
} else if (rel == HOSTILE || rel == AT_WAR ||
rel == SITZKRIEG || rel == MOBILIZATION) {
wu(0, sect.sct_own,
"%s spy shot in %s\n", cname(player->cnum),
xyas(sect.sct_x, sect.sct_y, sect.sct_own));
- pr("%s was shot and killed.\n", prland(&llp->land));
- llp->land.lnd_effic = 0;
- putland(llp->land.lnd_uid, &llp->land);
+ pr("%s was shot and killed.\n", prland(&llp->unit.land));
+ llp->unit.land.lnd_effic = 0;
+ putland(llp->unit.land.lnd_uid, &llp->unit.land);
lnd_delete(llp, 0);
}
}
emp_initque(&cur);
emp_initque(&done);
while (!QEMPTY(list)) {
- llp = (struct llist *)list->q_back;
- newx = llp->land.lnd_x;
- newy = llp->land.lnd_y;
+ llp = (struct ulist *)list->q_back;
+ newx = llp->unit.land.lnd_x;
+ newy = llp->unit.land.lnd_y;
/* move units in NEWX,NEWY to cur */
visible = 0;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- llp = (struct llist *)qp;
- if (llp->land.lnd_x == newx && llp->land.lnd_y == newy) {
+ llp = (struct ulist *)qp;
+ if (llp->unit.land.lnd_x == newx && llp->unit.land.lnd_y == newy) {
emp_remque(qp);
emp_insque(qp, &cur);
- if (!(lchr[(int)llp->land.lnd_type].l_flags & L_SPY))
+ if (!(lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY))
visible = 1;
}
}
/* move survivors to done */
for (qp = cur.q_back; qp != &cur; qp = next) {
next = qp->q_back;
- llp = (struct llist *)qp;
+ llp = (struct ulist *)qp;
emp_remque(qp);
emp_insque(qp, &done);
}
#include <stdlib.h>
#include "damage.h"
#include "file.h"
-#include "item.h"
-#include "land.h"
#include "map.h"
#include "misc.h"
#include "mission.h"
-#include "nat.h"
-#include "news.h"
#include "nsc.h"
#include "optlist.h"
#include "path.h"
-#include "plane.h"
#include "player.h"
#include "prototypes.h"
#include "queue.h"
-#include "sect.h"
#include "server.h"
-#include "ship.h"
#include "xy.h"
+#include "empobj.h"
+#include "unit.h"
-static int shp_check_one_mines(struct mlist *);
+static int shp_check_one_mines(struct ulist *);
static int shp_hit_mine(struct shpstr *, struct mchrstr *);
-static void shp_mess(char *, struct mlist *);
+static void shp_mess(char *, struct ulist *);
void
shp_sel(struct nstr_item *ni, struct emp_qelem *list)
{
struct shpstr ship;
struct mchrstr *mcp;
- struct mlist *mlp;
+ struct ulist *mlp;
emp_initque(list);
while (nxtitem(ni, &ship)) {
ship.shp_rflags = 0;
memset(ship.shp_rpath, 0, sizeof(ship.shp_rpath));
putship(ship.shp_uid, &ship);
- mlp = malloc(sizeof(struct mlist));
- mlp->mcp = mcp;
- mlp->ship = ship;
+ mlp = malloc(sizeof(struct ulist));
+ mlp->chrp = (struct empobj_chr *)mcp;
+ mlp->unit.ship = ship;
mlp->mobil = ship.shp_mobil;
emp_insque(&mlp->queue, list);
}
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct mlist *mlp;
+ struct ulist *mlp;
struct sctstr sect;
struct shpstr ship;
coord allx;
*togetherp = 1;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- mlp = (struct mlist *)qp;
- getship(mlp->ship.shp_uid, &ship);
+ mlp = (struct ulist *)qp;
+ getship(mlp->unit.ship.shp_uid, &ship);
if (ship.shp_own != actor) {
mpr(actor, "%s was sunk at %s\n",
prship(&ship), xyas(ship.shp_x, ship.shp_y, actor));
*minmobp = mlp->mobil;
if (mlp->mobil > *maxmobp)
*maxmobp = mlp->mobil;
- mlp->ship = ship;
+ mlp->unit.ship = ship;
}
}
{
struct emp_qelem *qp;
struct emp_qelem *newqp;
- struct mlist *mlp;
+ struct ulist *mlp;
qp = list->q_back;
while (qp != list) {
- mlp = (struct mlist *)qp;
- mpr(actor, "%s stopped at %s\n", prship(&mlp->ship),
- xyas(mlp->ship.shp_x, mlp->ship.shp_y, mlp->ship.shp_own));
- mlp->ship.shp_mobil = (int)mlp->mobil;
- putship(mlp->ship.shp_uid, &mlp->ship);
+ mlp = (struct ulist *)qp;
+ mpr(actor, "%s stopped at %s\n", prship(&mlp->unit.ship),
+ xyas(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y,
+ mlp->unit.ship.shp_own));
+ mlp->unit.ship.shp_mobil = (int)mlp->mobil;
+ putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
newqp = qp->q_back;
emp_remque(qp);
free(qp);
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct mlist *mlp;
+ struct ulist *mlp;
struct sctstr sect;
int mines, m, max, shells;
int changed = 0;
for (qp = ship_list->q_back; qp != ship_list; qp = next) {
next = qp->q_back;
- mlp = (struct mlist *)qp;
- if (!(mlp->mcp->m_flags & M_SWEEP)) {
+ mlp = (struct ulist *)qp;
+ if (!(((struct mchrstr *)mlp->chrp)->m_flags & M_SWEEP)) {
if (verbose)
mpr(actor, "%s doesn't have minesweeping capability!\n",
- prship(&mlp->ship));
+ prship(&mlp->unit.ship));
continue;
}
if (takemob && mlp->mobil <= 0.0) {
if (verbose)
- mpr(actor, "%s is out of mobility!\n", prship(&mlp->ship));
+ mpr(actor, "%s is out of mobility!\n",
+ prship(&mlp->unit.ship));
continue;
}
- getsect(mlp->ship.shp_x, mlp->ship.shp_y, §);
+ getsect(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y, §);
if (sect.sct_type != SCT_WATER) {
if (verbose)
mpr(actor, "%s is not at sea. No mines there!\n",
- prship(&mlp->ship));
+ prship(&mlp->unit.ship));
continue;
}
if (takemob) {
- mlp->mobil -= shp_mobcost(&mlp->ship);
- mlp->ship.shp_mobil = (int)mlp->mobil;
+ mlp->mobil -= shp_mobcost(&mlp->unit.ship);
+ mlp->unit.ship.shp_mobil = (int)mlp->mobil;
}
- putship(mlp->ship.shp_uid, &mlp->ship);
+ putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
if (!(mines = sect.sct_mines))
continue;
- max = mlp->mcp->m_item[I_SHELL];
- shells = mlp->ship.shp_item[I_SHELL];
+ max = ((struct mchrstr *)mlp->chrp)->m_item[I_SHELL];
+ shells = mlp->unit.ship.shp_item[I_SHELL];
for (m = 0; mines > 0 && m < 5; m++) {
if (chance(0.66)) {
mpr(actor, "Sweep...\n");
}
}
sect.sct_mines = mines;
- mlp->ship.shp_item[I_SHELL] = shells;
+ mlp->unit.ship.shp_item[I_SHELL] = shells;
if (shp_check_one_mines(mlp)) {
stopping = 1;
emp_remque(qp);
free(qp);
}
- putship(mlp->ship.shp_uid, &mlp->ship);
+ putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
putsect(§);
}
if (changed)
}
static int
-shp_check_one_mines(struct mlist *mlp)
+shp_check_one_mines(struct ulist *mlp)
{
struct sctstr sect;
int actor;
- getsect(mlp->ship.shp_x, mlp->ship.shp_y, §);
+ getsect(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y, §);
if (sect.sct_type != SCT_WATER)
return 0;
if (!sect.sct_mines)
return 0;
if (chance(DMINE_HITCHANCE(sect.sct_mines))) {
- actor = mlp->ship.shp_own;
- shp_hit_mine(&mlp->ship, mlp->mcp);
+ actor = mlp->unit.ship.shp_own;
+ shp_hit_mine(&mlp->unit.ship, ((struct mchrstr *)mlp->chrp));
sect.sct_mines--;
if (map_set(actor, sect.sct_x, sect.sct_y, 'X', 0))
writemap(actor);
putsect(§);
- putship(mlp->ship.shp_uid, &mlp->ship);
- if (!mlp->ship.shp_own)
+ putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
+ if (!mlp->unit.ship.shp_own)
return 1;
}
return 0;
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct mlist *mlp;
+ struct ulist *mlp;
int stopping = 0;
for (qp = ship_list->q_back; qp != ship_list; qp = next) {
next = qp->q_back;
- mlp = (struct mlist *)qp;
+ mlp = (struct ulist *)qp;
if (shp_check_one_mines(mlp)) {
stopping = 1;
emp_remque(qp);
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct mlist *mlp;
+ struct ulist *mlp;
struct shpstr *shp;
pr("shp# ship type x,y fl eff mil sh gun pn he xl ln mob tech\n");
for (qp = ship_list->q_back; qp != ship_list; qp = next) {
next = qp->q_back;
- mlp = (struct mlist *)qp;
- shp = &mlp->ship;
+ mlp = (struct ulist *)qp;
+ shp = &mlp->unit.ship;
pr("%4d ", shp->shp_uid);
- pr("%-16.16s ", mlp->mcp->m_name);
- prxy("%4d,%-4d ", shp->shp_x, shp->shp_y, mlp->ship.shp_own);
+ pr("%-16.16s ", ((struct mchrstr *)mlp->chrp)->m_name);
+ prxy("%4d,%-4d ", shp->shp_x, shp->shp_y, mlp->unit.ship.shp_own);
pr("%1.1s", &shp->shp_fleet);
pr("%4d%%", shp->shp_effic);
pr("%4d", shp->shp_item[I_MILIT]);
}
static void
-shp_mess(char *str, struct mlist *mlp)
+shp_mess(char *str, struct ulist *mlp)
{
- mpr(mlp->ship.shp_own, "%s %s & stays in %s\n",
- prship(&mlp->ship),
- str, xyas(mlp->ship.shp_x, mlp->ship.shp_y, mlp->ship.shp_own));
- mlp->ship.shp_mobil = (int)mlp->mobil;
- putship(mlp->ship.shp_uid, &mlp->ship);
+ mpr(mlp->unit.ship.shp_own, "%s %s & stays in %s\n",
+ prship(&mlp->unit.ship),
+ str, xyas(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y,
+ mlp->unit.ship.shp_own));
+ mlp->unit.ship.shp_mobil = (int)mlp->mobil;
+ putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
emp_remque((struct emp_qelem *)mlp);
free(mlp);
}
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct mlist *mlp;
+ struct ulist *mlp;
int count = 0;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- mlp = (struct mlist *)qp;
- if (mlp->ship.shp_x != x || mlp->ship.shp_y != y)
+ mlp = (struct ulist *)qp;
+ if (mlp->unit.ship.shp_x != x || mlp->unit.ship.shp_y != y)
continue;
- if (wantflags && (mlp->mcp->m_flags & wantflags) != wantflags)
+ if (wantflags &&
+ (((struct mchrstr *)mlp->chrp)->m_flags & wantflags) != wantflags)
continue;
- if (nowantflags && mlp->mcp->m_flags & nowantflags)
+ if (nowantflags &&
+ ((struct mchrstr *)mlp->chrp)->m_flags & nowantflags)
continue;
++count;
}
}
static void
-shp_damage_one(struct mlist *mlp, int dam)
+shp_damage_one(struct ulist *mlp, int dam)
{
- shipdamage(&mlp->ship, dam);
- putship(mlp->ship.shp_uid, &mlp->ship);
- if (!mlp->ship.shp_own) {
+ shipdamage(&mlp->unit.ship, dam);
+ putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
+ if (!mlp->unit.ship.shp_own) {
emp_remque((struct emp_qelem *)mlp);
free(mlp);
}
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct mlist *mlp;
+ struct ulist *mlp;
int dam;
int count;
dam = ldround((double)totdam / count, 1);
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- mlp = (struct mlist *)qp;
- if (mlp->ship.shp_x != x || mlp->ship.shp_y != y)
+ mlp = (struct ulist *)qp;
+ if (mlp->unit.ship.shp_x != x || mlp->unit.ship.shp_y != y)
continue;
- if (wantflags && (mlp->mcp->m_flags & wantflags) != wantflags)
+ if (wantflags &&
+ (((struct mchrstr *)mlp->chrp)->m_flags & wantflags) != wantflags)
continue;
- if (nowantflags && mlp->mcp->m_flags & nowantflags)
+ if (nowantflags &&
+ ((struct mchrstr *)mlp->chrp)->m_flags & nowantflags)
continue;
shp_damage_one(mlp, dam);
}
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct mlist *mlp;
+ struct ulist *mlp;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- mlp = (struct mlist *)qp;
+ mlp = (struct ulist *)qp;
/* If the ship isn't in the requested sector, then continue */
- if (newx != mlp->ship.shp_x || newy != mlp->ship.shp_y)
+ if (newx != mlp->unit.ship.shp_x || newy != mlp->unit.ship.shp_y)
continue;
- if (wantflags && (mlp->mcp->m_flags & wantflags) != wantflags)
+ if (wantflags &&
+ (((struct mchrstr *)mlp->chrp)->m_flags & wantflags) != wantflags)
continue;
- if (nowantflags && mlp->mcp->m_flags & nowantflags)
+ if (nowantflags &&
+ ((struct mchrstr *)mlp->chrp)->m_flags & nowantflags)
continue;
return 1;
}
return 0;
}
-static struct mlist *
+static struct ulist *
most_valuable_ship(struct emp_qelem *list)
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct mlist *mlp;
- struct mlist *mvs = 0;
+ struct ulist *mlp;
+ struct ulist *mvs = 0;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- mlp = (struct mlist *)qp;
- if (mlp->mcp->m_flags & M_SUB)
+ mlp = (struct ulist *)qp;
+ if (((struct mchrstr *)mlp->chrp)->m_flags & M_SUB)
continue;
- if (!mlp->mcp->m_nxlight &&
- !mlp->mcp->m_nchoppers &&
- mlp->mcp->m_cost < 1000 &&
- !mlp->mcp->m_nplanes && !mlp->mcp->m_nland)
+ if (!((struct mchrstr *)mlp->chrp)->m_nxlight &&
+ !((struct mchrstr *)mlp->chrp)->m_nchoppers &&
+ ((struct mchrstr *)mlp->chrp)->m_cost < 1000 &&
+ !((struct mchrstr *)mlp->chrp)->m_nplanes &&
+ !((struct mchrstr *)mlp->chrp)->m_nland)
continue;
if (!mvs) {
mvs = mlp;
continue;
}
- if (mlp->mcp->m_cost * mlp->ship.shp_effic >
- mvs->mcp->m_cost * mvs->ship.shp_effic)
+ if (((struct mchrstr *)mlp->chrp)->m_cost * mlp->unit.ship.shp_effic >
+ ((struct mchrstr *)mlp->chrp)->m_cost * mvs->unit.ship.shp_effic)
mvs = mlp;
}
return mvs;
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct mlist *mlp;
+ struct ulist *mlp;
int hard;
int easiest = 9876; /* things start great for victim */
int count = 0;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- mlp = (struct mlist *)qp;
- if (wantflags && (mlp->mcp->m_flags & wantflags) != wantflags)
+ mlp = (struct ulist *)qp;
+ if (wantflags &&
+ (((struct mchrstr *)mlp->chrp)->m_flags & wantflags) != wantflags)
continue;
- if (nowantflags && mlp->mcp->m_flags & nowantflags)
+ if (nowantflags &&
+ ((struct mchrstr *)mlp->chrp)->m_flags & nowantflags)
continue;
- hard = shp_hardtarget(&mlp->ship);
+ hard = shp_hardtarget(&mlp->unit.ship);
if (hard < easiest)
easiest = hard; /* things get worse for victim */
++count;
int twotries;
int stopping = 0;
struct emp_qelem msl_list, *qp, *newqp;
- struct mlist *mvs;
+ struct ulist *mvs;
char what[512];
msl_sel(&msl_list, newx, newy, victim, P_T | P_MAR, 0, MI_INTERDICT);
twotries = 0;
while (!QEMPTY(&msl_list) && (mvs = most_valuable_ship(list))) {
- sprintf(what, "%s", prship(&mvs->ship));
+ sprintf(what, "%s", prship(&mvs->unit.ship));
dam = msl_launch_mindam(&msl_list, newx, newy,
- shp_hardtarget(&mvs->ship),
+ shp_hardtarget(&mvs->unit.ship),
EF_SHIP, 1, what, victim, MI_INTERDICT);
if (dam) {
mpr(victim,
{
struct emp_qelem *qp;
struct emp_qelem *next;
- struct mlist *mlp;
+ struct ulist *mlp;
struct natstr *natp;
int vrange;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- mlp = (struct mlist *)qp;
- if (mlp->mcp->m_flags & M_SUB)
+ mlp = (struct ulist *)qp;
+ if (((struct mchrstr *)mlp->chrp)->m_flags & M_SUB)
continue;
if (natp->nat_flags & NF_COASTWATCH)
wu(0, sectp->sct_own,
"%s %s sighted at %s\n",
- cname(mlp->ship.shp_own),
- prship(&mlp->ship),
- xyas(mlp->ship.shp_x, mlp->ship.shp_y, sectp->sct_own));
+ cname(mlp->unit.ship.shp_own),
+ prship(&mlp->unit.ship),
+ xyas(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y,
+ sectp->sct_own));
if (opt_HIDDEN)
- setcont(sectp->sct_own, mlp->ship.shp_own, FOUND_COAST);
+ setcont(sectp->sct_own, mlp->unit.ship.shp_own, FOUND_COAST);
}
return 1;
struct sctstr sect;
struct emp_qelem *qp;
struct emp_qelem *next;
- struct mlist *mlp;
+ struct ulist *mlp;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- mlp = (struct mlist *)qp;
- getsect(mlp->ship.shp_x, mlp->ship.shp_y, §);
- if (mlp->mcp->m_flags & M_FOOD)
- mpr(mlp->ship.shp_own, "[fert:%d] ", sect.sct_fertil);
- if (mlp->mcp->m_flags & M_OIL)
- mpr(mlp->ship.shp_own, "[oil:%d] ", sect.sct_oil);
- mpr(mlp->ship.shp_own, "%s @ %s %d%% %s\n",
- prship(&mlp->ship),
- xyas(mlp->ship.shp_x, mlp->ship.shp_y, player->cnum),
+ mlp = (struct ulist *)qp;
+ getsect(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y, §);
+ if (((struct mchrstr *)mlp->chrp)->m_flags & M_FOOD)
+ mpr(mlp->unit.ship.shp_own, "[fert:%d] ", sect.sct_fertil);
+ if (((struct mchrstr *)mlp->chrp)->m_flags & M_OIL)
+ mpr(mlp->unit.ship.shp_own, "[oil:%d] ", sect.sct_oil);
+ mpr(mlp->unit.ship.shp_own, "%s @ %s %d%% %s\n",
+ prship(&mlp->unit.ship),
+ xyas(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y, player->cnum),
sect.sct_effic, dchr[sect.sct_type].d_name);
}
}
struct sctstr sect;
struct emp_qelem *qp;
struct emp_qelem *next;
- struct mlist *mlp;
+ struct ulist *mlp;
struct emp_qelem done;
coord dx;
coord dy;
dy = diroff[dir][1];
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- mlp = (struct mlist *)qp;
- newx = xnorm(mlp->ship.shp_x + dx);
- newy = ynorm(mlp->ship.shp_y + dy);
+ mlp = (struct ulist *)qp;
+ newx = xnorm(mlp->unit.ship.shp_x + dx);
+ newy = ynorm(mlp->unit.ship.shp_y + dy);
getsect(newx, newy, §);
- navigate = shp_check_nav(§, &mlp->ship);
+ navigate = shp_check_nav(§, &mlp->unit.ship);
if (navigate != CN_NAVIGABLE ||
(sect.sct_own && actor != sect.sct_own &&
getrel(getnatp(sect.sct_own), actor) < FRIENDLY)) {
if (dchr[sect.sct_type].d_nav == NAV_CANAL &&
- !(mlp->mcp->m_flags & M_CANAL) &&
+ !(((struct mchrstr *)mlp->chrp)->m_flags & M_CANAL) &&
navigate == CN_LANDLOCKED)
sprintf(dp,
"is too large to fit into the canal system at %s",
shp_mess("is out of mobility", mlp);
continue;
}
- mobcost = shp_mobcost(&mlp->ship);
- mlp->ship.shp_x = newx;
- mlp->ship.shp_y = newy;
+ mobcost = shp_mobcost(&mlp->unit.ship);
+ mlp->unit.ship.shp_x = newx;
+ mlp->unit.ship.shp_y = newy;
if (mlp->mobil - mobcost < -127) {
mlp->mobil = -127;
} else {
mlp->mobil -= mobcost;
}
- mlp->ship.shp_mobil = (int)mlp->mobil;
- putship(mlp->ship.shp_uid, &mlp->ship);
+ mlp->unit.ship.shp_mobil = (int)mlp->mobil;
+ putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
/* Now update the map for this ship */
- tech = techfact(mlp->ship.shp_tech, mlp->mcp->m_vrnge);
- if (mlp->mcp->m_flags & M_SONAR)
- tf = techfact(mlp->ship.shp_tech, 1.0);
+ tech = techfact(mlp->unit.ship.shp_tech,
+ ((struct mchrstr *)mlp->chrp)->m_vrnge);
+ if (((struct mchrstr *)mlp->chrp)->m_flags & M_SONAR)
+ tf = techfact(mlp->unit.ship.shp_tech, 1.0);
else
tf = 0.0;
- radmapupd(mlp->ship.shp_own, mlp->ship.shp_x, mlp->ship.shp_y,
- (int)mlp->ship.shp_effic, (int)tech, tf);
+ radmapupd(mlp->unit.ship.shp_own,
+ mlp->unit.ship.shp_x, mlp->unit.ship.shp_y,
+ (int)mlp->unit.ship.shp_effic, (int)tech, tf);
}
if (QEMPTY(list))
return stopping;
/* interdict ships sector by sector */
emp_initque(&done);
while (!QEMPTY(list)) {
- mlp = (struct mlist *)list->q_back;
- newx = mlp->ship.shp_x;
- newy = mlp->ship.shp_y;
+ mlp = (struct ulist *)list->q_back;
+ newx = mlp->unit.ship.shp_x;
+ newy = mlp->unit.ship.shp_y;
stopping |= shp_interdict(list, newx, newy, actor);
/* move survivors in this sector to done */
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
- mlp = (struct mlist *)qp;
- if (mlp->ship.shp_x == newx && mlp->ship.shp_y == newy) {
+ mlp = (struct ulist *)qp;
+ if (mlp->unit.ship.shp_x == newx &&
+ mlp->unit.ship.shp_y == newy) {
emp_remque(qp);
emp_insque(qp, &done);
}
shp_missdef(struct shpstr *sp, natid victim)
{
struct emp_qelem list;
- struct mlist *mlp;
+ struct ulist *mlp;
int eff;
char buf[512];
emp_initque(&list);
- mlp = malloc(sizeof(struct mlist));
- mlp->mcp = &mchr[(int)sp->shp_type];
- mlp->ship = *sp;
+ mlp = malloc(sizeof(struct ulist));
+ mlp->chrp = (struct empobj_chr *)&mchr[(int)sp->shp_type];
+ mlp->unit.ship = *sp;
mlp->mobil = sp->shp_mobil;
emp_insque(&mlp->queue, &list);
- sprintf(buf, "%s", prship(&mlp->ship));
+ sprintf(buf, "%s", prship(&mlp->unit.ship));
eff = sp->shp_effic;
if (most_valuable_ship(&list)) {
#include <ctype.h>
-#include "item.h"
#include "nsc.h"
#include "path.h"
-#include "ship.h"
#include "update.h"
+#include "empobj.h"
+#include "unit.h"
static void swap(struct shpstr *);
char buf[1024];
struct emp_qelem ship_list;
struct emp_qelem *qp, *newqp;
- struct mlist *mlp;
+ struct ulist *mlp;
int dummyint;
double dummydouble;
int dir;
/* Make a list of one ships so we can use the navi.c code */
emp_initque(&ship_list);
- mlp = malloc(sizeof(struct mlist));
- mlp->mcp = mchr + sp->shp_type;
- mlp->ship = *sp;
+ mlp = malloc(sizeof(struct ulist));
+ mlp->chrp = (struct empobj_chr *)(mchr + sp->shp_type);
+ mlp->unit.ship = *sp;
mlp->mobil = sp->shp_mobil;
emp_insque(&mlp->queue, &ship_list);
sectp = getsectp(sp->shp_x, sp->shp_y);
if (opt_FUEL &&
sectp->sct_own != 0 &&
- sp->shp_fuel <= 0 && mlp->mcp->m_fuelu != 0)
+ sp->shp_fuel <= 0 &&
+ ((struct mchrstr *)mlp->chrp)->m_fuelu != 0)
auto_fuel_ship(sp);
- mlp->ship.shp_fuel = sp->shp_fuel;
+ mlp->unit.ship.shp_fuel = sp->shp_fuel;
cp = BestShipPath(buf, sp->shp_x, sp->shp_y,
sp->shp_destx[0], sp->shp_desty[0],
#include <math.h>
#include "nsc.h"
#include "path.h"
-#include "ship.h"
#include "update.h"
+#include "empobj.h"
+#include "unit.h"
static void fltp_to_list(struct fltheadstr *, struct emp_qelem *);
fltp_to_list(struct fltheadstr *fltp, struct emp_qelem *list)
{
struct fltelemstr *fe;
- struct mlist *mlp;
+ struct ulist *mlp;
struct shpstr *sp;
emp_initque(list);
for (fe = fltp->head; fe; fe = fe->next) {
- mlp = malloc(sizeof(struct mlist));
+ mlp = malloc(sizeof(struct ulist));
sp = getshipp(fe->num);
- mlp->mcp = mchr + sp->shp_type;
- mlp->ship = *sp;
+ mlp->chrp = (struct empobj_chr *)(mchr + sp->shp_type);
+ mlp->unit.ship = *sp;
mlp->mobil = fe->mobil;
emp_insque(&mlp->queue, list);
}