Simplify control flow in ship_bomb(), plane_bomb(), land_bomb()
No functional change.
This commit is contained in:
parent
fcb9c7f546
commit
278c3fe2d8
1 changed files with 21 additions and 26 deletions
|
@ -455,7 +455,6 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
int n;
|
int n;
|
||||||
struct emp_qelem *qp;
|
struct emp_qelem *qp;
|
||||||
int shipno;
|
int shipno;
|
||||||
int ignore;
|
|
||||||
struct shpstr ship;
|
struct shpstr ship;
|
||||||
int nships = 0;
|
int nships = 0;
|
||||||
struct shiplist *head = NULL;
|
struct shiplist *head = NULL;
|
||||||
|
@ -467,8 +466,7 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
int gun;
|
int gun;
|
||||||
int shell;
|
int shell;
|
||||||
|
|
||||||
for (qp = list->q_forw; qp != list && !player->aborted;
|
for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
|
||||||
qp = qp->q_forw) {
|
|
||||||
free_shiplist(&head);
|
free_shiplist(&head);
|
||||||
plp = (struct plist *)qp;
|
plp = (struct plist *)qp;
|
||||||
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
|
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
|
||||||
|
@ -484,15 +482,14 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
}
|
}
|
||||||
(void)sprintf(prompt, "%s, %d bombs. Target ('~' to skip)? ",
|
(void)sprintf(prompt, "%s, %d bombs. Target ('~' to skip)? ",
|
||||||
prplane(&plp->plane), plp->bombs);
|
prplane(&plp->plane), plp->bombs);
|
||||||
ignore = 0;
|
|
||||||
shipno = -1;
|
shipno = -1;
|
||||||
while (shipno < 0 && !player->aborted && !ignore) {
|
while (shipno < 0) {
|
||||||
if ((q = getstring(prompt, buf)) == 0 || *q == 0)
|
if ((q = getstring(prompt, buf)) == 0)
|
||||||
|
goto out;
|
||||||
|
if (*q == 0)
|
||||||
continue;
|
continue;
|
||||||
if (*q == '~') {
|
if (*q == '~')
|
||||||
ignore = 1;
|
break;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (*q == '?') {
|
if (*q == '?') {
|
||||||
if (plp->pcp->pl_flags & P_A)
|
if (plp->pcp->pl_flags & P_A)
|
||||||
print_shiplist(head);
|
print_shiplist(head);
|
||||||
|
@ -581,6 +578,7 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
}
|
}
|
||||||
collateral_damage(target->sct_x, target->sct_y, dam / 2);
|
collateral_damage(target->sct_x, target->sct_y, dam / 2);
|
||||||
}
|
}
|
||||||
|
out:
|
||||||
free_shiplist(&head);
|
free_shiplist(&head);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -594,7 +592,6 @@ plane_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
struct plnstr plane;
|
struct plnstr plane;
|
||||||
struct emp_qelem *qp;
|
struct emp_qelem *qp;
|
||||||
int planeno;
|
int planeno;
|
||||||
int ignore;
|
|
||||||
struct plist *plp;
|
struct plist *plp;
|
||||||
char prompt[128];
|
char prompt[128];
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
@ -614,14 +611,13 @@ plane_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
(void)sprintf(prompt, "%s, %d bombs. Target ('~' to skip)? ",
|
(void)sprintf(prompt, "%s, %d bombs. Target ('~' to skip)? ",
|
||||||
prplane(&plp->plane), plp->bombs);
|
prplane(&plp->plane), plp->bombs);
|
||||||
planeno = -1;
|
planeno = -1;
|
||||||
ignore = 0;
|
while (planeno < 0) {
|
||||||
while (planeno < 0 && !player->aborted && !ignore) {
|
if ((q = getstring(prompt, buf)) == 0)
|
||||||
if ((q = getstring(prompt, buf)) == 0 || *q == 0)
|
return;
|
||||||
|
if (*q == 0)
|
||||||
continue;
|
continue;
|
||||||
if (*q == '~') {
|
if (*q == '~')
|
||||||
ignore = 1;
|
break;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (*q == '?') {
|
if (*q == '?') {
|
||||||
planesatxy(target->sct_x, target->sct_y, 0, 0);
|
planesatxy(target->sct_x, target->sct_y, 0, 0);
|
||||||
continue;
|
continue;
|
||||||
|
@ -699,7 +695,7 @@ land_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
struct lndstr land;
|
struct lndstr land;
|
||||||
struct emp_qelem *qp;
|
struct emp_qelem *qp;
|
||||||
int unitno;
|
int unitno;
|
||||||
int ignore, aaf, flak, hitchance;
|
int aaf, flak, hitchance;
|
||||||
struct plist *plp;
|
struct plist *plp;
|
||||||
int nukedam;
|
int nukedam;
|
||||||
int nunits;
|
int nunits;
|
||||||
|
@ -716,14 +712,13 @@ land_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
(void)sprintf(prompt, "%s, %d bombs. Target ('~' to skip)? ",
|
(void)sprintf(prompt, "%s, %d bombs. Target ('~' to skip)? ",
|
||||||
prplane(&plp->plane), plp->bombs);
|
prplane(&plp->plane), plp->bombs);
|
||||||
unitno = -1;
|
unitno = -1;
|
||||||
ignore = 0;
|
while (unitno < 0) {
|
||||||
while (unitno < 0 && !player->aborted && !ignore) {
|
if ((q = getstring(prompt, buf)) == 0)
|
||||||
if ((q = getstring(prompt, buf)) == 0 || *q == 0)
|
return;
|
||||||
|
if (*q == 0)
|
||||||
continue;
|
continue;
|
||||||
if (*q == '~') {
|
if (*q == '~')
|
||||||
ignore = 1;
|
break;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (*q == '?') {
|
if (*q == '?') {
|
||||||
unitsatxy(target->sct_x, target->sct_y, 0, 0);
|
unitsatxy(target->sct_x, target->sct_y, 0, 0);
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue