Store them and ef_type in bit-fields.
Allocate eight bits for ef_type. Values range from 0 to EF_GAME
(currently 16), so this is plenty.
Allocate twelve bits for sequence numbers. Sequence number mismatches
are now missed when the numbers are equal modulo 2^12. Still
sufficiently improbable.
Common machines store the bit-fields in a 32 bit word. There are
twelve bits left in that word for future use. Total savings 16 bits,
which is exactly what the previous commit spent on wider uids on
common machines.
15 files changed:
struct comstr {
/* initial part must match struct empobj */
struct comstr {
/* initial part must match struct empobj */
+ signed ef_type: 8;
+ unsigned com_seqno: 12;
time_t com_timestamp;
natid com_owner;
/* end of part matching struct empobj */
time_t com_timestamp;
natid com_owner;
/* end of part matching struct empobj */
* initial part must match struct emptypedstr
* valid if EFF_TYPED is set in table's flags
*/
* initial part must match struct emptypedstr
* valid if EFF_TYPED is set in table's flags
*/
+ signed ef_type: 8;
+ unsigned seqno: 12;
time_t timestamp;
/* end of part matching struct emptypedstr */
natid own; /* valid if EFF_OWNER is in table's flags */
time_t timestamp;
/* end of part matching struct emptypedstr */
natid own; /* valid if EFF_OWNER is in table's flags */
};
union empobj_storage {
};
union empobj_storage {
struct empobj gen;
struct comstr comm;
struct gamestr game;
struct empobj gen;
struct comstr comm;
struct gamestr game;
+ signed ef_type: 8;
+ unsigned seqno: 12;
struct gamestr {
/* initial part must match struct empobj */
struct gamestr {
/* initial part must match struct empobj */
+ signed ef_type: 8;
+ unsigned game_seqno: 12;
time_t game_timestamp;
/* end of part matching struct empobj */
char game_upd_disable; /* updates disabled? */
time_t game_timestamp;
/* end of part matching struct empobj */
char game_upd_disable; /* updates disabled? */
struct lndstr {
/* initial part must match struct empobj */
struct lndstr {
/* initial part must match struct empobj */
+ signed ef_type: 8;
+ unsigned lnd_seqno: 12;
int lnd_uid; /* unit id (land #) */
int lnd_uid; /* unit id (land #) */
time_t lnd_timestamp; /* Last time this unit was touched */
natid lnd_own; /* owner's country num */
coord lnd_x; /* x location in abs coords */
time_t lnd_timestamp; /* Last time this unit was touched */
natid lnd_own; /* owner's country num */
coord lnd_x; /* x location in abs coords */
struct lonstr {
/* initial part must match struct empobj */
struct lonstr {
/* initial part must match struct empobj */
+ signed ef_type: 8;
+ unsigned l_seqno: 12;
time_t l_timestamp;
/* end of part matching struct empobj */
natid l_loner; /* loan shark */
time_t l_timestamp;
/* end of part matching struct empobj */
natid l_loner; /* loan shark */
struct loststr {
/* initial part must match struct empobj */
struct loststr {
/* initial part must match struct empobj */
+ signed ef_type: 8;
+ unsigned lost_seqno: 12;
time_t lost_timestamp; /* When it was lost */
natid lost_owner; /* Who lost it */
/* end of part matching struct empobj */
time_t lost_timestamp; /* When it was lost */
natid lost_owner; /* Who lost it */
/* end of part matching struct empobj */
*/
struct realmstr {
/* initial part must match struct empobj */
*/
struct realmstr {
/* initial part must match struct empobj */
+ signed ef_type: 8;
+ unsigned r_seqno: 12;
int r_uid; /* realm table index */
int r_uid; /* realm table index */
time_t r_timestamp; /* Last time this realm was touched */
natid r_cnum; /* country number */
/* end of part matching struct empobj */
time_t r_timestamp; /* Last time this realm was touched */
natid r_cnum; /* country number */
/* end of part matching struct empobj */
struct natstr {
/* initial part must match struct empobj */
struct natstr {
/* initial part must match struct empobj */
+ signed ef_type: 8;
+ unsigned nat_seqno: 12;
int nat_uid; /* equals nat_cnum */
int nat_uid; /* equals nat_cnum */
time_t nat_timestamp;
natid nat_cnum; /* our country number */
/* end of part matching struct empobj */
time_t nat_timestamp;
natid nat_cnum; /* our country number */
/* end of part matching struct empobj */
struct nukstr {
/* initial part must match struct empobj */
struct nukstr {
/* initial part must match struct empobj */
+ signed ef_type: 8;
+ unsigned nuk_seqno: 12;
int nuk_uid; /* unit id (nuke #) */
int nuk_uid; /* unit id (nuke #) */
time_t nuk_timestamp; /* Last time this nuke was touched */
natid nuk_own;
coord nuk_x, nuk_y; /* current loc of device */
time_t nuk_timestamp; /* Last time this nuke was touched */
natid nuk_own;
coord nuk_x, nuk_y; /* current loc of device */
struct plnstr {
/* initial part must match struct empobj */
struct plnstr {
/* initial part must match struct empobj */
+ signed ef_type: 8;
+ unsigned pln_seqno: 12;
int pln_uid; /* unit id (plane #) */
int pln_uid; /* unit id (plane #) */
time_t pln_timestamp; /* Last time this plane was touched */
natid pln_own; /* owning country */
coord pln_x; /* plane x-y */
time_t pln_timestamp; /* Last time this plane was touched */
natid pln_own; /* owning country */
coord pln_x; /* plane x-y */
struct sctstr {
/* initial part must match struct empobj */
struct sctstr {
/* initial part must match struct empobj */
+ signed ef_type: 8;
+ unsigned sct_seqno: 12;
int sct_uid; /* equals XYOFFSET(sct_x, sct_y) */
int sct_uid; /* equals XYOFFSET(sct_x, sct_y) */
time_t sct_timestamp; /* Last time this sector was written to */
natid sct_own; /* owner's country num */
coord sct_x; /* x coord of sector */
time_t sct_timestamp; /* Last time this sector was written to */
natid sct_own; /* owner's country num */
coord sct_x; /* x coord of sector */
struct shpstr {
/* initial part must match struct empobj */
struct shpstr {
/* initial part must match struct empobj */
+ signed ef_type: 8;
+ unsigned shp_seqno: 12;
int shp_uid; /* unit it (ship #) */
int shp_uid; /* unit it (ship #) */
time_t shp_timestamp; /* Last time this ship was touched. */
natid shp_own; /* owner's country num */
coord shp_x; /* x location in abs coords */
time_t shp_timestamp; /* Last time this ship was touched. */
natid shp_own; /* owner's country num */
coord shp_x; /* x location in abs coords */
struct trdstr {
/* initial part must match struct empobj */
struct trdstr {
/* initial part must match struct empobj */
+ signed ef_type: 8;
+ unsigned trd_seqno: 12;
time_t trd_timestamp;
natid trd_owner;
/* end of part matching struct empobj */
time_t trd_timestamp;
natid trd_owner;
/* end of part matching struct empobj */
struct trtstr {
/* initial part must match struct empobj */
struct trtstr {
/* initial part must match struct empobj */
+ signed ef_type: 8;
+ unsigned trt_seqno: 12;
time_t trt_timestamp;
/* end of part matching struct empobj */
natid trt_cna; /* proposer */
time_t trt_timestamp;
/* end of part matching struct empobj */
natid trt_cna; /* proposer */
return;
qp = unit_list->q_back;
ulp = (struct ulist *)qp;
return;
qp = unit_list->q_back;
ulp = (struct ulist *)qp;
- type = ulp->unit.ef_type;
+ type = ulp->unit.gen.ef_type;
if (CANT_HAPPEN(type != EF_LAND && type != EF_SHIP))
return;
if (CANT_HAPPEN(type != EF_LAND && type != EF_SHIP))
return;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
ulp = (struct ulist *)qp;
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
ulp = (struct ulist *)qp;
- if (CANT_HAPPEN(!(ef_flags(ulp->unit.ef_type) & EFF_XY)))
+ if (CANT_HAPPEN(!(ef_flags(ulp->unit.gen.ef_type) & EFF_XY)))
continue;
getsect(ulp->unit.gen.x, ulp->unit.gen.y, §);
continue;
getsect(ulp->unit.gen.x, ulp->unit.gen.y, §);
- if (ulp->unit.ef_type == EF_SHIP) {
+ if (ulp->unit.gen.ef_type == EF_SHIP) {
if (((struct mchrstr *)ulp->chrp)->m_flags & M_FOOD)
pr("[fert:%d] ", sect.sct_fertil);
if (((struct mchrstr *)ulp->chrp)->m_flags & M_OIL)
if (((struct mchrstr *)ulp->chrp)->m_flags & M_FOOD)
pr("[fert:%d] ", sect.sct_fertil);
if (((struct mchrstr *)ulp->chrp)->m_flags & M_OIL)