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:
parent
aef790f7f3
commit
49780e2c6c
19 changed files with 32 additions and 17 deletions
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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? */
|
||||
/*
|
||||
|
|
|
@ -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[] */
|
||||
|
|
|
@ -41,9 +41,11 @@
|
|||
#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) */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -45,9 +45,11 @@
|
|||
#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 */
|
||||
|
|
|
@ -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% */
|
||||
|
|
|
@ -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[] */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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[] */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -38,9 +38,11 @@
|
|||
#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;
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue