(ef_init): Remove cadef member from fileinit,
insert directly into the empfile structure. Add ef_type member to fileinit to identify rows with data. Remove unused rows of fileinit.
This commit is contained in:
parent
29d21997b9
commit
cf4faac293
3 changed files with 27 additions and 40 deletions
|
@ -113,10 +113,10 @@ struct empfile {
|
||||||
instead of bmap or map. */
|
instead of bmap or map. */
|
||||||
|
|
||||||
struct fileinit {
|
struct fileinit {
|
||||||
|
int ef_type;
|
||||||
void (*init) (int, char *);
|
void (*init) (int, char *);
|
||||||
int (*postread) (int, char *);
|
int (*postread) (int, char *);
|
||||||
int (*prewrite) (int, char *);
|
int (*prewrite) (int, char *);
|
||||||
struct castr *cadef;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct castr *ef_cadef(int);
|
extern struct castr *ef_cadef(int);
|
||||||
|
|
|
@ -57,37 +57,37 @@ struct empfile empfile[] = {
|
||||||
/* Dynamic game data */
|
/* Dynamic game data */
|
||||||
{"sect", "sector", EFF_XY | EFF_OWNER,
|
{"sect", "sector", EFF_XY | EFF_OWNER,
|
||||||
0, sizeof(struct sctstr), NULL, NULL, NULL,
|
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,
|
{"ship", "ship", EFF_XY | EFF_OWNER | EFF_GROUP,
|
||||||
0, sizeof(struct shpstr), NULL, NULL, NULL,
|
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,
|
{"plane", "plane", EFF_XY | EFF_OWNER | EFF_GROUP,
|
||||||
0, sizeof(struct plnstr), NULL, NULL, NULL,
|
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,
|
{"land", "land", EFF_XY | EFF_OWNER | EFF_GROUP,
|
||||||
0, sizeof(struct lndstr), NULL, NULL, NULL,
|
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,
|
{"nuke", "nuke", EFF_XY | EFF_OWNER,
|
||||||
0, sizeof(struct nukstr), NULL, NULL, NULL,
|
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,
|
{"news", "news", 0,
|
||||||
0, sizeof(struct nwsstr), NULL, NULL, NULL,
|
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,
|
{"treaty", "treaty", 0,
|
||||||
0, sizeof(struct trtstr), NULL, NULL, NULL,
|
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,
|
{"trade", "trade", 0,
|
||||||
0, sizeof(struct trdstr), NULL, NULL, NULL,
|
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,
|
{"pow", "power", 0,
|
||||||
0, sizeof(struct powstr), NULL, NULL, NULL,
|
0, sizeof(struct powstr), NULL, NULL, NULL,
|
||||||
-1, -1, 0, 0, NULL, 0, NULL},
|
-1, -1, 0, 0, NULL, 0, NULL},
|
||||||
{"nat", "nation", EFF_OWNER,
|
{"nat", "nation", EFF_OWNER,
|
||||||
0, sizeof(struct natstr), NULL, NULL, NULL,
|
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,
|
{"loan", "loan", 0,
|
||||||
0, sizeof(struct lonstr), NULL, NULL, NULL,
|
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,
|
{"map", "map", 0,
|
||||||
0, DEF_WORLD_X * DEF_WORLD_Y / 2, NULL, NULL, NULL,
|
0, DEF_WORLD_X * DEF_WORLD_Y / 2, NULL, NULL, NULL,
|
||||||
-1, -1, 0, 0, NULL, 0, NULL},
|
-1, -1, 0, 0, NULL, 0, NULL},
|
||||||
|
@ -96,10 +96,10 @@ struct empfile empfile[] = {
|
||||||
-1, -1, 0, 0, NULL, 0, NULL},
|
-1, -1, 0, 0, NULL, 0, NULL},
|
||||||
{"commodity", "commodity", 0,
|
{"commodity", "commodity", 0,
|
||||||
0, sizeof(struct comstr), NULL, NULL, NULL,
|
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,
|
{"lost", "lostitems", EFF_OWNER,
|
||||||
0, sizeof(struct loststr), NULL, NULL, NULL,
|
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) */
|
/* Static game data (configuation) */
|
||||||
{"sect chr", NULL, EFF_MEM,
|
{"sect chr", NULL, EFF_MEM,
|
||||||
|
|
|
@ -25,10 +25,12 @@
|
||||||
*
|
*
|
||||||
* ---
|
* ---
|
||||||
*
|
*
|
||||||
* fileinit.c: Stuff that ef_init uses to initialize the ca pointers and
|
* fileinit.c: Fill the empfile[] with function pointers only required for
|
||||||
* the pre/post i/o calls.
|
* full server operations. This allows the empfile[] to be
|
||||||
|
* used in files and fairland.
|
||||||
*
|
*
|
||||||
* Known contributors to this file:
|
* Known contributors to this file:
|
||||||
|
* Ron Koenderink, 2005
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -39,38 +41,23 @@
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
|
|
||||||
struct fileinit fileinit[EF_MAX] = {
|
struct fileinit fileinit[] = {
|
||||||
{NULL, sct_postread, sct_prewrite, sect_ca},
|
{EF_SECTOR, NULL, sct_postread, sct_prewrite},
|
||||||
{shp_init, shp_postread, shp_prewrite, ship_ca},
|
{EF_SHIP, shp_init, shp_postread, shp_prewrite},
|
||||||
{pln_init, pln_postread, pln_prewrite, plane_ca},
|
{EF_PLANE, pln_init, pln_postread, pln_prewrite},
|
||||||
{lnd_init, lnd_postread, lnd_prewrite, land_ca},
|
{EF_LAND, lnd_init, lnd_postread, lnd_prewrite},
|
||||||
{nuk_init, nuk_postread, nuk_prewrite, nuke_ca},
|
{EF_NUKE, nuk_init, nuk_postread, nuk_prewrite}
|
||||||
{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}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
ef_init(void)
|
ef_init(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct empfile *ef;
|
|
||||||
struct fileinit *fi;
|
|
||||||
|
|
||||||
ef = empfile;
|
for (i = 0; i < sizeof(fileinit) / sizeof(fileinit[0]); i++) {
|
||||||
fi = fileinit;
|
empfile[fileinit[i].ef_type].init = fileinit[i].init;
|
||||||
for (i = 0; i < EF_MAX; i++, ef++, fi++) {
|
empfile[fileinit[i].ef_type].postread = fileinit[i].postread;
|
||||||
ef->init = fi->init;
|
empfile[fileinit[i].ef_type].prewrite = fileinit[i].prewrite;
|
||||||
ef->postread = fi->postread;
|
|
||||||
ef->prewrite = fi->prewrite;
|
|
||||||
ef->cadef = fi->cadef;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
empfile[EF_MAP].size = empfile[EF_BMAP].size = (WORLD_X * WORLD_Y) / 2;
|
empfile[EF_MAP].size = empfile[EF_BMAP].size = (WORLD_X * WORLD_Y) / 2;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue