]> git.pond.sub.org Git - empserver/commitdiff
(EF_COUNTRY, cou_ca): New.
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 14 Jan 2006 16:28:33 +0000 (16:28 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 14 Jan 2006 16:28:33 +0000 (16:28 +0000)
(empfile): Add it.
(xdvisible): Deal with it.
(ef_open_srv, ef_close_srv): Set it up.
(ef_init_view, ef_fina_view): New.

include/file.h
include/nsc.h
src/lib/commands/xdump.c
src/lib/global/file.c
src/lib/global/nsc.c
src/lib/subs/fileinit.c

index 7f8a847eb89a0490108a46798c522ad52e0ff5b7..173293d5ef44f35834d4ae1e46a458fdbb056f8b 100644 (file)
@@ -145,6 +145,9 @@ enum {
     EF_PACKING,
     EF_RESOURCES,
     EF_NATION_STATUS,
+    /* Views */
+    EF_COUNTRY,
+    /* Number of types: */
     EF_MAX
 };
 
index da0d96f81be4788e7acbf27c901cefa7d84fd806..850fd6a715f090c1a3d893cc5e86070bd4ff3856 100644 (file)
@@ -212,6 +212,7 @@ extern struct castr lost_ca[];
 extern struct castr commodity_ca[];
 extern struct castr trade_ca[];
 extern struct castr nat_ca[];
+extern struct castr cou_ca[];
 extern struct castr realm_ca[];
 extern struct castr intrchr_ca[];
 extern struct castr rpt_ca[];
index de1a1cbb8ee061f1aed49684e031fa36d0474058..4382bde7986857f6136dddb204b3b55e44421f5e 100644 (file)
@@ -204,8 +204,11 @@ xdvisible(int type, void *p)
     case EF_LOST:
        return gp->own != 0 && (gp->own == player->cnum || player->god);
     case EF_NATION:
-       return ((struct natstr *)p)->nat_stat != STAT_UNUSED
-           && (gp->own == player->cnum || player->god);
+       if (gp->own == player->cnum || player->god)
+           return 1;
+       /* fall through */
+    case EF_COUNTRY:
+       return ((struct natstr *)p)->nat_stat != STAT_UNUSED;
     case EF_NEWS:
        return ((struct nwsstr *)p)->nws_vrb != 0
            && (!opt_HIDDEN || player->god); /* FIXME */
index 62446c9985f36cfc02cb83ff4abb051e7047ef0c..f5fd4e25fc44ed8f0fec3d77536b5e3b85c00461 100644 (file)
@@ -190,6 +190,9 @@ struct empfile empfile[] = {
     {EF_NATION_STATUS, "nation-status", NULL, symbol_ca,
      PTR_CACHE(nation_status, EFF_CFG)},
 
+    /* Views */
+    {EF_COUNTRY, "country", NULL, cou_ca, UNMAPPED_CACHE(struct natstr, 0)},
+
     /* Sentinel */
     {EF_BAD, NULL, NULL, NULL, 0, 0, NULL, 0, 0, 0, 0, -1, NULL, NULL, NULL},
 };
index 0dd4568ff1b7a128a01ffe9c50d6238a65c00798..9dcb44eaf13daafb2fe9da39f6921d03d4d38380 100644 (file)
@@ -400,7 +400,6 @@ struct castr nchr_ca[] = {
 };
 
 struct castr treaty_ca[] = {
-    /* FIXME disclose only to cna, cnb */
     {NSC_SHORT, 0, 0, fldoff(trtstr, trt_uid), "uid", EF_TREATY},
     {NSC_NATID, 0, 0, fldoff(trtstr, trt_cna), "cna", EF_NATION},
     {NSC_NATID, 0, 0, fldoff(trtstr, trt_cnb), "cnb", EF_NATION},
@@ -415,7 +414,6 @@ struct castr treaty_ca[] = {
 };
 
 struct castr loan_ca[] = {
-    /* FIXME disclose only to loaner, loanee and partially to all if signed */
     {NSC_SHORT, 0, 0, fldoff(lonstr, l_uid), "uid", EF_LOAN},
     {NSC_NATID, 0, 0, fldoff(lonstr, l_loner), "loaner", EF_NATION},
     {NSC_NATID, 0, 0, fldoff(lonstr, l_lonee), "loanee", EF_NATION},
@@ -431,7 +429,6 @@ struct castr loan_ca[] = {
 };
 
 struct castr news_ca[] = {
-    /* FIXME if HIDDEN disclose requires contact with actor and victim, and new */
     {NSC_SHORT, 0, 0, fldoff(nwsstr, nws_uid), "uid", EF_NEWS},
     {NSC_NATID, 0, 0, fldoff(nwsstr, nws_ano), "actor", EF_NATION},
     {NSC_CHAR, 0, 0, fldoff(nwsstr, nws_vrb), "action", EF_NEWS_CHR},
@@ -515,7 +512,6 @@ struct castr nat_ca[] = {
      EF_BAD},
     {NSC_FLOAT, 0, 0, fldoff(natstr, nat_level[NAT_HLEV]), "happiness",
      EF_BAD},
-    /* FIXME nat_b[] */
     {NSC_SHORT, 0, MAXNOC, fldoff(natstr, nat_relate), "relations",
      EF_NATION_RELATIONS},
     {NSC_UCHAR, NSC_DEITY, MAXNOC, fldoff(natstr, nat_contact), "contacts",
@@ -526,6 +522,14 @@ struct castr nat_ca[] = {
     {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
 };
 
+struct castr cou_ca[] = {
+    {NSC_NATID, 0, 0, fldoff(natstr, nat_cnum), "cnum", EF_NATION},
+    {NSC_CHAR, 0, 0, fldoff(natstr, nat_stat), "stat",
+     EF_NATION_STATUS},
+    {NSC_STRINGY, 0, 20, fldoff(natstr, nat_cnam), "cname", EF_BAD},
+    {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
+};
+
 struct castr realm_ca[] = {
     {NSC_SHORT, 0, 0, fldoff(realmstr, r_uid), "uid", EF_REALM},
     {NSC_NATID, 0, 0, fldoff(realmstr, r_cnum), "cnum", EF_NATION},
index c1ab7ec453cab1f282e2e50d6b62df40d1b03696..30b1d9b0dbd3d7930fd2cf44ed887c37d12676d8 100644 (file)
@@ -54,6 +54,8 @@ static struct fileinit fileinit[] = {
 
 static void ef_open_srv(void);
 static void ef_close_srv(void);
+static int ef_init_view(int, int);
+static void ef_fina_view(int);
 
 /*
  * Initialize empfile for full server operations.
@@ -107,6 +109,7 @@ ef_open_srv(void)
     failed |= !ef_open(EF_COMM, 0);
     failed |= !ef_open(EF_LOST, 0);
     failed |= !ef_open(EF_REALM, EFF_MEM);
+    failed |= ef_init_view(EF_COUNTRY, EF_NATION);
     if (failed) {
        logerror("Missing files, giving up");
        exit(EXIT_FAILURE);
@@ -116,6 +119,7 @@ ef_open_srv(void)
 static void
 ef_close_srv(void)
 {
+    ef_fina_view(EF_COUNTRY);
     ef_close(EF_NATION);
     ef_close(EF_SECTOR);
     ef_close(EF_SHIP);
@@ -133,3 +137,23 @@ ef_close_srv(void)
     ef_close(EF_LOST);
     ef_close(EF_REALM);
 }
+
+static int
+ef_init_view(int type, int base)
+{
+    if (CANT_HAPPEN(!(empfile[base].flags & EFF_MEM)))
+       return -1;
+    empfile[type].cache = empfile[base].cache;
+    empfile[type].csize = empfile[base].csize;
+    empfile[type].flags |= EFF_MEM;
+    empfile[type].baseid = empfile[base].baseid;
+    empfile[type].cids = empfile[base].cids;
+    empfile[type].fids = empfile[base].fids;
+    return 0;
+}
+
+static void
+ef_fina_view(int type)
+{
+    empfile[type].cache = NULL;
+}