attack assault board: Really require offensive strength

The server doesn't let you send land units without offensive strength
into combat: ask_olist() doesn't offer them.  But if their strength
gets somehow destroyed between ask_olist() and the actual fight, they
go anyway.

Check again before the fight, and leave land units without offensive
strength behind.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-07-24 13:59:52 +02:00
parent 406fdab125
commit 490b9392f0

View file

@ -1218,6 +1218,7 @@ get_ototal(int combat_mode, struct combat *off, struct emp_qelem *olist,
struct emp_qelem *qp, *next; struct emp_qelem *qp, *next;
struct ulist *llp; struct ulist *llp;
int n, w; int n, w;
double att_val;
/* /*
* first, total the attacking mil * first, total the attacking mil
@ -1240,6 +1241,18 @@ get_ototal(int combat_mode, struct combat *off, struct emp_qelem *olist,
llp = (struct ulist *)qp; llp = (struct ulist *)qp;
if (check && !get_oland(combat_mode, llp)) if (check && !get_oland(combat_mode, llp))
continue; continue;
att_val = attack_val(combat_mode, &llp->unit.land);
if (check && att_val < 1.0) {
/*
* No offensive strength, and fighting hasn't even begun.
* Since ask_olist() doesn't offer such land units, the
* strength must have been destroyed since then. Leave it
* behind.
*/
lnd_print(player->cnum, llp, "has no offensive strength");
lnd_put_one(llp);
continue;
}
if (combat_mode == A_ATTACK) { if (combat_mode == A_ATTACK) {
w = -1; w = -1;
for (n = 0; n <= off->last; ++n) { for (n = 0; n <= off->last; ++n) {
@ -1255,11 +1268,9 @@ get_ototal(int combat_mode, struct combat *off, struct emp_qelem *olist,
lnd_put_one(llp); lnd_put_one(llp);
continue; continue;
} }
ototal += attack_val(combat_mode, &llp->unit.land) * att_val *= att_combat_eff(off + w);
att_combat_eff(off + w);
} else {
ototal += attack_val(combat_mode, &llp->unit.land);
} }
ototal += att_val;
} }
ototal *= osupport; ototal *= osupport;