All callers of getrejects() also check whether the sender is a deity.
Factor out the common code into nat_accepts(), and drop getrejects().
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
extern char *natstate(struct natstr *np);
extern int getrel(struct natstr *np, natid them);
extern int relations_with(natid, natid);
-extern int getrejects(natid them, struct natstr *np);
+extern int nat_accepts(struct natstr *, natid, int);
extern int in_contact(natid, natid);
extern void putrel(struct natstr *np, natid them, int relate);
extern void agecontact(struct natstr *np);
pr_accept(struct natstr *to, natid from)
{
static char *yes_no[] = { "YES", " NO" };
- int rej = getrejects(from, to);
- int from_deity = getnatp(from)->nat_stat == STAT_GOD;
pr(" %s %s %s",
- yes_no[!from_deity && (rej & REJ_TELE)],
- yes_no[!from_deity && (rej & REJ_ANNO)],
- yes_no[!from_deity && (rej & REJ_LOAN)]);
+ yes_no[!nat_accepts(to, from, REJ_TELE)],
+ yes_no[!nat_accepts(to, from, REJ_ANNO)],
+ yes_no[!nat_accepts(to, from, REJ_LOAN)]);
}
return RET_FAIL;
}
natp = getnatp(recipient);
- if (!player->god && (getrejects(player->cnum, natp) & REJ_LOAN)) {
+ if (!nat_accepts(natp, player->cnum, REJ_LOAN)) {
pr("%s is rejecting your loans.\n", cname(recipient));
return RET_SYN;
}
if (res <= 0)
break;
if (*kind == 'a') {
- if ((getnatp(tgm.tel_from)->nat_stat != STAT_GOD
- && (getrejects(tgm.tel_from, np) & REJ_ANNO))
+ if ((!nat_accepts(np, tgm.tel_from, REJ_ANNO))
|| tgm.tel_date < then) {
res = tel_read_body(telfp, mbox, &tgm, NULL, NULL);
if (res < 0)
kk++;
continue;
}
- if (!player->god
- && (getrejects(player->cnum, natp) & REJ_TELE)) {
+ if (!nat_accepts(natp, player->cnum, REJ_TELE)) {
pr("%s is rejecting your telegrams.\n", cname(to));
return RET_SYN;
}
}
int
-getrejects(natid them, struct natstr *np)
+nat_accepts(struct natstr *np, natid them, int what)
{
- return np->nat_rejects[them];
+ return getnatp(them)->nat_stat == STAT_GOD
+ || !(np->nat_rejects[them] & what);
}
void
pr("%s\n", addendum);
mpr(us, "Diplomatic relations with %s %s to \"%s\".\n",
cname(them), whichway, relates[rel]);
- if (mynp->nat_stat == STAT_GOD || !(getrejects(us, themnp) & REJ_TELE))
+ if (nat_accepts(themnp, us, REJ_TELE))
mpr(them,
"Country %s has %s their relations with you to \"%s\"!\n",
prnat(mynp), whichway, relates[rel]);
for (to = 0; NULL != (np = getnatp(to)); to++) {
if (np->nat_stat < STAT_SANCT)
continue;
- if (getnatp(from)->nat_stat != STAT_GOD
- && (getrejects(from, np) & REJ_ANNO))
+ if (!nat_accepts(np, from, REJ_ANNO))
continue;
if (!np->nat_ann || !tel.tel_cont) {
np->nat_ann++;