New relations_with()
Relations checking with getrel() often needs a special case for "is
same country". If you forget, you get behavior appropriate for a
neutral foreign country, which is usually very wrong (see commit
16c68eb4
for an example).
Unlike getrel(), relations_with() considers countries allied to
themselves. Less dangerous. In fact, allied behavior is typically
just right, so the special case isn't even needed.
This commit is contained in:
parent
0c60e574a9
commit
bb5cd07ce5
2 changed files with 11 additions and 0 deletions
|
@ -104,6 +104,16 @@ getrel(struct natstr *np, natid them)
|
|||
return np->nat_relate[them];
|
||||
}
|
||||
|
||||
/*
|
||||
* Return relations US has with THEM.
|
||||
* Countries are considered allied to themselves.
|
||||
*/
|
||||
int
|
||||
relations_with(natid us, natid them)
|
||||
{
|
||||
return us == them ? ALLIED : getrel(getnatp(us), them);
|
||||
}
|
||||
|
||||
int
|
||||
getrejects(natid them, struct natstr *np)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue