(fuel, load, shp_check_nav, retreat_ship1, shp_nav_one_sector)
(shp_check_nav, sail_nav_fleet, bigcity_dchr[], sector_navigation[]) (d_navigation): Add a NEW d_navigation enum NAV_CANAL to indicate that a sector has canal capability. Add canal determination logic to shp_check_nav(). Update sector_navigation[] with new canal navigation enum. Use shp_check_nav() to determine the sector can be navigated.
This commit is contained in:
parent
82df8cfe0c
commit
74e4e2810a
9 changed files with 44 additions and 45 deletions
|
@ -684,7 +684,7 @@ extern int shp_sweep(struct emp_qelem *, int, natid);
|
||||||
extern s_char *shp_path(int, struct shpstr *, s_char *);
|
extern s_char *shp_path(int, struct shpstr *, s_char *);
|
||||||
extern void shp_put(struct emp_qelem *, natid);
|
extern void shp_put(struct emp_qelem *, natid);
|
||||||
extern void shp_list(struct emp_qelem *);
|
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 sect_has_dock(struct sctstr *);
|
||||||
extern int shp_hardtarget(struct shpstr *);
|
extern int shp_hardtarget(struct shpstr *);
|
||||||
extern void shp_view(struct emp_qelem *);
|
extern void shp_view(struct emp_qelem *);
|
||||||
|
|
|
@ -93,6 +93,7 @@ typedef enum {
|
||||||
NAV_NONE, /* ships can't navigate */
|
NAV_NONE, /* ships can't navigate */
|
||||||
NAVOK, /* ships can always navigate */
|
NAVOK, /* ships can always navigate */
|
||||||
NAV_02, /* requires 2% effic to 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 */
|
NAV_60 /* requires 60% effic to navigate */
|
||||||
} d_navigation;
|
} d_navigation;
|
||||||
|
|
||||||
|
|
|
@ -121,13 +121,9 @@ fuel(void)
|
||||||
if (!item.ship.shp_own)
|
if (!item.ship.shp_own)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((sect.sct_type != SCT_HARBR)
|
if (shp_check_nav(§, &item.ship) == CN_LANDLOCKED) {
|
||||||
&& (sect.sct_type != SCT_WATER)
|
pr("%s is landlocked and cannot be fueled.\n",
|
||||||
&& (sect.sct_type != SCT_BSPAN)
|
prship(&item.ship));
|
||||||
&& (!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));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,8 +153,8 @@ load(void)
|
||||||
if (noisy)
|
if (noisy)
|
||||||
pr("Sector %s is not a harbor%s%s.\n",
|
pr("Sector %s is not a harbor%s%s.\n",
|
||||||
xyas(ship.shp_x, ship.shp_y, player->cnum),
|
xyas(ship.shp_x, ship.shp_y, player->cnum),
|
||||||
dchr[SCT_CAPIT].d_nav == NAV_02 ? " or a " : "",
|
dchr[SCT_CAPIT].d_nav == NAV_CANAL ? " or a " : "",
|
||||||
dchr[SCT_CAPIT].d_nav == NAV_02 ?
|
dchr[SCT_CAPIT].d_nav == NAV_CANAL ?
|
||||||
dchr[SCT_CAPIT].d_name : "");
|
dchr[SCT_CAPIT].d_name : "");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -787,6 +787,7 @@ struct symbol sector_navigation[] = { /* for d_nav */
|
||||||
{NAV_NONE, "land"},
|
{NAV_NONE, "land"},
|
||||||
{NAVOK, "sea"},
|
{NAVOK, "sea"},
|
||||||
{NAV_02, "harbor"},
|
{NAV_02, "harbor"},
|
||||||
|
{NAV_CANAL, "canal"},
|
||||||
{NAV_60, "bridge"},
|
{NAV_60, "bridge"},
|
||||||
{0, NULL}
|
{0, NULL}
|
||||||
};
|
};
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
#include "product.h"
|
#include "product.h"
|
||||||
|
|
||||||
struct dchrstr bigcity_dchr = {
|
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[] = {
|
struct dchrstr dchr[] = {
|
||||||
|
|
|
@ -188,7 +188,7 @@ retreat_ship1(struct shpstr *sp, s_char code, int orig)
|
||||||
}
|
}
|
||||||
|
|
||||||
getsect(sp->shp_x, sp->shp_y, §);
|
getsect(sp->shp_x, sp->shp_y, §);
|
||||||
switch (shp_check_nav(§)) {
|
switch (shp_check_nav(§, sp)) {
|
||||||
case CN_CONSTRUCTION:
|
case CN_CONSTRUCTION:
|
||||||
wu(0, sp->shp_own,
|
wu(0, sp->shp_own,
|
||||||
"%s %s,\nbut was caught in a construction zone, and couldn't retreat!\n",
|
"%s %s,\nbut was caught in a construction zone, and couldn't retreat!\n",
|
||||||
|
@ -262,7 +262,7 @@ retreat_ship1(struct shpstr *sp, s_char code, int orig)
|
||||||
mobcost = 480.0 / (mobcost + techfact(sp->shp_tech, mobcost));
|
mobcost = 480.0 / (mobcost + techfact(sp->shp_tech, mobcost));
|
||||||
|
|
||||||
getsect(newx, newy, §);
|
getsect(newx, newy, §);
|
||||||
if (shp_check_nav(§) != CN_NAVIGABLE ||
|
if (shp_check_nav(§, sp) != CN_NAVIGABLE ||
|
||||||
(sect.sct_own && !player->owner &&
|
(sect.sct_own && !player->owner &&
|
||||||
getrel(getnatp(sect.sct_own), sp->shp_own) < FRIENDLY)) {
|
getrel(getnatp(sect.sct_own), sp->shp_own) < FRIENDLY)) {
|
||||||
wu(0, sp->shp_own, "%s %s,\nbut could not retreat to %s!\n",
|
wu(0, sp->shp_own, "%s %s,\nbut could not retreat to %s!\n",
|
||||||
|
|
|
@ -156,7 +156,7 @@ shp_nav(struct emp_qelem *list, double *minmobp, double *maxmobp,
|
||||||
shp_mess("was sucked into the sky by a strange looking spaceship", mlp); /* heh -KHS */
|
shp_mess("was sucked into the sky by a strange looking spaceship", mlp); /* heh -KHS */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
switch (shp_check_nav(§)) {
|
switch (shp_check_nav(§, &ship)) {
|
||||||
case CN_CONSTRUCTION:
|
case CN_CONSTRUCTION:
|
||||||
shp_mess("is caught in a construction zone", mlp);
|
shp_mess("is caught in a construction zone", mlp);
|
||||||
continue;
|
continue;
|
||||||
|
@ -368,12 +368,18 @@ shp_mess(s_char *str, struct mlist *mlp)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
shp_check_nav(struct sctstr *sect)
|
shp_check_nav(struct sctstr *sect, struct shpstr *shp)
|
||||||
{
|
{
|
||||||
switch (dchr[sect->sct_type].d_nav) {
|
switch (dchr[sect->sct_type].d_nav) {
|
||||||
case NAVOK:
|
case NAVOK:
|
||||||
break;
|
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:
|
case NAV_02:
|
||||||
if (sect->sct_effic < 2)
|
if (sect->sct_effic < 2)
|
||||||
return CN_CONSTRUCTION;
|
return CN_CONSTRUCTION;
|
||||||
|
@ -821,6 +827,7 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor,
|
||||||
double tech; /* for mapping */
|
double tech; /* for mapping */
|
||||||
double tf; /* for mapping */
|
double tf; /* for mapping */
|
||||||
s_char dp[80];
|
s_char dp[80];
|
||||||
|
int navigate;
|
||||||
|
|
||||||
if (dir <= DIR_STOP || dir >= DIR_VIEW) {
|
if (dir <= DIR_STOP || dir >= DIR_VIEW) {
|
||||||
shp_put(list, actor);
|
shp_put(list, actor);
|
||||||
|
@ -834,27 +841,27 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor,
|
||||||
newx = xnorm(mlp->ship.shp_x + dx);
|
newx = xnorm(mlp->ship.shp_x + dx);
|
||||||
newy = ynorm(mlp->ship.shp_y + dy);
|
newy = ynorm(mlp->ship.shp_y + dy);
|
||||||
getsect(newx, newy, §);
|
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 &&
|
(sect.sct_own && actor != sect.sct_own &&
|
||||||
getrel(getnatp(sect.sct_own), actor) < FRIENDLY)) {
|
getrel(getnatp(sect.sct_own), actor) < FRIENDLY)) {
|
||||||
if (together) {
|
if (dchr[sect.sct_type].d_nav == NAV_CANAL &&
|
||||||
mpr(actor, "can't go to %s\n", xyas(newx, newy, actor));
|
!(mlp->mcp->m_flags & M_CANAL) &&
|
||||||
return 2;
|
navigate == CN_LANDLOCKED)
|
||||||
} 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)) {
|
|
||||||
sprintf(dp,
|
sprintf(dp,
|
||||||
"is too large to fit into the canal system at %s",
|
"is too large to fit into the canal system at %s",
|
||||||
xyas(newx, newy, actor));
|
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);
|
shp_mess(dp, mlp);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mlp->mobil <= 0.0) {
|
if (mlp->mobil <= 0.0) {
|
||||||
shp_mess("is out of mobility", mlp);
|
shp_mess("is out of mobility", mlp);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -216,7 +216,6 @@ sail_nav_fleet(struct fltheadstr *fltp)
|
||||||
natid own;
|
natid own;
|
||||||
struct emp_qelem ship_list;
|
struct emp_qelem ship_list;
|
||||||
int dir;
|
int dir;
|
||||||
int canal = 1;
|
|
||||||
|
|
||||||
#ifdef SAILDEBUG
|
#ifdef SAILDEBUG
|
||||||
switch (fltp->real_q) {
|
switch (fltp->real_q) {
|
||||||
|
@ -239,6 +238,7 @@ sail_nav_fleet(struct fltheadstr *fltp)
|
||||||
wu(0, fltp->own, " %d", fe->num);
|
wu(0, fltp->own, " %d", fe->num);
|
||||||
wu(0, fltp->own, "\n");
|
wu(0, fltp->own, "\n");
|
||||||
#endif
|
#endif
|
||||||
|
sectp = getsectp(fltp->x, fltp->y);
|
||||||
for (fe = fltp->head; fe; fe = fe->next) {
|
for (fe = fltp->head; fe; fe = fe->next) {
|
||||||
sp = getshipp(fe->num);
|
sp = getshipp(fe->num);
|
||||||
if (sp->shp_item[I_MILIT] == 0 && sp->shp_item[I_CIVIL] == 0) {
|
if (sp->shp_item[I_MILIT] == 0 && sp->shp_item[I_CIVIL] == 0) {
|
||||||
|
@ -246,28 +246,22 @@ sail_nav_fleet(struct fltheadstr *fltp)
|
||||||
" ship #%d (%s) is crewless and can't go on\n",
|
" ship #%d (%s) is crewless and can't go on\n",
|
||||||
fe->num, cname(fe->own));
|
fe->num, cname(fe->own));
|
||||||
error = 1;
|
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)
|
if (error)
|
||||||
return 0;
|
return 0;
|
||||||
|
sp = getshipp(fltp->leader);
|
||||||
sectp = getsectp(fltp->x, fltp->y);
|
sectp = getsectp(fltp->x, fltp->y);
|
||||||
switch (shp_check_nav(sectp)) {
|
if (shp_check_nav(sectp, sp) != CN_NAVIGABLE)
|
||||||
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:
|
|
||||||
wu(0, fltp->own, "Your fleet lead by %d is trapped by land.\n",
|
wu(0, fltp->own, "Your fleet lead by %d is trapped by land.\n",
|
||||||
fltp->leader);
|
fltp->leader);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
sp = getshipp(fltp->leader);
|
sp = getshipp(fltp->leader);
|
||||||
own = sp->shp_own;
|
own = sp->shp_own;
|
||||||
fltp_to_list(fltp, &ship_list); /* hack -KHS 1995 */
|
fltp_to_list(fltp, &ship_list); /* hack -KHS 1995 */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue