]> git.pond.sub.org Git - empserver/commitdiff
(natstr, add, getrejects, putreject): Simplify rejections storage.
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 18 May 2006 18:43:38 +0000 (18:43 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 18 May 2006 18:43:38 +0000 (18:43 +0000)
The space savings of nibble storage are not worth the hassle,
especially for xdump.

(nat_ca): New selector rejects.

include/nat.h
src/lib/commands/add.c
src/lib/common/nat.c
src/lib/global/nsc.c

index a5c4640d233e99ec5d7f8fa53eaa2df1ed7e7cbd..0d0dc19285c5f2d5fb1ffcd0c88644900a252ba3 100644 (file)
@@ -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];
index c6066a6d18e632eb8fa5c79bb7d42a2e09ae46fe..64b7b09864ab2b082b6c10bfe055dcef71e8fe4e 100644 (file)
@@ -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;
index 65a5763e226b1dca07724f7b2b44af698262c128..2e1fdcb2c05be8658ea2796272e4169cc2344e46 100644 (file)
@@ -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
index 637119a393239313ab4a72c6aae9df687bc78a2f..f53cff35c9ea3cf54cbb7031e8037d91547a96c4 100644 (file)
@@ -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}