diff --git a/src/lib/subs/lndsub.c b/src/lib/subs/lndsub.c index b5a4d113..0fd6b783 100644 --- a/src/lib/subs/lndsub.c +++ b/src/lib/subs/lndsub.c @@ -404,12 +404,19 @@ int lnd_may_mar(struct lndstr *lp, struct lndstr *ldr, char *suffix) { struct sctstr sect; + int mobtype; if (!lp->lnd_own || !getsect(lp->lnd_x, lp->lnd_y, §)) { CANT_REACH(); return 0; } + if (opt_MARKET && ontradingblock(EF_LAND, lp)) { + mpr(lp->lnd_own, "%s is on the trading block%s\n", + prland(lp), suffix); + return 0; + } + if (lp->lnd_ship >= 0) { mpr(lp->lnd_own, "%s is on a ship%s\n", prland(lp), suffix); return 0; @@ -455,6 +462,25 @@ lnd_may_mar(struct lndstr *lp, struct lndstr *ldr, char *suffix) prland(lp), suffix); return 0; } + + /* + * The marching code gets confused when trains and non-trains + * march together. Disallow for now. + */ + mobtype = lnd_mobtype(lp); + if (!ldr || mobtype == lnd_mobtype(ldr)) + ; + else if (mobtype == MOB_RAIL) { + mpr(lp->lnd_own, + "%s is a train and can't march with the leader%s\n", + prland(lp), suffix); + return 0; + } else { + mpr(lp->lnd_own, "%s can't rail-march with the leading train%s\n", + prland(lp), suffix); + return 0; + } + return 1; } @@ -463,8 +489,6 @@ lnd_sel(struct nstr_item *ni, struct emp_qelem *list) { struct lndstr land, *ldr = NULL; struct ulist *llp; - int this_mot; - int mobtype = MOB_MOVE; /* indeterminate */ emp_initque(list); while (nxtitem(ni, &land)) { @@ -475,33 +499,8 @@ lnd_sel(struct nstr_item *ni, struct emp_qelem *list) */ if (!land.lnd_own || land.lnd_own != player->cnum) continue; - if (opt_MARKET) { - if (ontradingblock(EF_LAND, &land)) { - pr("unit #%d inelligible - it's for sale.\n", - land.lnd_uid); - continue; - } - } if (!lnd_may_mar(&land, ldr, "")) continue; - /* - * The marching code gets confused when trains and non-trains - * march together. Disallow for now. - */ - this_mot = lnd_mobtype(&land); - if (this_mot != mobtype) { - if (mobtype == MOB_MOVE) - mobtype = this_mot; - else if (mobtype == MOB_MARCH) { - pr("%s is a train and can't march with the leader.\n", - prland(&land)); - continue; - } else { - pr("%s can't rail-march with the leading train.\n", - prland(&land)); - continue; - } - } land.lnd_mission = 0; land.lnd_rflags = 0; diff --git a/src/lib/subs/shpsub.c b/src/lib/subs/shpsub.c index 92e5f0b8..1ab137f1 100644 --- a/src/lib/subs/shpsub.c +++ b/src/lib/subs/shpsub.c @@ -82,6 +82,12 @@ shp_may_nav(struct shpstr *sp, struct shpstr *flg, char *suffix) return 0; } + if (opt_MARKET && ontradingblock(EF_SHIP, sp)) { + mpr(sp->shp_own, "%s is on the trading block%s\n", + prship(sp), suffix); + return 0; + } + if (sp->shp_item[I_MILIT] == 0 && sp->shp_item[I_CIVIL] == 0) { mpr(sp->shp_own, "%s is crewless%s\n", prship(sp), suffix); return 0; @@ -126,13 +132,6 @@ shp_sel(struct nstr_item *ni, struct emp_qelem *list) */ if (!ship.shp_own || ship.shp_own != player->cnum) continue; - if (opt_MARKET) { - if (ontradingblock(EF_SHIP, &ship)) { - pr("ship #%d inelligible - it's for sale.\n", - ship.shp_uid); - continue; - } - } if (!shp_may_nav(&ship, flg, "")) continue; diff --git a/tests/navi-march/journal.log b/tests/navi-march/journal.log index cd747459..96557690 100644 --- a/tests/navi-march/journal.log +++ b/tests/navi-march/journal.log @@ -64,7 +64,7 @@ Play#1 output Play#1 6 0 638 Play#1 input navi 12/10/19/11/13 Play#1 command navigate - Play#1 output Play#1 1 ship #12 inelligible - it's for sale. + Play#1 output Play#1 1 pt patrol boat (#12) is on the trading block Play#1 output Play#1 1 pt patrol boat (#13) is crewless Play#1 output Play#1 1 Flagship is pt patrol boat (#10) Play#1 output Play#1 1 . i @@ -750,7 +750,7 @@ Play#1 output Play#1 6 0 588 Play#1 input march 12/10/19/11/13/14/15 Play#1 command march - Play#1 output Play#1 1 unit #12 inelligible - it's for sale. + Play#1 output Play#1 1 cav cavalry #12 is on the trading block Play#1 output Play#1 1 cav cavalry #13 has no mil on it to guide it Play#1 output Play#1 1 cav cavalry #14 is on a ship Play#1 output Play#1 1 cav cavalry #15 is on a unit @@ -764,13 +764,13 @@ Play#1 output Play#1 6 0 587 Play#1 input march 20/22 jh Play#1 command march - Play#1 output Play#1 1 tra train #22 is a train and can't march with the leader. + Play#1 output Play#1 1 tra train #22 is a train and can't march with the leader Play#1 output Play#1 1 Leader is cav cavalry #20 Play#1 output Play#1 1 cav cavalry #20 stopped at 3,3 Play#1 output Play#1 6 0 586 Play#1 input march 22/21/23 jh Play#1 command march - Play#1 output Play#1 1 cav cavalry #21 can't rail-march with the leading train. + Play#1 output Play#1 1 cav cavalry #21 can't rail-march with the leading train Play#1 output Play#1 1 Leader is tra train #22 Play#1 output Play#1 1 tra train #22 stopped at 3,3 Play#1 output Play#1 1 tra train #23 stopped at 3,3