]> git.pond.sub.org Git - empserver/commitdiff
Extend the common header of struct empobj to include uid
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 25 Feb 2008 07:23:19 +0000 (08:23 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 5 Mar 2008 21:48:20 +0000 (22:48 +0100)
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.

19 files changed:
include/commodity.h
include/empobj.h
include/game.h
include/land.h
include/loan.h
include/lost.h
include/nat.h
include/news.h
include/nuke.h
include/plane.h
include/sect.h
include/ship.h
include/trade.h
include/treaty.h
src/lib/commands/edit.c
src/lib/commands/swap.c
src/lib/global/nsc.c
src/util/fairland.c
src/util/files.c

index 41573303bf1eec32880258ca9ed7b3636f22de79..46a038eb8c96f3b111abb9be244d56954c3cfe46 100644 (file)
@@ -43,8 +43,8 @@
 struct comstr {
     /* initial part must match struct empobj */
     short ef_type;
-    natid com_owner;
     short com_uid;
+    natid com_owner;
     /* end of part matching struct empobj */
     i_type com_type;
     int com_amount;
index 97dc00e5182aabdffb855e7e3a887aa9064f7157..8300211fe514eb65b31215e6e6a0f97e8d06b2c8 100644 (file)
@@ -52,8 +52,8 @@
 
 struct empobj {
     short ef_type;     /* is always valid */
-    natid own;         /* is valid if EFF_OWNER   is set in table def. */
     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 y;           /* is valid if EFF_XY      is set in table def. */
     signed char type;  /* is valid for sectors and units */
index 2e32924816db3d0be54120f24195f2809ab7512b..5d0d897b6f7b551ee81d0737a6ded7285f6cbeee 100644 (file)
@@ -39,6 +39,7 @@
 struct gamestr {
     /* initial part must match struct empobj */
     short ef_type;
+    short game_uid;
     /* end of part matching struct empobj */
     char game_upd_disable;     /* updates disabled? */
     /*
index 339cf410c8edf9916f0d5ea1b6053ee89aee60af..bd497231519bf792ee899832a76053bd6df2867e 100644 (file)
@@ -49,8 +49,8 @@
 struct lndstr {
     /* initial part must match struct empobj */
     short ef_type;
-    natid lnd_own;             /* owner's country num */
     short lnd_uid;             /* unit id (land unit) */
+    natid lnd_own;             /* owner's country num */
     coord lnd_x;               /* x location in abs coords */
     coord lnd_y;               /* y location in abs coords */
     signed char lnd_type;      /* index in lchr[] */
index 21c60b13b58c119601040911fa406385a5d70cb5..f2ec2c082fd8be06ec71a0dc7e388dc278bcbe75 100644 (file)
 #define SECS_PER_DAY   (60*60*24)
 
 struct lonstr {
+    /* initial part must match struct empobj */
     short ef_type;
-    natid l_loner;             /* loan shark */
     short l_uid;
+    /* end of part matching struct empobj */
+    natid l_loner;             /* loan shark */
     natid l_lonee;             /* sucker */
     signed char l_status;      /* loan status */
     short l_sell;              /* pointer to trade file (unused) */
index acfae5c9754eb1c4f53efcae680a34840ee1001d..a377c6ec19c52743389d3df9057412161dbdaf4d 100644 (file)
@@ -40,9 +40,9 @@
 struct loststr {
     /* initial part must match struct empobj */
     short ef_type;
+    int lost_uid;              /* lost ID (assigned, otherwise unused) */
     natid lost_owner;          /* Who lost it */
     /* 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_id;             /* ID of lost thing */
     coord lost_x;
index c7cb0173175428dfcd75bbe3841d0fc5d994c4b0..b54c8bf9ebde001422ccfa564bb8a97f68f07da9 100644 (file)
@@ -69,9 +69,9 @@ typedef enum {
 struct realmstr {
     /* initial part must match struct empobj */
     short ef_type;
+    short r_uid;               /* realm table index */
     natid r_cnum;              /* country number */
     /* end of part matching struct empobj */
-    short r_uid;               /* realm table index */
     unsigned short r_realm;    /* realm number */
     short r_xl, r_xh;          /* horizontal bounds */
     short r_yl, r_yh;          /* vertical bounds */
@@ -81,6 +81,7 @@ struct realmstr {
 struct natstr {
     /* initial part must match struct empobj */
     short ef_type;
+    short nat_uid;             /* equals nat_cnum */
     natid nat_cnum;            /* our country number */
     /* end of part matching struct empobj */
     nat_status nat_stat;
index 888c78d416480bfcb5979e6e2f860e3e62a28c75..cc182a9109a14a72f7be77cc93d326b7f346166d 100644 (file)
 #include "nsc.h"
 
 struct nwsstr {
+    /* initial part must match struct empobj */
     short ef_type;
-    natid nws_ano;             /* "actor" country # */
     short nws_uid;             /* unused */
+    /* end of part matching struct empobj */
+    natid nws_ano;             /* "actor" country # */
     signed char nws_vrb;       /* action (verb) */
     natid nws_vno;             /* "victim" country # */
     signed char nws_ntm;       /* number of times */
index 3c42a4e9e3ddb9fb4231fb644b677486d639aa35..cc90de9513049a5b37a43c940ff8439990c8a177 100644 (file)
@@ -43,8 +43,8 @@
 struct nukstr {
     /* initial part must match struct empobj */
     short ef_type;
-    natid nuk_own;
     short nuk_uid;
+    natid nuk_own;
     coord nuk_x, nuk_y;                /* current loc of device */
     signed char nuk_type;      /* index in nchr[] */
     signed char nuk_effic;     /* unused, always 100% */
index 25c6fd0e4d3ab5f88cfd1993ab7f15b8783fc0e9..f072ba785abd8d5e79061b4b0b72e20f39c74978 100644 (file)
@@ -46,8 +46,8 @@
 struct plnstr {
     /* initial part must match struct empobj */
     short ef_type;
-    natid pln_own;             /* owning country */
     short pln_uid;             /* plane unit id */
+    natid pln_own;             /* owning country */
     coord pln_x;               /* plane x-y */
     coord pln_y;
     signed char pln_type;      /* index in plchr[] */
index a960706ee500c88c7a53cfd091effdcc4179cc6f..8d9f9d4eb21eaf0618bc28075395679cd12d92ca 100644 (file)
@@ -44,8 +44,8 @@
 struct sctstr {
     /* initial part must match struct empobj */
     short ef_type;
+    short sct_uid;             /* equals sctoff(sct_x, sct_y) */
     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 */
     signed char sct_type;      /* sector type */
@@ -62,7 +62,7 @@ struct sctstr {
     coord sct_dist_y;
     short sct_avail;           /* available workforce for "other things" */
     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_coastal; /* is this a coastal sector? */
     signed char sct_newtype;   /* for changing designations */
index 65097564f67bb6ed2cfaa2d63d92d0ea457d8066..cbfed235be30a681e50c7a32aaad9b93ff1a3e0a 100644 (file)
@@ -63,8 +63,8 @@
 struct shpstr {
     /* initial part must match struct empobj */
     short ef_type;
-    natid shp_own;             /* owner's country num */
     short shp_uid;             /* unit id (ship #) */
+    natid shp_own;             /* owner's country num */
     coord shp_x;               /* x location in abs coords */
     coord shp_y;               /* y location in abs coords */
     signed char shp_type;      /* index in mchr[] */
index 45b4dfe0bb1fb9b3e7e78342bd00223e5b55d0b7..8db1e6fe9477f61e6a367db304adbee0c77ae4fe 100644 (file)
@@ -43,8 +43,8 @@
 struct trdstr {
     /* initial part must match struct empobj */
     short ef_type;
-    natid trd_owner;
     short trd_uid;
+    natid trd_owner;
     /* end of part matching struct empobj */
     short trd_type;
     short trd_unitid;
index ba072745a46b5d7b7b62c697e820dcfad76c9044..a8c5d258b33b613085a4f223983b02cf0476405c 100644 (file)
 #include "types.h"
 
 struct trtstr {
+    /* initial part must match struct empobj */
     short ef_type;
-    natid trt_cna;             /* proposer */
     short trt_uid;
+    /* end of part matching struct empobj */
+    natid trt_cna;             /* proposer */
     natid trt_cnb;             /* acceptor */
     signed char trt_status;    /* treaty status */
     char trt_fill;
index b15f8e018adb96ea729d867a9ea0fcc956b0f23d..6e678c8042155f014949d0bf3676b52873a8195c 100644 (file)
@@ -593,6 +593,7 @@ doland(char op, int arg, char *p, struct sctstr *sect)
            return RET_SYN;
        sect->sct_x = newx;
        sect->sct_y = newy;
+       sect->sct_uid = XYOFFSET(newx, newy);
        break;
     case 'D':
        if (!sarg_xy(p, &newx, &newy))
index 6c8fd3073db29522f1cfaee180c5c3f781c35604..a28b89913c38ae3c266f01166e00eeef40c0ed12 100644 (file)
@@ -63,12 +63,14 @@ swaps(void)
     /* change the location of secta to that of sectb */
     secta.sct_x = sectb.sct_x;
     secta.sct_y = sectb.sct_y;
+    secta.sct_uid = sectb.sct_uid;
     secta.sct_dist_x = sectb.sct_x;
     secta.sct_dist_y = sectb.sct_y;
     secta.sct_coastal = sectb.sct_coastal;
     /* change the location of sectb to where secta was */
     sectb.sct_x = tmp.sct_x;
     sectb.sct_y = tmp.sct_y;
+    sectb.sct_uid = tmp.sct_uid;
     sectb.sct_dist_x = tmp.sct_x;
     sectb.sct_dist_y = tmp.sct_y;
     sectb.sct_coastal = tmp.sct_coastal;
index b23987e35aea4fb3aff2b88c7009e9be31bdfff5..b463e04912e7b3d49456eed988b7906f9ed98dcc 100644 (file)
@@ -103,9 +103,10 @@ struct castr pchr_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_SHORT, NSC_DEITY, 0, fldoff(sctstr, sct_elev), "elev", 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_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_YCOORD, 0, 0, fldoff(sctstr, sct_dist_y), "ydist", 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_coastal), "coastal", EF_BAD},
     {NSC_CHAR, 0, 0, fldoff(sctstr, sct_newtype), "newdes", EF_SECTOR_CHR},
index 104aa9df787f3be1488e1a639795a270e7f476cc..4598eba614b08318f526c109144bc6866dd2a90a 100644 (file)
@@ -1214,6 +1214,7 @@ static void
 fl_sct_init(coord x, coord y, struct sctstr *sp)
 {
     sp->ef_type = EF_SECTOR;
+    sp->sct_uid = XYOFFSET(x, y);
     sp->sct_x = x;
     sp->sct_y = y;
     sp->sct_dist_x = x;
index 2d8c9371268050494766d62fb04d380f009c1e78..4618ba6efc7c7dfaa5f1d47523950420a58fdebf 100644 (file)
@@ -154,7 +154,7 @@ main(int argc, char *argv[])
     memset(&nat, 0, sizeof(nat));
     for (i = 1; i < MAXNOC; i++) {
        nat.ef_type = EF_NATION;
-       nat.nat_cnum = i;
+       nat.nat_cnum = nat.nat_uid = i;
        putnat((&nat));
     }
     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;
 
     sp->ef_type = EF_SECTOR;
+    sp->sct_uid = XYOFFSET(x, y);
     sp->sct_x = x;
     sp->sct_y = y;
     sp->sct_dist_x = x;