]> git.pond.sub.org Git - empserver/commitdiff
edit: Report unit loss and gain properly for key 'U'
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 27 Jan 2013 17:10:48 +0000 (18:10 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 6 Jun 2013 17:55:02 +0000 (19:55 +0200)
Send bulletin to owner and report news exactly like for key 'O' or
sector key 'L'.

Print a "duplicated" message, just for consistency with other keys.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/commands/edit.c
tests/actofgod/actofgod.xdump
tests/actofgod/journal.log

index 7f5ed1a1393638daa57731259ac1b673fe27cd27..8dea60900fdc5866356123005b8a5a2a4a8e709f 100644 (file)
@@ -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)
index ac73f70f23f410270410a20e67f79c96a583cbaa..fedfee8d7d20f66e63035db9b752a5b419270703 100644 (file)
@@ -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
index c80a004bb2062043be10b3fd3b6051e7bca73286..397cedd5c212dee559fe4562ec26bb941557bb7b 100644 (file)
     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 <country|land|ship|plane|unit> <NAT|SECT|SHIP|PLANE|LAND> [<KEY> <VALUE>]...
     Play#0 output Play#0 6 0 640
     Play#0 input edit s 2 L 3,-1
     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 <country|land|ship|plane|unit> <NAT|SECT|SHIP|PLANE|LAND> [<KEY> <VALUE>]...
     Play#0 output Play#0 6 0 640
     Play#0 input edit p 2 l 3,-1
     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 <country|land|ship|plane|unit> <NAT|SECT|SHIP|PLANE|LAND> [<KEY> <VALUE>]...
     Play#0 output Play#0 6 0 640
     Play#0 input edit u 2 L 3,-1
     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