diff --git a/include/combat.h b/include/combat.h index 5ced9ff2..0f24ae0f 100644 --- a/include/combat.h +++ b/include/combat.h @@ -28,6 +28,7 @@ * * Known contributors to this file: * Ken Stevens, 1995 + * Markus Armbruster, 2005-2016 */ #ifndef COMBAT_H @@ -69,6 +70,8 @@ struct combat { /* src/lib/subs/attsub.c */ extern double att_combat_eff(struct combat *); +extern void att_move_land(int, struct combat *, struct emp_qelem *, + struct combat *); extern void att_move_in_off(int, struct combat *, struct emp_qelem *, struct combat *); extern int att_combat_init(struct combat *, int); diff --git a/src/lib/commands/assa.c b/src/lib/commands/assa.c index 43b585c5..e2d0a23b 100644 --- a/src/lib/commands/assa.c +++ b/src/lib/commands/assa.c @@ -41,7 +41,8 @@ #include "unit.h" static int only_spies(struct combat[], struct emp_qelem *); -static void sneak_ashore(struct emp_qelem *, struct combat *); +static void sneak_ashore(struct combat[], struct emp_qelem *, + struct combat *); int assa(void) @@ -139,7 +140,7 @@ assa(void) /* If no attacking forces (i.e. we got here with only spies) * then try to sneak on-land. */ if (only_spies(off, &olist)) { - sneak_ashore(&olist, def); + sneak_ashore(off, &olist, def); return RET_OK; } @@ -191,7 +192,8 @@ only_spies(struct combat off[], struct emp_qelem *olist) } static void -sneak_ashore(struct emp_qelem *olist, struct combat *def) +sneak_ashore(struct combat off[], struct emp_qelem *olist, + struct combat *def) { struct emp_qelem *qp; struct ulist *llp; @@ -200,15 +202,14 @@ sneak_ashore(struct emp_qelem *olist, struct combat *def) pr("Trying to sneak on shore...\n"); + att_move_land(A_ASSAULT, off, olist, def); + for (qp = olist->q_forw; qp != olist; qp = qp->q_forw) { llp = (struct ulist *)qp; lp = &llp->unit.land; rel = relations_with(def->own, player->cnum); if (chance(0.10) || rel == ALLIED || !def->own) { pr("%s made it on shore safely.\n", prland(lp)); - lp->lnd_x = def->x; - lp->lnd_y = def->y; - lp->lnd_ship = -1; } else { pr("%s was spotted", prland(lp)); if (rel <= HOSTILE) { @@ -222,9 +223,6 @@ sneak_ashore(struct emp_qelem *olist, struct combat *def) cname(player->cnum), xyas(def->x, def->y, def->own)); pr(" but made it ok.\n"); - lp->lnd_x = def->x; - lp->lnd_y = def->y; - lp->lnd_ship = -1; } } } diff --git a/src/lib/subs/attsub.c b/src/lib/subs/attsub.c index 59f7258f..f0c18647 100644 --- a/src/lib/subs/attsub.c +++ b/src/lib/subs/attsub.c @@ -2299,15 +2299,12 @@ ask_move_in(struct combat *off, struct emp_qelem *olist, move_in_land(A_ATTACK, off, olist, def); } -/* Move offensive land units to the conquered sector or ship */ - -static void -move_in_land(int combat_mode, struct combat *off, struct emp_qelem *olist, - struct combat *def) +void +att_move_land(int combat_mode, struct combat *off, struct emp_qelem *olist, + struct combat *def) { struct emp_qelem *qp, *next; struct ulist *llp; - char buf[512]; for (qp = olist->q_forw; qp != olist; qp = next) { next = qp->q_forw; @@ -2322,6 +2319,19 @@ move_in_land(int combat_mode, struct combat *off, struct emp_qelem *olist, else llp->unit.land.lnd_ship = -1; } +} + +/* Move offensive land units to the conquered sector or ship */ + +static void +move_in_land(int combat_mode, struct combat *off, struct emp_qelem *olist, + struct combat *def) +{ + struct emp_qelem *qp, *next; + struct ulist *llp; + char buf[512]; + + att_move_land(combat_mode, off, olist, def); if (def->type == EF_SECTOR) { if (opt_INTERDICT_ATT) {