diff --git a/src/lib/commands/edit.c b/src/lib/commands/edit.c index 7f5ed1a1..8dea6090 100644 --- a/src/lib/commands/edit.c +++ b/src/lib/commands/edit.c @@ -740,16 +740,29 @@ edit_unit(struct empobj *unit, char *key, char *p, { int arg = atoi(p); coord newx, newy; + union empobj_storage newunit; switch (toupper(*key)) { case 'U': if (arg < 0) return RET_SYN; + if (arg == unit->uid) { + pr("%s unchanged\n", unit_nameof(unit)); + break; + } if (!ef_ensure_space(unit->ef_type, arg, 50)) { pr("Can't copy to %s #%d\n", ef_nameof(unit->ef_type), arg); return RET_FAIL; } + pr("%s duplicated to (#%d)\n", unit_nameof(unit), arg); ef_set_uid(unit->ef_type, unit, arg); + if (get_empobj(unit->ef_type, arg, &newunit) && newunit.gen.own) { + pr("Replacing %s of %s\n", + unit_nameof(&newunit.gen), prnatid(newunit.gen.own)); + report_god_takes("", unit_nameof(&newunit.gen), + newunit.gen.own); + } + report_god_gives("", unit_nameof(unit), unit->own); break; case 'O': if (arg < 0 || arg >= MAXNOC) diff --git a/tests/actofgod/actofgod.xdump b/tests/actofgod/actofgod.xdump index ac73f70f..fedfee8d 100644 --- a/tests/actofgod/actofgod.xdump +++ b/tests/actofgod/actofgod.xdump @@ -366,12 +366,12 @@ actor action victim times duration time 0 44 3 1 0 0 0 44 1 32 0 0 0 43 2 5 0 0 -0 44 3 10 0 0 +0 44 3 13 0 0 0 43 1 67 0 0 0 42 1 4 0 0 1 45 0 1 0 0 +0 43 3 7 0 0 0 42 3 4 0 0 -0 43 3 1 0 0 /config config treaty uid cna cnb status acond bcond exp diff --git a/tests/actofgod/journal.log b/tests/actofgod/journal.log index c80a004b..397cedd5 100644 --- a/tests/actofgod/journal.log +++ b/tests/actofgod/journal.log @@ -855,9 +855,13 @@ Play#0 output Play#0 6 0 640 Play#0 input edit s 3 U 5 U 3 Play#0 command edit + Play#0 output Play#0 1 cs cargo ship (#3) duplicated to (#5) + Play#0 output Play#0 1 cs cargo ship (#5) duplicated to (#3) + Play#0 output Play#0 1 Replacing cs cargo ship (#3) of 3 (#3) Play#0 output Play#0 6 0 640 Play#0 input edit s 0 U 0 U -1 Play#0 command edit + Play#0 output Play#0 1 cs cargo ship (#0) unchanged Play#0 output Play#0 1 Usage: edit [ ]... Play#0 output Play#0 6 0 640 Play#0 input edit s 2 L 3,-1 @@ -893,9 +897,13 @@ Play#0 output Play#0 6 0 640 Play#0 input edit p 3 U 5 U 3 Play#0 command edit + Play#0 output Play#0 1 f1 Sopwith Camel #3 duplicated to (#5) + Play#0 output Play#0 1 f1 Sopwith Camel #5 duplicated to (#3) + Play#0 output Play#0 1 Replacing f1 Sopwith Camel #3 of 3 (#3) Play#0 output Play#0 6 0 640 Play#0 input edit p 0 U 0 U -1 Play#0 command edit + Play#0 output Play#0 1 f1 Sopwith Camel #0 unchanged Play#0 output Play#0 1 Usage: edit [ ]... Play#0 output Play#0 6 0 640 Play#0 input edit p 2 l 3,-1 @@ -931,9 +939,13 @@ Play#0 output Play#0 6 0 640 Play#0 input edit u 3 U 5 U 3 Play#0 command edit + Play#0 output Play#0 1 sup supply #3 duplicated to (#5) + Play#0 output Play#0 1 sup supply #5 duplicated to (#3) + Play#0 output Play#0 1 Replacing sup supply #3 of 3 (#3) Play#0 output Play#0 6 0 640 Play#0 input edit u 0 U 0 U -1 Play#0 command edit + Play#0 output Play#0 1 sup supply #0 unchanged Play#0 output Play#0 1 Usage: edit [ ]... Play#0 output Play#0 6 0 640 Play#0 input edit u 2 L 3,-1 @@ -1652,12 +1664,21 @@ Play#0 output Play#0 1 cs cargo ship (#0) taken from you by an act of POGO! Play#0 output Play#0 1 cs cargo ship (#1) taken from you by an act of POGO! Play#0 output Play#0 1 cs cargo ship (#2) taken from you by an act of POGO! + Play#0 output Play#0 1 cs cargo ship (#5) given to you by an act of POGO! + Play#0 output Play#0 1 cs cargo ship (#3) taken from you by an act of POGO! + Play#0 output Play#0 1 cs cargo ship (#3) given to you by an act of POGO! Play#0 output Play#0 1 f1 Sopwith Camel #0 taken from you by an act of POGO! Play#0 output Play#0 1 f1 Sopwith Camel #1 taken from you by an act of POGO! Play#0 output Play#0 1 f1 Sopwith Camel #2 taken from you by an act of POGO! + Play#0 output Play#0 1 f1 Sopwith Camel #5 given to you by an act of POGO! + Play#0 output Play#0 1 f1 Sopwith Camel #3 taken from you by an act of POGO! + Play#0 output Play#0 1 f1 Sopwith Camel #3 given to you by an act of POGO! Play#0 output Play#0 1 sup supply #0 taken from you by an act of POGO! Play#0 output Play#0 1 sup supply #1 taken from you by an act of POGO! Play#0 output Play#0 1 sup supply #2 taken from you by an act of POGO! + Play#0 output Play#0 1 sup supply #5 given to you by an act of POGO! + Play#0 output Play#0 1 sup supply #3 taken from you by an act of POGO! + Play#0 output Play#0 1 sup supply #3 given to you by an act of POGO! Play#0 output Play#0 1 POGO gave you 50 military in cs cargo ship (#4) Play#0 output Play#0 1 POGO gave you 50 military in cs cargo ship (#5) Play#0 output Play#0 1 POGO gave you 25 military in sup supply #4