Unlike the other "may move" conditions, "same mobility type
(MOB_MARCH, MOB_RAIL) as leader" and "not on sale" are only checked
when collecting ships and land units.
The former breaks when a deity unwisely edits a land unit's type while
it is being marched. Messed up when the check was added in commit
36e41e5 (v4.3.7). However, editing has become possible only recently,
in commit
6b0b6f1.
The latter would break if a ship could be put on the market while it
is being navigated, but that's not possible, because only the owner
can navigate (see also commit
8c502d4), and only the owner can sell.
Same for land units. Messed up in 4.0.9. Clean it up anyway. Bonus:
nicer error message, even spelled correctly.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
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;
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;
}
{
struct lndstr land, *ldr = NULL;
struct ulist *llp;
- int this_mot;
- int mobtype = MOB_MOVE; /* indeterminate */
emp_initque(list);
while (nxtitem(ni, &land)) {
*/
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;
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;
*/
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;
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
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
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