edit &c: Add remaining missing sector change reporting

edit, setresource and setsector report change in three ways:

* Print a message.

* Send a bulletin to the changed object's owner.  This should be done
  if and only if the change is visible to the owner, e.g. in census or
  xdump.

* Report divine aid in news.  This should be done if and only if a
  bulletin was sent, except for changes that are neither negative nor
  positive, such as changing the distribution sector.

Fix the places that don't get it right for sectors:

    cmd  key    sctstr member   before  after   notes
    -------------------------------------------------
    edit l O    sct_oldown      --      B-
    edit l F    sct_fallout     --      BN      1
    edit l M    sct_mines       --      BN      2 3
    edit l D    sct_dist_x,y    --      B-      1
    edit l s    sct_type        --      B-      1
    edit l S    sct_newtype     --      B-      1
    setse ow    sct_own         B-      BN
    setse ol    sct_oldown      --      B-
    setse e     sct_effic       --      BN      2
    setse mo    sct_mobil       --      BN      2
    setse a     sct_avail       --      BN      2
    setse w     sct_work        --      BN      2

The two characters in columns before, after show whether the command
sends a bulletin (B) or not (-), and whether it reports news (N) or
not (-).

Notes:

1. Printed message massaged slightly for consistency with other keys.

2. Printed message improved to show the old value, too.  Necessary to
   give the deity a chance to catch unexpected changes, e.g. a player
   laying mines right before the deity edits them.  Watching out for
   such changes is especially important with non-interactive edit.

3. Bulletin and news suppressed for occupied sectors.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2013-01-26 11:45:18 +01:00
parent fec5ad692d
commit 542a9ef83f
4 changed files with 143 additions and 61 deletions

View file

@ -38,6 +38,7 @@
#include "news.h"
#include "optlist.h"
static void resbenefit(natid, int);
/*
* format: setres thing <sect> <#>
@ -107,12 +108,15 @@ setsector(void)
"Sector %s taken from you by an act of %s!\n",
xyas(sect.sct_x, sect.sct_y, sect.sct_own),
cname(player->cnum));
resbenefit(sect.sct_own, -1);
}
if (amt && amt != player->cnum)
if (amt && amt != player->cnum) {
wu(0, amt,
"Sector %s given to you by an act of %s!\n",
xyas(sect.sct_x, sect.sct_y, amt),
cname(player->cnum));
resbenefit(amt, 1);
}
sect.sct_own = (natid)amt;
break;
case 'l':
@ -121,6 +125,15 @@ setsector(void)
pr("Old owner of %s changed from %s to %s.\n",
xyas(sect.sct_x, sect.sct_y, player->cnum),
prnatid(sect.sct_oldown), prnatid(amt));
if (amt == sect.sct_oldown)
break;
if (sect.sct_own && sect.sct_own != player->cnum)
wu(0, sect.sct_own,
"Old owner of %s changed from %s to %s"
" by an act of %s\n",
xyas(sect.sct_x, sect.sct_y, player->cnum),
prnatid(sect.sct_oldown), prnatid(amt),
cname(player->cnum));
sect.sct_oldown = (natid)amt;
break;
default:
@ -132,8 +145,7 @@ setsector(void)
current = sect.sct_effic;
current += amt;
current = LIMIT_TO(current, 0, 100);
pr("Efficiency in %s changed to %d.\n",
xyas(sect.sct_x, sect.sct_y, player->cnum), current);
resnoise(&sect, "Efficiency", sect.sct_effic, current);
sect.sct_effic = current;
break;
case 'm':
@ -154,8 +166,7 @@ setsector(void)
current = sect.sct_mobil;
current += amt;
current = LIMIT_TO(current, -127, 127);
pr("Mobility in %s changed to %d.\n",
xyas(sect.sct_x, sect.sct_y, player->cnum), current);
resnoise(&sect, "Mobility", sect.sct_mobil, current);
sect.sct_mobil = current;
break;
default:
@ -167,16 +178,14 @@ setsector(void)
current = sect.sct_avail;
current += amt;
current = LIMIT_TO(current, 0, 9999);
pr("Available in %s changed to %d.\n",
xyas(sect.sct_x, sect.sct_y, player->cnum), current);
resnoise(&sect, "Available workforce", sect.sct_avail, current);
sect.sct_avail = (short)current;
break;
case 'w':
current = sect.sct_work;
current += amt;
current = LIMIT_TO(current, 0, 100);
pr("Work in %s changed to %d.\n",
xyas(sect.sct_x, sect.sct_y, player->cnum), current);
resnoise(&sect, "Workforce percentage", sect.sct_work, current);
sect.sct_work = (unsigned char)current;
break;
case 'f':