(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:
parent
af9c94d06f
commit
6844c94b4a
4 changed files with 8 additions and 22 deletions
|
@ -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];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue