Document struct equivalence hack and implications of EFF_XY and

EFF_GROUP.
This commit is contained in:
Markus Armbruster 2005-05-28 08:03:31 +00:00
parent 7ef7aa83b8
commit 4a67b91f8a
6 changed files with 18 additions and 0 deletions

View file

@ -55,11 +55,19 @@ struct empfile {
struct castr *cadef; /* ca defs selection list */ 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_XY bit(0) /* has location */
#define EFF_MEM bit(1) /* stored entirely in-memory */ #define EFF_MEM bit(1) /* stored entirely in-memory */
#define EFF_OWNER bit(2) /* has concept of owner */ #define EFF_OWNER bit(2) /* has concept of owner */
#define EFF_GROUP bit(3) /* has concept of group */ #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_BAD -1 /* illegal file type */
#define EF_SECTOR 0 #define EF_SECTOR 0
#define EF_SHIP 1 #define EF_SHIP 1

View file

@ -47,6 +47,7 @@
#define LND_MINMOBCOST 0.200 #define LND_MINMOBCOST 0.200
struct lndstr { struct lndstr {
/* initial part must match struct genitem */
short ef_type; short ef_type;
natid lnd_own; /* owner's country num */ natid lnd_own; /* owner's country num */
short lnd_uid; /* unit id (land unit) */ short lnd_uid; /* unit id (land unit) */
@ -60,6 +61,7 @@ struct lndstr {
coord lnd_opx, lnd_opy; /* Op sector coords */ coord lnd_opx, lnd_opy; /* Op sector coords */
short lnd_mission; /* mission code */ short lnd_mission; /* mission code */
short lnd_radius; /* mission radius */ short lnd_radius; /* mission radius */
/* end of part matching struct genitem */
s_char lnd_flags; /* unit flags (unused) */ s_char lnd_flags; /* unit flags (unused) */
short lnd_ship; /* pointer to transporting ship */ short lnd_ship; /* pointer to transporting ship */
s_char lnd_harden; /* for missiles */ s_char lnd_harden; /* for missiles */

View file

@ -37,11 +37,13 @@
#define N_MAXNUKE 15 #define N_MAXNUKE 15
struct nukstr { struct nukstr {
/* initial part must match struct genitem */
short ef_type; short ef_type;
natid nuk_own; natid nuk_own;
short nuk_uid; short nuk_uid;
coord nuk_x; /* current loc of device */ coord nuk_x; /* current loc of device */
coord nuk_y; coord nuk_y;
/* end of part matching struct genitem */
s_char nuk_n; /* number of nukes in list */ s_char nuk_n; /* number of nukes in list */
short nuk_ship; /* currently aboard ship (unused) */ short nuk_ship; /* currently aboard ship (unused) */
short nuk_trade; /* index into trade file (unused) */ short nuk_trade; /* index into trade file (unused) */

View file

@ -46,6 +46,7 @@
* exactly equivalent with shp_x to shp_fleet * exactly equivalent with shp_x to shp_fleet
*/ */
struct plnstr { struct plnstr {
/* initial part must match struct genitem */
short ef_type; short ef_type;
natid pln_own; /* owning country */ natid pln_own; /* owning country */
short pln_uid; /* plane unit id */ short pln_uid; /* plane unit id */
@ -60,6 +61,7 @@ struct plnstr {
coord pln_opy; /* Op sector coords */ coord pln_opy; /* Op sector coords */
short pln_mission; /* mission code */ short pln_mission; /* mission code */
short pln_radius; /* mission radius */ short pln_radius; /* mission radius */
/* end of part matching struct genitem */
u_char pln_range; /* total distance, not radius */ u_char pln_range; /* total distance, not radius */
u_char pln_range_max; /* max range for this plane */ u_char pln_range_max; /* max range for this plane */
short pln_ship; /* pointer to carrier */ short pln_ship; /* pointer to carrier */

View file

@ -42,11 +42,13 @@
/* The order of the following elements is there to match up with genitem */ /* The order of the following elements is there to match up with genitem */
struct sctstr { struct sctstr {
/* initial part must match struct genitem */
short ef_type; short ef_type;
natid sct_own; /* owner's country num */ natid sct_own; /* owner's country num */
short sct_elev; /* elevation/depth */ short sct_elev; /* elevation/depth */
coord sct_x; /* x coord of sector */ coord sct_x; /* x coord of sector */
coord sct_y; /* y 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_type; /* sector type */
u_char sct_effic; /* 0% to 100% */ u_char sct_effic; /* 0% to 100% */
short sct_mobil; /* mobility units */ short sct_mobil; /* mobility units */

View file

@ -60,6 +60,7 @@
#define MAXSHPNAMLEN 24 #define MAXSHPNAMLEN 24
struct shpstr { struct shpstr {
/* initial part must match struct genitem */
short ef_type; short ef_type;
natid shp_own; /* owner's country num */ natid shp_own; /* owner's country num */
short shp_uid; /* unit id (ship #) */ short shp_uid; /* unit id (ship #) */
@ -73,6 +74,7 @@ struct shpstr {
coord shp_opx, shp_opy; /* Op sector coords */ coord shp_opx, shp_opy; /* Op sector coords */
short shp_mission; /* mission code */ short shp_mission; /* mission code */
short shp_radius; /* mission radius */ short shp_radius; /* mission radius */
/* end of part matching struct genitem */
u_char shp_nplane; /* number of planes on board */ u_char shp_nplane; /* number of planes on board */
u_char shp_nland; /* number of land units on board */ u_char shp_nland; /* number of land units on board */
short shp_armor; short shp_armor;