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:
parent
1fee5028a2
commit
c03db4c5ef
6 changed files with 53 additions and 47 deletions
|
@ -172,25 +172,27 @@ retreat_ship1(struct shpstr *sp, char code, int orig)
|
|||
}
|
||||
|
||||
getsect(sp->shp_x, sp->shp_y, §);
|
||||
switch (shp_check_nav(§, sp)) {
|
||||
case CN_CONSTRUCTION:
|
||||
switch (shp_check_nav(sp, §)) {
|
||||
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, §);
|
||||
if (shp_check_nav(§, sp) != CN_NAVIGABLE ||
|
||||
if (shp_check_nav(sp, §) != 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",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue