Extend the common header of struct empobj to include uid

Make sure all members of unit empobj_storage share uid in addition to
ef_type.

Add matching uid member to struct gamestr, struct natstr and struct
sctstr, and set them.

Swap struct empobj members uid and own to make that easier, and update
struct comstr, struct lndstr, struct lonstr, struct loststr, struct
nwsstr, struct nukstr, struct plnstr, struct realmstr, struct shpstr,
struct trdstr, struct trtstr accordingly.

Note that the uid isn't properly set for struct nwsstr, struct lonstr,
struct trdstr, struct comstr and struct loststr.  To be fixed.
This commit is contained in:
Markus Armbruster 2008-02-25 08:23:19 +01:00
parent aef790f7f3
commit 49780e2c6c
19 changed files with 32 additions and 17 deletions

View file

@ -43,8 +43,8 @@
struct comstr { struct comstr {
/* initial part must match struct empobj */ /* initial part must match struct empobj */
short ef_type; short ef_type;
natid com_owner;
short com_uid; short com_uid;
natid com_owner;
/* end of part matching struct empobj */ /* end of part matching struct empobj */
i_type com_type; i_type com_type;
int com_amount; int com_amount;

View file

@ -52,8 +52,8 @@
struct empobj { struct empobj {
short ef_type; /* is always valid */ short ef_type; /* is always valid */
natid own; /* is valid if EFF_OWNER is set in table def. */
short uid; short uid;
natid own; /* is valid if EFF_OWNER is set in table def. */
coord x; /* is valid if EFF_XY is set in table def. */ coord x; /* is valid if EFF_XY is set in table def. */
coord y; /* is valid if EFF_XY is set in table def. */ coord y; /* is valid if EFF_XY is set in table def. */
signed char type; /* is valid for sectors and units */ signed char type; /* is valid for sectors and units */

View file

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

View file

@ -49,8 +49,8 @@
struct lndstr { struct lndstr {
/* initial part must match struct empobj */ /* initial part must match struct empobj */
short ef_type; short ef_type;
natid lnd_own; /* owner's country num */
short lnd_uid; /* unit id (land unit) */ short lnd_uid; /* unit id (land unit) */
natid lnd_own; /* owner's country num */
coord lnd_x; /* x location in abs coords */ coord lnd_x; /* x location in abs coords */
coord lnd_y; /* y location in abs coords */ coord lnd_y; /* y location in abs coords */
signed char lnd_type; /* index in lchr[] */ signed char lnd_type; /* index in lchr[] */

View file

@ -41,9 +41,11 @@
#define SECS_PER_DAY (60*60*24) #define SECS_PER_DAY (60*60*24)
struct lonstr { struct lonstr {
/* initial part must match struct empobj */
short ef_type; short ef_type;
natid l_loner; /* loan shark */
short l_uid; short l_uid;
/* end of part matching struct empobj */
natid l_loner; /* loan shark */
natid l_lonee; /* sucker */ natid l_lonee; /* sucker */
signed char l_status; /* loan status */ signed char l_status; /* loan status */
short l_sell; /* pointer to trade file (unused) */ short l_sell; /* pointer to trade file (unused) */

View file

@ -40,9 +40,9 @@
struct loststr { struct loststr {
/* initial part must match struct empobj */ /* initial part must match struct empobj */
short ef_type; short ef_type;
int lost_uid; /* lost ID (assigned, otherwise unused) */
natid lost_owner; /* Who lost it */ natid lost_owner; /* Who lost it */
/* end of part matching struct empobj */ /* end of part matching struct empobj */
int lost_uid; /* lost ID (assigned, otherwise unused) */
short lost_type; /* Type of thing (ship, plane, nuke, land, sector) */ short lost_type; /* Type of thing (ship, plane, nuke, land, sector) */
short lost_id; /* ID of lost thing */ short lost_id; /* ID of lost thing */
coord lost_x; coord lost_x;

View file

@ -69,9 +69,9 @@ typedef enum {
struct realmstr { struct realmstr {
/* initial part must match struct empobj */ /* initial part must match struct empobj */
short ef_type; short ef_type;
short r_uid; /* realm table index */
natid r_cnum; /* country number */ natid r_cnum; /* country number */
/* end of part matching struct empobj */ /* end of part matching struct empobj */
short r_uid; /* realm table index */
unsigned short r_realm; /* realm number */ unsigned short r_realm; /* realm number */
short r_xl, r_xh; /* horizontal bounds */ short r_xl, r_xh; /* horizontal bounds */
short r_yl, r_yh; /* vertical bounds */ short r_yl, r_yh; /* vertical bounds */
@ -81,6 +81,7 @@ struct realmstr {
struct natstr { struct natstr {
/* initial part must match struct empobj */ /* initial part must match struct empobj */
short ef_type; short ef_type;
short nat_uid; /* equals nat_cnum */
natid nat_cnum; /* our country number */ natid nat_cnum; /* our country number */
/* end of part matching struct empobj */ /* end of part matching struct empobj */
nat_status nat_stat; nat_status nat_stat;

View file

@ -45,9 +45,11 @@
#include "nsc.h" #include "nsc.h"
struct nwsstr { struct nwsstr {
/* initial part must match struct empobj */
short ef_type; short ef_type;
natid nws_ano; /* "actor" country # */
short nws_uid; /* unused */ short nws_uid; /* unused */
/* end of part matching struct empobj */
natid nws_ano; /* "actor" country # */
signed char nws_vrb; /* action (verb) */ signed char nws_vrb; /* action (verb) */
natid nws_vno; /* "victim" country # */ natid nws_vno; /* "victim" country # */
signed char nws_ntm; /* number of times */ signed char nws_ntm; /* number of times */

View file

@ -43,8 +43,8 @@
struct nukstr { struct nukstr {
/* initial part must match struct empobj */ /* initial part must match struct empobj */
short ef_type; short ef_type;
natid nuk_own;
short nuk_uid; short nuk_uid;
natid nuk_own;
coord nuk_x, nuk_y; /* current loc of device */ coord nuk_x, nuk_y; /* current loc of device */
signed char nuk_type; /* index in nchr[] */ signed char nuk_type; /* index in nchr[] */
signed char nuk_effic; /* unused, always 100% */ signed char nuk_effic; /* unused, always 100% */

View file

@ -46,8 +46,8 @@
struct plnstr { struct plnstr {
/* initial part must match struct empobj */ /* initial part must match struct empobj */
short ef_type; short ef_type;
natid pln_own; /* owning country */
short pln_uid; /* plane unit id */ short pln_uid; /* plane unit id */
natid pln_own; /* owning country */
coord pln_x; /* plane x-y */ coord pln_x; /* plane x-y */
coord pln_y; coord pln_y;
signed char pln_type; /* index in plchr[] */ signed char pln_type; /* index in plchr[] */

View file

@ -44,8 +44,8 @@
struct sctstr { struct sctstr {
/* initial part must match struct empobj */ /* initial part must match struct empobj */
short ef_type; short ef_type;
short sct_uid; /* equals sctoff(sct_x, sct_y) */
natid sct_own; /* owner's country num */ natid sct_own; /* owner's country num */
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 */
signed char sct_type; /* sector type */ signed char sct_type; /* sector type */
@ -62,7 +62,7 @@ struct sctstr {
coord sct_dist_y; coord sct_dist_y;
short sct_avail; /* available workforce for "other things" */ short sct_avail; /* available workforce for "other things" */
short sct_flags; /* temporary flags */ short sct_flags; /* temporary flags */
short sct_fill; /* gunk */ short sct_elev; /* elevation/depth */
unsigned char sct_work; /* pct of civ actually working */ unsigned char sct_work; /* pct of civ actually working */
unsigned char sct_coastal; /* is this a coastal sector? */ unsigned char sct_coastal; /* is this a coastal sector? */
signed char sct_newtype; /* for changing designations */ signed char sct_newtype; /* for changing designations */

View file

@ -63,8 +63,8 @@
struct shpstr { struct shpstr {
/* initial part must match struct empobj */ /* initial part must match struct empobj */
short ef_type; short ef_type;
natid shp_own; /* owner's country num */
short shp_uid; /* unit id (ship #) */ short shp_uid; /* unit id (ship #) */
natid shp_own; /* owner's country num */
coord shp_x; /* x location in abs coords */ coord shp_x; /* x location in abs coords */
coord shp_y; /* y location in abs coords */ coord shp_y; /* y location in abs coords */
signed char shp_type; /* index in mchr[] */ signed char shp_type; /* index in mchr[] */

View file

@ -43,8 +43,8 @@
struct trdstr { struct trdstr {
/* initial part must match struct empobj */ /* initial part must match struct empobj */
short ef_type; short ef_type;
natid trd_owner;
short trd_uid; short trd_uid;
natid trd_owner;
/* end of part matching struct empobj */ /* end of part matching struct empobj */
short trd_type; short trd_type;
short trd_unitid; short trd_unitid;

View file

@ -38,9 +38,11 @@
#include "types.h" #include "types.h"
struct trtstr { struct trtstr {
/* initial part must match struct empobj */
short ef_type; short ef_type;
natid trt_cna; /* proposer */
short trt_uid; short trt_uid;
/* end of part matching struct empobj */
natid trt_cna; /* proposer */
natid trt_cnb; /* acceptor */ natid trt_cnb; /* acceptor */
signed char trt_status; /* treaty status */ signed char trt_status; /* treaty status */
char trt_fill; char trt_fill;

View file

@ -593,6 +593,7 @@ doland(char op, int arg, char *p, struct sctstr *sect)
return RET_SYN; return RET_SYN;
sect->sct_x = newx; sect->sct_x = newx;
sect->sct_y = newy; sect->sct_y = newy;
sect->sct_uid = XYOFFSET(newx, newy);
break; break;
case 'D': case 'D':
if (!sarg_xy(p, &newx, &newy)) if (!sarg_xy(p, &newx, &newy))

View file

@ -63,12 +63,14 @@ swaps(void)
/* change the location of secta to that of sectb */ /* change the location of secta to that of sectb */
secta.sct_x = sectb.sct_x; secta.sct_x = sectb.sct_x;
secta.sct_y = sectb.sct_y; secta.sct_y = sectb.sct_y;
secta.sct_uid = sectb.sct_uid;
secta.sct_dist_x = sectb.sct_x; secta.sct_dist_x = sectb.sct_x;
secta.sct_dist_y = sectb.sct_y; secta.sct_dist_y = sectb.sct_y;
secta.sct_coastal = sectb.sct_coastal; secta.sct_coastal = sectb.sct_coastal;
/* change the location of sectb to where secta was */ /* change the location of sectb to where secta was */
sectb.sct_x = tmp.sct_x; sectb.sct_x = tmp.sct_x;
sectb.sct_y = tmp.sct_y; sectb.sct_y = tmp.sct_y;
sectb.sct_uid = tmp.sct_uid;
sectb.sct_dist_x = tmp.sct_x; sectb.sct_dist_x = tmp.sct_x;
sectb.sct_dist_y = tmp.sct_y; sectb.sct_dist_y = tmp.sct_y;
sectb.sct_coastal = tmp.sct_coastal; sectb.sct_coastal = tmp.sct_coastal;

View file

@ -103,9 +103,10 @@ struct castr pchr_ca[] = {
}; };
struct castr sect_ca[] = { struct castr sect_ca[] = {
/* uid is encoded in x, y */ /* uid needs to be NSC_DEITY because it discloses true origin */
{NSC_SHORT, NSC_DEITY | NSC_EXTRA, 0, fldoff(sctstr, sct_uid), "uid",
EF_SECTOR},
{NSC_NATID, 0, 0, fldoff(sctstr, sct_own), "owner", EF_NATION}, {NSC_NATID, 0, 0, fldoff(sctstr, sct_own), "owner", EF_NATION},
{NSC_SHORT, NSC_DEITY, 0, fldoff(sctstr, sct_elev), "elev", EF_BAD},
{NSC_XCOORD, NSC_CONST, 0, fldoff(sctstr, sct_x), "xloc", EF_BAD}, {NSC_XCOORD, NSC_CONST, 0, fldoff(sctstr, sct_x), "xloc", EF_BAD},
{NSC_YCOORD, NSC_CONST, 0, fldoff(sctstr, sct_y), "yloc", EF_BAD}, {NSC_YCOORD, NSC_CONST, 0, fldoff(sctstr, sct_y), "yloc", EF_BAD},
{NSC_CHAR, 0, 0, fldoff(sctstr, sct_type), "des", EF_SECTOR_CHR}, {NSC_CHAR, 0, 0, fldoff(sctstr, sct_type), "des", EF_SECTOR_CHR},
@ -121,6 +122,7 @@ struct castr sect_ca[] = {
{NSC_XCOORD, 0, 0, fldoff(sctstr, sct_dist_x), "xdist", EF_BAD}, {NSC_XCOORD, 0, 0, fldoff(sctstr, sct_dist_x), "xdist", EF_BAD},
{NSC_YCOORD, 0, 0, fldoff(sctstr, sct_dist_y), "ydist", EF_BAD}, {NSC_YCOORD, 0, 0, fldoff(sctstr, sct_dist_y), "ydist", EF_BAD},
{NSC_SHORT, 0, 0, fldoff(sctstr, sct_avail), "avail", EF_BAD}, {NSC_SHORT, 0, 0, fldoff(sctstr, sct_avail), "avail", EF_BAD},
{NSC_SHORT, NSC_DEITY, 0, fldoff(sctstr, sct_elev), "elev", EF_BAD},
{NSC_UCHAR, 0, 0, fldoff(sctstr, sct_work), "work", EF_BAD}, {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_work), "work", EF_BAD},
{NSC_UCHAR, 0, 0, fldoff(sctstr, sct_coastal), "coastal", EF_BAD}, {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_coastal), "coastal", EF_BAD},
{NSC_CHAR, 0, 0, fldoff(sctstr, sct_newtype), "newdes", EF_SECTOR_CHR}, {NSC_CHAR, 0, 0, fldoff(sctstr, sct_newtype), "newdes", EF_SECTOR_CHR},

View file

@ -1214,6 +1214,7 @@ static void
fl_sct_init(coord x, coord y, struct sctstr *sp) fl_sct_init(coord x, coord y, struct sctstr *sp)
{ {
sp->ef_type = EF_SECTOR; sp->ef_type = EF_SECTOR;
sp->sct_uid = XYOFFSET(x, y);
sp->sct_x = x; sp->sct_x = x;
sp->sct_y = y; sp->sct_y = y;
sp->sct_dist_x = x; sp->sct_dist_x = x;

View file

@ -154,7 +154,7 @@ main(int argc, char *argv[])
memset(&nat, 0, sizeof(nat)); memset(&nat, 0, sizeof(nat));
for (i = 1; i < MAXNOC; i++) { for (i = 1; i < MAXNOC; i++) {
nat.ef_type = EF_NATION; nat.ef_type = EF_NATION;
nat.nat_cnum = i; nat.nat_cnum = nat.nat_uid = i;
putnat((&nat)); putnat((&nat));
} }
memset(&realm, 0, sizeof(realm)); memset(&realm, 0, sizeof(realm));
@ -208,6 +208,7 @@ file_sct_init(coord x, coord y, struct sctstr *ptr)
struct sctstr *sp = (struct sctstr *)ptr; struct sctstr *sp = (struct sctstr *)ptr;
sp->ef_type = EF_SECTOR; sp->ef_type = EF_SECTOR;
sp->sct_uid = XYOFFSET(x, y);
sp->sct_x = x; sp->sct_x = x;
sp->sct_y = y; sp->sct_y = y;
sp->sct_dist_x = x; sp->sct_dist_x = x;