struct flist {
struct emp_qelem queue; /* list of fired things */
- int type; /* ship? otherwise sector */
- int uid; /* ship uid */
+ short type; /* EF_SECTOR, EF_SHIP or EF_LAND */
+ short uid; /* ship or land unit uid */
coord x, y; /* sector coords */
int defdam; /* damage defenders did */
- int victim; /* who I was shooting at */
+ natid victim;
};
static void add_to_fired_queue(struct emp_qelem *, struct emp_qelem *);
memset(fp, 0, sizeof(struct flist));
fp->defdam = dam;
fp->victim = vict;
- switch (attgp->ef_type) {
- case EF_SECTOR:
- fp->x = attgp->x;
- fp->y = attgp->y;
- fp->type = targ_land;
- break;
- default:
- fp->type = targ_ship;
- fp->uid = attgp->uid;
- break;
- }
+ fp->type = attgp->ef_type;
+ fp->uid = attgp->uid;
+ fp->x = attgp->x;
+ fp->y = attgp->y;
emp_insque(&fp->queue, al);
}
do_defdam(struct emp_qelem *list, double odds)
{
- int dam, vict, first = 1;
+ int dam, first = 1;
+ natid vict;
struct flist *fp;
struct shpstr ship;
struct sctstr sect;
for (qp = list->q_forw; qp != list; qp = next) {
next = qp->q_forw;
fp = (struct flist *)qp;
- if (fp->type == targ_ship) {
+ if (fp->type == EF_SHIP) {
if (!getship(fp->uid, &ship) || !ship.shp_own)
continue;
}
}
dam = odds * fp->defdam;
- if (fp->type == targ_ship) {
+ if (fp->type == EF_SHIP) {
vict = fp->victim;
pr("Return fire hit %s in %s for %d damage.\n",
prship(&ship),
shipdamage(&ship, dam);
putship(ship.shp_uid, &ship);
} else {
+ CANT_HAPPEN(fp->type != EF_SECTOR);
getsect(fp->x, fp->y, §);
vict = fp->victim;
pr("Return fire hit sector %s for %d damage.\n",
(*nfiring)++;
fp = malloc(sizeof(struct flist));
memset(fp, 0, sizeof(struct flist));
- fp->type = targ_ship;
+ fp->type = EF_SHIP;
fp->uid = ship.shp_uid;
add_to_fired_queue(&fp->queue, list);
dam += dam2;
(*nfiring)++;
fp = malloc(sizeof(struct flist));
memset(fp, 0, sizeof(struct flist));
- fp->type = targ_unit;
+ fp->type = EF_LAND;
fp->uid = land.lnd_uid;
add_to_fired_queue(&fp->queue, list);
nreport(land.lnd_own, N_FIRE_BACK, player->cnum, 1);
memset(fp, 0, sizeof(struct flist));
fp->x = firing.sct_x;
fp->y = firing.sct_y;
- fp->type = targ_land;
+ fp->type = EF_SECTOR;
add_to_fired_queue(&fp->queue, list);
nreport(firing.sct_own, N_FIRE_BACK, player->cnum, 1);
dam += dam2;
for (qp = list->q_forw; qp != list; qp = next) {
next = qp->q_forw;
fp = (struct flist *)qp;
- if (fp->type == targ_ship) {
+ if (fp->type == EF_SHIP) {
getship(fp->uid, &ship);
item = ship.shp_item;
if (mchr[(int)ship.shp_type].m_flags & M_SUB) {
/* mob cost = 1/2 a sect's mob */
ship.shp_mobil -= shp_mobcost(&ship) / 2.0;
}
- } else if (fp->type == targ_land) {
+ } else if (fp->type == EF_SECTOR) {
getsect(fp->x, fp->y, §);
item = sect.sct_item;
} else {
if (shell < 0)
shell = 0;
item[I_SHELL] = shell;
- if (fp->type == targ_ship)
+ if (fp->type == EF_SHIP)
putship(ship.shp_uid, &ship);
- else if (fp->type == targ_land)
+ else if (fp->type == EF_SECTOR)
putsect(§);
else
putland(land.lnd_uid, &land);
/* Don't put them on the list if they're already there */
for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
fp = (struct flist *)qp;
- if (fp->type == targ_land
+ if (fp->type == EF_SECTOR
? fp->x == ep->x && fp->y == ep->y
: fp->uid == ep->uid) {
free(ep);