From d35303d426c79f79fa98bdfcc84ee95b3d52e3a5 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 29 Oct 2016 09:06:12 +0200 Subject: [PATCH] contact: Change in_contact()'s first parameter to natid Signed-off-by: Markus Armbruster --- include/nat.h | 2 +- src/lib/commands/decl.c | 5 ++--- src/lib/commands/news.c | 4 ++-- src/lib/commands/rela.c | 4 ++-- src/lib/commands/repo.c | 2 +- src/lib/common/nat.c | 4 ++-- src/lib/common/nstreval.c | 12 ++++++------ src/lib/subs/natarg.c | 4 ++-- src/lib/update/nat.c | 2 +- 9 files changed, 19 insertions(+), 20 deletions(-) diff --git a/include/nat.h b/include/nat.h index b1fde33b9..93794e25b 100644 --- a/include/nat.h +++ b/include/nat.h @@ -182,7 +182,7 @@ 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 in_contact(struct natstr *np, natid them); +extern int in_contact(natid, natid); extern void putrel(struct natstr *np, natid them, int relate); extern void putreject(struct natstr *np, natid them, int how, int what); extern void agecontact(struct natstr *np); diff --git a/src/lib/commands/decl.c b/src/lib/commands/decl.c index 5eeda4f92..703b573a5 100644 --- a/src/lib/commands/decl.c +++ b/src/lib/commands/decl.c @@ -38,7 +38,7 @@ int decl(void) { - struct natstr nat, *natp; + struct natstr nat; int rel; int who; struct nstr_item ni; @@ -80,14 +80,13 @@ decl(void) return RET_SYN; } - natp = getnatp(who); while (nxtitem(&ni, &nat)) { if (nat.nat_stat == STAT_UNUSED) continue; if (who == (natid)ni.cur) continue; if (opt_HIDDEN) { - if (!player->god && !in_contact(natp, ni.cur)) { + if (!player->god && !in_contact(who, ni.cur)) { pr("You haven't contacted country #%d yet\n", ni.cur); continue; } diff --git a/src/lib/commands/news.c b/src/lib/commands/news.c index 53adfb7ee..51137ca81 100644 --- a/src/lib/commands/news.c +++ b/src/lib/commands/news.c @@ -103,8 +103,8 @@ news(void) nws.nws_ntm = 1; if (opt_HIDDEN) { if (!player->god && - !(in_contact(getnatp(player->cnum), nws.nws_ano) && - in_contact(getnatp(player->cnum), nws.nws_vno))) + !(in_contact(player->cnum, nws.nws_ano) && + in_contact(player->cnum, nws.nws_vno))) continue; } page_has_news[rpt[nws.nws_vrb].r_newspage] = 1; diff --git a/src/lib/commands/rela.c b/src/lib/commands/rela.c index da73d6419..3ef2018a2 100644 --- a/src/lib/commands/rela.c +++ b/src/lib/commands/rela.c @@ -69,9 +69,9 @@ rela(void) if (np->nat_stat < STAT_SANCT) continue; if (opt_HIDDEN) { - if (!player->god && !in_contact(natp, cn)) + if (!player->god && !in_contact(as, cn)) continue; - if (!player->god && !in_contact(getnatp(player->cnum), cn)) + if (!player->god && !in_contact(player->cnum, cn)) continue; } pr("%3d) %-20.20s ", cn, cname(cn)); diff --git a/src/lib/commands/repo.c b/src/lib/commands/repo.c index 1c73fd43e..4b119b63d 100644 --- a/src/lib/commands/repo.c +++ b/src/lib/commands/repo.c @@ -58,7 +58,7 @@ repo(void) if (nat.nat_stat == STAT_UNUSED) continue; if (opt_HIDDEN) { - if (!player->god && !in_contact(natp, ni.cur)) + if (!player->god && !in_contact(player->cnum, ni.cur)) continue; } if (!player->god && nat.nat_stat != STAT_ACTIVE) diff --git a/src/lib/common/nat.c b/src/lib/common/nat.c index 077b8632e..eef71ccdf 100644 --- a/src/lib/common/nat.c +++ b/src/lib/common/nat.c @@ -110,9 +110,9 @@ agecontact(struct natstr *np) } int -in_contact(struct natstr *np, natid them) +in_contact(natid us, natid them) { - return getcontactp(np->nat_cnum)->con_contact[them]; + return getcontactp(us)->con_contact[them]; } void diff --git a/src/lib/common/nstreval.c b/src/lib/common/nstreval.c index e5820947e..47ee9ba1e 100644 --- a/src/lib/common/nstreval.c +++ b/src/lib/common/nstreval.c @@ -29,7 +29,7 @@ * Known contributors to this file: * Dave Pare, 1989 * Steve McClure, 1997 - * Markus Armbruster, 2004-2015 + * Markus Armbruster, 2004-2016 */ #include @@ -178,13 +178,13 @@ nstr_eval(struct valstr *val, natid cnum, void *ptr, enum nsc_type want) if (hidden) { if (CANT_HAPPEN(hidden && valtype != NSC_LONG)) break; /* not implemented */ - if (CANT_HAPPEN(((struct natstr *)ptr)->ef_type != EF_NATION)) + natp = ptr; + if (CANT_HAPPEN(natp->ef_type != EF_NATION)) break; /* only defined for nation selectors */ - if (!opt_HIDDEN || cnum == NATID_BAD) + if (!opt_HIDDEN || cnum == NATID_BAD + || getnatp(cnum)->nat_stat == STAT_GOD) break; - natp = getnatp(cnum); - if (natp->nat_stat != STAT_GOD - && !(in_contact(natp, idx) && in_contact(ptr, idx))) + if (!in_contact(cnum, idx) || !in_contact(natp->nat_cnum, idx)) val->val_as.lng = -1; } break; diff --git a/src/lib/subs/natarg.c b/src/lib/subs/natarg.c index 48f4bcf6c..21713e4b7 100644 --- a/src/lib/subs/natarg.c +++ b/src/lib/subs/natarg.c @@ -27,7 +27,7 @@ * natarg.c: Return countr # given country name or country # * * Known contributors to this file: - * Markus Armbruster, 2006-2009 + * Markus Armbruster, 2006-2016 */ #include @@ -96,7 +96,7 @@ natarg(char *arg, char *prompt) return -1; if (opt_HIDDEN) { if (!player->god - && !in_contact(getnatp(player->cnum), np->nat_cnum)) { + && !in_contact(player->cnum, np->nat_cnum)) { if (np->nat_stat != STAT_GOD) { pr("Country '%s' has not been contacted.\n", arg); return -1; diff --git a/src/lib/update/nat.c b/src/lib/update/nat.c index ad3607a84..c36c41e64 100644 --- a/src/lib/update/nat.c +++ b/src/lib/update/nat.c @@ -252,7 +252,7 @@ share_incr(double res[], double tech[]) if (other->nat_stat != STAT_ACTIVE) continue; if (opt_HIDDEN) { - if (!in_contact(np, j)) + if (!in_contact(i, j)) continue; } -- 2.43.0