From ccd436867915702890ea9340ddf1bd93b818d8e9 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 27 Jan 2013 15:37:51 +0100 Subject: [PATCH] edit: Report unit loss and gain properly for unit key 'O' Print a message describing the actual change. Necessary to give the deity a chance to catch unexpected changes, e.g. a player boarding a ship right before the deity edits it. Watching out for such changes is especially important with non-interactive edit. Code already sends bulletins. Also report news. Signed-off-by: Markus Armbruster --- src/lib/commands/edit.c | 15 +++++++-------- tests/actofgod/actofgod.xdump | 4 ++-- tests/actofgod/journal.log | 9 +++++++++ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/lib/commands/edit.c b/src/lib/commands/edit.c index 967c234fe..28877ad7e 100644 --- a/src/lib/commands/edit.c +++ b/src/lib/commands/edit.c @@ -754,14 +754,13 @@ edit_unit(struct empobj *unit, char *key, char *p, case 'O': if (arg < 0 || arg >= MAXNOC) return RET_SYN; - if (arg == unit->own) - break; - if (unit->own && unit->own != player->cnum) - wu(0, unit->own, "%s taken from you by an act of %s!\n", - unit_nameof(unit), cname(player->cnum)); - if (arg && arg != player->cnum) - wu(0, arg, "%s given to you by an act of %s!\n", - unit_nameof(unit), cname(player->cnum)); + divine_unit_change_quiet(unit, "Owner", arg != unit->own, + "from %s to %s", + prnatid(unit->own), prnatid(arg)); + if (arg != unit->own) { + report_god_takes("", unit_nameof(unit), unit->own); + report_god_gives("", unit_nameof(unit), arg); + } unit->own = arg; break; case 'L': diff --git a/tests/actofgod/actofgod.xdump b/tests/actofgod/actofgod.xdump index 76a3e5183..ac73f70f2 100644 --- a/tests/actofgod/actofgod.xdump +++ b/tests/actofgod/actofgod.xdump @@ -365,8 +365,8 @@ actor action victim times duration time 0 42 1 39 0 0 0 44 3 1 0 0 0 44 1 32 0 0 -0 43 2 2 0 0 -0 44 3 1 0 0 +0 43 2 5 0 0 +0 44 3 10 0 0 0 43 1 67 0 0 0 42 1 4 0 0 1 45 0 1 0 0 diff --git a/tests/actofgod/journal.log b/tests/actofgod/journal.log index 1a71d6692..e88857947 100644 --- a/tests/actofgod/journal.log +++ b/tests/actofgod/journal.log @@ -835,6 +835,7 @@ Play#0 output Play#0 6 0 640 Play#0 input edit s 0 O 0 Play#0 command edit + Play#0 output Play#0 1 Owner of cs cargo ship (#0) changed from 3 (#3) to POGO (#0) Play#0 output Play#0 6 0 640 Play#0 input edit s 0 O -1 Play#0 command edit @@ -842,6 +843,7 @@ Play#0 output Play#0 6 0 640 Play#0 input edit s 1 O 98 Play#0 command edit + Play#0 output Play#0 1 Owner of cs cargo ship (#1) changed from 3 (#3) to 98 (#98) Play#0 output Play#0 6 0 640 Play#0 input edit s 1 O 99 Play#0 command edit @@ -849,6 +851,7 @@ Play#0 output Play#0 6 0 640 Play#0 input edit s 2 O 2 Play#0 command edit + Play#0 output Play#0 1 Owner of cs cargo ship (#2) changed from 3 (#3) to 2 (#2) Play#0 output Play#0 6 0 640 Play#0 input edit s 3 U 5 U 3 Play#0 command edit @@ -870,6 +873,7 @@ Play#0 output Play#0 6 0 640 Play#0 input edit p 0 O 0 Play#0 command edit + Play#0 output Play#0 1 Owner of f1 Sopwith Camel #0 changed from 3 (#3) to POGO (#0) Play#0 output Play#0 6 0 640 Play#0 input edit p 0 O -1 Play#0 command edit @@ -877,6 +881,7 @@ Play#0 output Play#0 6 0 640 Play#0 input edit p 1 O 98 Play#0 command edit + Play#0 output Play#0 1 Owner of f1 Sopwith Camel #1 changed from 3 (#3) to 98 (#98) Play#0 output Play#0 6 0 640 Play#0 input edit p 1 O 99 Play#0 command edit @@ -884,6 +889,7 @@ Play#0 output Play#0 6 0 640 Play#0 input edit p 2 O 2 Play#0 command edit + Play#0 output Play#0 1 Owner of f1 Sopwith Camel #2 changed from 3 (#3) to 2 (#2) Play#0 output Play#0 6 0 640 Play#0 input edit p 3 U 5 U 3 Play#0 command edit @@ -905,6 +911,7 @@ Play#0 output Play#0 6 0 640 Play#0 input edit u 0 O 0 Play#0 command edit + Play#0 output Play#0 1 Owner of sup supply #0 changed from 3 (#3) to POGO (#0) Play#0 output Play#0 6 0 640 Play#0 input edit u 0 O -1 Play#0 command edit @@ -912,6 +919,7 @@ Play#0 output Play#0 6 0 640 Play#0 input edit u 1 O 98 Play#0 command edit + Play#0 output Play#0 1 Owner of sup supply #1 changed from 3 (#3) to 98 (#98) Play#0 output Play#0 6 0 640 Play#0 input edit u 1 O 99 Play#0 command edit @@ -919,6 +927,7 @@ Play#0 output Play#0 6 0 640 Play#0 input edit u 2 O 2 Play#0 command edit + Play#0 output Play#0 1 Owner of sup supply #2 changed from 3 (#3) to 2 (#2) Play#0 output Play#0 6 0 640 Play#0 input edit u 3 U 5 U 3 Play#0 command edit -- 2.43.0