]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/actofgod.c
Update copyright notice
[empserver] / src / lib / subs / actofgod.c
index 792bc7027b2d1a7857529686acaf7aa51aa96bf2..1299d6b940eb625e1d2b80326715b2cf8f238861 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2020, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
  *  actofgod.c: Deity meddling subroutines
  *
  *  Known contributors to this file:
- *     Markus Armbruster, 2013
+ *     Markus Armbruster, 2013-2016
  */
 
 #include <config.h>
 
 #include <stdarg.h>
 #include "actofgod.h"
-#include "file.h"
 #include "news.h"
 #include "optlist.h"
 #include "player.h"
@@ -70,17 +69,17 @@ report_god_gives(char *prefix, char *what, natid to)
 }
 
 /*
- * Report deity meddling with sector SP.
+ * Report deity meddling with sector @sp.
  * Print a message (always), send a bulletin to the sector owner and
  * report news (sometimes).
- * NAME names what is being changed in the sector.
- * If CHANGE is zero, the meddling is a no-op (bulletin suppressed).
- * If CHANGE is negative, it's secret (bulletin suppressed).
- * If a bulletin is sent, report N_AIDS news for positive GOODNESS,
- * N_HURTS news for negative GOODNESS
- * The bulletin's text is like "NAME of sector X,Y changed <how> by an
+ * @name names what is being changed in the sector.
+ * If @change is zero, the meddling is a no-op (bulletin suppressed).
+ * If @change is negative, it's secret (bulletin suppressed).
+ * If a bulletin is sent, report N_AIDS news for positive @goodness,
+ * N_HURTS news for negative @goodness
+ * The bulletin's text is like "@name of sector X,Y changed <how> by an
  * act of <deity>, where <deity> is the deity's name, and <how> comes
- * from formatting printf-style FMT with optional arguments.
+ * from formatting printf-style @fmt with optional arguments.
  */
 void
 divine_sct_change(struct sctstr *sp, char *name,
@@ -110,7 +109,7 @@ divine_sct_change(struct sctstr *sp, char *name,
 }
 
 /*
- * Report deity meddling with NP.
+ * Report deity meddling with @np.
  * Just like divine_sct_change(), only for nations.
  */
 void
@@ -138,7 +137,7 @@ divine_nat_change(struct natstr *np, char *name,
 }
 
 /*
- * Report deity meddling with UNIT.
+ * Report deity meddling with @unit.
  * Just like divine_sct_change(), only for ships, planes, land units,
  * nukes.
  */
@@ -190,7 +189,7 @@ divine_load(struct empobj *unit, int type, int uid)
     divine_load_unload(unit, type, uid, "loaded onto");
     if (get_empobj(type, uid, &carrier)
        && (unit->x != carrier.gen.x || unit->y != carrier.gen.y)) {
-       pr("%s teleported from %s to %s!",
+       pr("%s teleported from %s to %s!\n",
           unit_nameof(unit), xyas(unit->x, unit->y, player->cnum),
           xyas(carrier.gen.x, carrier.gen.y, player->cnum));
        unit_teleport(unit, carrier.gen.x, carrier.gen.y);
@@ -203,33 +202,6 @@ divine_unload(struct empobj *unit, int type, int uid)
     divine_load_unload(unit, type, uid, "unloaded from");
 }
 
-static int
-fmtflags (char *buf, size_t sz, int flags, struct symbol symtab[], int all)
-{
-    char *sep = "";
-    int n, i;
-    char *p;
-
-    if (buf && sz)
-       buf[0] = 0;
-    n = 0;
-    for (i = 0; i < 32; i++) {
-       if (!(flags & bit(i)))
-           continue;
-       p = symbol_by_value(bit(i), symtab);
-       if (p)
-           n += snprintf(buf + n, sz - n, "%s%s", sep, p);
-       else if (all)
-           n += snprintf(buf + n, sz - n, "%s#%d", sep, i);
-       if ((size_t)n >= sz)
-           sz = n;
-       sep = ", ";
-    }
-
-    CANT_HAPPEN((size_t)n >= sz && buf);
-    return n;
-}
-
 void
 divine_flag_change(struct empobj *unit, char *name,
                   int old, int new, struct symbol sym[])
@@ -241,16 +213,16 @@ divine_flag_change(struct empobj *unit, char *name,
        return;
     }
 
-    fmtflags(set, sizeof(set), new & ~old, sym, 1);
-    fmtflags(clr, sizeof(clr), old & ~new, sym, 1);
+    symbol_set_fmt(set, sizeof(set), new & ~old, sym, ", ", 1);
+    symbol_set_fmt(clr, sizeof(clr), old & ~new, sym, ", ", 1);
     pr("%s of %s changed: %s%s%s%s%s\n",
        name, unit_nameof(unit),
        set, set[0] ? " set" : "",
        set[0] && clr[0] ? ", and " : "",
        clr, clr[0] ? " cleared" : "");
 
-    if (fmtflags(set, sizeof(set), new & ~old, sym, 0)
-       + fmtflags(clr, sizeof(clr), old & ~new, sym, 0))
+    if (symbol_set_fmt(set, sizeof(set), new & ~old, sym, ", ", 0)
+       + symbol_set_fmt(clr, sizeof(clr), old & ~new, sym, ", ", 0))
        wu(0, unit->own, "%s of %s changed by an act of %s: %s%s%s%s%s\n",
           name, unit_nameof(unit), cname(player->cnum),
           set, set[0] ? " set" : "",
@@ -259,8 +231,8 @@ divine_flag_change(struct empobj *unit, char *name,
 }
 
 /*
- * Report deity giving/taking commodities to/from WHOM.
- * Give AMT of IP in PLACE.
+ * Report deity giving/taking commodities to/from @whom.
+ * Give @amt of @ip in @place.
  */
 void
 report_divine_gift(natid whom, struct ichrstr *ip, int amt, char *place)