diff --git a/src/lib/commands/edit.c b/src/lib/commands/edit.c index bea5d312..5cda12de 100644 --- a/src/lib/commands/edit.c +++ b/src/lib/commands/edit.c @@ -736,7 +736,7 @@ edit_nat(struct natstr *np, char *key, char *p) static int edit_unit(struct empobj *unit, char *key, char *p, - int mineff, char *group_name) + int mineff, char *group_name, int on_carrier) { int arg = atoi(p); coord newx, newy; @@ -779,6 +779,10 @@ edit_unit(struct empobj *unit, char *key, char *p, case 'L': if (!sarg_xy(p, &newx, &newy)) return RET_SYN; + if (on_carrier && (newx != unit->x || newy != unit->y)) { + pr("Can't move %s while it's loaded\n", unit_nameof(unit)); + return RET_FAIL; + } unit->x = newx; unit->y = newy; break; @@ -823,7 +827,7 @@ edit_ship(struct shpstr *ship, char *key, char *p) case 'M': case 'F': return edit_unit((struct empobj *)ship, key, p, - SHIP_MINEFF, "fleet"); + SHIP_MINEFF, "fleet", 0); case 'T': arg = LIMIT_TO(arg, mcp->m_tech, SHRT_MAX); shp_set_tech(ship, arg); @@ -887,7 +891,8 @@ edit_land(struct lndstr *land, char *key, char *p) case 'M': case 'a': return edit_unit((struct empobj *)land, key, p, - LAND_MINEFF, "army"); + LAND_MINEFF, "army", + land->lnd_ship >= 0 || land->lnd_land >= 0); case 't': arg = LIMIT_TO(arg, lcp->l_tech, SHRT_MAX); lnd_set_tech(land, arg); @@ -979,7 +984,8 @@ edit_plane(struct plnstr *plane, char *key, char *p) case 'm': case 'w': return edit_unit((struct empobj *)plane, key, p, - PLANE_MINEFF, "wing"); + PLANE_MINEFF, "wing", + plane->pln_ship >= 0 || plane->pln_land >= 0); case 't': arg = LIMIT_TO(arg, pcp->pl_tech, SHRT_MAX); pln_set_tech(plane, arg); diff --git a/tests/actofgod/geninput.pl b/tests/actofgod/geninput.pl index f5f168ff..c81bef23 100755 --- a/tests/actofgod/geninput.pl +++ b/tests/actofgod/geninput.pl @@ -308,6 +308,9 @@ sub unit_carrier { unit_carrier('plane', 's', 'y'); unit_carrier('land', 'S', 'Y'); +# special case: move carrier's cargo away +edit('plane', 4, 'l', '5,1'); + # interactive edit iedit('ship', 0, 'M 2', 'm 1', 'f 1'); iedit('ship', 0, 'R n', 'R ""'); diff --git a/tests/actofgod/journal.log b/tests/actofgod/journal.log index ce8d0e05..df353a58 100644 --- a/tests/actofgod/journal.log +++ b/tests/actofgod/journal.log @@ -1229,6 +1229,11 @@ Play#0 output Play#0 1 sup supply #4 unloaded from ship #4 Play#0 output Play#0 1 sup supply #4 loaded onto land #4 Play#0 output Play#0 6 0 640 + Play#0 input edit p 4 l 5,1 + Play#0 command edit + Play#0 output Play#0 1 Can't move f1 Sopwith Camel #4 while it's loaded + Play#0 output Play#0 1 command failed + Play#0 output Play#0 6 0 640 Play#0 input edit s 0 Play#0 command edit Play#0 output Play#0 1 POGO (#0) cs cargo ship (#0)