reject: Change nat_accepts()'s first parameter to natid

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-10-31 13:58:16 +01:00
parent eaa678c903
commit e5db45058d
8 changed files with 13 additions and 15 deletions

View file

@ -199,7 +199,7 @@ extern char *relatename(struct natstr *np, natid other);
extern char *natstate(struct natstr *np); extern char *natstate(struct natstr *np);
extern int getrel(struct natstr *np, natid them); extern int getrel(struct natstr *np, natid them);
extern int relations_with(natid, natid); extern int relations_with(natid, natid);
extern int nat_accepts(struct natstr *, natid, enum rej_comm); extern int nat_accepts(natid, natid, enum rej_comm);
extern int in_contact(natid, natid); extern int in_contact(natid, natid);
extern void putrel(struct natstr *np, natid them, int relate); extern void putrel(struct natstr *np, natid them, int relate);
extern void agecontact(struct natstr *np); extern void agecontact(struct natstr *np);

View file

@ -34,7 +34,7 @@
#include "commands.h" #include "commands.h"
static void pr_accept(struct natstr *, natid); static void pr_accept(natid, natid);
/* /*
* report rejection status * report rejection status
@ -69,15 +69,15 @@ acce(void)
if (np->nat_stat == STAT_UNUSED) if (np->nat_stat == STAT_UNUSED)
continue; continue;
pr("%3d) %-14.14s ", cn, cname(cn)); pr("%3d) %-14.14s ", cn, cname(cn));
pr_accept(natp, cn); pr_accept(as, cn);
pr_accept(np, as); pr_accept(cn, as);
pr("\n"); pr("\n");
} }
return RET_OK; return RET_OK;
} }
static void static void
pr_accept(struct natstr *to, natid from) pr_accept(natid to, natid from)
{ {
static char *yes_no[] = { "YES", " NO" }; static char *yes_no[] = { "YES", " NO" };

View file

@ -77,8 +77,7 @@ do_loan(void)
pr("You can't loan yourself money!\n"); pr("You can't loan yourself money!\n");
return RET_FAIL; return RET_FAIL;
} }
natp = getnatp(recipient); if (!nat_accepts(recipient, player->cnum, REJ_LOAN)) {
if (!nat_accepts(natp, player->cnum, REJ_LOAN)) {
pr("%s is rejecting your loans.\n", cname(recipient)); pr("%s is rejecting your loans.\n", cname(recipient));
return RET_SYN; return RET_SYN;
} }

View file

@ -107,7 +107,7 @@ rea(void)
if (res <= 0) if (res <= 0)
break; break;
if (*kind == 'a') { if (*kind == 'a') {
if ((!nat_accepts(np, tgm.tel_from, REJ_ANNO)) if ((!nat_accepts(player->cnum, tgm.tel_from, REJ_ANNO))
|| tgm.tel_date < then) { || tgm.tel_date < then) {
res = tel_read_body(telfp, mbox, &tgm, NULL, NULL); res = tel_read_body(telfp, mbox, &tgm, NULL, NULL);
if (res < 0) if (res < 0)

View file

@ -92,7 +92,7 @@ tele(void)
kk++; kk++;
continue; continue;
} }
if (!nat_accepts(natp, player->cnum, REJ_TELE)) { if (!nat_accepts(to, player->cnum, REJ_TELE)) {
pr("%s is rejecting your telegrams.\n", cname(to)); pr("%s is rejecting your telegrams.\n", cname(to));
return RET_SYN; return RET_SYN;
} }

View file

@ -90,10 +90,10 @@ relations_with(natid us, natid them)
} }
int int
nat_accepts(struct natstr *np, natid them, enum rej_comm what) nat_accepts(natid us, natid them, enum rej_comm what)
{ {
return getnatp(them)->nat_stat == STAT_GOD return getnatp(them)->nat_stat == STAT_GOD
|| !(getrejectp(np->nat_cnum)->rej_rejects[them] & bit(what)); || !(getrejectp(us)->rej_rejects[them] & bit(what));
} }
void void

View file

@ -44,7 +44,6 @@ void
setrel(natid us, natid them, int rel) setrel(natid us, natid them, int rel)
{ {
struct natstr *mynp = getnatp(us); struct natstr *mynp = getnatp(us);
struct natstr *themnp = getnatp(them);
int oldrel; int oldrel;
char *whichway; char *whichway;
int n_up = 0; int n_up = 0;
@ -55,7 +54,7 @@ setrel(natid us, natid them, int rel)
rel = AT_WAR; rel = AT_WAR;
if (CANT_HAPPEN(rel > ALLIED)) if (CANT_HAPPEN(rel > ALLIED))
rel = ALLIED; rel = ALLIED;
if (CANT_HAPPEN(!mynp || !themnp)) if (CANT_HAPPEN(!mynp))
return; return;
if (us == them) if (us == them)
return; return;
@ -88,7 +87,7 @@ setrel(natid us, natid them, int rel)
pr("%s\n", addendum); pr("%s\n", addendum);
mpr(us, "Diplomatic relations with %s %s to \"%s\".\n", mpr(us, "Diplomatic relations with %s %s to \"%s\".\n",
cname(them), whichway, relates[rel]); cname(them), whichway, relates[rel]);
if (nat_accepts(themnp, us, REJ_TELE)) if (nat_accepts(them, us, REJ_TELE))
mpr(them, mpr(them,
"Country %s has %s their relations with you to \"%s\"!\n", "Country %s has %s their relations with you to \"%s\"!\n",
prnat(mynp), whichway, relates[rel]); prnat(mynp), whichway, relates[rel]);

View file

@ -153,7 +153,7 @@ typed_wu(natid from, natid to, char *message, int type)
for (to = 0; NULL != (np = getnatp(to)); to++) { for (to = 0; NULL != (np = getnatp(to)); to++) {
if (np->nat_stat < STAT_SANCT) if (np->nat_stat < STAT_SANCT)
continue; continue;
if (!nat_accepts(np, from, REJ_ANNO)) if (!nat_accepts(to, from, REJ_ANNO))
continue; continue;
if (!np->nat_ann || !tel.tel_cont) { if (!np->nat_ann || !tel.tel_cont) {
np->nat_ann++; np->nat_ann++;