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;
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;
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);
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);
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);
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 ""');
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)