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

@ -92,14 +92,6 @@ struct sctstr {
unsigned char sct_defense; /* Defensive value of a sector */
};
enum d_navigation {
NAV_NONE, /* ships can't navigate */
NAVOK, /* ships can always navigate */
NAV_02, /* requires 2% effic to navigate */
NAV_CANAL, /* requires 2% effic to navigate and M_CANAL capability */
NAV_60 /* requires 60% effic to navigate */
};
struct dchrstr {
unsigned char d_uid;
char d_mnem; /* map symbol */

View file

@ -155,12 +155,6 @@ extern struct mchrstr mchr[SHP_TYPE_MAX + 2];
/* Work required for building 100% */
#define SHP_BLD_WORK(lcm, hcm) (20 + (lcm) + 2 * (hcm))
/* return codes from shp_check_nav */
#define CN_NAVIGABLE 0
#define CN_LANDLOCKED 1
#define CN_CONSTRUCTION 2
#define CN_ERROR -1
enum {
SHP_AIROPS_EFF = 50, /* min. efficiency for air ops */
SHP_TORP_SHELLS = 3 /* number of shells used by a torpedo */
@ -191,7 +185,7 @@ extern double shp_torp_hitchance(struct shpstr *, int);
extern void shp_sel(struct nstr_item *, struct emp_qelem *);
extern void shp_nav(struct emp_qelem *, double *, double *, int *, natid);
extern int shp_sweep(struct emp_qelem *, int, int, natid);
extern int shp_check_nav(struct sctstr *, struct shpstr *);
extern enum d_navigation shp_check_nav(struct shpstr *, struct sctstr *);
extern int sect_has_dock(struct sctstr *);
extern int shp_hardtarget(struct shpstr *);
extern int shp_nav_one_sector(struct emp_qelem *, int, natid, int);

View file

@ -36,6 +36,14 @@
typedef unsigned char natid; /* NSC_NATID must match this */
typedef short coord;
enum d_navigation {
NAV_NONE, /* ships can't navigate */
NAVOK, /* ships can always navigate */
NAV_02, /* requires 2% effic to navigate */
NAV_CANAL, /* requires 2% effic to navigate and M_CANAL capability */
NAV_60 /* requires 60% effic to navigate */
};
struct bp;
struct emp_qelem;
struct empobj;