shpsub: Make shp_check_nav() return more useful information

Some callers have to second-guess shp_check_nav() to figure out
whether CN_LANDLOCKED means "too big to fit into the canal" or "can't
go there at all".

Fix that by returning d_navigation.  CN_LANDLOCKED becomes either
NAV_CANAL or NAV_NONE, CN_CONSTRUCTION becomes either NAV_02 or
NAV_60, and CN_NAVIGABLE becomes NAVOK.

The CN_NAVIGABLE, ... codes are now unused.  Drop them.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2014-01-20 22:34:17 +01:00
parent 1fee5028a2
commit c03db4c5ef
6 changed files with 53 additions and 47 deletions

View file

@ -172,25 +172,27 @@ retreat_ship1(struct shpstr *sp, char code, int orig)
}
getsect(sp->shp_x, sp->shp_y, &sect);
switch (shp_check_nav(&sect, sp)) {
case CN_CONSTRUCTION:
switch (shp_check_nav(sp, &sect)) {
case NAV_02:
case NAV_60:
wu(0, sp->shp_own,
"%s %s,\nbut was caught in a construction zone, and couldn't retreat!\n",
prship(sp), conditions[findcondition(code)].desc[orig]);
if (!orig)
putship(sp->shp_uid, sp);
return 0;
case CN_LANDLOCKED:
case NAV_NONE:
case NAV_CANAL:
wu(0, sp->shp_own,
"%s %s,\nbut was landlocked, and couldn't retreat!\n",
prship(sp), conditions[findcondition(code)].desc[orig]);
if (!orig)
putship(sp->shp_uid, sp);
return 0;
case CN_NAVIGABLE:
case NAVOK:
break;
case CN_ERROR:
default:
CANT_REACH();
wu(0, sp->shp_own,
"%s %s,\nbut was subject to an empire error, and couldn't retreat!\n",
prship(sp), conditions[findcondition(code)].desc[orig]);
@ -242,7 +244,7 @@ retreat_ship1(struct shpstr *sp, char code, int orig)
mobcost = shp_mobcost(sp);
getsect(newx, newy, &sect);
if (shp_check_nav(&sect, sp) != CN_NAVIGABLE ||
if (shp_check_nav(sp, &sect) != NAVOK ||
(sect.sct_own
&& relations_with(sect.sct_own, sp->shp_own) < FRIENDLY)) {
wu(0, sp->shp_own, "%s %s,\nbut could not retreat to %s!\n",