From: Markus Armbruster Date: Sun, 3 Feb 2013 16:42:18 +0000 (+0100) Subject: actofgod: New divine_nat_change(), similar to divine_sct_change() X-Git-Tag: v4.3.32~30 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=e6c1476c2f006a1afb6981757e33eb7e43f8b49f actofgod: New divine_nat_change(), similar to divine_sct_change() Signed-off-by: Markus Armbruster --- diff --git a/include/actofgod.h b/include/actofgod.h index 69ba33db5..87a3f2d26 100644 --- a/include/actofgod.h +++ b/include/actofgod.h @@ -45,6 +45,10 @@ extern void divine_sct_change(struct sctstr *, char *, int, int, char *, ...) ATTRIBUTE((format (printf, 5, 6))); #define divine_sct_change_quiet(sp, name, change, ...) \ divine_sct_change((sp), (name), -(change), 0, __VA_ARGS__) +extern void divine_nat_change(struct natstr *, char *, int, int, char *, ...) + ATTRIBUTE((format (printf, 5, 6))); +#define divine_nat_change_quiet(np, name, change, ...) \ + divine_nat_change((np), (name), -(change), 0, __VA_ARGS__) extern void divine_unit_change(struct empobj *, char *, int, int, char *, ...) ATTRIBUTE((format (printf, 5, 6))); #define divine_unit_change_quiet(unit, name, change, ...) \ diff --git a/src/lib/subs/actofgod.c b/src/lib/subs/actofgod.c index 06054ee0a..e564eaf09 100644 --- a/src/lib/subs/actofgod.c +++ b/src/lib/subs/actofgod.c @@ -109,6 +109,34 @@ divine_sct_change(struct sctstr *sp, char *name, } } +/* + * Report deity meddling with NP. + * Just like divine_sct_change(), only for nations. + */ +void +divine_nat_change(struct natstr *np, char *name, + int change, int goodness, char *fmt, ...) +{ + va_list ap; + char buf[4096]; + + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + + if (!change) { + pr("%s of %s unchanged\n", name, prnat(np)); + return; + } + + pr("%s of %s changed %s\n", name, prnat(np), buf); + if (change > 0 && np->nat_cnum != player->cnum) { + wu(0, np->nat_cnum, "%s changed %s by an act of %s!\n", + name, buf, cname(player->cnum)); + nreport_divine_aid(np->nat_cnum, goodness); + } +} + /* * Report deity meddling with UNIT. * Just like divine_sct_change(), only for ships, planes, land units,