From a680c81110d562afd759ff5e91e4a2fba624544c Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 5 Mar 2008 22:36:48 +0100 Subject: [PATCH] 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. --- include/commodity.h | 1 + include/empobj.h | 1 + include/file.h | 1 + include/game.h | 1 + include/land.h | 2 +- include/loan.h | 1 + include/lost.h | 2 +- include/nat.h | 3 ++- include/news.h | 1 + include/nuke.h | 2 +- include/plane.h | 2 +- include/sect.h | 2 +- include/ship.h | 2 +- include/trade.h | 1 + include/treaty.h | 1 + src/lib/global/nsc.c | 20 +++++++------------- 16 files changed, 23 insertions(+), 20 deletions(-) diff --git a/include/commodity.h b/include/commodity.h index 46a038eb..c3757661 100644 --- a/include/commodity.h +++ b/include/commodity.h @@ -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; diff --git a/include/empobj.h b/include/empobj.h index 57c517eb..0fbeb0f7 100644 --- a/include/empobj.h +++ b/include/empobj.h @@ -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 */ diff --git a/include/file.h b/include/file.h index f4d8453e..70ec1e1b 100644 --- a/include/file.h +++ b/include/file.h @@ -67,6 +67,7 @@ struct empfile { struct emptypedstr { short ef_type; short uid; + time_t timestamp; }; /* diff --git a/include/game.h b/include/game.h index 5d0d897b..a553eaba 100644 --- a/include/game.h +++ b/include/game.h @@ -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? */ /* diff --git a/include/land.h b/include/land.h index d74db621..3f815873 100644 --- a/include/land.h +++ b/include/land.h @@ -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 { diff --git a/include/loan.h b/include/loan.h index f2ec2c08..542af6c8 100644 --- a/include/loan.h +++ b/include/loan.h @@ -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 */ diff --git a/include/lost.h b/include/lost.h index 179c7b9d..c371f936 100644 --- a/include/lost.h +++ b/include/lost.h @@ -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)) diff --git a/include/nat.h b/include/nat.h index 58421b5b..b2f2bd5f 100644 --- a/include/nat.h +++ b/include/nat.h @@ -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; diff --git a/include/news.h b/include/news.h index 3a2a9b4b..c7361144 100644 --- a/include/news.h +++ b/include/news.h @@ -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) */ diff --git a/include/nuke.h b/include/nuke.h index cc90de95..2f7fcdaa 100644 --- a/include/nuke.h +++ b/include/nuke.h @@ -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 { diff --git a/include/plane.h b/include/plane.h index 6356a1eb..1ead6d5b 100644 --- a/include/plane.h +++ b/include/plane.h @@ -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 */ }; diff --git a/include/sect.h b/include/sect.h index 15aca8b9..5932170f 100644 --- a/include/sect.h +++ b/include/sect.h @@ -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 { diff --git a/include/ship.h b/include/ship.h index 0cfab53c..0b9ed35b 100644 --- a/include/ship.h +++ b/include/ship.h @@ -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; diff --git a/include/trade.h b/include/trade.h index 8db1e6fe..307f990b 100644 --- a/include/trade.h +++ b/include/trade.h @@ -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; diff --git a/include/treaty.h b/include/treaty.h index a8c5d258..d5efd77e 100644 --- a/include/treaty.h +++ b/include/treaty.h @@ -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 */ diff --git a/src/lib/global/nsc.c b/src/lib/global/nsc.c index 71edc220..b145ec36 100644 --- a/src/lib/global/nsc.c +++ b/src/lib/global/nsc.c @@ -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 };