]> git.pond.sub.org Git - empserver/commitdiff
(ef_init): Remove cadef member from fileinit,
authorRon Koenderink <rkoenderink@yahoo.ca>
Sat, 22 Oct 2005 13:55:04 +0000 (13:55 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Sat, 22 Oct 2005 13:55:04 +0000 (13:55 +0000)
insert directly into the empfile structure.
Add ef_type member to fileinit to identify rows with data.
Remove unused rows of fileinit.

include/file.h
src/lib/global/file.c
src/lib/subs/fileinit.c

index 9fae5c18e8d30144c24204bdcd054ebe1f64ab20..546d102e2f18a9b8099b7772ddd69ea6e158bde5 100644 (file)
@@ -113,10 +113,10 @@ struct empfile {
                                   instead of bmap or map. */
 
 struct fileinit {
+    int ef_type;
     void (*init) (int, char *);
     int (*postread) (int, char *);
     int (*prewrite) (int, char *);
-    struct castr *cadef;
 };
 
 extern struct castr *ef_cadef(int);
index ad62f5f17d369d328e3e13ea7a60e931468b666e..95f70bf3849effd640744eb5386ef63dbdca3560 100644 (file)
@@ -57,37 +57,37 @@ struct empfile empfile[] = {
     /* Dynamic game data */
     {"sect", "sector", EFF_XY | EFF_OWNER,
      0, sizeof(struct sctstr), NULL, NULL, NULL,
-     -1, -1, 0, 0, NULL, 0, NULL},
+     -1, -1, 0, 0, NULL, 0, sect_ca},
     {"ship", "ship", EFF_XY | EFF_OWNER | EFF_GROUP,
      0, sizeof(struct shpstr), NULL, NULL, NULL,
-     -1, -1, 0, 0, NULL, 0, NULL},
+     -1, -1, 0, 0, NULL, 0, ship_ca},
     {"plane", "plane", EFF_XY | EFF_OWNER | EFF_GROUP,
      0, sizeof(struct plnstr), NULL, NULL, NULL,
-     -1, -1, 0, 0, NULL, 0, NULL},
+     -1, -1, 0, 0, NULL, 0, plane_ca},
     {"land", "land", EFF_XY | EFF_OWNER | EFF_GROUP,
      0, sizeof(struct lndstr), NULL, NULL, NULL,
-     -1, -1, 0, 0, NULL, 0, NULL},
+     -1, -1, 0, 0, NULL, 0, land_ca},
     {"nuke", "nuke", EFF_XY | EFF_OWNER,
      0, sizeof(struct nukstr), NULL, NULL, NULL,
-     -1, -1, 0, 0, NULL, 0, NULL},
+     -1, -1, 0, 0, NULL, 0, nuke_ca},
     {"news", "news", 0,
      0, sizeof(struct nwsstr), NULL, NULL, NULL,
-     -1, -1, 0, 0, NULL, 0, NULL},
+     -1, -1, 0, 0, NULL, 0, news_ca},
     {"treaty", "treaty", 0,
      0, sizeof(struct trtstr), NULL, NULL, NULL,
-     -1, -1, 0, 0, NULL, 0, NULL},
+     -1, -1, 0, 0, NULL, 0, treaty_ca},
     {"trade", "trade", 0,
      0, sizeof(struct trdstr), NULL, NULL, NULL,
-     -1, -1, 0, 0, NULL, 0, NULL},
+     -1, -1, 0, 0, NULL, 0, trade_ca},
     {"pow", "power", 0,
      0, sizeof(struct powstr), NULL, NULL, NULL,
      -1, -1, 0, 0, NULL, 0, NULL},
     {"nat", "nation", EFF_OWNER,
      0, sizeof(struct natstr), NULL, NULL, NULL,
-     -1, -1, 0, 0, NULL, 0, NULL},
+     -1, -1, 0, 0, NULL, 0, nat_ca},
     {"loan", "loan", 0,
      0, sizeof(struct lonstr), NULL, NULL, NULL,
-     -1, -1, 0, 0, NULL, 0, NULL},
+     -1, -1, 0, 0, NULL, 0, loan_ca},
     {"map", "map", 0,
      0, DEF_WORLD_X * DEF_WORLD_Y / 2, NULL, NULL, NULL,
      -1, -1, 0, 0, NULL, 0, NULL},
@@ -96,10 +96,10 @@ struct empfile empfile[] = {
      -1, -1, 0, 0, NULL, 0, NULL},
     {"commodity", "commodity", 0,
      0, sizeof(struct comstr), NULL, NULL, NULL,
-     -1, -1, 0, 0, NULL, 0, NULL},
+     -1, -1, 0, 0, NULL, 0, commodity_ca},
     {"lost", "lostitems", EFF_OWNER,
      0, sizeof(struct loststr), NULL, NULL, NULL,
-     -1, -1, 0, 0, NULL, 0, NULL},
+     -1, -1, 0, 0, NULL, 0, lost_ca},
 
     /* Static game data (configuation) */
     {"sect chr", NULL, EFF_MEM,
index 3f0ab6b066d87a74ca9fe858a65f2ce2cca637df..57f41916476b07e86d1789e28803f464fc3cf452 100644 (file)
  *
  *  ---
  *
- *  fileinit.c: Stuff that ef_init uses to initialize the ca pointers and
- *              the pre/post i/o calls.
+ *  fileinit.c: Fill the empfile[] with function pointers only required for
+ *              full server operations.  This allows the empfile[] to be
+ *              used in files and fairland.
  * 
  *  Known contributors to this file:
+ *     Ron Koenderink, 2005
  *  
  */
 
 #include "prototypes.h"
 #include "optlist.h"
 
-struct fileinit fileinit[EF_MAX] = {
-    {NULL, sct_postread, sct_prewrite, sect_ca},
-    {shp_init, shp_postread, shp_prewrite, ship_ca},
-    {pln_init, pln_postread, pln_prewrite, plane_ca},
-    {lnd_init, lnd_postread, lnd_prewrite, land_ca},
-    {nuk_init, nuk_postread, nuk_prewrite, nuke_ca},
-    {NULL, NULL, NULL, news_ca},
-    {NULL, NULL, NULL, treaty_ca},
-    {NULL, NULL, NULL, trade_ca},
-    {NULL, NULL, NULL, NULL},          /* power */
-    {NULL, NULL, NULL, nat_ca},        /* nation */
-    {NULL, NULL, NULL, loan_ca},
-    {NULL, NULL, NULL, NULL},          /* map, a.k.a. true bmap */
-    {NULL, NULL, NULL, NULL},          /* (working) bmap */
-    {NULL, NULL, NULL, commodity_ca},
-    {NULL, NULL, NULL, lost_ca}
+struct fileinit fileinit[] = {
+    {EF_SECTOR, NULL, sct_postread, sct_prewrite},
+    {EF_SHIP, shp_init, shp_postread, shp_prewrite},
+    {EF_PLANE, pln_init, pln_postread, pln_prewrite},
+    {EF_LAND, lnd_init, lnd_postread, lnd_prewrite},
+    {EF_NUKE, nuk_init, nuk_postread, nuk_prewrite}
 };
 
 void
 ef_init(void)
 {
     int i;
-    struct empfile *ef;
-    struct fileinit *fi;
 
-    ef = empfile;
-    fi = fileinit;
-    for (i = 0; i < EF_MAX; i++, ef++, fi++) {
-       ef->init = fi->init;
-       ef->postread = fi->postread;
-       ef->prewrite = fi->prewrite;
-       ef->cadef = fi->cadef;
+    for (i = 0; i < sizeof(fileinit) / sizeof(fileinit[0]); i++) {
+       empfile[fileinit[i].ef_type].init = fileinit[i].init;
+       empfile[fileinit[i].ef_type].postread = fileinit[i].postread;
+       empfile[fileinit[i].ef_type].prewrite = fileinit[i].prewrite;
     }
 
     empfile[EF_MAP].size = empfile[EF_BMAP].size = (WORLD_X * WORLD_Y) / 2;