]> git.pond.sub.org Git - empserver/commitdiff
Simplify control logic in msl_intercept()
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 10 Oct 2009 16:23:38 +0000 (12:23 -0400)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 13 Dec 2009 07:04:07 +0000 (08:04 +0100)
src/lib/subs/mslsub.c

index 3bb8cb75ff91d5241b6a7ae33fd0b497f7d01a6b..6c779d7e93c346eec14f9b042ac17886852c0f5e 100644 (file)
@@ -218,7 +218,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
     struct emp_qelem *next;
     struct plist *ip;
     int icount = 0;
-    short destroyed = 0;
+    short destroyed;
     char *att_name;
     char *def_name;
     int news_item;
@@ -296,12 +296,13 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
     }
     if (icount == 0) {
        mpr(sect.sct_own, "No %ss launched to intercept.\n", def_name);
-       return destroyed;
+       return 0;
     }
 
     /* attempt to destroy incoming missile */
 
-    while (!QEMPTY(intlist)) {
+    destroyed = 0;
+    while (!destroyed && !QEMPTY(intlist)) {
        qp = intlist->q_forw;
        ip = (struct plist *)qp;
        pp = &ip->plane;
@@ -321,8 +322,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
                def_name, who, att_name, cname(sect.sct_own));
        }
 
-       if (!destroyed &&
-           msl_hit(pp, hardtarget, EF_PLANE, news_item, news_item,
+       if (msl_hit(pp, hardtarget, EF_PLANE, news_item, news_item,
                    att_name, x, y, bombown)) {
            mpr(bombown, "%s destroyed by %s %s!\n",
                att_name, cname(pp->pln_own), def_name);
@@ -336,8 +336,6 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
        putplane(pp->pln_uid, pp);
        emp_remque(qp);
        free(qp);
-       if (destroyed)
-           break;
     }
     /* Clean out what is left in the list */
     while (!QEMPTY(intlist)) {
@@ -346,14 +344,14 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
        free(qp);
     }
     if (destroyed)
-       return destroyed;
+       return 1;
     if (icount) {
        mpr(bombown, "%s made it through %s defenses!\n",
            att_name, def_name);
        mpr(sect.sct_own, "%s made it through %s defenses!\n",
            att_name, def_name);
     }
-    return destroyed;
+    return 0;
 }
 
 /* Keep launching missiles on list until mindam damage has been done */