From 762d39d90513064349456f8b33f18e6d308cad00 Mon Sep 17 00:00:00 2001 From: Ron Koenderink Date: Fri, 18 Nov 2005 23:40:30 +0000 Subject: [PATCH] (getcontact, putcontact, nat_contact): Change nat_contact to unsigned char to reduce the space required for natstr. --- include/nat.h | 7 ++++--- src/lib/common/nat.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/nat.h b/include/nat.h index 2504556f..4c292ace 100644 --- a/include/nat.h +++ b/include/nat.h @@ -86,7 +86,7 @@ struct natstr { float nat_level[4]; /* technology, etc */ struct boundstr nat_b[MAXNOR]; /* realm bounds */ short nat_relate[MAXNOC]; - short nat_contact[MAXNOC]; + unsigned char nat_contact[MAXNOC]; short nat_rejects[(MAXNOC + 3) / 4]; /* four bits for each country */ s_char nat_priorities[PRI_MAX+1]; /* budget priority */ long nat_flags; /* nation flags */ @@ -167,10 +167,11 @@ extern s_char *rejectname(struct natstr *np, natid other); extern s_char *natstate(struct natstr *np); extern int getrel(struct natstr *np, natid them); extern int getrejects(natid them, struct natstr *np); -extern int getcontact(struct natstr *np, natid them); +extern unsigned char getcontact(struct natstr *np, natid them); extern void putrel(struct natstr *np, natid them, int relate); extern void putreject(struct natstr *np, natid them, int how, int what); -extern void putcontact(struct natstr *np, natid them, int contact); +extern void putcontact(struct natstr *np, natid them, + unsigned char contact); extern void agecontact(struct natstr *np); /* nation flags */ diff --git a/src/lib/common/nat.c b/src/lib/common/nat.c index bcd07752..b6628f15 100644 --- a/src/lib/common/nat.c +++ b/src/lib/common/nat.c @@ -128,7 +128,7 @@ agecontact(struct natstr *np) } } -int +unsigned char getcontact(struct natstr *np, natid them) { return np->nat_contact[them]; @@ -159,7 +159,7 @@ putreject(struct natstr *np, natid them, int how, int what) } void -putcontact(struct natstr *np, natid them, int contact) +putcontact(struct natstr *np, natid them, unsigned char contact) { if (np->nat_contact[them] < contact) np->nat_contact[them] = contact;