]> git.pond.sub.org Git - empserver/commitdiff
(pln_dropoff): Restructure for clarity and to avoid `might be used
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 4 Mar 2004 15:45:34 +0000 (15:45 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 4 Mar 2004 15:45:34 +0000 (15:45 +0000)
uninitialized' warning.

include/prototypes.h
src/lib/subs/plnsub.c

index c6a9afe89561813435f11879cca5308ed4bba6c0..79315ee040870b93ee4a5317fd0772ba57577907 100644 (file)
@@ -395,8 +395,8 @@ extern int pln_onewaymission(struct sctstr *, int *, int *);
 extern void pln_newlanding(struct emp_qelem *, coord, coord, int);
 extern int can_be_on_ship(int, int);
 extern int put_plane_on_ship(struct plnstr *, struct shpstr *);
-extern void pln_dropoff(struct emp_qelem *, struct ichrstr *, coord,
-                       coord, s_char *, int);
+extern void pln_dropoff(struct emp_qelem *, struct ichrstr *,
+                       coord, coord, void *, int);
 extern void pln_sel(struct nstr_item *, struct emp_qelem *,
                    struct sctstr *, int, int, int, int);
 extern int pln_arm(struct emp_qelem *, int, int, struct ichrstr *,
index 3db372f0c0470ecdc1bb9323413fa706ad44dd9a..277bf4935c521617d20fc11dd76e72d30c7473e3 100644 (file)
@@ -208,12 +208,13 @@ 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,
-           s_char *ptr, int type)
+           void *ptr, int type)
 {
     struct emp_qelem *qp;
     struct plist *plp;
     int amt;
-    struct shpstr *ship;
+    struct sctstr *sectp;
+    struct shpstr *sp;
     int there;
     int max;
     struct mchrstr *mp;
@@ -225,54 +226,52 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
        plp = (struct plist *)qp;
        amt += plp->misc;
     }
-    if (type == EF_SECTOR &&
-       (((struct sctstr *)ptr)->sct_type == SCT_WATER) &&
-       ip->i_vtype == V_SHELL) {
-       ((struct sctstr *)ptr)->sct_mines += amt;
-       pr("%d mines laid in %s.\n", amt,
-          xyas(((struct sctstr *)ptr)->sct_x,
-               ((struct sctstr *)ptr)->sct_y, player->cnum));
-       if (amt > 0 &&
-           map_set(player->cnum, ((struct sctstr *)ptr)->sct_x,
-                   ((struct sctstr *)ptr)->sct_y, 'X', 0))
-           writemap(player->cnum);
+    if (type == EF_SECTOR) {
+       sectp = ptr;
+       if (sectp->sct_type == SCT_WATER && ip->i_vtype == V_SHELL) {
+           /* aerial mining */
+           sectp->sct_mines += amt;
+           pr("%d mines laid in %s.\n", amt,
+              xyas(sectp->sct_x, sectp->sct_y, player->cnum));
+           if (amt > 0
+               && map_set(player->cnum, sectp->sct_x, sectp->sct_y, 'X', 0))
+               writemap(player->cnum);
+           putsect(sectp);
+           return;
+       }
+       there = sectp->sct_item[ip->i_vtype];
+       max = 32767;
+    } else {
+       sp = ptr;
+       there = sp->shp_item[ip->i_vtype];
+       mp = &mchr[(int)sp->shp_type];
+       max = vl_find(ip->i_vtype, mp->m_vtype,
+                     mp->m_vamt, (int)mp->m_nv);
+    }
+    there += amt;
+    if (there > max) {
+       pr("%d excess %s discarded\n", max - there, ip->i_name);
+       amt = max - there;
+       there = max;
+    }
+    pr("%d %s landed safely", amt, ip->i_name);
+    if (type == EF_SECTOR) {
+       sectp = ptr;
+       sectp->sct_item[ip->i_vtype] = there;
+       if (sectp->sct_own != player->cnum)
+           wu(0, sectp->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));
+       pr(" at %s\n", xyas(tx, ty, player->cnum));
        putsect((struct sctstr *)ptr);
     } else {
-       if (type == EF_SHIP) {
-           ship = (struct shpstr *)ptr;
-           there = ship->shp_item[ip->i_vtype];
-           mp = &mchr[(int)ship->shp_type];
-           max = vl_find(ip->i_vtype, mp->m_vtype,
-                         mp->m_vamt, (int)mp->m_nv);
-       } else {
-           there = ((struct sctstr *)ptr)->sct_item[ip->i_vtype];
-           max = 32767;
-       }
-       there += amt;
-       if (there > max) {
-           pr("%d excess %s discarded\n", max - there, ip->i_name);
-           amt = max - there;
-           there = max;
-       }
-       pr("%d %s landed safely", amt, ip->i_name);
-       if (type == EF_SECTOR) {
-           struct sctstr *sectp = (struct sctstr *)ptr;
-           sectp->sct_item[ip->i_vtype] = there;
-           if (sectp->sct_own != player->cnum)
-               wu(0, sectp->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));
-           pr(" at %s\n", xyas(tx, ty, player->cnum));
-           putsect((struct sctstr *)ptr);
-       } else {
-           struct shpstr *sp = (struct shpstr *)ptr;
-           sp->shp_item[ip->i_vtype] = 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", ship->shp_uid);
-           putship(ship->shp_uid, ship);
-       }
+       struct shpstr *sp = (struct shpstr *)ptr;
+       sp->shp_item[ip->i_vtype] = 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);
     }
 }