Simplify control logic in msl_intercept()
This commit is contained in:
parent
0f0d785601
commit
e043ea4531
1 changed files with 7 additions and 9 deletions
|
@ -218,7 +218,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
|
||||||
struct emp_qelem *next;
|
struct emp_qelem *next;
|
||||||
struct plist *ip;
|
struct plist *ip;
|
||||||
int icount = 0;
|
int icount = 0;
|
||||||
short destroyed = 0;
|
short destroyed;
|
||||||
char *att_name;
|
char *att_name;
|
||||||
char *def_name;
|
char *def_name;
|
||||||
int news_item;
|
int news_item;
|
||||||
|
@ -296,12 +296,13 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
|
||||||
}
|
}
|
||||||
if (icount == 0) {
|
if (icount == 0) {
|
||||||
mpr(sect.sct_own, "No %ss launched to intercept.\n", def_name);
|
mpr(sect.sct_own, "No %ss launched to intercept.\n", def_name);
|
||||||
return destroyed;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* attempt to destroy incoming missile */
|
/* attempt to destroy incoming missile */
|
||||||
|
|
||||||
while (!QEMPTY(intlist)) {
|
destroyed = 0;
|
||||||
|
while (!destroyed && !QEMPTY(intlist)) {
|
||||||
qp = intlist->q_forw;
|
qp = intlist->q_forw;
|
||||||
ip = (struct plist *)qp;
|
ip = (struct plist *)qp;
|
||||||
pp = &ip->plane;
|
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));
|
def_name, who, att_name, cname(sect.sct_own));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!destroyed &&
|
if (msl_hit(pp, hardtarget, EF_PLANE, news_item, news_item,
|
||||||
msl_hit(pp, hardtarget, EF_PLANE, news_item, news_item,
|
|
||||||
att_name, x, y, bombown)) {
|
att_name, x, y, bombown)) {
|
||||||
mpr(bombown, "%s destroyed by %s %s!\n",
|
mpr(bombown, "%s destroyed by %s %s!\n",
|
||||||
att_name, cname(pp->pln_own), def_name);
|
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);
|
putplane(pp->pln_uid, pp);
|
||||||
emp_remque(qp);
|
emp_remque(qp);
|
||||||
free(qp);
|
free(qp);
|
||||||
if (destroyed)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
/* Clean out what is left in the list */
|
/* Clean out what is left in the list */
|
||||||
while (!QEMPTY(intlist)) {
|
while (!QEMPTY(intlist)) {
|
||||||
|
@ -346,14 +344,14 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
|
||||||
free(qp);
|
free(qp);
|
||||||
}
|
}
|
||||||
if (destroyed)
|
if (destroyed)
|
||||||
return destroyed;
|
return 1;
|
||||||
if (icount) {
|
if (icount) {
|
||||||
mpr(bombown, "%s made it through %s defenses!\n",
|
mpr(bombown, "%s made it through %s defenses!\n",
|
||||||
att_name, def_name);
|
att_name, def_name);
|
||||||
mpr(sect.sct_own, "%s made it through %s defenses!\n",
|
mpr(sect.sct_own, "%s made it through %s defenses!\n",
|
||||||
att_name, def_name);
|
att_name, def_name);
|
||||||
}
|
}
|
||||||
return destroyed;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Keep launching missiles on list until mindam damage has been done */
|
/* Keep launching missiles on list until mindam damage has been done */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue