Sectors need space for items, deliveries and distribution thresholds.
To save space, the ancients invented `variables': a collection of key-value pairs, missing means zero value, space for `enough' keys. This complicates the code, as assigning to a `variable' can fail for lack of space. Over time, `enough' increased, and for quite some time now `variables' have been *wasting* space. This changeset replaces them, except in struct mchrstr, struct lchrstr and struct pchrstr, where they are read-only, and will be replaced later. It is only a first step; further cleanup is required. To simplify and minimize this necessarily huge changeset, the new item[] arrays have an unused slot 0, and the old variable types V_CIVIL, ... are still defined, but must have the same values as the item types I_CIVIL, ...
This commit is contained in:
parent
ba86513b01
commit
eccc5cb7d7
86 changed files with 853 additions and 1226 deletions
|
@ -31,7 +31,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <struct.h>
|
||||
#include <stddef.h>
|
||||
#include "misc.h"
|
||||
#include "var.h"
|
||||
#include "xy.h"
|
||||
|
@ -56,45 +56,48 @@
|
|||
|
||||
struct empfile empfile[] = {
|
||||
{"sect", EMPDIR "/data/sector", EFF_COM | EFF_XY | EFF_OWNER,
|
||||
0, sizeof(struct sctstr),
|
||||
0, 0, 0, {fldoff(sctstr, sct_nv), fldoff(sctstr, sct_vtype[0]),
|
||||
fldoff(sctstr, sct_vamt[0])}, MAXSCTV,
|
||||
0, sizeof(struct sctstr), 0, 0, 0, offsetof(struct sctstr, sct_item),
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"ship", EMPDIR "/data/ship", EFF_COM | EFF_XY | EFF_OWNER | EFF_GROUP,
|
||||
0, sizeof(struct shpstr),
|
||||
0, 0, 0, {fldoff(shpstr, shp_nv), fldoff(shpstr, shp_vtype[0]),
|
||||
fldoff(shpstr, shp_vamt[0])}, MAXSHPV,
|
||||
0, sizeof(struct shpstr), 0, 0, 0, offsetof(struct shpstr, shp_item),
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"plane", EMPDIR "/data/plane", EFF_XY | EFF_OWNER | EFF_GROUP,
|
||||
0, sizeof(struct plnstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"land", EMPDIR "/data/land", EFF_COM | EFF_XY | EFF_OWNER | EFF_GROUP,
|
||||
0, sizeof(struct lndstr),
|
||||
0, 0, 0, {fldoff(lndstr, lnd_nv), fldoff(lndstr, lnd_vtype[0]),
|
||||
fldoff(lndstr, lnd_vamt[0])}, MAXLNDV,
|
||||
0, sizeof(struct plnstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"land", EMPDIR "/data/land", EFF_COM | EFF_XY | EFF_OWNER | EFF_GROUP,
|
||||
0, sizeof(struct lndstr), 0, 0, 0, offsetof(struct lndstr, lnd_item),
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"nuke", EMPDIR "/data/nuke", EFF_XY | EFF_OWNER,
|
||||
0, sizeof(struct nukstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"nuke", EMPDIR "/data/nuke", EFF_XY | EFF_OWNER, 0, sizeof(struct nukstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"news", EMPDIR "/data/news", 0,
|
||||
0, sizeof(struct nwsstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"treaty", EMPDIR "/data/treaty", 0, 0, sizeof(struct trtstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"trade", EMPDIR "/data/trade", 0, 0, sizeof(struct trdstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"pow", EMPDIR "/data/power", 0, 0, sizeof(struct powstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"nat", EMPDIR "/data/nation", 0, 0, sizeof(struct natstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
0, sizeof(struct nwsstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"treaty", EMPDIR "/data/treaty", 0,
|
||||
0, sizeof(struct trtstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"trade", EMPDIR "/data/trade", 0,
|
||||
0, sizeof(struct trdstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"pow", EMPDIR "/data/power", 0,
|
||||
0, sizeof(struct powstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"nat", EMPDIR "/data/nation", 0,
|
||||
0, sizeof(struct natstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"loan", EMPDIR "/data/loan", 0,
|
||||
0, sizeof(struct lonstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"map", EMPDIR "/data/map", 0, 0, DEF_WORLD_X * DEF_WORLD_Y / 2,
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"bmap", EMPDIR "/data/bmap", 0, 0, DEF_WORLD_X * DEF_WORLD_Y / 2,
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"commodity", EMPDIR "/data/commodity", 0, 0, sizeof(struct comstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"lost", EMPDIR "/data/lostitems", 0, 0, sizeof(struct loststr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0}
|
||||
0, sizeof(struct lonstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"map", EMPDIR "/data/map", 0,
|
||||
0, DEF_WORLD_X * DEF_WORLD_Y / 2, 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"bmap", EMPDIR "/data/bmap", 0,
|
||||
0, DEF_WORLD_X * DEF_WORLD_Y / 2, 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"commodity", EMPDIR "/data/commodity", 0,
|
||||
0, sizeof(struct comstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"lost", EMPDIR "/data/lostitems", 0, 0,
|
||||
sizeof(struct loststr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
|
|
@ -59,3 +59,5 @@ struct ichrstr ichr[I_MAX + 2] = {
|
|||
{'r', V_RAD, 150, 1, 8, {1, 10, 1, 1}, "radioactive materials"},
|
||||
{0, 0, 0, 0, 0, {0, 0, 0, 0}, 0}
|
||||
};
|
||||
|
||||
int itm_maxno = (sizeof(ichr) / sizeof(struct ichrstr)) - 1;
|
||||
|
|
|
@ -52,11 +52,6 @@
|
|||
#include "lost.h"
|
||||
|
||||
struct castr var_ca[] = {
|
||||
{NSC_DEITY | NSC_VAR | V_PSTAGE, "pstage", 0},
|
||||
{NSC_DEITY | NSC_VAR | V_PTIME, "ptime", 0},
|
||||
{NSC_DEITY | NSC_VAR | V_CHE, "che", 0},
|
||||
{NSC_DEITY | NSC_VAR | V_MINE, "lmine", 0},
|
||||
{NSC_VAR | V_FALLOUT, "fallout", 0},
|
||||
{NSC_VAR | V_CIVIL, "civil", 0},
|
||||
{NSC_VAR | V_MILIT, "milit", 0},
|
||||
{NSC_VAR | V_SHELL, "shell", 0},
|
||||
|
@ -71,34 +66,6 @@ struct castr var_ca[] = {
|
|||
{NSC_VAR | V_HCM, "hcm", 0},
|
||||
{NSC_VAR | V_UW, "uw", 0},
|
||||
{NSC_VAR | V_RAD, "rad", 0},
|
||||
{NSC_VAR | V_CDIST, "c_dist", 0},
|
||||
{NSC_VAR | V_MDIST, "m_dist", 0},
|
||||
{NSC_VAR | V_UDIST, "u_dist", 0},
|
||||
{NSC_VAR | V_SDIST, "s_dist", 0},
|
||||
{NSC_VAR | V_GDIST, "g_dist", 0},
|
||||
{NSC_VAR | V_PDIST, "p_dist", 0},
|
||||
{NSC_VAR | V_IDIST, "i_dist", 0},
|
||||
{NSC_VAR | V_DDIST, "d_dist", 0},
|
||||
{NSC_VAR | V_BDIST, "b_dist", 0},
|
||||
{NSC_VAR | V_FDIST, "f_dist", 0},
|
||||
{NSC_VAR | V_ODIST, "o_dist", 0},
|
||||
{NSC_VAR | V_LDIST, "l_dist", 0},
|
||||
{NSC_VAR | V_HDIST, "h_dist", 0},
|
||||
{NSC_VAR | V_RDIST, "r_dist", 0},
|
||||
{NSC_VAR | V_CDEL, "c_del", 0},
|
||||
{NSC_VAR | V_MDEL, "m_del", 0},
|
||||
{NSC_VAR | V_UDEL, "u_del", 0},
|
||||
{NSC_VAR | V_SDEL, "s_del", 0},
|
||||
{NSC_VAR | V_GDEL, "g_del", 0},
|
||||
{NSC_VAR | V_PDEL, "p_del", 0},
|
||||
{NSC_VAR | V_IDEL, "i_del", 0},
|
||||
{NSC_VAR | V_DDEL, "d_del", 0},
|
||||
{NSC_VAR | V_BDEL, "b_del", 0},
|
||||
{NSC_VAR | V_FDEL, "f_del", 0},
|
||||
{NSC_VAR | V_ODEL, "o_del", 0},
|
||||
{NSC_VAR | V_LDEL, "l_del", 0},
|
||||
{NSC_VAR | V_HDEL, "h_del", 0},
|
||||
{NSC_VAR | V_RDEL, "r_del", 0},
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -127,6 +94,43 @@ struct castr sect_ca[] = {
|
|||
{NSC_XCOORD | NSC_OFF | fldoff(sctstr, sct_dist_x), "xdist", 0},
|
||||
{NSC_YCOORD | NSC_OFF | fldoff(sctstr, sct_dist_y), "ydist", 0},
|
||||
{NSC_SHORT | NSC_OFF | fldoff(sctstr, sct_avail), "avail", 0},
|
||||
#define distoff(itype) (fldoff(sctstr, sct_dist) + (itype)*sizeof(u_short))
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_CIVIL), "c_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_MILIT), "m_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_UW), "u_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_SHELL), "s_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_GUN), "g_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_PETROL), "p_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_IRON), "i_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_DUST), "d_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_BAR), "b_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_FOOD), "f_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_OIL), "o_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_LCM), "l_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_HCM), "h_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_RAD), "r_dist", 0},
|
||||
#undef distoff
|
||||
#define deloff(itype) (fldoff(sctstr, sct_del) + (itype)*sizeof(u_short))
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_CIVIL), "c_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_MILIT), "m_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_UW), "u_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_SHELL), "s_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_GUN), "g_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_PETROL), "p_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_IRON), "i_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_DUST), "d_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_BAR), "b_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_FOOD), "f_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_OIL), "o_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_LCM), "l_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_HCM), "h_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_RAD), "r_del", 0},
|
||||
#undef deloff
|
||||
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(sctstr, sct_mines), "mines", 0},
|
||||
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(sctstr, sct_pstage), "pstage", 0},
|
||||
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(sctstr, sct_ptime), "ptime", 0},
|
||||
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(sctstr, sct_che), "che", 0},
|
||||
{NSC_USHORT | NSC_OFF | fldoff(sctstr, sct_fallout), "fallout", 0},
|
||||
{NSC_UCHAR | NSC_OFF | fldoff(sctstr, sct_road), "road", 0},
|
||||
{NSC_UCHAR | NSC_OFF | fldoff(sctstr, sct_rail), "rail", 0},
|
||||
{NSC_UCHAR | NSC_OFF | fldoff(sctstr, sct_defense), "dfense", 0},
|
||||
|
@ -162,6 +166,8 @@ struct castr ship_ca[] = {
|
|||
{NSC_UCHAR | NSC_OFF | fldoff(shpstr, shp_nxlight), "nxlight", 0},
|
||||
{NSC_UCHAR | NSC_OFF | fldoff(shpstr, shp_nchoppers), "nchoppers", 0},
|
||||
{NSC_UCHAR | NSC_OFF | fldoff(shpstr, shp_autonav), "autonav", 0},
|
||||
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(shpstr, shp_pstage), "pstage", 0},
|
||||
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(shpstr, shp_ptime), "ptime", 0},
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -189,6 +195,8 @@ struct castr land_ca[] = {
|
|||
{NSC_SHORT | NSC_OFF | fldoff(lndstr, lnd_retreat), "retreat", 0},
|
||||
{NSC_UCHAR | NSC_OFF | fldoff(lndstr, lnd_fuel), "fuel", 0},
|
||||
{NSC_UCHAR | NSC_OFF | fldoff(lndstr, lnd_nxlight), "nxlight", 0},
|
||||
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(lndstr, lnd_pstage), "pstage", 0},
|
||||
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(lndstr, lnd_ptime), "ptime", 0},
|
||||
{NSC_FLOAT | NSC_OFF | fldoff(lndstr, lnd_att), "att", 0},
|
||||
{NSC_FLOAT | NSC_OFF | fldoff(lndstr, lnd_def), "def", 0},
|
||||
{NSC_INT | NSC_OFF | fldoff(lndstr, lnd_vul), "vul", 0},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue