]> git.pond.sub.org Git - empserver/commitdiff
Simplify how fire command passes defender to defend()
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 13 Mar 2008 20:32:12 +0000 (21:32 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Fri, 14 Mar 2008 19:25:45 +0000 (20:25 +0100)
Pass defender country number instead of target type, sector (used if
target type is targ_land), and ship (used otherwise).

src/lib/commands/mfir.c

index 4b034922d1587e75bebb44670a2218d5360ee2e8..1e5a6c6b281a61a99c5d459d5a2db657059bc98d 100644 (file)
@@ -54,11 +54,9 @@ struct flist {
 static void add_to_fired_queue(struct emp_qelem *, struct emp_qelem *);
 static int defend(struct emp_qelem *al,
                  struct emp_qelem *dl,
-                 enum targ_type target,
+                 natid,
                  enum targ_type attacker,
-                 struct sctstr *vsect,
                  struct sctstr *fsect,
-                 struct shpstr *vship,
                  struct shpstr *fship, int fx, int fy, int *nd);
 static void do_defdam(struct emp_qelem *, double);
 static int quiet_bigdef(int, struct emp_qelem *, natid, natid, coord,
@@ -557,8 +555,8 @@ multifire(void)
            getsect(fland.lnd_x, fland.lnd_y, &fsect);
        }
        totaldefdam =
-           defend(&fired, &defended, target, attacker, &vsect, &fsect,
-                  &vship, &fship, fx, fy, &ndefending);
+           defend(&fired, &defended, vict, attacker,
+                  &fsect, &fship, fx, fy, &ndefending);
        switch (target) {
        case targ_land:
            putsect(&vsect);
@@ -595,13 +593,13 @@ multifire(void)
 }
 
 static int
-defend(struct emp_qelem *al, struct emp_qelem *dl, enum targ_type target,
-       enum targ_type attacker, struct sctstr *vsect, struct sctstr *fsect,
-       struct shpstr *vship, struct shpstr *fship, int fx, int fy, int *nd)
+defend(struct emp_qelem *al, struct emp_qelem *dl, natid vict,
+       enum targ_type attacker, struct sctstr *fsect,
+       struct shpstr *fship, int fx, int fy, int *nd)
 {
 
     int dam;
-    int vict, nfiring = 0;
+    int nfiring = 0;
     struct flist *fp;
     int aown;
 
@@ -610,11 +608,6 @@ defend(struct emp_qelem *al, struct emp_qelem *dl, enum targ_type target,
     else
        aown = fship->shp_own;
 
-    if (target == targ_land)
-       vict = vsect->sct_own;
-    else
-       vict = vship->shp_own;
-
     if (0 !=
        (dam = quiet_bigdef(attacker, dl, vict, aown, fx, fy, &nfiring))) {
        if (nfiring > *nd)