edit: Fix fortification limit of embarked planes and land units
We generally preserve the invariant "land units and missiles loaded on a land unit or ship are never fortified / hardened": fortify and harden refuse to touch embarked land units and missiles, load and lload zap land unit fortification on load, and refuse to load hardened missiles. The exception is edit, which happily fortifies embarked land units (edit u key 'F'), hardens embarked missiles (edit p key 'F'), loads fortified land units (edit u keys 'S' and 'Y') and hardened planes (edit p keys 's' and 'y'). Fix the first two by correcting the new value's upper limit to zero for embarked land units and planes. The next commit will take care of the rest. The fix is visible in tests where test setup fortifies land units with "edit u * F ?..." without excepting embarked ones. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
b2be5a227d
commit
f5514cb452
5 changed files with 17 additions and 10 deletions
|
@ -31,7 +31,7 @@
|
|||
* Chad Zabel, 1994
|
||||
* Steve McClure, 1998-2000
|
||||
* Ron Koenderink, 2003-2009
|
||||
* Markus Armbruster, 2003-2017
|
||||
* Markus Armbruster, 2003-2018
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -1001,6 +1001,8 @@ edit_land(struct lndstr *land, char *key, char *p)
|
|||
break;
|
||||
case 'F':
|
||||
arg = LIMIT_TO(arg, 0, 127);
|
||||
if (land->lnd_ship >= 0 || land->lnd_land >= 0)
|
||||
arg = 0;
|
||||
divine_unit_change((struct empobj *)land, "Fortification",
|
||||
arg != land->lnd_harden, arg - land->lnd_harden,
|
||||
"from %d to %d", land->lnd_harden, arg);
|
||||
|
@ -1134,7 +1136,10 @@ edit_plane(struct plnstr *plane, char *key, char *p)
|
|||
pln_set_tech(plane, arg);
|
||||
break;
|
||||
case 'F':
|
||||
arg = LIMIT_TO(arg, 0, pcp->pl_flags & P_M ? 127 : 0);
|
||||
arg = LIMIT_TO(arg, 0, 127);
|
||||
if (!(pcp->pl_flags & P_M)
|
||||
|| plane->pln_ship >= 0 || plane->pln_land >= 0)
|
||||
arg = 0;
|
||||
divine_unit_change((struct empobj *)plane, "Fortification",
|
||||
arg != plane->pln_harden, arg - plane->pln_harden,
|
||||
"from %d to %d", plane->pln_harden, arg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue