actofgod: Factor report_divine_gift() out of give()
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
004c4d0f23
commit
2f475a54dc
3 changed files with 26 additions and 17 deletions
|
@ -42,5 +42,6 @@ extern void divine_sct_change(struct sctstr *, char *, int, int, char *, ...)
|
||||||
ATTRIBUTE((format (printf, 5, 6)));
|
ATTRIBUTE((format (printf, 5, 6)));
|
||||||
#define divine_sct_change_quiet(sp, name, change, ...) \
|
#define divine_sct_change_quiet(sp, name, change, ...) \
|
||||||
divine_sct_change((sp), (name), -(change), 0, __VA_ARGS__)
|
divine_sct_change((sp), (name), -(change), 0, __VA_ARGS__)
|
||||||
|
extern void report_divine_gift(natid, struct ichrstr *, int, char *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "actofgod.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "news.h"
|
#include "news.h"
|
||||||
|
@ -74,23 +75,8 @@ give(void)
|
||||||
m = n + amt;
|
m = n + amt;
|
||||||
sect.sct_item[ip->i_uid] = m;
|
sect.sct_item[ip->i_uid] = m;
|
||||||
putsect(§);
|
putsect(§);
|
||||||
if (sect.sct_own != 0 && sect.sct_own != player->cnum && m != n) {
|
report_divine_gift(sect.sct_own, ip, 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));
|
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m - n != amt)
|
if (m - n != amt)
|
||||||
pr("Only %d %s in %s\n", abs(m - n),
|
pr("Only %d %s in %s\n", abs(m - n),
|
||||||
m - n >= 0 ? "given" : "taken",
|
m - n >= 0 ? "given" : "taken",
|
||||||
|
|
|
@ -107,3 +107,25 @@ divine_sct_change(struct sctstr *sp, char *name,
|
||||||
nreport_divine_aid(sp->sct_own, goodness);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue