]> git.pond.sub.org Git - empserver/commitdiff
edit &c: Suppress news and bulletins on no-op acts of god
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 22 Jan 2013 20:33:40 +0000 (21:33 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 6 Jun 2013 17:55:00 +0000 (19:55 +0200)
give already suppresses when the new value equals the old one, but
edit, setresource and setsector don't.  Make them.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/commands/edit.c
src/lib/commands/setsect.c
tests/actofgod/actofgod.xdump
tests/actofgod/journal.log

index 85a876102c908039268050872b0a817749660f69..f8d4f99ca8e2242eb63db336cdc619f4ad2e8d78 100644 (file)
@@ -225,18 +225,10 @@ edit(void)
 }
 
 static void
-benefit(natid who, int good)
+benefit(natid who, int goodness)
 {
-    if (!opt_GODNEWS)
-       return;
-
-    if (good) {
-       if (who)
-           nreport(player->cnum, N_AIDS, who, 1);
-    } else {
-       if (who)
-           nreport(player->cnum, N_HURTS, who, 1);
-    }
+    if (opt_GODNEWS && who && goodness)
+       nreport(player->cnum, goodness > 0 ? N_AIDS : N_HURTS, who, 1);
 }
 
 static void
@@ -244,12 +236,12 @@ noise(struct sctstr *sptr, char *name, int old, int new)
 {
     pr("%s of %s changed from %d to %d\n",
        name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
-    if (sptr->sct_own)
+    if (sptr->sct_own && new != old)
        wu(0, sptr->sct_own,
           "%s in %s was changed from %d to %d by an act of %s\n",
           name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
           old, new, cname(player->cnum));
-    benefit(sptr->sct_own, old < new);
+    benefit(sptr->sct_own, new - old);
 }
 
 static void
@@ -437,13 +429,15 @@ edit_sect(struct sctstr *sect, char *key, int arg, char *p)
        pr("Owner of %s changed from %s to %s.\n",
           xyas(sect->sct_x, sect->sct_y, player->cnum),
           prnatid(sect->sct_own), prnatid(arg));
+       if (arg == sect->sct_own)
+           break;
        if (sect->sct_own) {
            wu(0, sect->sct_own,
               "Sector %s taken from you by an act of %s!\n",
               xyas(sect->sct_x, sect->sct_y, sect->sct_own),
               cname(player->cnum));
        }
-       benefit(sect->sct_own, 0);
+       benefit(sect->sct_own, -1);
        sect->sct_own = arg;
        if (arg) {
            wu(0, arg,
@@ -644,9 +638,11 @@ edit_nat(struct natstr *np, char *key, int arg, char *p)
        break;
     case 'm':
        arg = LIMIT_TO(arg, 0, INT_MAX);
-       benefit(nat, np->nat_reserve < arg);
+       benefit(nat, arg - np->nat_reserve);
        pr("Military reserves changed from %d to %d\n",
           np->nat_reserve, arg);
+       if (arg == np->nat_reserve)
+           break;
        wu(0, nat,
           "Military reserves changed from %d to %d by an act of %s\n",
           np->nat_reserve, arg, cname(player->cnum));
@@ -681,6 +677,8 @@ edit_nat(struct natstr *np, char *key, int arg, char *p)
        break;
     case 'M':
        pr("Money changed from %d to %d\n", np->nat_money, arg);
+       if (arg == np->nat_money)
+           break;
        wu(0, nat, "Money changed from %d to %d by an act of %s\n",
           np->nat_money, arg, cname(player->cnum));
        np->nat_money = arg;
@@ -746,6 +744,8 @@ edit_ship(struct shpstr *ship, char *key, int arg, char *p)
     case 'O':
        if (arg < 0 || arg >= MAXNOC)
            return RET_SYN;
+       if (arg == ship->shp_own)
+           break;
        if (ship->shp_own)
            wu(0, ship->shp_own, "%s taken from you by an act of %s!\n",
               prship(ship), cname(player->cnum));
@@ -827,6 +827,8 @@ edit_land(struct lndstr *land, char *key, int arg, char *p)
     case 'O':
        if (arg < 0 || arg >= MAXNOC)
            return RET_SYN;
+       if (arg == land->lnd_own)
+           break;
        if (land->lnd_own)
            wu(0, land->lnd_own, "%s taken from you by an act of %s!\n",
               prland(land), cname(player->cnum));
@@ -925,6 +927,8 @@ edit_plane(struct plnstr *plane, char *key, int arg, char *p)
     case 'O':
        if (arg < 0 || arg >= MAXNOC)
            return RET_SYN;
+       if (arg == plane->pln_own)
+           break;
        if (plane->pln_own)
            wu(0, plane->pln_own, "%s taken from you by an act of %s!\n",
               prplane(plane), cname(player->cnum));
index 0a7dedc79ddcd52962df59c16a36926b5b35af5b..686913f256c29f5618a644d30af55918df387436 100644 (file)
@@ -103,6 +103,8 @@ setsector(void)
                pr("Owner of %s changed from %s to %s.\n",
                   xyas(sect.sct_x, sect.sct_y, player->cnum),
                   prnatid(sect.sct_own), prnatid(amt));
+               if (amt == sect.sct_own)
+                   break;
                if (sect.sct_own) {
                    wu(0, sect.sct_own,
                       "Sector %s taken from you by an act of %s!\n",
@@ -202,18 +204,10 @@ setsector(void)
 }
 
 static void
-resbenefit(natid who, int good)
+resbenefit(natid who, int goodness)
 {
-    if (!opt_GODNEWS)
-       return;
-
-    if (good) {
-       if (who)
-           nreport(player->cnum, N_AIDS, who, 1);
-    } else {
-       if (who)
-           nreport(player->cnum, N_HURTS, who, 1);
-    }
+    if (opt_GODNEWS && who && goodness)
+       nreport(player->cnum, goodness > 0 ? N_AIDS : N_HURTS, who, 1);
 }
 
 void
@@ -221,10 +215,10 @@ resnoise(struct sctstr *sptr, char *name, int old, int new)
 {
     pr("%s of %s changed from %d to %d\n",
        name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
-    if (sptr->sct_own)
+    if (sptr->sct_own && new != old)
        wu(0, sptr->sct_own,
           "%s in %s was changed from %d to %d by an act of %s\n",
           name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
           old, new, cname(player->cnum));
-    resbenefit(sptr->sct_own, (old < new));
+    resbenefit(sptr->sct_own, new - old);
 }
index cf3315da1f094b4b3c8f5738bc4c525baab81b95..6927d1b25b2a83e621420e0926e2989b6c983c44 100644 (file)
@@ -360,13 +360,12 @@ actor action victim times duration time
 0 42 3 49 0 0
 0 42 2 38 0 0
 0 42 1 39 0 0
-0 44 1 58 0 0
+0 44 1 19 0 0
 0 43 98 1 0 0
 0 43 2 1 0 0
 0 43 1 54 0 0
 0 42 1 4 0 0
 1 45 0 1 0 0
-0 44 2 1 0 0
 0 43 3 1 0 0
 /config
 config treaty
index f52ebade91a666acae8403326350dfad284b8f67..af7b1ca344e7e756dba6f64ff837dda0031d59d1 100644 (file)
     Play#0 output Play#0 1 Sector 7,7 taken from you by an act of POGO!
     Play#0 output Play#0 1 Sector 9,7 taken from you by an act of POGO!
     Play#0 output Play#0 1 Sector 11,7 taken from you by an act of POGO!
-    Play#0 output Play#0 1 Efficiency in 1,1 was changed from 0 to 0 by an act of POGO
-    Play#0 output Play#0 1 Efficiency in 3,1 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Efficiency in 5,1 was changed from 0 to 100 by an act of POGO
     Play#0 output Play#0 1 Efficiency in 7,1 was changed from 0 to 100 by an act of POGO
     Play#0 output Play#0 1 Mobility in 1,1 was changed from 0 to -127 by an act of POGO
     Play#0 output Play#0 1 Mobility in 3,1 was changed from 0 to -127 by an act of POGO
     Play#0 output Play#0 1 Mobility in 5,1 was changed from 0 to 127 by an act of POGO
     Play#0 output Play#0 1 Mobility in 7,1 was changed from 0 to 127 by an act of POGO
-    Play#0 output Play#0 1 Iron ore content in 1,1 was changed from 0 to 0 by an act of POGO
-    Play#0 output Play#0 1 Iron ore content in 3,1 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Iron ore content in 5,1 was changed from 0 to 127 by an act of POGO
     Play#0 output Play#0 1 Iron ore content in 7,1 was changed from 0 to 127 by an act of POGO
-    Play#0 output Play#0 1 Iron ore content in 2,2 was changed from 0 to 0 by an act of POGO
-    Play#0 output Play#0 1 Iron ore content in 4,2 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Iron ore content in 6,2 was changed from 0 to 100 by an act of POGO
     Play#0 output Play#0 1 Iron ore content in 8,2 was changed from 0 to 100 by an act of POGO
-    Play#0 output Play#0 1 Iron ore content in 1,3 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Iron ore content in 3,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Iron ore content in 5,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Iron ore content in 7,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Iron ore content in 5,3 was changed from 1 to 0 by an act of POGO
     Play#0 output Play#0 1 Iron ore content in 7,3 was changed from 1 to 0 by an act of POGO
-    Play#0 output Play#0 1 Gold content in 1,1 was changed from 0 to 0 by an act of POGO
-    Play#0 output Play#0 1 Gold content in 3,1 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Gold content in 5,1 was changed from 0 to 127 by an act of POGO
     Play#0 output Play#0 1 Gold content in 7,1 was changed from 0 to 127 by an act of POGO
-    Play#0 output Play#0 1 Gold content in 2,2 was changed from 0 to 0 by an act of POGO
-    Play#0 output Play#0 1 Gold content in 4,2 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Gold content in 6,2 was changed from 0 to 100 by an act of POGO
     Play#0 output Play#0 1 Gold content in 8,2 was changed from 0 to 100 by an act of POGO
-    Play#0 output Play#0 1 Gold content in 1,3 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Gold content in 3,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Gold content in 5,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Gold content in 7,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Gold content in 5,3 was changed from 1 to 0 by an act of POGO
     Play#0 output Play#0 1 Gold content in 7,3 was changed from 1 to 0 by an act of POGO
-    Play#0 output Play#0 1 Fertility in 1,1 was changed from 0 to 0 by an act of POGO
-    Play#0 output Play#0 1 Fertility in 3,1 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Fertility in 5,1 was changed from 0 to 127 by an act of POGO
     Play#0 output Play#0 1 Fertility in 7,1 was changed from 0 to 127 by an act of POGO
-    Play#0 output Play#0 1 Fertility content in 2,2 was changed from 0 to 0 by an act of POGO
-    Play#0 output Play#0 1 Fertility content in 4,2 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Fertility content in 6,2 was changed from 0 to 100 by an act of POGO
     Play#0 output Play#0 1 Fertility content in 8,2 was changed from 0 to 100 by an act of POGO
-    Play#0 output Play#0 1 Fertility content in 1,3 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Fertility content in 3,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Fertility content in 5,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Fertility content in 7,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Fertility content in 5,3 was changed from 1 to 0 by an act of POGO
     Play#0 output Play#0 1 Fertility content in 7,3 was changed from 1 to 0 by an act of POGO
-    Play#0 output Play#0 1 Oil content in 1,1 was changed from 0 to 0 by an act of POGO
-    Play#0 output Play#0 1 Oil content in 3,1 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Oil content in 5,1 was changed from 0 to 127 by an act of POGO
     Play#0 output Play#0 1 Oil content in 7,1 was changed from 0 to 127 by an act of POGO
-    Play#0 output Play#0 1 Oil content in 2,2 was changed from 0 to 0 by an act of POGO
-    Play#0 output Play#0 1 Oil content in 4,2 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Oil content in 6,2 was changed from 0 to 100 by an act of POGO
     Play#0 output Play#0 1 Oil content in 8,2 was changed from 0 to 100 by an act of POGO
-    Play#0 output Play#0 1 Oil content in 1,3 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Oil content in 3,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Oil content in 5,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Oil content in 7,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Oil content in 5,3 was changed from 1 to 0 by an act of POGO
     Play#0 output Play#0 1 Oil content in 7,3 was changed from 1 to 0 by an act of POGO
-    Play#0 output Play#0 1 Uranium content in 1,1 was changed from 0 to 0 by an act of POGO
-    Play#0 output Play#0 1 Uranium content in 3,1 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Uranium content in 5,1 was changed from 0 to 127 by an act of POGO
     Play#0 output Play#0 1 Uranium content in 7,1 was changed from 0 to 127 by an act of POGO
-    Play#0 output Play#0 1 Uranium content in 2,2 was changed from 0 to 0 by an act of POGO
-    Play#0 output Play#0 1 Uranium content in 4,2 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Uranium content in 6,2 was changed from 0 to 100 by an act of POGO
     Play#0 output Play#0 1 Uranium content in 8,2 was changed from 0 to 100 by an act of POGO
-    Play#0 output Play#0 1 Uranium content in 1,3 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Uranium content in 3,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Uranium content in 5,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Uranium content in 7,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Uranium content in 7,3 was changed from 1 to 0 by an act of POGO
     Play#0 output Play#0 1 Workforce percentage in 1,1 was changed from 100 to 0 by an act of POGO
     Play#0 output Play#0 1 Workforce percentage in 3,1 was changed from 100 to 0 by an act of POGO
-    Play#0 output Play#0 1 Workforce percentage in 5,1 was changed from 100 to 100 by an act of POGO
-    Play#0 output Play#0 1 Workforce percentage in 7,1 was changed from 100 to 100 by an act of POGO
-    Play#0 output Play#0 1 Available workforce in 1,1 was changed from 0 to 0 by an act of POGO
-    Play#0 output Play#0 1 Available workforce in 3,1 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Available workforce in 5,1 was changed from 0 to 9999 by an act of POGO
     Play#0 output Play#0 1 Available workforce in 7,1 was changed from 0 to 9999 by an act of POGO
-    Play#0 output Play#0 1 Mines in 1,3 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Mines in 3,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Mines in 5,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Mines in 7,3 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 Mines in 5,3 was changed from 1 to 0 by an act of POGO
     Play#0 output Play#0 1 Mines in 7,3 was changed from 1 to 0 by an act of POGO
-    Play#0 output Play#0 1 Road percentage in 1,1 was changed from 0 to 0 by an act of POGO
-    Play#0 output Play#0 1 Road percentage in 3,1 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Road percentage in 5,1 was changed from 0 to 100 by an act of POGO
     Play#0 output Play#0 1 Road percentage in 7,1 was changed from 0 to 100 by an act of POGO
-    Play#0 output Play#0 1 Rail percentage in 1,1 was changed from 0 to 0 by an act of POGO
-    Play#0 output Play#0 1 Rail percentage in 3,1 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Rail percentage in 5,1 was changed from 0 to 100 by an act of POGO
     Play#0 output Play#0 1 Rail percentage in 7,1 was changed from 0 to 100 by an act of POGO
-    Play#0 output Play#0 1 Defense percentage in 1,1 was changed from 0 to 0 by an act of POGO
-    Play#0 output Play#0 1 Defense percentage in 3,1 was changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Defense percentage in 5,1 was changed from 0 to 100 by an act of POGO
     Play#0 output Play#0 1 Defense percentage in 7,1 was changed from 0 to 100 by an act of POGO
     Play#0 output Play#0 1 Mobility in 1,5 was changed from 0 to 1 by an act of POGO
     Play#0 output Play#0 1 POGO gave you 1 civilians in 8,6
     Play#0 output Play#0 1 POGO gave you 9997 civilians in 6,6
     Play#0 output Play#0 1 POGO stole 1 civilians from 8,6
-    Play#0 output Play#0 1 Military reserves changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 1 Money changed from 0 to -2147483648 by an act of POGO
     Play#0 output Play#0 6 0 640
     Play#0 input read 2
     Play#0 output Play#0 1 cs   cargo ship (#2) given to you by an act of POGO!
     Play#0 output Play#0 1 f1   Sopwith Camel #2 given to you by an act of POGO!
     Play#0 output Play#0 1 sup  supply #2 given to you by an act of POGO!
-    Play#0 output Play#0 1 Military reserves changed from 0 to 0 by an act of POGO
     Play#0 output Play#0 6 0 640
     Play#0 input read 3
     Play#0 command read