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:
parent
fec5ad692d
commit
542a9ef83f
4 changed files with 143 additions and 61 deletions
|
@ -447,6 +447,14 @@ edit_sect(struct sctstr *sect, char *key, int arg, char *p)
|
|||
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(arg));
|
||||
if (arg == 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(arg),
|
||||
cname(player->cnum));
|
||||
sect->sct_oldown = arg;
|
||||
break;
|
||||
case 'e':
|
||||
|
@ -529,9 +537,7 @@ edit_sect(struct sctstr *sect, char *key, int arg, char *p)
|
|||
break;
|
||||
case 'F':
|
||||
new = LIMIT_TO(arg, 0, FALLOUT_MAX);
|
||||
pr("Fallout for sector %s changed from %d to %d\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum),
|
||||
sect->sct_fallout, new);
|
||||
noise(sect, "Fallout", sect->sct_fallout, new);
|
||||
sect->sct_fallout = new;
|
||||
break;
|
||||
case 'a':
|
||||
|
@ -541,8 +547,13 @@ edit_sect(struct sctstr *sect, char *key, int arg, char *p)
|
|||
break;
|
||||
case 'M':
|
||||
new = LIMIT_TO(arg, 0, MINES_MAX);
|
||||
if (sect->sct_own == sect->sct_oldown)
|
||||
noise(sect, "Mines", sect->sct_mines, new);
|
||||
else
|
||||
pr("Mines of %s changed from %d to %d\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum),
|
||||
sect->sct_mines, new);
|
||||
sect->sct_mines = new;
|
||||
pr("Mines changed to %d\n", new);
|
||||
break;
|
||||
case 'L':
|
||||
if (!sarg_xy(p, &newx, &newy))
|
||||
|
@ -562,10 +573,20 @@ edit_sect(struct sctstr *sect, char *key, int arg, char *p)
|
|||
case 'D':
|
||||
if (!sarg_xy(p, &newx, &newy))
|
||||
return RET_SYN;
|
||||
pr("Distribution location for sector %s changed from %s to %s\n",
|
||||
pr("Distribution sector of sector %s changed from %s to %s\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum),
|
||||
xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum),
|
||||
xyas(newx, newy, player->cnum));
|
||||
if (newx == sect->sct_dist_x && newy == sect->sct_dist_y)
|
||||
break;
|
||||
if (sect->sct_own && sect->sct_own != player->cnum)
|
||||
wu(0, sect->sct_own,
|
||||
"Distribution sector of sector %s changed from %s to %s"
|
||||
" by an act of %s\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum),
|
||||
xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum),
|
||||
xyas(newx, newy, player->cnum),
|
||||
cname(player->cnum));
|
||||
sect->sct_dist_x = newx;
|
||||
sect->sct_dist_y = newy;
|
||||
break;
|
||||
|
@ -573,9 +594,18 @@ edit_sect(struct sctstr *sect, char *key, int arg, char *p)
|
|||
new = sct_typematch(p);
|
||||
if (new < 0)
|
||||
return RET_SYN;
|
||||
pr("Designation for sector %s changed from %c to %c\n",
|
||||
pr("Designation of sector %s changed from %c to %c\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum),
|
||||
dchr[sect->sct_type].d_mnem, dchr[new].d_mnem);
|
||||
if (new == sect->sct_type)
|
||||
break;
|
||||
if (sect->sct_own && sect->sct_own != player->cnum)
|
||||
wu(0, sect->sct_own,
|
||||
"Designation of sector %s changed from %c to %c"
|
||||
" by an act of %s\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum),
|
||||
dchr[sect->sct_type].d_mnem, dchr[new].d_mnem,
|
||||
cname(player->cnum));
|
||||
set_coastal(sect, sect->sct_type, new);
|
||||
sect->sct_type = new;
|
||||
break;
|
||||
|
@ -583,9 +613,18 @@ edit_sect(struct sctstr *sect, char *key, int arg, char *p)
|
|||
new = sct_typematch(p);
|
||||
if (new < 0)
|
||||
return RET_SYN;
|
||||
pr("New designation for sector %s changed from %c to %c\n",
|
||||
pr("New designation of sector %s changed from %c to %c\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum),
|
||||
dchr[sect->sct_newtype].d_mnem, dchr[new].d_mnem);
|
||||
if (new == sect->sct_newtype)
|
||||
break;
|
||||
if (sect->sct_own && sect->sct_own != player->cnum)
|
||||
wu(0, sect->sct_own,
|
||||
"New designation of sector %s changed from %c to %c"
|
||||
" by an act of %s\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum),
|
||||
dchr[sect->sct_newtype].d_mnem, dchr[new].d_mnem,
|
||||
cname(player->cnum));
|
||||
sect->sct_newtype = new;
|
||||
break;
|
||||
case 'R':
|
||||
|
|
|
@ -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(§, "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(§, "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(§, "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(§, "Workforce percentage", sect.sct_work, current);
|
||||
sect.sct_work = (unsigned char)current;
|
||||
break;
|
||||
case 'f':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue