diff --git a/include/file.h b/include/file.h index 1242a660..640adbc9 100644 --- a/include/file.h +++ b/include/file.h @@ -71,18 +71,21 @@ struct empfile { * The remaining flags record how the table is being used. */ /* Immutable flags, fixed at compile-time */ +/* Table entries' addresses can't be safely cast to struct emptyped *. */ +#define EFF_TYPED bit(0) /* * EFF_XY / EFF_OWNER / EFF_GROUP assert that coordinates / owner / * group of such a table's entries can be safely obtained by - * dereferencing entry address cast to struct empobj *. + * dereferencing the entry's address cast to struct empobj *. */ -#define EFF_XY bit(0) -#define EFF_OWNER bit(1) -#define EFF_GROUP bit(2) +#define EFF_XY bit(1) +#define EFF_OWNER bit(2) +#define EFF_GROUP bit(3) /* Table is allocated statically */ -#define EFF_STATIC bit(3) +#define EFF_STATIC bit(4) /* All the immutable flags */ -#define EFF_IMMUTABLE (EFF_XY | EFF_OWNER | EFF_GROUP | EFF_STATIC) +#define EFF_IMMUTABLE \ + (EFF_TYPED | EFF_XY | EFF_OWNER | EFF_GROUP | EFF_STATIC) /* Flags set when table contents is mapped */ /* Table is entirely in memory */ #define EFF_MEM bit(8) diff --git a/src/lib/global/file.c b/src/lib/global/file.c index 0a0031a6..5e6ec469 100644 --- a/src/lib/global/file.c +++ b/src/lib/global/file.c @@ -117,39 +117,42 @@ struct empfile empfile[] = { * Fixed up by empfile_fixup(). */ {EF_SECTOR, "sect", "sector", sect_ca, - UNMAPPED_CACHE(struct sctstr, EFF_XY | EFF_OWNER)}, + UNMAPPED_CACHE(struct sctstr, EFF_TYPED | EFF_XY | EFF_OWNER)}, {EF_SHIP, "ship", "ship", ship_ca, - UNMAPPED_CACHE(struct shpstr, EFF_XY | EFF_OWNER | EFF_GROUP)}, + UNMAPPED_CACHE(struct shpstr, + EFF_TYPED | EFF_XY | EFF_OWNER | EFF_GROUP)}, {EF_PLANE, "plane", "plane", plane_ca, - UNMAPPED_CACHE(struct plnstr, EFF_XY | EFF_OWNER | EFF_GROUP)}, + UNMAPPED_CACHE(struct plnstr, + EFF_TYPED | EFF_XY | EFF_OWNER | EFF_GROUP)}, {EF_LAND, "land", "land", land_ca, - UNMAPPED_CACHE(struct lndstr, EFF_XY | EFF_OWNER | EFF_GROUP)}, + UNMAPPED_CACHE(struct lndstr, + EFF_TYPED | EFF_XY | EFF_OWNER | EFF_GROUP)}, {EF_NUKE, "nuke", "nuke", nuke_ca, - UNMAPPED_CACHE(struct nukstr, EFF_XY | EFF_OWNER)}, + UNMAPPED_CACHE(struct nukstr, EFF_TYPED | EFF_XY | EFF_OWNER)}, {EF_NEWS, "news", "news", news_ca, - UNMAPPED_CACHE(struct nwsstr, 0)}, + UNMAPPED_CACHE(struct nwsstr, EFF_TYPED)}, {EF_TREATY, "treaty", "treaty", treaty_ca, - UNMAPPED_CACHE(struct trtstr, 0)}, + UNMAPPED_CACHE(struct trtstr, EFF_TYPED)}, {EF_TRADE, "trade", "trade", trade_ca, - UNMAPPED_CACHE(struct trdstr, EFF_OWNER)}, + UNMAPPED_CACHE(struct trdstr, EFF_TYPED | EFF_OWNER)}, {EF_POWER, "pow", "power", NULL, UNMAPPED_CACHE(struct powstr, 0)}, {EF_NATION, "nat", "nation", nat_ca, - UNMAPPED_CACHE(struct natstr, EFF_OWNER)}, + UNMAPPED_CACHE(struct natstr, EFF_TYPED | EFF_OWNER)}, {EF_LOAN, "loan", "loan", loan_ca, - UNMAPPED_CACHE(struct lonstr, 0)}, + UNMAPPED_CACHE(struct lonstr, EFF_TYPED)}, {EF_MAP, "map", "map", NULL, 0, 0, NULL, 0, 0, 0, 0, -1, NULL, NULL, NULL}, {EF_BMAP, "bmap", "bmap", NULL, 0, 0, NULL, 0, 0, 0, 0, -1, NULL, NULL, NULL}, {EF_COMM, "commodity", "commodity", commodity_ca, - UNMAPPED_CACHE(struct comstr, EFF_OWNER)}, + UNMAPPED_CACHE(struct comstr, EFF_TYPED | EFF_OWNER)}, {EF_LOST, "lost", "lostitems", lost_ca, - UNMAPPED_CACHE(struct loststr, EFF_OWNER)}, + UNMAPPED_CACHE(struct loststr, EFF_TYPED | EFF_OWNER)}, {EF_REALM, "realm", "realms", realm_ca, - UNMAPPED_CACHE(struct realmstr, EFF_OWNER)}, + UNMAPPED_CACHE(struct realmstr, EFF_TYPED | EFF_OWNER)}, {EF_GAME, "game", "game", game_ca, - UNMAPPED_CACHE(struct gamestr, 0)}, + UNMAPPED_CACHE(struct gamestr, EFF_TYPED)}, /* * Static game data (configuration) @@ -215,7 +218,7 @@ struct empfile empfile[] = { /* Views */ {EF_COUNTRY, "country", NULL, cou_ca, - UNMAPPED_CACHE(struct natstr, EFF_OWNER)}, + UNMAPPED_CACHE(struct natstr, EFF_TYPED | EFF_OWNER)}, /* Sentinel */ {EF_BAD, NULL, NULL, NULL, 0, 0, NULL, 0, 0, 0, 0, -1, NULL, NULL, NULL},