march: Check for sector abandonment before anyone marches

Unlike the move command, march checks sector abandonment before every
step.

If the player declines, the last land unit stays put and is removed
from the march.

Except when sectors or land units change while we're waiting for the
player's reply.  Then the last unit is not removed from the march.
This can scatter land units.  Screwed up when checking for abandoning
the sector was added in 4.2.2.

Change march to work like move, and to avoid scattering land units: if
the player declines to abandon the sector, the command simply fails.

Put the check into new lnd_abandon_askyn().

Extend would_abandon() and want_to_abandon() from a single land unit
to many.  Rename the latter to abandon_askyn() for consistency.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2014-12-28 21:55:44 +01:00
parent 3b9f2a149b
commit 7c1b1661f5
11 changed files with 71 additions and 47 deletions

View file

@ -196,6 +196,7 @@ extern void lnd_mar(struct emp_qelem *, double *, double *, int *, natid);
extern void lnd_put(struct emp_qelem *);
extern void lnd_put_one(struct ulist *);
extern int lnd_hardtarget(struct lndstr *);
extern int lnd_abandon_askyn(struct emp_qelem *);
extern int lnd_mar_one_sector(struct emp_qelem *, int, natid, int);
extern int lnd_support(natid, natid, coord, coord, int);
extern int lnd_can_attack(struct lndstr *);

View file

@ -404,8 +404,8 @@ extern int check_trade_ok(struct trdstr *);
extern void set_coastal(struct sctstr *, int, int);
/* control.c */
extern int military_control(struct sctstr *);
extern int want_to_abandon(struct sctstr *, i_type, int, struct lndstr *);
extern int would_abandon(struct sctstr *, i_type, int, struct lndstr *);
extern int abandon_askyn(struct sctstr *, i_type, int, struct ulist *);
extern int would_abandon(struct sctstr *, i_type, int, struct ulist *);
/* damage.c */
extern void landdamage(struct lndstr *, int);
extern void ship_damage(struct shpstr *, int);