]> git.pond.sub.org Git - empserver/commitdiff
edit: Report ship and land unit commodity change properly
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 3 Feb 2013 12:16:48 +0000 (13:16 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 6 Jun 2013 17:55:01 +0000 (19:55 +0200)
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 <armbru@pond.sub.org>
src/lib/commands/edit.c
tests/actofgod/actofgod.xdump
tests/actofgod/journal.log

index b4f77354f160045bc5d2baeb96dccace1a5074da..018e256c9a2f07922582b850a393b1c5e0949189 100644 (file)
@@ -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]);
     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:
        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]);
     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:
        land->lnd_item[ip->i_uid] = arg;
        break;
     default:
index d6a3652d22c54f28a0e5f81848c7ca4d72d45f32..76a3e5183429a029fd6657f0cb096c59d72e5d1c 100644 (file)
@@ -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 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
 0 43 3 1 0 0
 /config
 config treaty
index 13fa985456725ff2c61b4e69757030d134a823e0..1a71d6692aa44f2dba153de3b426407f8a0fb4fa 100644 (file)
     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 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 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 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 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
     Play#0 output Play#0 6 0 640
     Play#0 input edit p 2 e 0
     Play#0 command edit
     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 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 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 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 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
     Play#0 output Play#0 6 0 640
     Play#0 input edit s 2 F ~
     Play#0 command edit
     Play#0 input M 2
     Play#0 output Play#0 4 %c xxxxx -- thing value : 
     Play#0 input m 1
     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 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)
     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)
     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 #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
     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