struct genlist {
struct emp_qelem queue; /* list of units */
- void *cp; /* pointer to desc of thing */
struct empobj *thing; /* thing's struct */
};
int, struct ichrstr *);
static void mission_pln_sel(struct emp_qelem *, int, int, int);
static int perform_mission_land(int, struct lndstr *, coord, coord,
- natid, int, char *, int, int);
+ natid, int, char *, int);
static int perform_mission_ship(int, struct shpstr *, coord, coord,
- natid, int, char *, int, int);
+ natid, int, char *, int);
static int perform_mission_msl(int, struct emp_qelem *, coord, coord,
natid, int);
static int perform_mission_bomb(int, struct emp_qelem *, coord, coord,
{
struct emp_qelem *qp;
struct genlist *glp;
- struct mchrstr *mcp;
for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
glp = (struct genlist *)qp;
if (glp->thing->ef_type != EF_SHIP)
return 0;
- mcp = glp->cp;
- if (!(mcp->m_flags & M_SUB))
+ if (!(mchr[glp->thing->type].m_flags & M_SUB))
return 0;
/* It's a sub! */
}
glp = malloc(sizeof(struct genlist));
memset(glp, 0, sizeof(struct genlist));
- glp->cp = get_empobj_chr(gp);
glp->thing = malloc(sizeof(item));
memcpy(glp->thing, &item, sizeof(item));
emp_insque(&glp->queue, &mi[gp->own].queue);
struct emp_qelem *qp, missiles, bombers;
struct genlist *glp;
struct plist *plp;
- struct empobj *gp;
struct sctstr sect;
struct plchrstr *pcp;
int dam = 0;
- int md;
int targeting_ships = *s == 's'; /* "subs" or "ships" FIXME gross! */
getsect(x, y, §);
for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
glp = (struct genlist *)qp;
- gp = glp->thing;
-
- md = mapdist(x, y, gp->x, gp->y);
if (glp->thing->ef_type == EF_LAND) {
dam = perform_mission_land(dam, (struct lndstr *)glp->thing,
x, y, victim, mission, s,
- md, targeting_ships);
+ targeting_ships);
} else if (glp->thing->ef_type == EF_SHIP) {
dam = perform_mission_ship(dam, (struct shpstr *)glp->thing,
x, y, victim, mission, s,
- md, targeting_ships);
+ targeting_ships);
} else if (glp->thing->ef_type == EF_PLANE) {
- pcp = glp->cp;
+ pcp = &plchr[glp->thing->type];
if (pcp->pl_flags & P_M)
/* units have their own missile interdiction */
if (hardtarget != SECT_HARDTARGET || pcp->pl_flags & P_MAR)
static int
perform_mission_land(int dam, struct lndstr *lp, coord x, coord y,
- natid victim, int mission, char *s, int md,
+ natid victim, int mission, char *s,
int targeting_ships)
{
- int range, dam2;
+ int md, range, dam2;
if (mission == MI_SINTERDICT)
return dam;
- if ((mission == MI_INTERDICT) &&
- (md > land_max_interdiction_range))
+ md = mapdist(x, y, lp->lnd_x, lp->lnd_y);
+
+ if (mission == MI_INTERDICT && md > land_max_interdiction_range)
return dam;
range = roundrange(lnd_fire_range(lp));
static int
perform_mission_ship(int dam, struct shpstr *sp, coord x, coord y,
- natid victim, int mission, char *s, int md,
+ natid victim, int mission, char *s,
int targeting_ships)
{
struct mchrstr *mcp = &mchr[sp->shp_type];
double vrange, hitchance;
- int range, dam2;
+ int md, range, dam2;
+
+ md = mapdist(x, y, sp->shp_x, sp->shp_y);
- if (((mission == MI_INTERDICT) ||
- (mission == MI_SINTERDICT)) &&
- (md > ship_max_interdiction_range))
+ if ((mission == MI_INTERDICT || mission == MI_SINTERDICT)
+ && md > ship_max_interdiction_range)
return dam;
+
if (mission == MI_SINTERDICT) {
if (!(mcp->m_flags & M_SONAR))
return dam;