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:
parent
f54f655130
commit
414a5e179f
3 changed files with 3 additions and 13 deletions
|
@ -200,7 +200,6 @@ extern double techfact(int level, double mult);
|
||||||
/* src/lib/common/nat.c */
|
/* src/lib/common/nat.c */
|
||||||
extern char *cname(natid n);
|
extern char *cname(natid n);
|
||||||
extern char *natstate(struct natstr *np);
|
extern char *natstate(struct natstr *np);
|
||||||
extern enum relations getrel(struct natstr *np, natid them);
|
|
||||||
extern enum relations relations_with(natid, natid);
|
extern enum relations relations_with(natid, natid);
|
||||||
extern char *relations_string(enum relations);
|
extern char *relations_string(enum relations);
|
||||||
extern int nat_accepts(natid, natid, enum rej_comm);
|
extern int nat_accepts(natid, natid, enum rej_comm);
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
int
|
int
|
||||||
rela(void)
|
rela(void)
|
||||||
{
|
{
|
||||||
struct natstr *natp;
|
|
||||||
struct natstr *np;
|
struct natstr *np;
|
||||||
natid cn;
|
natid cn;
|
||||||
natid as;
|
natid as;
|
||||||
|
@ -56,7 +55,6 @@ rela(void)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
as = (natid)n;
|
as = (natid)n;
|
||||||
}
|
}
|
||||||
natp = getnatp(as);
|
|
||||||
pr("\t%s Diplomatic Relations Report\t", cname(as));
|
pr("\t%s Diplomatic Relations Report\t", cname(as));
|
||||||
prdate();
|
prdate();
|
||||||
pr("\n Formal Relations %5s theirs\n",
|
pr("\n Formal Relations %5s theirs\n",
|
||||||
|
@ -76,8 +74,8 @@ rela(void)
|
||||||
}
|
}
|
||||||
pr("%3d) %-20.20s ", cn, cname(cn));
|
pr("%3d) %-20.20s ", cn, cname(cn));
|
||||||
pr("%-10s %s\n",
|
pr("%-10s %s\n",
|
||||||
relations_string(getrel(natp, cn)),
|
relations_string(relations_with(as, cn)),
|
||||||
relations_string(getrel(np, as)));
|
relations_string(relations_with(cn, as)));
|
||||||
}
|
}
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,13 +61,6 @@ natstate(struct natstr *np)
|
||||||
return stnam[np->nat_stat];
|
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.
|
* Return relations @us has with @them.
|
||||||
* Countries are considered allied to themselves.
|
* Countries are considered allied to themselves.
|
||||||
|
@ -75,7 +68,7 @@ getrel(struct natstr *np, natid them)
|
||||||
enum relations
|
enum relations
|
||||||
relations_with(natid us, natid them)
|
relations_with(natid us, natid them)
|
||||||
{
|
{
|
||||||
return us == them ? ALLIED : getrel(getnatp(us), them);
|
return us == them ? ALLIED : getnatp(us)->nat_relate[them];
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue