diff --git a/include/nat.h b/include/nat.h index e8c0d736..f44d30d2 100644 --- a/include/nat.h +++ b/include/nat.h @@ -170,6 +170,7 @@ extern char *relatename(struct natstr *np, natid other); extern char *rejectname(struct natstr *np, natid other); 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 getcontact(struct natstr *np, natid them); extern void putrel(struct natstr *np, natid them, int relate); diff --git a/src/lib/common/nat.c b/src/lib/common/nat.c index e71e1cf8..1efc5b19 100644 --- a/src/lib/common/nat.c +++ b/src/lib/common/nat.c @@ -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) {