(EFF_OWNER): The assertion that EFF_OWNER implies ef_read() sets
player->owner is no longer used. Use it to indicate that owner can be accessed through struct genitem, similar to EFF_XY and EFF_GROUP. (xdump): Fix ownership checking. Old version worked only when nxtitem() set player->owner. (empfile): Set EFF_OWNER for EF_LOST. This fixes `xdump lost' disclosing other countries' losses. (loststr): Document implications of EFF_OWNER. (empfile): Set EFF_OWNER for EF_NATION. (natstr): Rearrange members for EFF_OWNER, document. (nat_ca): Unused so far. Clean it up, add most missing selectors. (fileinit): Use it. This implements `xdump nation'. (fileinit): Simplify setting map file size.
This commit is contained in:
parent
b111abc2c5
commit
326ac671ba
7 changed files with 33 additions and 36 deletions
|
@ -58,11 +58,9 @@ struct empfile {
|
|||
/*
|
||||
* struct empfile flags
|
||||
*
|
||||
* EFF_XY and EFF_GROUP assert that coordinates / group of such a
|
||||
* file's record can be safely obtained by dereferencing its memory
|
||||
* address cast to struct genitem *.
|
||||
*
|
||||
* EFF_OWNER asserts that player->owner is set by ef_read().
|
||||
* EFF_XY / EFF_OWNER / EFF_GROUP assert that coordinates / owner /
|
||||
* group of such a file's record can be safely obtained by
|
||||
* dereferencing its memory address cast to struct genitem *.
|
||||
*/
|
||||
#define EFF_XY bit(0) /* has location */
|
||||
#define EFF_MEM bit(1) /* stored entirely in-memory */
|
||||
|
|
|
@ -35,8 +35,10 @@
|
|||
#define _LOST_H_
|
||||
|
||||
struct loststr {
|
||||
/* initial part must match struct genitem */
|
||||
short ef_type;
|
||||
natid lost_owner; /* Who lost it */
|
||||
/* end of part matching struct genitem */
|
||||
int lost_uid; /* lost ID */
|
||||
char lost_type; /* Type of thing (ship, plane, nuke, land, sector) */
|
||||
short lost_id; /* ID of lost thing */
|
||||
|
|
|
@ -57,7 +57,11 @@ struct boundstr {
|
|||
};
|
||||
|
||||
struct natstr {
|
||||
/* initial part must match struct genitem */
|
||||
short ef_type;
|
||||
natid nat_cnum; /* our country number */
|
||||
/* end of part matching struct genitem */
|
||||
s_char nat_stat; /* inuse, norm, god, abs */
|
||||
s_char nat_cnam[20]; /* country name */
|
||||
s_char nat_pnam[20]; /* representative */
|
||||
s_char nat_hostaddr[32]; /* host addr of last user */
|
||||
|
@ -66,8 +70,6 @@ struct natstr {
|
|||
coord nat_xstart, nat_ystart; /* cap location at start */
|
||||
coord nat_xcap, nat_ycap; /* cap location in abs coords */
|
||||
coord nat_xorg, nat_yorg; /* origin location in abs coords */
|
||||
natid nat_cnum; /* our country number */
|
||||
s_char nat_stat; /* inuse, norm, god, abs */
|
||||
s_char nat_dayno; /* day of the year mod 128 */
|
||||
s_char nat_connected; /* connected or not? */
|
||||
s_char nat_update; /* Want an update or not. */
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
* - News item characteristics: rpt[] (TODO)
|
||||
* - News page headings: page_headings[] (TODO)
|
||||
* - Treaty clause characteristics: tchr[]
|
||||
* - Commands: coms[] (TODO)
|
||||
* - Commands: player_coms[] (TODO)
|
||||
* - Options: Options[]
|
||||
* - Configuration: configkeys[]
|
||||
*
|
||||
|
@ -406,6 +406,7 @@ xdftr(int n)
|
|||
static int
|
||||
xditem(int type, char *arg)
|
||||
{
|
||||
int check_owner = !player->god && (ef_flags(type) & EFF_OWNER) != 0;
|
||||
struct castr *ca;
|
||||
struct nstr_item ni;
|
||||
int n;
|
||||
|
@ -422,7 +423,7 @@ xditem(int type, char *arg)
|
|||
|
||||
n = 0;
|
||||
while (nxtitem(&ni, buf)) {
|
||||
if (!player->owner)
|
||||
if (check_owner && ((struct genitem *)buf)->own != player->cnum)
|
||||
continue;
|
||||
++n;
|
||||
xdflds(ca, buf);
|
||||
|
|
|
@ -80,7 +80,7 @@ struct empfile empfile[] = {
|
|||
{"pow", "power", 0,
|
||||
0, sizeof(struct powstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"nat", "nation", 0,
|
||||
{"nat", "nation", EFF_OWNER,
|
||||
0, sizeof(struct natstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"loan", "loan", 0,
|
||||
|
@ -95,7 +95,7 @@ struct empfile empfile[] = {
|
|||
{"commodity", "commodity", 0,
|
||||
0, sizeof(struct comstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"lost", "lostitems", 0,
|
||||
{"lost", "lostitems", EFF_OWNER,
|
||||
0, sizeof(struct loststr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
|
|
@ -225,7 +225,7 @@ struct castr nuke_ca[] = {
|
|||
{NSC_XCOORD, 0, 0, fldoff(nukstr, nuk_x), "xloc"},
|
||||
{NSC_YCOORD, 0, 0, fldoff(nukstr, nuk_y), "yloc"},
|
||||
{NSC_CHAR, 0, 0, fldoff(nukstr, nuk_n), "number"},
|
||||
{NSC_SHORT, 0, N_MAXNUKE, fldoff(nukstr, nuk_types[0]), "types"},
|
||||
{NSC_SHORT, 0, N_MAXNUKE, fldoff(nukstr, nuk_types), "types"},
|
||||
{NSC_TIME, NSC_EXTRA, 0, fldoff(nukstr, nuk_timestamp), "timestamp"},
|
||||
{NSC_NOTYPE, 0, 0, 0, NULL}
|
||||
};
|
||||
|
@ -307,40 +307,36 @@ struct castr trade_ca[] = {
|
|||
};
|
||||
|
||||
struct castr nat_ca[] = {
|
||||
{NSC_CHAR, 0, 20, fldoff(natstr, nat_cnam[0]), "cnam"},
|
||||
{NSC_CHAR, NSC_DEITY, 20, fldoff(natstr, nat_pnam[0]), "pnam"},
|
||||
{NSC_NATID, 0, 0, fldoff(natstr, nat_cnum), "cnum"},
|
||||
{NSC_CHAR, 0, 0, fldoff(natstr, nat_stat), "stat"},
|
||||
{NSC_STRINGY, 0, 20, fldoff(natstr, nat_cnam), "cname"},
|
||||
{NSC_STRINGY, NSC_DEITY, 20, fldoff(natstr, nat_pnam), "passwd"},
|
||||
{NSC_STRINGY, 0, 32, fldoff(natstr, nat_hostaddr), "ip"},
|
||||
{NSC_STRINGY, 0, 512, fldoff(natstr, nat_hostname), "hostname"},
|
||||
{NSC_STRINGY, 0, 32, fldoff(natstr, nat_userid), "userid"},
|
||||
{NSC_XCOORD, 0, 0, fldoff(natstr, nat_xstart), "xstart"},
|
||||
{NSC_YCOORD, 0, 0, fldoff(natstr, nat_ystart), "ystart"},
|
||||
{NSC_XCOORD, 0, 0, fldoff(natstr, nat_xcap), "xcap"},
|
||||
{NSC_YCOORD, 0, 0, fldoff(natstr, nat_ycap), "ycap"},
|
||||
{NSC_XCOORD, NSC_DEITY, 0, fldoff(natstr, nat_xorg), "xorg"},
|
||||
{NSC_YCOORD, NSC_DEITY, 0, fldoff(natstr, nat_yorg), "yorg"},
|
||||
{NSC_NATID, 0, 0, fldoff(natstr, nat_cnum), "cnum"},
|
||||
#ifdef MAYBE_LATER
|
||||
{NSC_CHAR, 0, 0, fldoff(natstr, nat_stat), "stat"},
|
||||
{NSC_CHAR, 0, 0, fldoff(natstr, nat_dayno), "dayno"},
|
||||
{NSC_CHAR, 0, 0, fldoff(natstr, nat_update), "update"},
|
||||
{NSC_UCHAR, 0, 0, fldoff(natstr, nat_missed), "missed"},
|
||||
#endif /* MAYBE_LATER */
|
||||
{NSC_USHORT, 0, 0, fldoff(natstr, nat_tgms), "tgms"},
|
||||
{NSC_USHORT, 0, 0, fldoff(natstr, nat_ann), "ann"},
|
||||
{NSC_USHORT, 0, 0, fldoff(natstr, nat_minused), "minused"},
|
||||
{NSC_SHORT, 0, 0, fldoff(natstr, nat_btu), "btu"},
|
||||
{NSC_LONG, 0, 0, fldoff(natstr, nat_reserve), "reserve"},
|
||||
{NSC_LONG, 0, 0, fldoff(natstr, nat_reserve), "milreserve"},
|
||||
{NSC_LONG, 0, 0, fldoff(natstr, nat_money), "money"},
|
||||
#ifdef MAYBE_LATER
|
||||
{NSC_TIME, 0, 0, fldoff(natstr, nat_last_login), "last_login"},
|
||||
{NSC_TIME, 0, 0, fldoff(natstr, nat_last_logout), "last_logout"},
|
||||
{NSC_TIME, 0, 0, fldoff(natstr, nat_last_login), "login"},
|
||||
{NSC_TIME, 0, 0, fldoff(natstr, nat_last_logout), "logout"},
|
||||
{NSC_TIME, 0, 0, fldoff(natstr, nat_newstim), "newstim"},
|
||||
#endif /* MAYBE_LATER */
|
||||
{NSC_TIME, 0, 0, fldoff(natstr, nat_annotim), "annotim"},
|
||||
{NSC_FLOAT, 0, 0, fldoff(natstr, nat_level[NAT_TLEV]), "tech"},
|
||||
{NSC_FLOAT, 0, 0, fldoff(natstr, nat_level[NAT_RLEV]), "research"},
|
||||
{NSC_FLOAT, 0, 0, fldoff(natstr, nat_level[NAT_ELEV]), "education"},
|
||||
{NSC_FLOAT, 0, 0, fldoff(natstr, nat_level[NAT_HLEV]), "happiness"},
|
||||
#if 0
|
||||
{NSC_SHORT, 0, MAXNOC, fldoff(natstr, nat_relate[0]),"relate"},
|
||||
{NSC_CHAR, 0, PRI_MAX+1, fldoff(natstr, nat_priorities[0]),"priorities"},
|
||||
{NSC_LONG, 0, 0, fldoff(natstr, nat_flags),"flags",0},
|
||||
#endif
|
||||
/* FIXME nat_b[], nat_relate[], nat_contact[], nat_rejects[], nat_priorities[] */
|
||||
{NSC_LONG, 0, 0, fldoff(natstr, nat_flags),"flags"},
|
||||
{NSC_NOTYPE, 0, 0, 0, NULL}
|
||||
};
|
||||
|
|
|
@ -49,10 +49,10 @@ struct fileinit fileinit[EF_MAX] = {
|
|||
{NULL, NULL, NULL, treaty_ca},
|
||||
{NULL, NULL, NULL, trade_ca},
|
||||
{NULL, NULL, NULL, NULL}, /* power */
|
||||
{NULL, NULL, NULL, NULL}, /* nation */
|
||||
{NULL, NULL, NULL, nat_ca}, /* nation */
|
||||
{NULL, NULL, NULL, loan_ca},
|
||||
{NULL, NULL, NULL, NULL}, /* map */
|
||||
{NULL, NULL, NULL, NULL}, /* map */
|
||||
{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}
|
||||
};
|
||||
|
@ -71,9 +71,7 @@ ef_init(void)
|
|||
ef->postread = fi->postread;
|
||||
ef->prewrite = fi->prewrite;
|
||||
ef->cadef = fi->cadef;
|
||||
/* We have to set the size for the map and bmap files at
|
||||
runtime. */
|
||||
if (i == EF_MAP || i == EF_BMAP)
|
||||
ef->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