]> git.pond.sub.org Git - empserver/commitdiff
assault: Simplify only_spies()
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 23 Jul 2016 15:09:54 +0000 (17:09 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 18:09:18 +0000 (20:09 +0200)
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/commands/assa.c

index 55a806484aa1413a6b127ce83b6bb7c745553966..b4fb8b7b197f3c33b23c3cc0d03b631f513f6f91 100644 (file)
@@ -170,26 +170,24 @@ assa(void)
 static int
 only_spies(struct combat off[], struct emp_qelem *olist)
 {
-    int ourtotal;
     int n;
-    struct emp_qelem *qp, *next;
+    struct emp_qelem *qp;
     struct ulist *llp;
 
-    ourtotal = 0;
     for (n = 0; n <= off->last; n++) {
        if (off[n].type == EF_BAD)
            continue;
-       ourtotal += off[n].troops * att_combat_eff(off + n);
+       if (off[n].troops)
+           return 0;
     }
-    for (qp = olist->q_forw; qp != olist; qp = next) {
-       next = qp->q_forw;
+
+    for (qp = olist->q_forw; qp != olist; qp = qp->q_forw) {
        llp = (struct ulist *)qp;
-       if (lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY)
-           continue;
-       ourtotal++;
+       if (!(lchr[llp->unit.land.lnd_type].l_flags & L_SPY))
+           return 0;
     }
 
-    return ourtotal == 0;
+    return 1;
 }
 
 static void