(BestAirPath): Some callers assumed non-null return value must be the
first argument. Fix them. Simplify bestownedpath().
This commit is contained in:
parent
462bc9e7b2
commit
9c27a771b3
2 changed files with 15 additions and 18 deletions
|
@ -145,7 +145,6 @@ bestownedpath(s_char *bpath,
|
||||||
if (!mapindex)
|
if (!mapindex)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
bpath[0] = 0;
|
|
||||||
if (0 != (restr2 = (*terrain == 'R')))
|
if (0 != (restr2 = (*terrain == 'R')))
|
||||||
terrain++;
|
terrain++;
|
||||||
|
|
||||||
|
@ -154,11 +153,8 @@ bestownedpath(s_char *bpath,
|
||||||
ex = XNORM(ex);
|
ex = XNORM(ex);
|
||||||
ey = YNORM(ey);
|
ey = YNORM(ey);
|
||||||
|
|
||||||
if (x == ex && y == ey) {
|
if (x == ex && y == ey)
|
||||||
bpath[0] = 'h';
|
return "h";
|
||||||
bpath[1] = 0;
|
|
||||||
return bpath;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!valid(x, y) || !valid(ex, ey))
|
if (!valid(x, y) || !valid(ex, ey))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -180,11 +176,8 @@ bestownedpath(s_char *bpath,
|
||||||
maxy = y + 1;
|
maxy = y + 1;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (++routelen == MAXROUTE) {
|
if (++routelen == MAXROUTE)
|
||||||
bpath[0] = '?';
|
return "?";
|
||||||
bpath[1] = 0;
|
|
||||||
return bpath;
|
|
||||||
}
|
|
||||||
markedsectors = 0;
|
markedsectors = 0;
|
||||||
for (scanx = minx; scanx <= maxx; scanx++) {
|
for (scanx = minx; scanx <= maxx; scanx++) {
|
||||||
x = XNORM(scanx);
|
x = XNORM(scanx);
|
||||||
|
@ -229,7 +222,6 @@ bestownedpath(s_char *bpath,
|
||||||
maxx += 2;
|
maxx += 2;
|
||||||
} while (markedsectors);
|
} while (markedsectors);
|
||||||
|
|
||||||
bpath[0] = 0;
|
|
||||||
return NULL; /* no route possible */
|
return NULL; /* no route possible */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -712,7 +712,8 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
||||||
|
|
||||||
for (qp = airp.q_forw; qp != (&airp); qp = qp->q_forw) {
|
for (qp = airp.q_forw; qp != (&airp); qp = qp->q_forw) {
|
||||||
struct airport *air;
|
struct airport *air;
|
||||||
s_char pp[512];
|
char buf[512];
|
||||||
|
char *pp;
|
||||||
|
|
||||||
air = (struct airport *)qp;
|
air = (struct airport *)qp;
|
||||||
md = mapdist(x, y, air->x, air->y);
|
md = mapdist(x, y, air->x, air->y);
|
||||||
|
@ -734,14 +735,15 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
||||||
mission_flags = mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', 0,
|
mission_flags = mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', 0,
|
||||||
0, mission_flags, &tech);
|
0, mission_flags, &tech);
|
||||||
|
|
||||||
if (QEMPTY(&b)) {
|
if (QEMPTY(&b))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
mission_flags = mission_pln_arm(&e, air->x, air->y, 2 * md, 'p', 0,
|
mission_flags = mission_pln_arm(&e, air->x, air->y, 2 * md, 'p', 0,
|
||||||
P_F | P_ESC, mission_flags, &tech);
|
P_F | P_ESC, mission_flags, &tech);
|
||||||
|
|
||||||
BestAirPath(pp, air->x, air->y, x, y);
|
pp = BestAirPath(buf, air->x, air->y, x, y);
|
||||||
|
if (CANT_HAPPEN(!pp))
|
||||||
|
continue;
|
||||||
wu(0, plane_owner, "Flying %s mission from %s\n",
|
wu(0, plane_owner, "Flying %s mission from %s\n",
|
||||||
mission_name(mission), xyas(air->x, air->y, plane_owner));
|
mission_name(mission), xyas(air->x, air->y, plane_owner));
|
||||||
if (air->own && (air->own != plane_owner)) {
|
if (air->own && (air->own != plane_owner)) {
|
||||||
|
@ -1484,7 +1486,8 @@ air_defense(coord x, coord y, natid victim, struct emp_qelem *bomb_list,
|
||||||
struct genlist *glp;
|
struct genlist *glp;
|
||||||
struct genitem *gp;
|
struct genitem *gp;
|
||||||
struct genlist mi[MAXNOC];
|
struct genlist mi[MAXNOC];
|
||||||
s_char path[512];
|
char buf[512];
|
||||||
|
char *path;
|
||||||
int count;
|
int count;
|
||||||
int tcount;
|
int tcount;
|
||||||
|
|
||||||
|
@ -1618,7 +1621,9 @@ air_defense(coord x, coord y, natid victim, struct emp_qelem *bomb_list,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BestAirPath(path, air->x, air->y, x, y);
|
path = BestAirPath(buf, air->x, air->y, x, y);
|
||||||
|
if (CANT_HAPPEN(!path))
|
||||||
|
continue;
|
||||||
wu(0, cn, "Flying %s mission from %s\n",
|
wu(0, cn, "Flying %s mission from %s\n",
|
||||||
mission_name(MI_AIR_DEFENSE), xyas(air->x, air->y, cn));
|
mission_name(MI_AIR_DEFENSE), xyas(air->x, air->y, cn));
|
||||||
if (air->own && (air->own != cn)) {
|
if (air->own && (air->own != cn)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue