diff --git a/include/nat.h b/include/nat.h index a5c4640d..0d0dc192 100644 --- a/include/nat.h +++ b/include/nat.h @@ -116,7 +116,7 @@ struct natstr { float nat_level[4]; /* technology, etc */ short nat_relate[MAXNOC]; unsigned char nat_contact[MAXNOC]; - short nat_rejects[(MAXNOC + 3) / 4]; /* four bits for each country */ + unsigned char nat_rejects[MAXNOC]; signed char nat_priorities[PRI_MAX+1]; /* budget priority */ long nat_flags; /* nation flags */ char nat_spare[15]; diff --git a/src/lib/commands/add.c b/src/lib/commands/add.c index c6066a6d..64b7b098 100644 --- a/src/lib/commands/add.c +++ b/src/lib/commands/add.c @@ -215,7 +215,7 @@ add(void) natp->nat_level[NAT_RLEV] = start_research; natp->nat_level[NAT_ELEV] = start_education; natp->nat_level[NAT_HLEV] = start_happiness; - for (i = 0; i < MAXNOC / 4; i++) + for (i = 0; i < MAXNOC; i++) natp->nat_rejects[i] = 0; natp->nat_newstim = 0; natp->nat_annotim = 0; diff --git a/src/lib/common/nat.c b/src/lib/common/nat.c index 65a5763e..2e1fdcb2 100644 --- a/src/lib/common/nat.c +++ b/src/lib/common/nat.c @@ -107,14 +107,7 @@ getrel(struct natstr *np, natid them) int getrejects(natid them, struct natstr *np) { - int ind; - int shift; - int reject; - - ind = them / 4; - shift = 12 - ((them - ((them / 4) << 2)) * 4); - reject = (np->nat_rejects[ind] >> shift) & 0x0f; - return reject; + return np->nat_rejects[them]; } void @@ -144,19 +137,10 @@ putrel(struct natstr *np, natid them, int relate) void putreject(struct natstr *np, natid them, int how, int what) { - int shift; - int newrej; - int ind; - - what &= 0x0f; - ind = them / 4; - shift = 12 - ((them - ((them / 4) << 2)) * 4); - newrej = np->nat_rejects[ind]; if (how) - newrej |= (what << shift); + np->nat_rejects[them] |= what; else - newrej &= ~(what << shift); - np->nat_rejects[ind] = newrej; + np->nat_rejects[them] &= what; } void diff --git a/src/lib/global/nsc.c b/src/lib/global/nsc.c index 637119a3..f53cff35 100644 --- a/src/lib/global/nsc.c +++ b/src/lib/global/nsc.c @@ -532,7 +532,9 @@ struct castr nat_ca[] = { /* should show mortals whether there's contact (obvious from relations?) */ {NSC_UCHAR, NSC_DEITY, MAXNOC, fldoff(natstr, nat_contact), "contacts", EF_BAD}, - /* FIXME nat_rejects[], nat_priorities[] */ + {NSC_UCHAR, 0, MAXNOC, fldoff(natstr, nat_rejects), "rejects", + EF_BAD}, + /* FIXME nat_priorities[] */ {NSC_LONG, NSC_BITS, 0, fldoff(natstr, nat_flags), "flags", EF_NATION_FLAGS}, {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}