]> git.pond.sub.org Git - empserver/commitdiff
contact: Change in_contact()'s first parameter to natid
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 29 Oct 2016 07:06:12 +0000 (09:06 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 18:09:20 +0000 (20:09 +0200)
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
include/nat.h
src/lib/commands/decl.c
src/lib/commands/news.c
src/lib/commands/rela.c
src/lib/commands/repo.c
src/lib/common/nat.c
src/lib/common/nstreval.c
src/lib/subs/natarg.c
src/lib/update/nat.c

index b1fde33b90282a5b511f625ab8a0debc3d4e2e1d..93794e25b4cc529d5eda39b0c641961cd7644a12 100644 (file)
@@ -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);
index 5eeda4f927f9700a8bc45fc1d39c82d4fb7c6926..703b573a5211735dd6c922bc4b538f80a9bddae6 100644 (file)
@@ -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;
            }
index 53adfb7ee5c28c6cf54ae7c3f71b3520ba7cd7b0..51137ca81f805b821f1da1e590989f62e79d882d 100644 (file)
@@ -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;
index da73d6419993608fe1be92cf9f1eb729d3ed2ea3..3ef2018a22b3b128c54580dda638e1782d23b653 100644 (file)
@@ -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));
index 1c73fd43ed17dd56158688625a92b73c98148e5e..4b119b63d17d63a3cbfd8d7c0f392260b102d360 100644 (file)
@@ -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)
index 077b8632ed44d45557bcbe6aaf68616c6d942c12..eef71ccdf396f025ef6541044c8436e017d6e631 100644 (file)
@@ -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
index e5820947e6e51dc5dfa087085b6bbaf0b239259b..47ee9ba1e282d38f8092b80b3772f43c4fd6379b 100644 (file)
@@ -29,7 +29,7 @@
  *  Known contributors to this file:
  *     Dave Pare, 1989
  *     Steve McClure, 1997
- *     Markus Armbruster, 2004-2015
+ *     Markus Armbruster, 2004-2016
  */
 
 #include <config.h>
@@ -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;
index 48f4bcf6ce48cc882e35cfcc1d82a4223edca1d9..21713e4b71478c4e232b779d2dba1d84fd3a8999 100644 (file)
@@ -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 <config.h>
@@ -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;
index ad3607a84f86bf9f3c3c1302183ba43657fc112e..c36c41e64b7ef019cb744f37dcbd225b87289c27 100644 (file)
@@ -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;
            }