From 4a67b91f8a1d0b98b966156b3944b6277f89ed7b Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 28 May 2005 08:03:31 +0000 Subject: [PATCH] Document struct equivalence hack and implications of EFF_XY and EFF_GROUP. --- include/file.h | 8 ++++++++ include/land.h | 2 ++ include/nuke.h | 2 ++ include/plane.h | 2 ++ include/sect.h | 2 ++ include/ship.h | 2 ++ 6 files changed, 18 insertions(+) diff --git a/include/file.h b/include/file.h index b12ffc5a9..d1ffcf556 100644 --- a/include/file.h +++ b/include/file.h @@ -55,11 +55,19 @@ struct empfile { struct castr *cadef; /* ca defs selection list */ }; +/* + * 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 * + */ #define EFF_XY bit(0) /* has location */ #define EFF_MEM bit(1) /* stored entirely in-memory */ #define EFF_OWNER bit(2) /* has concept of owner */ #define EFF_GROUP bit(3) /* has concept of group */ +/* file types, types 0..EF_MAX-1 are empfile[] indexes */ #define EF_BAD -1 /* illegal file type */ #define EF_SECTOR 0 #define EF_SHIP 1 diff --git a/include/land.h b/include/land.h index 1ed6f3dc1..a34b43d83 100644 --- a/include/land.h +++ b/include/land.h @@ -47,6 +47,7 @@ #define LND_MINMOBCOST 0.200 struct lndstr { + /* initial part must match struct genitem */ short ef_type; natid lnd_own; /* owner's country num */ short lnd_uid; /* unit id (land unit) */ @@ -60,6 +61,7 @@ struct lndstr { coord lnd_opx, lnd_opy; /* Op sector coords */ short lnd_mission; /* mission code */ short lnd_radius; /* mission radius */ + /* end of part matching struct genitem */ s_char lnd_flags; /* unit flags (unused) */ short lnd_ship; /* pointer to transporting ship */ s_char lnd_harden; /* for missiles */ diff --git a/include/nuke.h b/include/nuke.h index 45e56658f..0ac51ea49 100644 --- a/include/nuke.h +++ b/include/nuke.h @@ -37,11 +37,13 @@ #define N_MAXNUKE 15 struct nukstr { + /* initial part must match struct genitem */ short ef_type; natid nuk_own; short nuk_uid; coord nuk_x; /* current loc of device */ coord nuk_y; + /* end of part matching struct genitem */ s_char nuk_n; /* number of nukes in list */ short nuk_ship; /* currently aboard ship (unused) */ short nuk_trade; /* index into trade file (unused) */ diff --git a/include/plane.h b/include/plane.h index 0508bf733..6bebae2b0 100644 --- a/include/plane.h +++ b/include/plane.h @@ -46,6 +46,7 @@ * exactly equivalent with shp_x to shp_fleet */ struct plnstr { + /* initial part must match struct genitem */ short ef_type; natid pln_own; /* owning country */ short pln_uid; /* plane unit id */ @@ -60,6 +61,7 @@ struct plnstr { coord pln_opy; /* Op sector coords */ short pln_mission; /* mission code */ short pln_radius; /* mission radius */ + /* end of part matching struct genitem */ u_char pln_range; /* total distance, not radius */ u_char pln_range_max; /* max range for this plane */ short pln_ship; /* pointer to carrier */ diff --git a/include/sect.h b/include/sect.h index 94e1c9ae5..ca5bd1cff 100644 --- a/include/sect.h +++ b/include/sect.h @@ -42,11 +42,13 @@ /* The order of the following elements is there to match up with genitem */ struct sctstr { + /* initial part must match struct genitem */ short ef_type; natid sct_own; /* owner's country num */ short sct_elev; /* elevation/depth */ coord sct_x; /* x coord of sector */ coord sct_y; /* y coord of sector */ + /* end of part matching struct genitem */ u_char sct_type; /* sector type */ u_char sct_effic; /* 0% to 100% */ short sct_mobil; /* mobility units */ diff --git a/include/ship.h b/include/ship.h index e8f3e29e4..32e25064a 100644 --- a/include/ship.h +++ b/include/ship.h @@ -60,6 +60,7 @@ #define MAXSHPNAMLEN 24 struct shpstr { + /* initial part must match struct genitem */ short ef_type; natid shp_own; /* owner's country num */ short shp_uid; /* unit id (ship #) */ @@ -73,6 +74,7 @@ struct shpstr { coord shp_opx, shp_opy; /* Op sector coords */ short shp_mission; /* mission code */ short shp_radius; /* mission radius */ + /* end of part matching struct genitem */ u_char shp_nplane; /* number of planes on board */ u_char shp_nland; /* number of land units on board */ short shp_armor; -- 2.43.0