(mission_pln_wanted): New, factored out of mission_pln_sel(). No
functional change.
This commit is contained in:
parent
213cf19ec5
commit
b982f284cf
1 changed files with 66 additions and 56 deletions
|
@ -902,6 +902,67 @@ oprange(struct empobj *gp, int *radius)
|
||||||
return range;
|
return range;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
mission_pln_wanted(struct plnstr *pp, int wantflags, int nowantflags)
|
||||||
|
{
|
||||||
|
int y, bad, bad1;
|
||||||
|
unsigned x;
|
||||||
|
struct plchrstr *pcp = plchr + pp->pln_type;
|
||||||
|
|
||||||
|
bad = 0;
|
||||||
|
bad1 = 0;
|
||||||
|
if (wantflags) {
|
||||||
|
for (x = 0; x < sizeof(wantflags) * 8; x++) {
|
||||||
|
y = (1 << x);
|
||||||
|
if ((wantflags & y) == y)
|
||||||
|
if ((pcp->pl_flags & y) != y) {
|
||||||
|
switch (y) {
|
||||||
|
case P_F:
|
||||||
|
case P_ESC:
|
||||||
|
bad1 = 2;
|
||||||
|
break;
|
||||||
|
case P_E:
|
||||||
|
case P_L:
|
||||||
|
case P_K:
|
||||||
|
bad1 = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
bad = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bad) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (bad1 == 2) {
|
||||||
|
if ((pcp->pl_flags & P_ESC) || (pcp->pl_flags & P_F))
|
||||||
|
bad1 = 0;
|
||||||
|
}
|
||||||
|
if (bad1 == 1) {
|
||||||
|
if ((pcp->pl_flags & P_E) ||
|
||||||
|
(pcp->pl_flags & P_K) || (pcp->pl_flags & P_L))
|
||||||
|
bad1 = 0;
|
||||||
|
}
|
||||||
|
if (bad1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bad = 0;
|
||||||
|
bad1 = 0;
|
||||||
|
if (nowantflags) {
|
||||||
|
for (x = 0; x < sizeof(nowantflags) * 8; x++) {
|
||||||
|
y = (1 << x);
|
||||||
|
if ((nowantflags & y) == y)
|
||||||
|
if ((pcp->pl_flags & y) == y)
|
||||||
|
bad = 1;
|
||||||
|
}
|
||||||
|
if (bad) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove all planes who cannot go on
|
* Remove all planes who cannot go on
|
||||||
* the mission from the plane list.
|
* the mission from the plane list.
|
||||||
|
@ -946,63 +1007,12 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bad = 0;
|
if (!mission_pln_wanted(pp, wantflags, nowantflags)) {
|
||||||
bad1 = 0;
|
emp_remque(qp);
|
||||||
if (wantflags) {
|
free(qp);
|
||||||
for (x = 0; x < sizeof(wantflags) * 8; x++) {
|
continue;
|
||||||
y = (1 << x);
|
|
||||||
if ((wantflags & y) == y)
|
|
||||||
if ((pcp->pl_flags & y) != y) {
|
|
||||||
switch (y) {
|
|
||||||
case P_F:
|
|
||||||
case P_ESC:
|
|
||||||
bad1 = 2;
|
|
||||||
break;
|
|
||||||
case P_E:
|
|
||||||
case P_L:
|
|
||||||
case P_K:
|
|
||||||
bad1 = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
bad = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (bad) {
|
|
||||||
emp_remque(qp);
|
|
||||||
free(qp);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (bad1 == 2) {
|
|
||||||
if ((pcp->pl_flags & P_ESC) || (pcp->pl_flags & P_F))
|
|
||||||
bad1 = 0;
|
|
||||||
}
|
|
||||||
if (bad1 == 1) {
|
|
||||||
if ((pcp->pl_flags & P_E) ||
|
|
||||||
(pcp->pl_flags & P_K) || (pcp->pl_flags & P_L))
|
|
||||||
bad1 = 0;
|
|
||||||
}
|
|
||||||
if (bad1) {
|
|
||||||
emp_remque(qp);
|
|
||||||
free(qp);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bad = 0;
|
|
||||||
bad1 = 0;
|
|
||||||
if (nowantflags) {
|
|
||||||
for (x = 0; x < sizeof(nowantflags) * 8; x++) {
|
|
||||||
y = (1 << x);
|
|
||||||
if ((nowantflags & y) == y)
|
|
||||||
if ((pcp->pl_flags & y) == y)
|
|
||||||
bad = 1;
|
|
||||||
}
|
|
||||||
if (bad) {
|
|
||||||
emp_remque(qp);
|
|
||||||
free(qp);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pp->pln_ship >= 0) {
|
if (pp->pln_ship >= 0) {
|
||||||
if (!getship(pp->pln_ship, &ship)) {
|
if (!getship(pp->pln_ship, &ship)) {
|
||||||
shipsunk:
|
shipsunk:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue