From b99a116dd6ee48fc20610e299d8f3171e3b254e0 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 3 Feb 2013 13:16:48 +0100 Subject: [PATCH] edit: Report ship and land unit commodity change properly Print a message describing the actual change. Necessary to give the deity a chance to catch unexpected changes, e.g. a player unloading stuff right before the deity edits it, leaving fewer items than the deity intends to take. Watching out for such changes is especially important with non-interactive edit. Send bulletin to owner and report news exactly like the give command. Signed-off-by: Markus Armbruster --- src/lib/commands/edit.c | 12 ++++++++++++ tests/actofgod/actofgod.xdump | 1 + tests/actofgod/journal.log | 14 ++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/src/lib/commands/edit.c b/src/lib/commands/edit.c index b4f77354f..018e256c9 100644 --- a/src/lib/commands/edit.c +++ b/src/lib/commands/edit.c @@ -821,6 +821,12 @@ edit_ship(struct shpstr *ship, char *key, char *p) case 'r': ip = item_by_name(key); arg = LIMIT_TO(arg, 0, mchr[ship->shp_type].m_item[ip->i_uid]); + divine_unit_change_quiet((struct empobj *)ship, ip->i_name, + arg != ship->shp_item[ip->i_uid], + "from %d to %d", + ship->shp_item[ip->i_uid], arg); + report_divine_gift(ship->shp_own, ip, + arg - ship->shp_item[ip->i_uid], prship(ship)); ship->shp_item[ip->i_uid] = arg; break; default: @@ -925,6 +931,12 @@ edit_land(struct lndstr *land, char *key, char *p) case 'r': ip = item_by_name(key); arg = LIMIT_TO(arg, 0, lchr[land->lnd_type].l_item[ip->i_uid]); + divine_unit_change_quiet((struct empobj *)land, ip->i_name, + arg != land->lnd_item[ip->i_uid], + "from %d to %d", + land->lnd_item[ip->i_uid], arg); + report_divine_gift(land->lnd_own, ip, + arg - land->lnd_item[ip->i_uid], prland(land)); land->lnd_item[ip->i_uid] = arg; break; default: diff --git a/tests/actofgod/actofgod.xdump b/tests/actofgod/actofgod.xdump index d6a3652d2..76a3e5183 100644 --- a/tests/actofgod/actofgod.xdump +++ b/tests/actofgod/actofgod.xdump @@ -370,6 +370,7 @@ actor action victim times duration time 0 43 1 67 0 0 0 42 1 4 0 0 1 45 0 1 0 0 +0 42 3 4 0 0 0 43 3 1 0 0 /config config treaty diff --git a/tests/actofgod/journal.log b/tests/actofgod/journal.log index 13fa98545..1a71d6692 100644 --- a/tests/actofgod/journal.log +++ b/tests/actofgod/journal.log @@ -995,15 +995,19 @@ Play#0 output Play#0 6 0 640 Play#0 input edit s 2 m 0 Play#0 command edit + Play#0 output Play#0 1 military of cs cargo ship (#2) unchanged Play#0 output Play#0 6 0 640 Play#0 input edit s 3 m -1 Play#0 command edit + Play#0 output Play#0 1 military of cs cargo ship (#3) unchanged Play#0 output Play#0 6 0 640 Play#0 input edit s 4 m 50 Play#0 command edit + Play#0 output Play#0 1 military of cs cargo ship (#4) changed from 0 to 50 Play#0 output Play#0 6 0 640 Play#0 input edit s 5 m 51 Play#0 command edit + Play#0 output Play#0 1 military of cs cargo ship (#5) changed from 0 to 50 Play#0 output Play#0 6 0 640 Play#0 input edit p 2 e 0 Play#0 command edit @@ -1115,15 +1119,19 @@ Play#0 output Play#0 6 0 640 Play#0 input edit u 2 m 0 Play#0 command edit + Play#0 output Play#0 1 military of sup supply #2 unchanged Play#0 output Play#0 6 0 640 Play#0 input edit u 3 m -1 Play#0 command edit + Play#0 output Play#0 1 military of sup supply #3 unchanged Play#0 output Play#0 6 0 640 Play#0 input edit u 4 m 25 Play#0 command edit + Play#0 output Play#0 1 military of sup supply #4 changed from 0 to 25 Play#0 output Play#0 6 0 640 Play#0 input edit u 5 m 26 Play#0 command edit + Play#0 output Play#0 1 military of sup supply #5 changed from 0 to 25 Play#0 output Play#0 6 0 640 Play#0 input edit s 2 F ~ Play#0 command edit @@ -1206,8 +1214,10 @@ Play#0 input M 2 Play#0 output Play#0 4 %c xxxxx -- thing value : Play#0 input m 1 + Play#0 output Play#0 1 military of cs cargo ship (#0) changed from 0 to 1 Play#0 output Play#0 4 %c xxxxx -- thing value : Play#0 input f 1 + Play#0 output Play#0 1 food of cs cargo ship (#0) changed from 0 to 1 Play#0 output Play#0 4 %c xxxxx -- thing value : Play#0 input Play#0 output Play#0 1 POGO (#0) cs cargo ship (#0) @@ -1639,6 +1649,10 @@ 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 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 + Play#0 output Play#0 1 POGO gave you 25 military in sup supply #5 Play#0 output Play#0 1 Military reserves changed from 0 to 2147483647 by an act of POGO Play#0 output Play#0 1 Money changed from 0 to 2147483647 by an act of POGO Play#0 output Play#0 6 0 640 -- 2.43.0