(diridx): New. Use instead of chkdir() where direction characters
must be valid. Oopses on bad direction characters. (pathtoxy, ac_encounter): Bad direction characters used to lead to bad array subscript and potential disaster. (pathrange, path): Stop on DIR_STOP as well as on bad direction characters. This is just for consistency with other code; DIR_STOP should occur only last in a path here. (sail_nav_fleet, nav_ship): No change except for the oops.
This commit is contained in:
parent
a88f12017e
commit
dfa56cb0ef
6 changed files with 31 additions and 18 deletions
|
@ -303,14 +303,11 @@ nav_ship(struct shpstr *sp)
|
|||
stopping = 0;
|
||||
|
||||
while (*cp && !stopping && sp->shp_own && mlp->mobil > 0.0) {
|
||||
dir = chkdir(*cp++, DIR_STOP, DIR_LAST);
|
||||
|
||||
dir = diridx(*cp++);
|
||||
stopping |= shp_nav_one_sector(&ship_list, dir,
|
||||
sp->shp_own, 0);
|
||||
}
|
||||
|
||||
/* sp->shp_mobil = (int) mobil;
|
||||
*/
|
||||
/* Ship not sunk */
|
||||
if (sp->shp_own)
|
||||
nav_check_atdest(sp);
|
||||
|
|
|
@ -262,10 +262,10 @@ sail_nav_fleet(struct fltheadstr *fltp)
|
|||
own = sp->shp_own;
|
||||
fltp_to_list(fltp, &ship_list); /* hack -KHS 1995 */
|
||||
for (s = sp->shp_path; (*s) && (fltp->maxmoves > 0); s++) {
|
||||
dir = chkdir(*s, DIR_STOP, DIR_LAST);
|
||||
if (0 != (error = shp_nav_one_sector(&ship_list, dir, own, 0)))
|
||||
dir = diridx(*s);
|
||||
if (0 != shp_nav_one_sector(&ship_list, dir, own, 0))
|
||||
fltp->maxmoves = 1;
|
||||
--(fltp->maxmoves);
|
||||
--fltp->maxmoves;
|
||||
}
|
||||
shp_put(&ship_list, own);
|
||||
getship(sp->shp_uid, &ship);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue