extern s_char *shp_path(int, struct shpstr *, s_char *);
extern void shp_put(struct emp_qelem *, natid);
extern void shp_list(struct emp_qelem *);
-extern int shp_check_nav(struct sctstr *);
+extern int shp_check_nav(struct sctstr *, struct shpstr *);
extern int sect_has_dock(struct sctstr *);
extern int shp_hardtarget(struct shpstr *);
extern void shp_view(struct emp_qelem *);
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 */
} d_navigation;
if (!item.ship.shp_own)
continue;
- if ((sect.sct_type != SCT_HARBR)
- && (sect.sct_type != SCT_WATER)
- && (sect.sct_type != SCT_BSPAN)
- && (!IS_BIG_CITY(sect.sct_type))) {
- pr("Sector %s is not a harbor, bridge span, or sea.\n",
- xyas(item.ship.shp_x, item.ship.shp_y,
- item.ship.shp_own));
+ if (shp_check_nav(§, &item.ship) == CN_LANDLOCKED) {
+ pr("%s is landlocked and cannot be fueled.\n",
+ prship(&item.ship));
continue;
}
if (noisy)
pr("Sector %s is not a harbor%s%s.\n",
xyas(ship.shp_x, ship.shp_y, player->cnum),
- dchr[SCT_CAPIT].d_nav == NAV_02 ? " or a " : "",
- dchr[SCT_CAPIT].d_nav == NAV_02 ?
+ dchr[SCT_CAPIT].d_nav == NAV_CANAL ? " or a " : "",
+ dchr[SCT_CAPIT].d_nav == NAV_CANAL ?
dchr[SCT_CAPIT].d_name : "");
continue;
}
{NAV_NONE, "land"},
{NAVOK, "sea"},
{NAV_02, "harbor"},
+ {NAV_CANAL, "canal"},
{NAV_60, "bridge"},
{0, NULL}
};
#include "product.h"
struct dchrstr bigcity_dchr = {
- SCT_CAPIT, 'c', 0, 2, NAV_02, UPKG, 1.0, 2.0, 30, 0, 10, 1, 2, 999, "city"
+ SCT_CAPIT, 'c', 0, 2, NAV_CANAL, UPKG, 1.0, 2.0, 30, 0, 10, 1, 2, 999, "city"
};
struct dchrstr dchr[] = {
}
getsect(sp->shp_x, sp->shp_y, §);
- switch (shp_check_nav(§)) {
+ switch (shp_check_nav(§, sp)) {
case CN_CONSTRUCTION:
wu(0, sp->shp_own,
"%s %s,\nbut was caught in a construction zone, and couldn't retreat!\n",
mobcost = 480.0 / (mobcost + techfact(sp->shp_tech, mobcost));
getsect(newx, newy, §);
- if (shp_check_nav(§) != CN_NAVIGABLE ||
+ if (shp_check_nav(§, sp) != CN_NAVIGABLE ||
(sect.sct_own && !player->owner &&
getrel(getnatp(sect.sct_own), sp->shp_own) < FRIENDLY)) {
wu(0, sp->shp_own, "%s %s,\nbut could not retreat to %s!\n",
shp_mess("was sucked into the sky by a strange looking spaceship", mlp); /* heh -KHS */
continue;
}
- switch (shp_check_nav(§)) {
+ switch (shp_check_nav(§, &ship)) {
case CN_CONSTRUCTION:
shp_mess("is caught in a construction zone", mlp);
continue;
}
int
-shp_check_nav(struct sctstr *sect)
+shp_check_nav(struct sctstr *sect, struct shpstr *shp)
{
switch (dchr[sect->sct_type].d_nav) {
case NAVOK:
break;
-
+ case NAV_CANAL:
+ if (mchr[(int)shp->shp_type].m_flags & M_CANAL == M_CANAL) {
+ if (sect->sct_effic < 2)
+ return CN_CONSTRUCTION;
+ } else
+ return CN_LANDLOCKED;
+ break;
case NAV_02:
if (sect->sct_effic < 2)
return CN_CONSTRUCTION;
double tech; /* for mapping */
double tf; /* for mapping */
s_char dp[80];
+ int navigate;
if (dir <= DIR_STOP || dir >= DIR_VIEW) {
shp_put(list, actor);
newx = xnorm(mlp->ship.shp_x + dx);
newy = ynorm(mlp->ship.shp_y + dy);
getsect(newx, newy, §);
- if (shp_check_nav(§) != CN_NAVIGABLE ||
+ navigate = shp_check_nav(§, &mlp->ship);
+ if (navigate != CN_NAVIGABLE ||
(sect.sct_own && actor != sect.sct_own &&
getrel(getnatp(sect.sct_own), actor) < FRIENDLY)) {
- if (together) {
- mpr(actor, "can't go to %s\n", xyas(newx, newy, actor));
- return 2;
- } else {
- sprintf(dp, "can't go to %s", xyas(newx, newy, actor));
- shp_mess(dp, mlp);
- continue;
- }
- }
- if (IS_BIG_CITY(sect.sct_type)) {
- if (!(mlp->mcp->m_flags & M_CANAL)) {
+ if (dchr[sect.sct_type].d_nav == NAV_CANAL &&
+ !(mlp->mcp->m_flags & M_CANAL) &&
+ navigate == CN_LANDLOCKED)
sprintf(dp,
"is too large to fit into the canal system at %s",
xyas(newx, newy, actor));
+ else
+ sprintf(dp, "can't go to %s", xyas(newx, newy, actor));
+ if (together) {
+ mpr(actor, "%s\n", dp);
+ return 2;
+ } else {
shp_mess(dp, mlp);
continue;
}
}
+
if (mlp->mobil <= 0.0) {
shp_mess("is out of mobility", mlp);
continue;
natid own;
struct emp_qelem ship_list;
int dir;
- int canal = 1;
#ifdef SAILDEBUG
switch (fltp->real_q) {
wu(0, fltp->own, " %d", fe->num);
wu(0, fltp->own, "\n");
#endif
+ sectp = getsectp(fltp->x, fltp->y);
for (fe = fltp->head; fe; fe = fe->next) {
sp = getshipp(fe->num);
if (sp->shp_item[I_MILIT] == 0 && sp->shp_item[I_CIVIL] == 0) {
" ship #%d (%s) is crewless and can't go on\n",
fe->num, cname(fe->own));
error = 1;
- } else if (!(mchr[sp->shp_type].m_flags & M_CANAL))
- canal = 0;
+ }
+ if ((shp_check_nav(sectp, sp) == CN_LANDLOCKED) &&
+ (dchr[sectp->sct_type].d_nav == NAV_CANAL)) {
+ wu(0, fltp->own,
+ "Your ship #%d (%s) is too big to fit through the canal.\n",
+ fe->num, cname(fe->own));
+ error = 1;
+ }
}
if (error)
return 0;
+ sp = getshipp(fltp->leader);
sectp = getsectp(fltp->x, fltp->y);
- switch (shp_check_nav(sectp)) {
- case CN_NAVIGABLE:
- if (IS_BIG_CITY(sectp->sct_type) && !canal) {
- wu(0, fltp->own,
- "Your fleet lead by %d is too big to fit through the canal.\n",
- fltp->leader);
- return 0;
- }
- break;
- case CN_CONSTRUCTION:
- case CN_LANDLOCKED:
- default:
+ if (shp_check_nav(sectp, sp) != CN_NAVIGABLE)
wu(0, fltp->own, "Your fleet lead by %d is trapped by land.\n",
fltp->leader);
- return 0;
- }
sp = getshipp(fltp->leader);
own = sp->shp_own;
fltp_to_list(fltp, &ship_list); /* hack -KHS 1995 */