relations: Eliminate getrel()

Most uses of getrel() have been replaced by the safer relations_with()
in commit 0c60e57..67b9135, v4.3.27.  Eliminate the remaining ones:

* Convert rela() to use relations_with().  The case of relations to
  self, where the two differ, doesn't occur.  The code becomes more
  easier to understand, even.

* relations_with() is then getrel()'s last user.  Inline.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-10-31 15:29:21 +01:00
parent f54f655130
commit 414a5e179f
3 changed files with 3 additions and 13 deletions

View file

@ -200,7 +200,6 @@ extern double techfact(int level, double mult);
/* src/lib/common/nat.c */
extern char *cname(natid n);
extern char *natstate(struct natstr *np);
extern enum relations getrel(struct natstr *np, natid them);
extern enum relations relations_with(natid, natid);
extern char *relations_string(enum relations);
extern int nat_accepts(natid, natid, enum rej_comm);

View file

@ -43,7 +43,6 @@
int
rela(void)
{
struct natstr *natp;
struct natstr *np;
natid cn;
natid as;
@ -56,7 +55,6 @@ rela(void)
return RET_SYN;
as = (natid)n;
}
natp = getnatp(as);
pr("\t%s Diplomatic Relations Report\t", cname(as));
prdate();
pr("\n Formal Relations %5s theirs\n",
@ -76,8 +74,8 @@ rela(void)
}
pr("%3d) %-20.20s ", cn, cname(cn));
pr("%-10s %s\n",
relations_string(getrel(natp, cn)),
relations_string(getrel(np, as)));
relations_string(relations_with(as, cn)),
relations_string(relations_with(cn, as)));
}
return RET_OK;
}

View file

@ -61,13 +61,6 @@ natstate(struct natstr *np)
return stnam[np->nat_stat];
}
/* This returns the relations that np has with them */
enum relations
getrel(struct natstr *np, natid them)
{
return np->nat_relate[them];
}
/*
* Return relations @us has with @them.
* Countries are considered allied to themselves.
@ -75,7 +68,7 @@ getrel(struct natstr *np, natid them)
enum relations
relations_with(natid us, natid them)
{
return us == them ? ALLIED : getrel(getnatp(us), them);
return us == them ? ALLIED : getnatp(us)->nat_relate[them];
}
char *