From: Markus Armbruster Date: Sun, 3 Feb 2013 11:24:32 +0000 (+0100) Subject: actofgod: Factor report_divine_gift() out of give() X-Git-Tag: v4.3.32~43 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=2f475a54dcac6f46d4f492e63844491d608e98bd actofgod: Factor report_divine_gift() out of give() Signed-off-by: Markus Armbruster --- diff --git a/include/actofgod.h b/include/actofgod.h index 786c53973..79d0b99db 100644 --- a/include/actofgod.h +++ b/include/actofgod.h @@ -42,5 +42,6 @@ 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 report_divine_gift(natid, struct ichrstr *, int, char *); #endif diff --git a/src/lib/commands/give.c b/src/lib/commands/give.c index 4de98b87b..4e1b4a0b0 100644 --- a/src/lib/commands/give.c +++ b/src/lib/commands/give.c @@ -34,6 +34,7 @@ #include +#include "actofgod.h" #include "commands.h" #include "item.h" #include "news.h" @@ -74,23 +75,8 @@ give(void) m = n + amt; sect.sct_item[ip->i_uid] = m; putsect(§); - if (sect.sct_own != 0 && sect.sct_own != player->cnum && m != n) { - if (m > n) { - if (opt_GODNEWS - && getnatp(sect.sct_own)->nat_stat != STAT_GOD) - nreport(player->cnum, N_GIFT, sect.sct_own, 1); - wu(0, sect.sct_own, "%s gave you %d %s in %s\n", - cname(player->cnum), m - n, ip->i_name, - xyas(sect.sct_x, sect.sct_y, sect.sct_own)); - } else { - if (opt_GODNEWS - && getnatp(sect.sct_own)->nat_stat != STAT_GOD) - nreport(sect.sct_own, N_TAKE, player->cnum, 1); - wu(0, sect.sct_own, "%s stole %d %s from %s\n", - cname(player->cnum), n - m, ip->i_name, - xyas(sect.sct_x, sect.sct_y, sect.sct_own)); - } - } + report_divine_gift(sect.sct_own, ip, m - n, + xyas(sect.sct_x, sect.sct_y, sect.sct_own)); if (m - n != amt) pr("Only %d %s in %s\n", abs(m - n), m - n >= 0 ? "given" : "taken", diff --git a/src/lib/subs/actofgod.c b/src/lib/subs/actofgod.c index c71b2d00a..215e944a6 100644 --- a/src/lib/subs/actofgod.c +++ b/src/lib/subs/actofgod.c @@ -107,3 +107,25 @@ divine_sct_change(struct sctstr *sp, char *name, nreport_divine_aid(sp->sct_own, goodness); } } + +/* + * 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) +{ + if (whom && whom != player->cnum && amt) { + if (amt > 0) { + if (opt_GODNEWS && getnatp(whom)->nat_stat != STAT_GOD) + nreport(player->cnum, N_GIFT, whom, 1); + wu(0, whom, "%s gave you %d %s in %s\n", + cname(player->cnum), amt, ip->i_name, place); + } else { + if (opt_GODNEWS && getnatp(whom)->nat_stat != STAT_GOD) + nreport(whom, N_TAKE, player->cnum, 1); + wu(0, whom, "%s stole %d %s from %s\n", + cname(player->cnum), -amt, ip->i_name, place); + } + } +}