]> git.pond.sub.org Git - empserver/commitdiff
Change pln_dropoff() parameters to match pln_newlanding()
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 12 Jul 2008 18:35:41 +0000 (14:35 -0400)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 12 Jul 2008 18:53:28 +0000 (14:53 -0400)
This moves getting the target sector or ship from caller into
pln_dropoff().  Makes sense, because that's where it's put.

include/prototypes.h
src/lib/commands/drop.c
src/lib/commands/fly.c
src/lib/subs/plnsub.c

index b60f22d2bf0e5d2f702a33f51329b39e3c6a5e22..57e8b8cfba96f6787116af5602ec7d95dcef5ee9 100644 (file)
@@ -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);
index fbfffcfebe7336323fbd237abbf49f6dc9a11fbf..004bab6bf8aebf11fd12818c3d92bf321ad51310 100644 (file)
@@ -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);
index 1fdfef90e13d340355e53573d68b7c9ded25c363..97304f7dc3a639636f0ff0d79351dc877bf0f93b 100644 (file)
@@ -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 = &target;
-           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);
     }
index 1e9b3b82bf8b693d7c2db7f8295777e1a1839c96..defe08abf788d5d7c0740e536d01804deac5d01d 100644 (file)
@@ -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, &sect);
+       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(&sect);
     } 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);
     }
 }