(natstr, add, getrejects, putreject): Simplify rejections storage.

The space savings of nibble storage are not worth the hassle,
especially for xdump.

(nat_ca): New selector rejects.
This commit is contained in:
Markus Armbruster 2006-05-18 18:43:38 +00:00
parent af9c94d06f
commit 6844c94b4a
4 changed files with 8 additions and 22 deletions

View file

@ -116,7 +116,7 @@ struct natstr {
float nat_level[4]; /* technology, etc */ float nat_level[4]; /* technology, etc */
short nat_relate[MAXNOC]; short nat_relate[MAXNOC];
unsigned char nat_contact[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 */ signed char nat_priorities[PRI_MAX+1]; /* budget priority */
long nat_flags; /* nation flags */ long nat_flags; /* nation flags */
char nat_spare[15]; char nat_spare[15];

View file

@ -215,7 +215,7 @@ add(void)
natp->nat_level[NAT_RLEV] = start_research; natp->nat_level[NAT_RLEV] = start_research;
natp->nat_level[NAT_ELEV] = start_education; natp->nat_level[NAT_ELEV] = start_education;
natp->nat_level[NAT_HLEV] = start_happiness; 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_rejects[i] = 0;
natp->nat_newstim = 0; natp->nat_newstim = 0;
natp->nat_annotim = 0; natp->nat_annotim = 0;

View file

@ -107,14 +107,7 @@ getrel(struct natstr *np, natid them)
int int
getrejects(natid them, struct natstr *np) getrejects(natid them, struct natstr *np)
{ {
int ind; return np->nat_rejects[them];
int shift;
int reject;
ind = them / 4;
shift = 12 - ((them - ((them / 4) << 2)) * 4);
reject = (np->nat_rejects[ind] >> shift) & 0x0f;
return reject;
} }
void void
@ -144,19 +137,10 @@ putrel(struct natstr *np, natid them, int relate)
void void
putreject(struct natstr *np, natid them, int how, int what) 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) if (how)
newrej |= (what << shift); np->nat_rejects[them] |= what;
else else
newrej &= ~(what << shift); np->nat_rejects[them] &= what;
np->nat_rejects[ind] = newrej;
} }
void void

View file

@ -532,7 +532,9 @@ struct castr nat_ca[] = {
/* should show mortals whether there's contact (obvious from relations?) */ /* should show mortals whether there's contact (obvious from relations?) */
{NSC_UCHAR, NSC_DEITY, MAXNOC, fldoff(natstr, nat_contact), "contacts", {NSC_UCHAR, NSC_DEITY, MAXNOC, fldoff(natstr, nat_contact), "contacts",
EF_BAD}, 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", {NSC_LONG, NSC_BITS, 0, fldoff(natstr, nat_flags), "flags",
EF_NATION_FLAGS}, EF_NATION_FLAGS},
{NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD} {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}