No functional change.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
* Dave Pare
* Ken Stevens, 1995
* Steve McClure, 1998
- * Markus Armbruster, 2004-2010
+ * Markus Armbruster, 2004-2014
*/
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 */
SHP_TORP_SHELLS = 3 /* number of shells used by a torpedo */
};
+/* Whether and why a ship is stuck in a sector */
+enum shp_stuck {
+ SHP_STUCK_NOT, /* not stuck */
+ SHP_STUCK_CONSTRUCTION, /* sector not efficient enough */
+ SHP_STUCK_CANAL, /* ship lacks M_CANAL */
+ SHP_STUCK_IMPASSABLE /* sector type not navigable */
+};
+
extern int m_armor(struct mchrstr *, int);
extern int m_speed(struct mchrstr *, int);
extern int m_visib(struct mchrstr *, int);
extern struct ulist *shp_insque(struct shpstr *, 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 enum d_navigation shp_check_nav(struct shpstr *, struct sctstr *);
+extern enum shp_stuck 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);
* types.h: Empire types
*
* Known contributors to this file:
- * Markus Armbruster, 2006-2013
+ * Markus Armbruster, 2006-2014
*/
#ifndef TYPES_H
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;
getsect(sp->shp_x, sp->shp_y, §);
switch (shp_check_nav(sp, §)) {
- case NAV_02:
- case NAV_60:
+ case SHP_STUCK_NOT:
+ break;
+ case SHP_STUCK_CONSTRUCTION:
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]);
return 0;
- 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]);
- return 0;
- case NAVOK:
- break;
default:
CANT_REACH();
+ /* fall through */
+ case SHP_STUCK_CANAL:
+ case SHP_STUCK_IMPASSABLE:
wu(0, sp->shp_own,
- "%s %s,\nbut was subject to an empire error, and couldn't retreat!\n",
+ "%s %s,\nbut was landlocked, and couldn't retreat!\n",
prship(sp), conditions[findcondition(code)].desc[orig]);
return 0;
}
mobcost = shp_mobcost(sp);
getsect(newx, newy, §);
- if (shp_check_nav(sp, §) != NAVOK ||
+ if (shp_check_nav(sp, §) != SHP_STUCK_NOT ||
(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",
continue;
}
switch (shp_check_nav(sp, §)) {
- case NAV_02:
- case NAV_60:
+ case SHP_STUCK_NOT:
+ break;
+ case SHP_STUCK_CONSTRUCTION:
shp_stays(actor, "is caught in a construction zone", mlp);
continue;
- case NAV_NONE:
- case NAV_CANAL:
- shp_stays(actor, "is landlocked", mlp);
- continue;
- case NAVOK:
- break;
default:
CANT_REACH();
- shp_stays(actor, "was just swallowed by a big green worm", mlp);
+ /* fall through */
+ case SHP_STUCK_CANAL:
+ case SHP_STUCK_IMPASSABLE:
+ shp_stays(actor, "is landlocked", mlp);
continue;
}
if (first) {
}
/*
- * Can SP navigate in SECTP?
- * Sector ownership is *not* considered!
- * Return NAVOK when yes.
- * Return NAV_02 when it could if the sector was at least 2% efficient.
- * Return NAV_60 when it could if the sector was at least 60% efficient.
- * Return NAV_CANAL when it lacks capability M_CANAL.
- * Return NAV_NONE when this sector type isn't navigable at all.
+ * Return whether and why SP would be stuck in SECTP.
*/
-enum d_navigation
+enum shp_stuck
shp_check_nav(struct shpstr *sp, struct sctstr *sectp)
{
switch (dchr[sectp->sct_type].d_nav) {
case NAVOK:
break;
case NAV_CANAL:
- if (mchr[sp->shp_type].m_flags & M_CANAL) {
- if (sectp->sct_effic < 2)
- return NAV_02;
- } else
- return NAV_CANAL;
- break;
+ if (!(mchr[sp->shp_type].m_flags & M_CANAL)) {
+ return SHP_STUCK_CANAL;
+ }
+ /* fall through */
case NAV_02:
if (sectp->sct_effic < 2)
- return NAV_02;
+ return SHP_STUCK_CONSTRUCTION;
break;
case NAV_60:
if (sectp->sct_effic < 60)
- return NAV_60;
+ return SHP_STUCK_CONSTRUCTION;
break;
default:
CANT_REACH();
+ /* fall through */
case NAV_NONE:
- return NAV_NONE;
+ return SHP_STUCK_IMPASSABLE;
}
- return NAVOK;
+ return SHP_STUCK_NOT;
}
int
coord newx;
coord newy;
int move;
+ enum shp_stuck stuck;
int stopping = 0;
double mobcost;
char dp[80];
- int navigate;
if (dir <= DIR_STOP || dir >= DIR_VIEW) {
shp_nav_put(list, actor);
newx = xnorm(mlp->unit.ship.shp_x + dx);
newy = ynorm(mlp->unit.ship.shp_y + dy);
getsect(newx, newy, §);
- navigate = shp_check_nav(&mlp->unit.ship, §);
- if (navigate == NAVOK &&
+ stuck = shp_check_nav(&mlp->unit.ship, §);
+ if (stuck == SHP_STUCK_NOT &&
(!sect.sct_own
|| relations_with(sect.sct_own, actor) >= FRIENDLY))
move = 1;
newx = xnorm(mlp->unit.ship.shp_x + dx);
newy = ynorm(mlp->unit.ship.shp_y + dy);
getsect(newx, newy, §);
- navigate = shp_check_nav(&mlp->unit.ship, §);
- if (navigate != NAVOK ||
+ stuck = shp_check_nav(&mlp->unit.ship, §);
+ if (stuck != SHP_STUCK_NOT ||
(sect.sct_own
&& relations_with(sect.sct_own, actor) < FRIENDLY)) {
- if (navigate == NAV_CANAL)
+ if (stuck == SHP_STUCK_CANAL)
sprintf(dp,
"is too large to fit into the canal system at %s",
xyas(newx, newy, actor));