contact: Change in_contact()'s first parameter to natid

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-10-29 09:06:12 +02:00
parent c8e7548f24
commit d35303d426
9 changed files with 19 additions and 20 deletions

View 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);

View 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;
}

View 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;

View 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));

View 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)

View 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

View 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;

View 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;

View 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;
}