Change pln_dropoff() parameters to match pln_newlanding()
This moves getting the target sector or ship from caller into pln_dropoff(). Makes sense, because that's where it's put.
This commit is contained in:
parent
42d9475d89
commit
27edba1f1b
4 changed files with 29 additions and 45 deletions
|
@ -543,7 +543,7 @@ extern void pln_newlanding(struct emp_qelem *, coord, coord, int);
|
|||
extern int could_be_on_ship(struct plnstr *, struct shpstr *);
|
||||
extern int put_plane_on_ship(struct plnstr *, struct shpstr *);
|
||||
extern void pln_dropoff(struct emp_qelem *, struct ichrstr *,
|
||||
coord, coord, void *, int);
|
||||
coord, coord, int);
|
||||
extern void pln_mine(struct emp_qelem *list, struct sctstr *sectp);
|
||||
extern int pln_capable(struct plnstr *, int, int);
|
||||
extern int pln_airbase_ok(struct plnstr *, int, int);
|
||||
|
|
|
@ -133,7 +133,7 @@ drop(void)
|
|||
if (wantflags & P_MINE)
|
||||
pln_mine(&bomb_list, &target);
|
||||
else
|
||||
pln_dropoff(&bomb_list, ip, tx, ty, &target, EF_SECTOR);
|
||||
pln_dropoff(&bomb_list, ip, tx, ty, -1);
|
||||
}
|
||||
pln_put(&bomb_list);
|
||||
pln_put(&esc_list);
|
||||
|
|
|
@ -49,7 +49,6 @@ fly(void)
|
|||
int ap_to_target;
|
||||
struct ichrstr *ip;
|
||||
char flightpath[MAX_PATH_LEN];
|
||||
struct shpstr ship;
|
||||
int cno;
|
||||
struct nstr_item ni_bomb;
|
||||
struct nstr_item ni_esc;
|
||||
|
@ -58,8 +57,6 @@ fly(void)
|
|||
struct emp_qelem esc_list;
|
||||
int wantflags;
|
||||
struct sctstr ap_sect;
|
||||
int dst_type;
|
||||
void *dst_ptr;
|
||||
char buf[1024];
|
||||
|
||||
wantflags = 0;
|
||||
|
@ -133,16 +130,7 @@ fly(void)
|
|||
if (QEMPTY(&bomb_list)) {
|
||||
pr("No planes got through fighter defenses\n");
|
||||
} else {
|
||||
getsect(tx, ty, &target);
|
||||
if (cno < 0) {
|
||||
dst_ptr = ⌖
|
||||
dst_type = EF_SECTOR;
|
||||
} else {
|
||||
getship(cno, &ship);
|
||||
dst_ptr = &ship;
|
||||
dst_type = EF_SHIP;
|
||||
}
|
||||
pln_dropoff(&bomb_list, ip, tx, ty, dst_ptr, dst_type);
|
||||
pln_dropoff(&bomb_list, ip, tx, ty, cno);
|
||||
pln_newlanding(&bomb_list, tx, ty, cno);
|
||||
pln_newlanding(&esc_list, tx, ty, cno);
|
||||
}
|
||||
|
|
|
@ -239,16 +239,15 @@ pln_newlanding(struct emp_qelem *list, coord tx, coord ty, int cno)
|
|||
|
||||
void
|
||||
pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
|
||||
void *ptr, int type)
|
||||
int cno)
|
||||
{
|
||||
struct emp_qelem *qp;
|
||||
struct plist *plp;
|
||||
int amt;
|
||||
struct sctstr *sectp;
|
||||
struct shpstr *sp;
|
||||
struct sctstr sect;
|
||||
struct shpstr ship;
|
||||
int there;
|
||||
int max;
|
||||
struct mchrstr *mp;
|
||||
|
||||
if (ip == 0)
|
||||
return;
|
||||
|
@ -257,33 +256,32 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
|
|||
plp = (struct plist *)qp;
|
||||
amt += plp->misc;
|
||||
}
|
||||
if (type == EF_SECTOR) {
|
||||
sectp = ptr;
|
||||
if (!sectp->sct_own) {
|
||||
if (sectp->sct_type == SCT_WATER)
|
||||
if (cno < 0) {
|
||||
getsect(tx, ty, §);
|
||||
if (!sect.sct_own) {
|
||||
if (sect.sct_type == SCT_WATER)
|
||||
pr("Your %s sink like a rock!\n", ip->i_name);
|
||||
else
|
||||
pr("Your %s vanish without a trace.\n", ip->i_name);
|
||||
return;
|
||||
}
|
||||
if (sectp->sct_own != player->cnum
|
||||
&& getrel(getnatp(sectp->sct_own), player->cnum) != ALLIED) {
|
||||
if (sect.sct_own != player->cnum
|
||||
&& getrel(getnatp(sect.sct_own), player->cnum) != ALLIED) {
|
||||
pr("You don't own %s! Cargo jettisoned...\n",
|
||||
xyas(tx, ty, player->cnum));
|
||||
return;
|
||||
}
|
||||
if (ip->i_uid == I_CIVIL && sectp->sct_own != sectp->sct_oldown) {
|
||||
if (ip->i_uid == I_CIVIL && sect.sct_own != sect.sct_oldown) {
|
||||
pr("%s is occupied. Your civilians suffer from identity crisis and die.\n",
|
||||
xyas(tx, ty, player->cnum));
|
||||
return;
|
||||
}
|
||||
there = sectp->sct_item[ip->i_uid];
|
||||
there = sect.sct_item[ip->i_uid];
|
||||
max = ITEM_MAX;
|
||||
} else {
|
||||
sp = ptr;
|
||||
there = sp->shp_item[ip->i_uid];
|
||||
mp = &mchr[(int)sp->shp_type];
|
||||
max = mp->m_item[ip->i_uid];
|
||||
getship(cno, &ship);
|
||||
there = ship.shp_item[ip->i_uid];
|
||||
max = mchr[ship.shp_type].m_item[ip->i_uid];
|
||||
}
|
||||
there += amt;
|
||||
if (there > max) {
|
||||
|
@ -292,23 +290,21 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
|
|||
there = max;
|
||||
}
|
||||
pr("%d %s landed safely", amt, ip->i_name);
|
||||
if (type == EF_SECTOR) {
|
||||
sectp = ptr;
|
||||
sectp->sct_item[ip->i_uid] = there;
|
||||
if (sectp->sct_own != player->cnum)
|
||||
wu(0, sectp->sct_own, "%s planes drop %d %s in %s\n",
|
||||
if (cno < 0) {
|
||||
sect.sct_item[ip->i_uid] = there;
|
||||
if (sect.sct_own != player->cnum)
|
||||
wu(0, sect.sct_own, "%s planes drop %d %s in %s\n",
|
||||
cname(player->cnum), amt, ip->i_name,
|
||||
xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
|
||||
xyas(tx, ty, sect.sct_own));
|
||||
pr(" at %s\n", xyas(tx, ty, player->cnum));
|
||||
putsect((struct sctstr *)ptr);
|
||||
putsect(§);
|
||||
} else {
|
||||
struct shpstr *sp = (struct shpstr *)ptr;
|
||||
sp->shp_item[ip->i_uid] = there;
|
||||
if (sp->shp_own != player->cnum)
|
||||
wu(0, sp->shp_own, "%s planes land %d %s on carrier %d\n",
|
||||
cname(player->cnum), amt, ip->i_name, sp->shp_uid);
|
||||
pr(" on carrier #%d\n", sp->shp_uid);
|
||||
putship(sp->shp_uid, sp);
|
||||
ship.shp_item[ip->i_uid] = there;
|
||||
if (ship.shp_own != player->cnum)
|
||||
wu(0, ship.shp_own, "%s planes land %d %s on carrier %d\n",
|
||||
cname(player->cnum), amt, ip->i_name, ship.shp_uid);
|
||||
pr(" on carrier #%d\n", ship.shp_uid);
|
||||
putship(ship.shp_uid, &ship);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue