diff --git a/src/lib/common/filetable.c b/src/lib/common/filetable.c index ecbf69bf..cc802afd 100644 --- a/src/lib/common/filetable.c +++ b/src/lib/common/filetable.c @@ -51,7 +51,6 @@ #include "ship.h" #include "server.h" #include "trade.h" -#include "version.h" #include "xy.h" static void sct_oninit(void *); @@ -67,6 +66,8 @@ static void plchr_oninit(void *); static void lchr_oninit(void *); static void nchr_oninit(void *); +static char dummy_cache; + /* Number of elements in ARRAY. */ #define SZ(array) (sizeof(array) / sizeof((array)[0])) @@ -225,7 +226,7 @@ struct empfile empfile[] = { ARRAY_TABLE(empfile, EF_MAX, EFF_CFG), NULL, NULL, NULL, NULL}, {EF_VERSION, "version", NULL, NULL, NULL, EF_BAD, - sizeof(PACKAGE_STRING), -1, EFF_STATIC, version, 1, 0, 1, 1, -1, + 0, -1, EFF_MEM | EFF_STATIC, &dummy_cache, 1, 0, 1, 1, -1, NULL, NULL, NULL, NULL}, {EF_META, "meta", NULL, NULL, mdchr_ca, EF_BAD, PTR_CACHE(mdchr_ca, EFF_CFG), diff --git a/src/lib/common/nsc.c b/src/lib/common/nsc.c index 3d2f5fd7..1874beac 100644 --- a/src/lib/common/nsc.c +++ b/src/lib/common/nsc.c @@ -37,6 +37,7 @@ #include +#include #include #include "empobj.h" #include "optlist.h" @@ -44,9 +45,11 @@ #include "nsc.h" #include "product.h" #include "unit.h" +#include "version.h" static void *nsc_ver(struct valstr *, struct natstr *, void *); static void *nsc_ver_maxnoc(struct valstr *, struct natstr *, void *); +static void *nsc_ver_version(struct valstr *, struct natstr *, void *); static void *nsc_sct_terr(struct valstr *, struct natstr *, void *); static void *nsc_sct_track(struct valstr *, struct natstr *, void *); static void *nsc_cargo_nplane(struct valstr *, struct natstr *, void *); @@ -755,8 +758,7 @@ void nsc_init(void) { static struct castr version_ca0 = { - "version", 0, NSC_STRINGY, sizeof(PACKAGE_STRING), NULL, EF_BAD, 0, - CA_DUMP + "version", 0, NSC_STRING, 0, nsc_ver_version, EF_BAD, 0, CA_DUMP }; static struct castr version_ca1 = { "maxnoc", 0, NSC_LONG, 0, nsc_ver_maxnoc, EF_BAD, 0, CA_DUMP @@ -820,6 +822,14 @@ nsc_ver_maxnoc(struct valstr *val, struct natstr *np, void *ptr) return NULL; } +static void * +nsc_ver_version(struct valstr *val, struct natstr *np, void *ptr) +{ + val->val_as.str.base = version; + val->val_as.str.maxsz = INT_MAX; /* really SIZE_MAX, but that's C99 */ + return NULL; +} + static void * nsc_sct_terr(struct valstr *val, struct natstr *np, void *ptr) {