Put a timestamp into struct emptypedstr

Make sure all members of unit empobj_storage share it.

Add matching timestamp member to struct comstr, struct empobj, struct
gamestr, struct lonstr, struct natstr, struct nwsstr, struct trdstr,
struct trtstr.  The timestamp isn't yet set for these.  To be fixed.

Move the timestamp member to the right place in struct lndstr, struct
loststr, struct realmstr, struct nukstr, struct plnstr, struct sctstr,
struct shpstr.
This commit is contained in:
Markus Armbruster 2008-03-05 22:36:48 +01:00
parent e1a68c721d
commit a680c81110
16 changed files with 23 additions and 20 deletions

View file

@ -44,6 +44,7 @@ struct comstr {
/* initial part must match struct empobj */
short ef_type;
short com_uid;
time_t com_timestamp;
natid com_owner;
/* end of part matching struct empobj */
i_type com_type;

View file

@ -57,6 +57,7 @@ struct empobj {
*/
short ef_type;
short uid;
time_t timestamp;
/* end of part matching struct emptypedstr */
natid own; /* valid if EFF_OWNER is in table's flags */
coord x; /* valid if EFF_XY is in table's flags */

View file

@ -67,6 +67,7 @@ struct empfile {
struct emptypedstr {
short ef_type;
short uid;
time_t timestamp;
};
/*

View file

@ -40,6 +40,7 @@ struct gamestr {
/* initial part must match struct empobj */
short ef_type;
short game_uid;
time_t game_timestamp;
/* end of part matching struct empobj */
char game_upd_disable; /* updates disabled? */
/*

View file

@ -50,6 +50,7 @@ struct lndstr {
/* initial part must match struct empobj */
short ef_type;
short lnd_uid; /* unit id (land unit) */
time_t lnd_timestamp; /* Last time this unit was touched */
natid lnd_own; /* owner's country num */
coord lnd_x; /* x location in abs coords */
coord lnd_y; /* y location in abs coords */
@ -79,7 +80,6 @@ struct lndstr {
short lnd_land; /* pointer to transporting unit */
unsigned char lnd_nland;
short lnd_access; /* Last tick mob was updated (MOB_ACCESS) */
time_t lnd_timestamp; /* Last time this unit was touched */
};
struct lchrstr {

View file

@ -44,6 +44,7 @@ struct lonstr {
/* initial part must match struct empobj */
short ef_type;
short l_uid;
time_t l_timestamp;
/* end of part matching struct empobj */
natid l_loner; /* loan shark */
natid l_lonee; /* sucker */

View file

@ -41,13 +41,13 @@ struct loststr {
/* initial part must match struct empobj */
short ef_type;
int lost_uid;
time_t lost_timestamp; /* When it was lost */
natid lost_owner; /* Who lost it */
/* end of part matching struct empobj */
short lost_type; /* Type of thing (ship, plane, nuke, land, sector) */
short lost_id; /* ID of lost thing */
coord lost_x;
coord lost_y;
time_t lost_timestamp; /* When it was lost */
};
#define getlost(n, p) ef_read(EF_LOST, (n), (p))

View file

@ -70,18 +70,19 @@ struct realmstr {
/* initial part must match struct empobj */
short ef_type;
short r_uid; /* realm table index */
time_t r_timestamp; /* Last time this realm was touched */
natid r_cnum; /* country number */
/* end of part matching struct empobj */
unsigned short r_realm; /* realm number */
short r_xl, r_xh; /* horizontal bounds */
short r_yl, r_yh; /* vertical bounds */
time_t r_timestamp; /* Last time this realm was touched */
};
struct natstr {
/* initial part must match struct empobj */
short ef_type;
short nat_uid; /* equals nat_cnum */
time_t nat_timestamp;
natid nat_cnum; /* our country number */
/* end of part matching struct empobj */
enum nat_status nat_stat;

View file

@ -48,6 +48,7 @@ struct nwsstr {
/* initial part must match struct empobj */
short ef_type;
short nws_uid;
time_t nws_timestamp;
/* end of part matching struct empobj */
natid nws_ano; /* "actor" country # */
unsigned char nws_vrb; /* action (verb) */

View file

@ -44,6 +44,7 @@ struct nukstr {
/* initial part must match struct empobj */
short ef_type;
short nuk_uid;
time_t nuk_timestamp; /* Last time this nuke was touched */
natid nuk_own;
coord nuk_x, nuk_y; /* current loc of device */
signed char nuk_type; /* index in nchr[] */
@ -59,7 +60,6 @@ struct nukstr {
short nuk_ship; /* currently aboard ship (unused) */
short nuk_plane; /* currently aboard plane */
short nuk_land; /* currently aboard land (unused) */
time_t nuk_timestamp; /* Last time this nuke was touched */
};
struct nchrstr {

View file

@ -47,6 +47,7 @@ struct plnstr {
/* initial part must match struct empobj */
short ef_type;
short pln_uid; /* plane unit id */
time_t pln_timestamp; /* Last time this plane was touched */
natid pln_own; /* owning country */
coord pln_x; /* plane x-y */
coord pln_y;
@ -68,7 +69,6 @@ struct plnstr {
signed char pln_nuketype; /* type of nuclear armament (if any) */
signed char pln_flags; /* State of the plane */
short pln_access; /* Last tick mob was updated (MOB_ACCESS) */
time_t pln_timestamp; /* Last time this plane was touched */
float pln_theta; /* position in orbital sine wave */
};

View file

@ -45,6 +45,7 @@ struct sctstr {
/* initial part must match struct empobj */
short ef_type;
short sct_uid; /* equals sctoff(sct_x, sct_y) */
time_t sct_timestamp; /* Last time this sector was written to */
natid sct_own; /* owner's country num */
coord sct_x; /* x coord of sector */
coord sct_y; /* y coord of sector */
@ -87,7 +88,6 @@ struct sctstr {
unsigned char sct_road; /* Road value of a sector */
unsigned char sct_rail; /* Rail value of a sector */
unsigned char sct_defense; /* Defensive value of a sector */
time_t sct_timestamp; /* Last time this sector was written to */
};
enum d_navigation {

View file

@ -64,6 +64,7 @@ struct shpstr {
/* initial part must match struct empobj */
short ef_type;
short shp_uid; /* unit id (ship #) */
time_t shp_timestamp; /* Last time this ship was touched. */
natid shp_own; /* owner's country num */
coord shp_x; /* x location in abs coords */
coord shp_y; /* y location in abs coords */
@ -90,7 +91,6 @@ struct shpstr {
short shp_pstage; /* plague stage */
short shp_ptime; /* how many etus remain in this stage */
short shp_access; /* Last tick mob was updated (MOB_ACCESS) */
time_t shp_timestamp; /* Last time this ship was touched. */
unsigned char shp_mobquota; /* mobility quota */
char shp_path[MAXSHPPATH];
short shp_follow;

View file

@ -44,6 +44,7 @@ struct trdstr {
/* initial part must match struct empobj */
short ef_type;
short trd_uid;
time_t trd_timestamp;
natid trd_owner;
/* end of part matching struct empobj */
short trd_type;

View file

@ -41,6 +41,7 @@ struct trtstr {
/* initial part must match struct empobj */
short ef_type;
short trt_uid;
time_t trt_timestamp;
/* end of part matching struct empobj */
natid trt_cna; /* proposer */
natid trt_cnb; /* acceptor */

View file

@ -123,6 +123,8 @@ struct castr sect_ca[] = {
/* uid needs to be NSC_DEITY because it discloses true origin */
{"uid", fldoff(sct_uid), NSC_SHORT, 0, NULL,
EF_SECTOR, NSC_DEITY | NSC_EXTRA},
{"timestamp", fldoff(sct_timestamp), NSC_TIME, 0, NULL,
EF_BAD, NSC_EXTRA},
{"owner", fldoff(sct_own), NSC_NATID, 0, NULL, EF_NATION, 0},
{"xloc", fldoff(sct_x), NSC_XCOORD, 0, NULL, EF_BAD, NSC_CONST},
{"yloc", fldoff(sct_y), NSC_YCOORD, 0, NULL, EF_BAD, NSC_CONST},
@ -166,8 +168,6 @@ struct castr sect_ca[] = {
{"road", fldoff(sct_road), NSC_UCHAR, 0, NULL, EF_BAD, 0},
{"rail", fldoff(sct_rail), NSC_UCHAR, 0, NULL, EF_BAD, 0},
{"dfense", fldoff(sct_defense), NSC_UCHAR, 0, NULL, EF_BAD, 0},
{"timestamp", fldoff(sct_timestamp), NSC_TIME, 0, NULL,
EF_BAD, NSC_EXTRA},
{NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
#undef CURSTR
};
@ -199,6 +199,7 @@ struct castr dchr_ca[] = {
#define NSC_GENITEM(ef_type, ef_chr) \
{"uid", empobjoff(uid), NSC_SHORT, 0, NULL, ef_type, 0}, \
{"timestamp", empobjoff(timestamp), NSC_TIME, 0, NULL, EF_BAD, NSC_EXTRA}, \
{"owner", empobjoff(own), NSC_NATID, 0, NULL, EF_NATION, 0}, \
{"xloc", empobjoff(x), NSC_XCOORD, 0, NULL, EF_BAD, 0}, \
{"yloc", empobjoff(y), NSC_YCOORD, 0, NULL, EF_BAD, 0}, \
@ -235,8 +236,6 @@ struct castr ship_ca[] = {
EF_PLAGUE_STAGES, NSC_DEITY},
{"ptime", fldoff(shp_ptime), NSC_SHORT, 0, NULL, EF_BAD, NSC_DEITY},
{"access", fldoff(shp_access), NSC_SHORT, 0, NULL, EF_BAD, 0},
{"timestamp", fldoff(shp_timestamp), NSC_TIME, 0, NULL,
EF_BAD, NSC_EXTRA},
{"mquota", fldoff(shp_mobquota), NSC_UCHAR, 0, NULL, EF_BAD, 0},
{"path", fldoff(shp_path), NSC_STRINGY, MAXSHPPATH, NULL, EF_BAD, 0},
{"follow", fldoff(shp_follow), NSC_SHORT, 0, NULL, EF_BAD, 0},
@ -300,8 +299,6 @@ struct castr plane_ca[] = {
{"flags", fldoff(pln_flags), NSC_CHAR, 0, NULL,
EF_PLANE_FLAGS, NSC_BITS},
{"access", fldoff(pln_access), NSC_SHORT, 0, NULL, EF_BAD, 0},
{"timestamp", fldoff(pln_timestamp), NSC_TIME, 0, NULL,
EF_BAD, NSC_EXTRA},
{"theta", fldoff(pln_theta), NSC_FLOAT, 0, NULL, EF_BAD, 0},
{"att", 0, NSC_LONG, 0, nsc_pln_att, EF_BAD, NSC_EXTRA},
{"def", 0, NSC_LONG, 0, nsc_pln_def, EF_BAD, NSC_EXTRA},
@ -352,8 +349,6 @@ struct castr land_ca[] = {
{"land", fldoff(lnd_land), NSC_SHORT, 0, NULL, EF_BAD, 0},
{"nland", fldoff(lnd_nland), NSC_UCHAR, 0, NULL, EF_BAD, NSC_EXTRA},
{"access", fldoff(lnd_access), NSC_SHORT, 0, NULL, EF_BAD, 0},
{"timestamp", fldoff(lnd_timestamp), NSC_TIME, 0, NULL,
EF_BAD, NSC_EXTRA},
{"att", 0, NSC_DOUBLE, 0, nsc_lnd_att, EF_BAD, NSC_EXTRA},
{"def", 0, NSC_DOUBLE, 0, nsc_lnd_def, EF_BAD, NSC_EXTRA},
{"vul", 0, NSC_LONG, 0, nsc_lnd_vul, EF_BAD, NSC_EXTRA},
@ -411,8 +406,6 @@ struct castr nuke_ca[] = {
#define CURSTR struct nukstr
NSC_GENITEM(EF_NUKE, EF_NUKE_CHR),
{"plane", fldoff(nuk_plane), NSC_SHORT, 0, NULL, EF_BAD, 0},
{"timestamp", fldoff(nuk_timestamp), NSC_TIME, 0, NULL,
EF_BAD, NSC_EXTRA},
{NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
#undef CURSTR
};
@ -484,12 +477,13 @@ struct castr news_ca[] = {
struct castr lost_ca[] = {
#define CURSTR struct loststr
/* no need for uid as long as it's not referenced from other tables */
{"timestamp", fldoff(lost_timestamp), NSC_TIME, 0, NULL,
EF_BAD, 0},
{"owner", fldoff(lost_owner), NSC_NATID, 0, NULL, EF_NATION, 0},
{"type", fldoff(lost_type), NSC_CHAR, 0, NULL, EF_TABLE, 0},
{"id", fldoff(lost_id), NSC_SHORT, 0, NULL, EF_BAD, 0},
{"x", fldoff(lost_x), NSC_XCOORD, 0, NULL, EF_BAD, 0},
{"y", fldoff(lost_y), NSC_YCOORD, 0, NULL, EF_BAD, 0},
{"timestamp", fldoff(lost_timestamp), NSC_TIME, 0, NULL, EF_BAD, 0},
{NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
#undef CURSTR
};
@ -595,14 +589,14 @@ struct castr nat_ca[sizeof(cou_ca) / sizeof(*cou_ca)];
struct castr realm_ca[] = {
#define CURSTR struct realmstr
/* uid is encoded in cnum, realm */
{"timestamp", fldoff(r_timestamp), NSC_TIME, 0, NULL,
EF_BAD, NSC_EXTRA},
{"cnum", fldoff(r_cnum), NSC_NATID, 0, NULL, EF_NATION, NSC_CONST},
{"realm", fldoff(r_realm), NSC_USHORT, 0, NULL, EF_BAD, NSC_CONST},
{"xl", fldoff(r_xl), NSC_SHORT, 0, NULL, EF_BAD, 0},
{"xh", fldoff(r_xh), NSC_SHORT, 0, NULL, EF_BAD, 0},
{"yl", fldoff(r_yl), NSC_SHORT, 0, NULL, EF_BAD, 0},
{"yh", fldoff(r_yh), NSC_SHORT, 0, NULL, EF_BAD, 0},
{"timestamp", fldoff(r_timestamp), NSC_TIME, 0, NULL,
EF_BAD, NSC_EXTRA},
{NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
#undef CURSTR
};