Compare commits
21 commits
master
...
hvy-plasti
Author | SHA1 | Date | |
---|---|---|---|
9731e6692a | |||
bdcd59155a | |||
f571a37cde | |||
957f774a90 | |||
56f2ca96f7 | |||
2900de1f63 | |||
56c28caf5b | |||
b8804d1cc0 | |||
551676d5f2 | |||
48ba06732c | |||
839c6001d3 | |||
ddbf8c482b | |||
8ebed5ba05 | |||
bba8db34d0 | |||
20b31defe7 | |||
f8be963202 | |||
1bf3f557e9 | |||
9a19dc973a | |||
87512fb644 | |||
c4687e15d5 | |||
1c1fa720d4 |
36 changed files with 225 additions and 12 deletions
|
@ -45,6 +45,7 @@ struct comstr {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
short com_uid;
|
short com_uid;
|
||||||
unsigned com_seqno;
|
unsigned com_seqno;
|
||||||
|
unsigned com_generation;
|
||||||
time_t com_timestamp;
|
time_t com_timestamp;
|
||||||
natid com_owner;
|
natid com_owner;
|
||||||
/* end of part matching struct empobj */
|
/* end of part matching struct empobj */
|
||||||
|
|
|
@ -58,6 +58,7 @@ struct empobj {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
short uid;
|
short uid;
|
||||||
unsigned seqno;
|
unsigned seqno;
|
||||||
|
unsigned generation;
|
||||||
time_t timestamp;
|
time_t timestamp;
|
||||||
/* end of part matching struct emptypedstr */
|
/* end of part matching struct emptypedstr */
|
||||||
natid own; /* valid if EFF_OWNER is in table's flags */
|
natid own; /* valid if EFF_OWNER is in table's flags */
|
||||||
|
|
|
@ -88,6 +88,7 @@ struct emptypedstr {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
short uid;
|
short uid;
|
||||||
unsigned seqno;
|
unsigned seqno;
|
||||||
|
unsigned generation;
|
||||||
time_t timestamp;
|
time_t timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -203,6 +204,8 @@ enum {
|
||||||
|
|
||||||
extern struct castr *ef_cadef(int);
|
extern struct castr *ef_cadef(int);
|
||||||
extern int ef_read(int, int, void *);
|
extern int ef_read(int, int, void *);
|
||||||
|
extern void ef_make_stale(void);
|
||||||
|
extern void ef_mark_fresh(int, void *);
|
||||||
extern void *ef_ptr(int, int);
|
extern void *ef_ptr(int, int);
|
||||||
extern char *ef_nameof(int);
|
extern char *ef_nameof(int);
|
||||||
extern time_t ef_mtime(int);
|
extern time_t ef_mtime(int);
|
||||||
|
|
|
@ -41,6 +41,7 @@ struct gamestr {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
short game_uid;
|
short game_uid;
|
||||||
unsigned game_seqno;
|
unsigned game_seqno;
|
||||||
|
unsigned game_generation;
|
||||||
time_t game_timestamp;
|
time_t game_timestamp;
|
||||||
/* end of part matching struct empobj */
|
/* end of part matching struct empobj */
|
||||||
char game_upd_disable; /* updates disabled? */
|
char game_upd_disable; /* updates disabled? */
|
||||||
|
|
|
@ -34,13 +34,17 @@
|
||||||
#ifndef JOURNAL_H
|
#ifndef JOURNAL_H
|
||||||
#define JOURNAL_H
|
#define JOURNAL_H
|
||||||
|
|
||||||
|
struct player; /* FIXME temporary hack */
|
||||||
|
|
||||||
int journal_startup(void);
|
int journal_startup(void);
|
||||||
void journal_shutdown(void);
|
void journal_shutdown(void);
|
||||||
int journal_reopen(void);
|
int journal_reopen(void);
|
||||||
void journal_login(void);
|
void journal_login(void);
|
||||||
void journal_logout(void);
|
void journal_logout(void);
|
||||||
void journal_prng(unsigned);
|
void journal_prng(unsigned);
|
||||||
|
void journal_output(struct player *, int, char *);
|
||||||
void journal_input(char *);
|
void journal_input(char *);
|
||||||
|
void journal_command(char *);
|
||||||
void journal_update(int);
|
void journal_update(int);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -52,6 +52,7 @@ struct lndstr {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
short lnd_uid; /* unit id (land unit) */
|
short lnd_uid; /* unit id (land unit) */
|
||||||
unsigned lnd_seqno;
|
unsigned lnd_seqno;
|
||||||
|
unsigned lnd_generation;
|
||||||
time_t lnd_timestamp; /* Last time this unit was touched */
|
time_t lnd_timestamp; /* Last time this unit was touched */
|
||||||
natid lnd_own; /* owner's country num */
|
natid lnd_own; /* owner's country num */
|
||||||
coord lnd_x; /* x location in abs coords */
|
coord lnd_x; /* x location in abs coords */
|
||||||
|
|
|
@ -45,6 +45,7 @@ struct lonstr {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
short l_uid;
|
short l_uid;
|
||||||
unsigned l_seqno;
|
unsigned l_seqno;
|
||||||
|
unsigned l_generation;
|
||||||
time_t l_timestamp;
|
time_t l_timestamp;
|
||||||
/* end of part matching struct empobj */
|
/* end of part matching struct empobj */
|
||||||
natid l_loner; /* loan shark */
|
natid l_loner; /* loan shark */
|
||||||
|
|
|
@ -42,6 +42,7 @@ struct loststr {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
short lost_uid;
|
short lost_uid;
|
||||||
unsigned lost_seqno;
|
unsigned lost_seqno;
|
||||||
|
unsigned lost_generation;
|
||||||
time_t lost_timestamp; /* When it was lost */
|
time_t lost_timestamp; /* When it was lost */
|
||||||
natid lost_owner; /* Who lost it */
|
natid lost_owner; /* Who lost it */
|
||||||
/* end of part matching struct empobj */
|
/* end of part matching struct empobj */
|
||||||
|
|
|
@ -73,6 +73,7 @@ struct realmstr {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
short r_uid; /* realm table index */
|
short r_uid; /* realm table index */
|
||||||
unsigned r_seqno;
|
unsigned r_seqno;
|
||||||
|
unsigned r_generation;
|
||||||
time_t r_timestamp; /* Last time this realm was touched */
|
time_t r_timestamp; /* Last time this realm was touched */
|
||||||
natid r_cnum; /* country number */
|
natid r_cnum; /* country number */
|
||||||
/* end of part matching struct empobj */
|
/* end of part matching struct empobj */
|
||||||
|
@ -86,6 +87,7 @@ struct natstr {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
short nat_uid; /* equals nat_cnum */
|
short nat_uid; /* equals nat_cnum */
|
||||||
unsigned nat_seqno;
|
unsigned nat_seqno;
|
||||||
|
unsigned nat_generation;
|
||||||
time_t nat_timestamp;
|
time_t nat_timestamp;
|
||||||
natid nat_cnum; /* our country number */
|
natid nat_cnum; /* our country number */
|
||||||
/* end of part matching struct empobj */
|
/* end of part matching struct empobj */
|
||||||
|
|
|
@ -49,6 +49,7 @@ struct nwsstr {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
short nws_uid;
|
short nws_uid;
|
||||||
unsigned nws_seqno;
|
unsigned nws_seqno;
|
||||||
|
unsigned nws_generation;
|
||||||
time_t nws_timestamp;
|
time_t nws_timestamp;
|
||||||
/* end of part matching struct empobj */
|
/* end of part matching struct empobj */
|
||||||
natid nws_ano; /* "actor" country # */
|
natid nws_ano; /* "actor" country # */
|
||||||
|
|
|
@ -45,6 +45,7 @@ struct nukstr {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
short nuk_uid;
|
short nuk_uid;
|
||||||
unsigned nuk_seqno;
|
unsigned nuk_seqno;
|
||||||
|
unsigned nuk_generation;
|
||||||
time_t nuk_timestamp; /* Last time this nuke was touched */
|
time_t nuk_timestamp; /* Last time this nuke was touched */
|
||||||
natid nuk_own;
|
natid nuk_own;
|
||||||
coord nuk_x, nuk_y; /* current loc of device */
|
coord nuk_x, nuk_y; /* current loc of device */
|
||||||
|
|
|
@ -49,6 +49,7 @@ struct plnstr {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
short pln_uid; /* plane unit id */
|
short pln_uid; /* plane unit id */
|
||||||
unsigned pln_seqno;
|
unsigned pln_seqno;
|
||||||
|
unsigned pln_generation;
|
||||||
time_t pln_timestamp; /* Last time this plane was touched */
|
time_t pln_timestamp; /* Last time this plane was touched */
|
||||||
natid pln_own; /* owning country */
|
natid pln_own; /* owning country */
|
||||||
coord pln_x; /* plane x-y */
|
coord pln_x; /* plane x-y */
|
||||||
|
|
|
@ -47,6 +47,7 @@ struct sctstr {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
short sct_uid; /* equals XYOFFSET(sct_x, sct_y) */
|
short sct_uid; /* equals XYOFFSET(sct_x, sct_y) */
|
||||||
unsigned sct_seqno;
|
unsigned sct_seqno;
|
||||||
|
unsigned sct_generation;
|
||||||
time_t sct_timestamp; /* Last time this sector was written to */
|
time_t sct_timestamp; /* Last time this sector was written to */
|
||||||
natid sct_own; /* owner's country num */
|
natid sct_own; /* owner's country num */
|
||||||
coord sct_x; /* x coord of sector */
|
coord sct_x; /* x coord of sector */
|
||||||
|
|
|
@ -66,6 +66,7 @@ struct shpstr {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
short shp_uid; /* unit id (ship #) */
|
short shp_uid; /* unit id (ship #) */
|
||||||
unsigned shp_seqno;
|
unsigned shp_seqno;
|
||||||
|
unsigned shp_generation;
|
||||||
time_t shp_timestamp; /* Last time this ship was touched. */
|
time_t shp_timestamp; /* Last time this ship was touched. */
|
||||||
natid shp_own; /* owner's country num */
|
natid shp_own; /* owner's country num */
|
||||||
coord shp_x; /* x location in abs coords */
|
coord shp_x; /* x location in abs coords */
|
||||||
|
|
|
@ -45,6 +45,7 @@ struct trdstr {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
short trd_uid;
|
short trd_uid;
|
||||||
unsigned trd_seqno;
|
unsigned trd_seqno;
|
||||||
|
unsigned trd_generation;
|
||||||
time_t trd_timestamp;
|
time_t trd_timestamp;
|
||||||
natid trd_owner;
|
natid trd_owner;
|
||||||
/* end of part matching struct empobj */
|
/* end of part matching struct empobj */
|
||||||
|
|
|
@ -42,6 +42,7 @@ struct trtstr {
|
||||||
short ef_type;
|
short ef_type;
|
||||||
short trt_uid;
|
short trt_uid;
|
||||||
unsigned trt_seqno;
|
unsigned trt_seqno;
|
||||||
|
unsigned trt_generation;
|
||||||
time_t trt_timestamp;
|
time_t trt_timestamp;
|
||||||
/* end of part matching struct empobj */
|
/* end of part matching struct empobj */
|
||||||
natid trt_cna; /* proposer */
|
natid trt_cna; /* proposer */
|
||||||
|
|
54
info/Hvy-Plastic.t
Normal file
54
info/Hvy-Plastic.t
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
.TH Concept "Hvy-Plastic"
|
||||||
|
.NA Hvy-Plastic "Special rules for Hvy Plastic"
|
||||||
|
.LV Basic
|
||||||
|
.s1
|
||||||
|
Ship types are customized. Better check show for the details.
|
||||||
|
.s1
|
||||||
|
Dreadnoughts are more heavily armored. Frigates are more fragile.
|
||||||
|
.s1
|
||||||
|
More ships can carry choppers. Some ships are not ideal for this, and
|
||||||
|
this is reflected by the lack of large petrol and shell storage.
|
||||||
|
.s1
|
||||||
|
Land unit types are heavily customized. Better check show for the
|
||||||
|
details. Non-mechanized units are slower and more vulnerable,
|
||||||
|
artillery firing ranges differ, few units are light (but troop
|
||||||
|
transports and landing ships can carry non-light units).
|
||||||
|
.s1
|
||||||
|
Planes are tweaked somewhat. show is your friend.
|
||||||
|
.s1
|
||||||
|
Nukes are on sale, but nuclear plants are not. Did I mention the show
|
||||||
|
command?
|
||||||
|
.s1
|
||||||
|
Infrastructure is disabled.
|
||||||
|
.s1
|
||||||
|
Your refineries make less petrol from each barrel of oil than usual.
|
||||||
|
.s1
|
||||||
|
Natural resources gold, oil and uran deplete much slower than usual.
|
||||||
|
A 100% gold resource contains 2500d, a 100% oil resource contains
|
||||||
|
2500o, and a 100% uranium resource contains 500u. Fully depleting a
|
||||||
|
sector will take you several updates, and a small fraction of the
|
||||||
|
resource contents will be lost.
|
||||||
|
.s1
|
||||||
|
Gold in mountains does not deplete at all.
|
||||||
|
.s1
|
||||||
|
Oil production does not depend on tech; you don't have to micro-manage
|
||||||
|
to conserve oil.
|
||||||
|
.s1
|
||||||
|
Ship capability anti-missile is disabled because of bugs.
|
||||||
|
.s1
|
||||||
|
Server time is in UTC, which means there will be no daylight savings
|
||||||
|
time.
|
||||||
|
.s1
|
||||||
|
Missed updates due to server problems will be forced if caught within
|
||||||
|
15 minutes of planned update time or skipped otherwise.
|
||||||
|
.s1
|
||||||
|
Everything you do in this game is logged by the deities for their own
|
||||||
|
nefarious purposes. However, the logs are treated confidentially.
|
||||||
|
.s1
|
||||||
|
Make the deity laugh and get up to 5 gold bars.
|
||||||
|
.s1
|
||||||
|
Source code and configuration is available from
|
||||||
|
.br
|
||||||
|
http://www.pond.sub.org/~armbru/empire/hvy-plastic.html
|
||||||
|
.s1
|
||||||
|
.SA "Introduction, Server, show"
|
|
@ -181,7 +181,7 @@ assa(void)
|
||||||
pr(" and was killed in the attempt.\n");
|
pr(" and was killed in the attempt.\n");
|
||||||
llp->unit.land.lnd_effic = 0;
|
llp->unit.land.lnd_effic = 0;
|
||||||
putland(llp->unit.land.lnd_uid, &llp->unit.land);
|
putland(llp->unit.land.lnd_uid, &llp->unit.land);
|
||||||
lnd_delete(llp, "");
|
lnd_delete(llp, NULL);
|
||||||
} else {
|
} else {
|
||||||
wu(0, def->own, "%s spy spotted in %s.\n",
|
wu(0, def->own, "%s spy spotted in %s.\n",
|
||||||
cname(player->cnum), xyas(def->x, def->y,
|
cname(player->cnum), xyas(def->x, def->y,
|
||||||
|
|
|
@ -157,6 +157,11 @@ bomb(void)
|
||||||
plp = (struct plist *)qp;
|
plp = (struct plist *)qp;
|
||||||
changed_plane_aborts(plp);
|
changed_plane_aborts(plp);
|
||||||
}
|
}
|
||||||
|
for (qp = esc_list.q_forw; qp != &esc_list; qp = next) {
|
||||||
|
next = qp->q_forw;
|
||||||
|
plp = (struct plist *)qp;
|
||||||
|
changed_plane_aborts(plp);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
if (opt_SLOW_WAR) {
|
if (opt_SLOW_WAR) {
|
||||||
|
|
|
@ -227,7 +227,7 @@ tend_land(struct shpstr *tenderp, char *units)
|
||||||
if (!snxtitem(&targets, EF_SHIP,
|
if (!snxtitem(&targets, EF_SHIP,
|
||||||
player->argp[4], "Ship to be tended? "))
|
player->argp[4], "Ship to be tended? "))
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
if (!check_land_ok(&land))
|
if (!check_ship_ok(tenderp) || !check_land_ok(&land))
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
while (nxtitem(&targets, &target)) {
|
while (nxtitem(&targets, &target)) {
|
||||||
if (!player->owner &&
|
if (!player->owner &&
|
||||||
|
|
|
@ -241,24 +241,33 @@ unit_cargo_init(void)
|
||||||
unit_onresize(i);
|
unit_onresize(i);
|
||||||
|
|
||||||
for (i = 0; (pp = getplanep(i)); i++) {
|
for (i = 0; (pp = getplanep(i)); i++) {
|
||||||
if (!pp->pln_own)
|
if (!pp->pln_own) {
|
||||||
|
if (CANT_HAPPEN(pp->pln_ship >= 0 || pp->pln_land >= 0))
|
||||||
|
pp->pln_ship = pp->pln_land = -1;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (CANT_HAPPEN(pp->pln_ship >= 0 && pp->pln_land >= 0))
|
if (CANT_HAPPEN(pp->pln_ship >= 0 && pp->pln_land >= 0))
|
||||||
pp->pln_land = -1;
|
pp->pln_land = -1;
|
||||||
pln_carrier_change(pp, EF_SHIP, -1, pp->pln_ship);
|
pln_carrier_change(pp, EF_SHIP, -1, pp->pln_ship);
|
||||||
pln_carrier_change(pp, EF_LAND, -1, pp->pln_land);
|
pln_carrier_change(pp, EF_LAND, -1, pp->pln_land);
|
||||||
}
|
}
|
||||||
for (i = 0; (lp = getlandp(i)); i++) {
|
for (i = 0; (lp = getlandp(i)); i++) {
|
||||||
if (!lp->lnd_own)
|
if (!lp->lnd_own) {
|
||||||
|
if (CANT_HAPPEN(lp->lnd_ship >= 0 || lp->lnd_land >= 0))
|
||||||
|
lp->lnd_ship = lp->lnd_land = -1;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (CANT_HAPPEN(lp->lnd_ship >= 0 && lp->lnd_land >= 0))
|
if (CANT_HAPPEN(lp->lnd_ship >= 0 && lp->lnd_land >= 0))
|
||||||
lp->lnd_land = -1;
|
lp->lnd_land = -1;
|
||||||
lnd_carrier_change(lp, EF_SHIP, -1, lp->lnd_ship);
|
lnd_carrier_change(lp, EF_SHIP, -1, lp->lnd_ship);
|
||||||
lnd_carrier_change(lp, EF_LAND, -1, lp->lnd_land);
|
lnd_carrier_change(lp, EF_LAND, -1, lp->lnd_land);
|
||||||
}
|
}
|
||||||
for (i = 0; (np = getnukep(i)); i++) {
|
for (i = 0; (np = getnukep(i)); i++) {
|
||||||
if (!np->nuk_own)
|
if (!np->nuk_own) {
|
||||||
|
if (CANT_HAPPEN(np->nuk_plane >= 0))
|
||||||
|
np->nuk_plane = -1;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
nuk_carrier_change(np, EF_PLANE, -1, np->nuk_plane);
|
nuk_carrier_change(np, EF_PLANE, -1, np->nuk_plane);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,9 +52,12 @@ static int do_read(struct empfile *, void *, int, int);
|
||||||
static int do_write(struct empfile *, void *, int, int);
|
static int do_write(struct empfile *, void *, int, int);
|
||||||
static unsigned get_seqno(struct empfile *, int);
|
static unsigned get_seqno(struct empfile *, int);
|
||||||
static void new_seqno(struct empfile *, void *);
|
static void new_seqno(struct empfile *, void *);
|
||||||
|
static void must_be_fresh(struct empfile *, void *);
|
||||||
static void do_blank(struct empfile *, void *, int, int);
|
static void do_blank(struct empfile *, void *, int, int);
|
||||||
static int ef_check(int);
|
static int ef_check(int);
|
||||||
|
|
||||||
|
static unsigned ef_generation;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open the file-backed table TYPE (EF_SECTOR, ...).
|
* Open the file-backed table TYPE (EF_SECTOR, ...).
|
||||||
* HOW are flags to control operation. Naturally, immutable flags are
|
* HOW are flags to control operation. Naturally, immutable flags are
|
||||||
|
@ -338,6 +341,7 @@ ef_read(int type, int id, void *into)
|
||||||
cachep = ep->cache + (id - ep->baseid) * ep->size;
|
cachep = ep->cache + (id - ep->baseid) * ep->size;
|
||||||
}
|
}
|
||||||
memcpy(into, cachep, ep->size);
|
memcpy(into, cachep, ep->size);
|
||||||
|
ef_mark_fresh(type, into);
|
||||||
|
|
||||||
if (ep->postread)
|
if (ep->postread)
|
||||||
ep->postread(id, into);
|
ep->postread(id, into);
|
||||||
|
@ -500,9 +504,11 @@ ef_write(int type, int id, void *from)
|
||||||
if (ep->onresize && ep->onresize(type) < 0)
|
if (ep->onresize && ep->onresize(type) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (id >= ep->baseid && id < ep->baseid + ep->cids)
|
if (id >= ep->baseid && id < ep->baseid + ep->cids) {
|
||||||
cachep = ep->cache + (id - ep->baseid) * ep->size;
|
cachep = ep->cache + (id - ep->baseid) * ep->size;
|
||||||
else
|
if (cachep != from)
|
||||||
|
must_be_fresh(ep, from);
|
||||||
|
} else
|
||||||
cachep = NULL;
|
cachep = NULL;
|
||||||
if (ep->prewrite)
|
if (ep->prewrite)
|
||||||
ep->prewrite(id, cachep, from);
|
ep->prewrite(id, cachep, from);
|
||||||
|
@ -586,6 +592,35 @@ new_seqno(struct empfile *ep, void *buf)
|
||||||
elt->seqno = old_seqno + 1;
|
elt->seqno = old_seqno + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ef_make_stale(void)
|
||||||
|
{
|
||||||
|
ef_generation++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ef_mark_fresh(int type, void *buf)
|
||||||
|
{
|
||||||
|
struct empfile *ep;
|
||||||
|
|
||||||
|
if (ef_check(type) < 0)
|
||||||
|
return;
|
||||||
|
ep = &empfile[type];
|
||||||
|
if (!(ep->flags & EFF_TYPED))
|
||||||
|
return;
|
||||||
|
((struct emptypedstr *)buf)->generation = ef_generation;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
must_be_fresh(struct empfile *ep, void *buf)
|
||||||
|
{
|
||||||
|
struct emptypedstr *elt = buf;
|
||||||
|
|
||||||
|
if (!(ep->flags & EFF_TYPED))
|
||||||
|
return;
|
||||||
|
CANT_HAPPEN(elt->generation != ef_generation);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Extend table TYPE by COUNT elements.
|
* Extend table TYPE by COUNT elements.
|
||||||
* Any pointers obtained from ef_ptr() become invalid.
|
* Any pointers obtained from ef_ptr() become invalid.
|
||||||
|
@ -663,6 +698,7 @@ ef_blank(int type, int id, void *buf)
|
||||||
elt = buf;
|
elt = buf;
|
||||||
elt->seqno = get_seqno(ep, elt->uid);
|
elt->seqno = get_seqno(ep, elt->uid);
|
||||||
}
|
}
|
||||||
|
ef_mark_fresh(type, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "empio.h"
|
#include "empio.h"
|
||||||
#include "empthread.h"
|
#include "empthread.h"
|
||||||
|
#include "file.h"
|
||||||
#include "ioqueue.h"
|
#include "ioqueue.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
|
@ -123,6 +124,9 @@ io_input(struct iop *iop, int waitforinput)
|
||||||
int cc;
|
int cc;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
if (waitforinput)
|
||||||
|
ef_make_stale();
|
||||||
|
|
||||||
/* Not a read IOP */
|
/* Not a read IOP */
|
||||||
if ((iop->flags & IO_READ) == 0) {
|
if ((iop->flags & IO_READ) == 0) {
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
|
@ -183,6 +187,9 @@ io_output(struct iop *iop, int waitforoutput)
|
||||||
int n;
|
int n;
|
||||||
int remain;
|
int remain;
|
||||||
|
|
||||||
|
if (waitforoutput)
|
||||||
|
ef_make_stale();
|
||||||
|
|
||||||
/* If there is no output waiting. */
|
/* If there is no output waiting. */
|
||||||
if (!io_outputwaiting(iop))
|
if (!io_outputwaiting(iop))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -264,6 +271,9 @@ io_write(struct iop *iop, char *buf, int nbytes, int doWait)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
if (doWait)
|
||||||
|
ef_make_stale();
|
||||||
|
|
||||||
if ((iop->flags & IO_WRITE) == 0)
|
if ((iop->flags & IO_WRITE) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
ioq_append(iop->output, buf, nbytes);
|
ioq_append(iop->output, buf, nbytes);
|
||||||
|
@ -285,6 +295,8 @@ io_output_all(struct iop *iop)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
|
ef_make_stale();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mustn't block a player thread while update is pending, or else
|
* Mustn't block a player thread while update is pending, or else
|
||||||
* a malicous player could delay the update indefinitely
|
* a malicous player could delay the update indefinitely
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "empthread.h"
|
#include "empthread.h"
|
||||||
|
#include "file.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
/* Flags that were passed to empth_init() */
|
/* Flags that were passed to empth_init() */
|
||||||
|
@ -65,6 +66,7 @@ empth_create(void (*entry)(void *), int size, int flags,
|
||||||
{
|
{
|
||||||
if (!flags)
|
if (!flags)
|
||||||
flags = empth_flags;
|
flags = empth_flags;
|
||||||
|
ef_make_stale();
|
||||||
return lwpCreate(1, entry, size, flags, name, 0, 0, ud);
|
return lwpCreate(1, entry, size, flags, name, 0, 0, ud);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,18 +91,21 @@ empth_set_name(empth_t *thread, char *name)
|
||||||
void
|
void
|
||||||
empth_exit(void)
|
empth_exit(void)
|
||||||
{
|
{
|
||||||
|
ef_make_stale();
|
||||||
lwpExit();
|
lwpExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
empth_yield(void)
|
empth_yield(void)
|
||||||
{
|
{
|
||||||
|
ef_make_stale();
|
||||||
lwpYield();
|
lwpYield();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
empth_select(int fd, int flags, struct timeval *timeout)
|
empth_select(int fd, int flags, struct timeval *timeout)
|
||||||
{
|
{
|
||||||
|
ef_make_stale();
|
||||||
return lwpSleepFd(fd, flags, timeout);
|
return lwpSleepFd(fd, flags, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +118,7 @@ empth_wakeup(empth_t *a)
|
||||||
int
|
int
|
||||||
empth_sleep(time_t until)
|
empth_sleep(time_t until)
|
||||||
{
|
{
|
||||||
|
ef_make_stale();
|
||||||
return lwpSleepUntil(until);
|
return lwpSleepUntil(until);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +129,7 @@ empth_wait_for_signal(void)
|
||||||
int sig, err;
|
int sig, err;
|
||||||
time_t now;
|
time_t now;
|
||||||
|
|
||||||
|
ef_make_stale();
|
||||||
sigemptyset(&set);
|
sigemptyset(&set);
|
||||||
sigaddset(&set, SIGHUP);
|
sigaddset(&set, SIGHUP);
|
||||||
sigaddset(&set, SIGINT);
|
sigaddset(&set, SIGINT);
|
||||||
|
@ -153,12 +160,14 @@ empth_rwlock_destroy(empth_rwlock_t *rwlock)
|
||||||
void
|
void
|
||||||
empth_rwlock_wrlock(empth_rwlock_t *rwlock)
|
empth_rwlock_wrlock(empth_rwlock_t *rwlock)
|
||||||
{
|
{
|
||||||
|
ef_make_stale();
|
||||||
lwp_rwlock_wrlock(rwlock);
|
lwp_rwlock_wrlock(rwlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
empth_rwlock_rdlock(empth_rwlock_t *rwlock)
|
empth_rwlock_rdlock(empth_rwlock_t *rwlock)
|
||||||
{
|
{
|
||||||
|
ef_make_stale();
|
||||||
lwp_rwlock_rdlock(rwlock);
|
lwp_rwlock_rdlock(rwlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "com.h"
|
#include "com.h"
|
||||||
#include "empio.h"
|
#include "empio.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
#include "journal.h"
|
||||||
#include "match.h"
|
#include "match.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "nat.h"
|
#include "nat.h"
|
||||||
|
@ -102,6 +103,7 @@ dispatch(char *buf, char *redir)
|
||||||
uprnf(buf);
|
uprnf(buf);
|
||||||
pr("\n");
|
pr("\n");
|
||||||
}
|
}
|
||||||
|
journal_command(command->c_form);
|
||||||
switch (command->c_addr()) {
|
switch (command->c_addr()) {
|
||||||
case RET_OK:
|
case RET_OK:
|
||||||
player->btused += command->c_cost;
|
player->btused += command->c_cost;
|
||||||
|
|
|
@ -121,7 +121,7 @@ command(void)
|
||||||
time_t now;
|
time_t now;
|
||||||
|
|
||||||
if (getcommand(player->combuf) < 0)
|
if (getcommand(player->combuf) < 0)
|
||||||
return 0;
|
return player->aborted;
|
||||||
|
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
update_timeused(now);
|
update_timeused(now);
|
||||||
|
|
|
@ -52,7 +52,11 @@ obj_changed(struct empobj *obj, size_t sz)
|
||||||
get_empobj(obj->ef_type, obj->uid, &old);
|
get_empobj(obj->ef_type, obj->uid, &old);
|
||||||
memcpy(&tobj, obj, sz);
|
memcpy(&tobj, obj, sz);
|
||||||
old.gen.timestamp = tobj.gen.timestamp = 0;
|
old.gen.timestamp = tobj.gen.timestamp = 0;
|
||||||
return memcmp(&tobj, &old, sz);
|
old.gen.generation = tobj.gen.generation = 0;
|
||||||
|
if (memcmp(&tobj, &old, sz))
|
||||||
|
return 1;
|
||||||
|
ef_mark_fresh(obj->ef_type, obj);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -44,7 +44,9 @@
|
||||||
* prng NAME SEED
|
* prng NAME SEED
|
||||||
* login CNUM HOSTADDR USER
|
* login CNUM HOSTADDR USER
|
||||||
* logout CNUM
|
* logout CNUM
|
||||||
|
* command NAME
|
||||||
* input INPUT
|
* input INPUT
|
||||||
|
* output THREAD ID OUTPUT
|
||||||
* update ETU
|
* update ETU
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -67,6 +69,7 @@ static FILE *journal;
|
||||||
|
|
||||||
static void journal_entry(char *fmt, ...)
|
static void journal_entry(char *fmt, ...)
|
||||||
ATTRIBUTE((format (printf, 1, 2)));
|
ATTRIBUTE((format (printf, 1, 2)));
|
||||||
|
static void journal_output_1(struct player *, int, char *, char *, int);
|
||||||
|
|
||||||
static FILE *
|
static FILE *
|
||||||
journal_open(void)
|
journal_open(void)
|
||||||
|
@ -98,6 +101,7 @@ journal_entry(char *fmt, ...)
|
||||||
fprintf(journal, "\\%03o", *p);
|
fprintf(journal, "\\%03o", *p);
|
||||||
}
|
}
|
||||||
fputs("\n", journal);
|
fputs("\n", journal);
|
||||||
|
if (fmt[0] != 'o') /* FIXME disgusting hack */
|
||||||
fflush(journal);
|
fflush(journal);
|
||||||
if (ferror(journal)) {
|
if (ferror(journal)) {
|
||||||
logerror("Error writing journal (%s)", strerror(errno));
|
logerror("Error writing journal (%s)", strerror(errno));
|
||||||
|
@ -167,12 +171,57 @@ journal_logout(void)
|
||||||
journal_entry("logout %d", player->cnum);
|
journal_entry("logout %d", player->cnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
journal_output(struct player *pl, int id, char *output)
|
||||||
|
{
|
||||||
|
static char buf[1024];
|
||||||
|
static struct player *bpl;
|
||||||
|
static int bid;
|
||||||
|
char *s, *e;
|
||||||
|
|
||||||
|
if (keep_journal < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (buf[0] && (pl != bpl && id != bid)) {
|
||||||
|
journal_output_1(bpl, bid, buf, "", -1);
|
||||||
|
buf[0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (s = output; (e = strchr(s, '\n')); s = e + 1) {
|
||||||
|
journal_output_1(pl, id, buf, s, (int)(e + 1 - s));
|
||||||
|
buf[0] = 0;
|
||||||
|
}
|
||||||
|
if (strlen(buf) + strlen(s) < 1024) {
|
||||||
|
strcpy(buf + strlen(buf), s);
|
||||||
|
bpl = pl;
|
||||||
|
bid = id;
|
||||||
|
} else {
|
||||||
|
journal_output_1(pl, id, buf, s, -1);
|
||||||
|
buf[0] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
journal_output_1(struct player *pl, int id,
|
||||||
|
char *buf1, char *buf2, int buf2prec)
|
||||||
|
{
|
||||||
|
journal_entry("output %s %d %s%.*s",
|
||||||
|
empth_name(empth_self()), id, buf1, buf2prec, buf2);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
journal_input(char *input)
|
journal_input(char *input)
|
||||||
{
|
{
|
||||||
journal_entry("input %s", input);
|
journal_entry("input %s", input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
journal_command(char *cmd)
|
||||||
|
{
|
||||||
|
char *eptr = strchr(cmd, ' ');
|
||||||
|
journal_entry("command %.*s", eptr ? (int)(eptr - cmd) : -1, cmd);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
journal_update(int etu)
|
journal_update(int etu)
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,6 +61,8 @@ nreport(natid actor, int event, natid victim, int times)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
np = ncache(actor, event, victim, times);
|
np = ncache(actor, event, victim, times);
|
||||||
|
/* TODO get rid of nws_generation? */
|
||||||
|
ef_mark_fresh(EF_NEWS, np);
|
||||||
putnews(np->nws_uid, np);
|
putnews(np->nws_uid, np);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
#include "com.h"
|
#include "com.h"
|
||||||
#include "empio.h"
|
#include "empio.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
#include "journal.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "nat.h"
|
#include "nat.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
@ -124,6 +125,7 @@ pr_id(struct player *p, int id, char *format, ...)
|
||||||
|
|
||||||
if (p->curid >= 0) {
|
if (p->curid >= 0) {
|
||||||
io_puts(p->iop, "\n");
|
io_puts(p->iop, "\n");
|
||||||
|
journal_output(p, p->curid, "\n");
|
||||||
p->curid = -1;
|
p->curid = -1;
|
||||||
}
|
}
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
|
@ -245,6 +247,7 @@ pr_player(struct player *pl, int id, char *buf)
|
||||||
bp += len;
|
bp += len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
journal_output(pl, id, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -299,6 +302,7 @@ upr_player(struct player *pl, int id, char *buf)
|
||||||
io_puts(pl->iop, printbuf);
|
io_puts(pl->iop, printbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
journal_output(pl, id, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -402,7 +402,7 @@ s_commod(struct empobj *sink, short *vec,
|
||||||
|
|
||||||
if (actually_doit)
|
if (actually_doit)
|
||||||
put_empobj(sink->ef_type, sink->uid, sink);
|
put_empobj(sink->ef_type, sink->uid, sink);
|
||||||
return wanted <= vec[type];
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -125,6 +125,7 @@ upd_land(struct lndstr *lp, int etus,
|
||||||
makelost(EF_LAND, lp->lnd_own, lp->lnd_uid,
|
makelost(EF_LAND, lp->lnd_own, lp->lnd_uid,
|
||||||
lp->lnd_x, lp->lnd_y);
|
lp->lnd_x, lp->lnd_y);
|
||||||
lp->lnd_own = 0;
|
lp->lnd_own = 0;
|
||||||
|
lp->lnd_ship = lp->lnd_land = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wu(0, lp->lnd_own,
|
wu(0, lp->lnd_own,
|
||||||
|
|
|
@ -268,6 +268,7 @@ nav_ship(struct shpstr *sp)
|
||||||
mlp = malloc(sizeof(struct ulist));
|
mlp = malloc(sizeof(struct ulist));
|
||||||
mlp->chrp = (struct empobj_chr *)(mchr + sp->shp_type);
|
mlp->chrp = (struct empobj_chr *)(mchr + sp->shp_type);
|
||||||
mlp->unit.ship = *sp;
|
mlp->unit.ship = *sp;
|
||||||
|
ef_mark_fresh(EF_SHIP, &mlp->unit.ship);
|
||||||
mlp->mobil = sp->shp_mobil;
|
mlp->mobil = sp->shp_mobil;
|
||||||
emp_insque(&mlp->queue, &ship_list);
|
emp_insque(&mlp->queue, &ship_list);
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,7 @@ upd_plane(struct plnstr *pp, int etus,
|
||||||
makelost(EF_PLANE, pp->pln_own, pp->pln_uid,
|
makelost(EF_PLANE, pp->pln_own, pp->pln_uid,
|
||||||
pp->pln_x, pp->pln_y);
|
pp->pln_x, pp->pln_y);
|
||||||
pp->pln_own = 0;
|
pp->pln_own = 0;
|
||||||
|
pp->pln_ship = pp->pln_land = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wu(0, pp->pln_own,
|
wu(0, pp->pln_own,
|
||||||
|
|
|
@ -347,6 +347,7 @@ fltp_to_list(struct fltheadstr *fltp, struct emp_qelem *list)
|
||||||
sp = getshipp(fe->num);
|
sp = getshipp(fe->num);
|
||||||
mlp->chrp = (struct empobj_chr *)(mchr + sp->shp_type);
|
mlp->chrp = (struct empobj_chr *)(mchr + sp->shp_type);
|
||||||
mlp->unit.ship = *sp;
|
mlp->unit.ship = *sp;
|
||||||
|
ef_mark_fresh(EF_SHIP, &mlp->unit.ship);
|
||||||
mlp->mobil = fe->mobil;
|
mlp->mobil = fe->mobil;
|
||||||
emp_insque(&mlp->queue, list);
|
emp_insque(&mlp->queue, list);
|
||||||
}
|
}
|
||||||
|
|
|
@ -821,7 +821,7 @@ grow_islands(void)
|
||||||
secs = 0;
|
secs = 0;
|
||||||
if (!place_island(c, &x, &y))
|
if (!place_island(c, &x, &y))
|
||||||
return;
|
return;
|
||||||
isiz = 1 + rnd(2 * is - 1);
|
isiz = 1 + rnd(is) + rnd(is);
|
||||||
do {
|
do {
|
||||||
++secs;
|
++secs;
|
||||||
find_coast(c);
|
find_coast(c);
|
||||||
|
@ -1092,6 +1092,7 @@ write_sects(void)
|
||||||
sct->sct_type = SCT_MOUNT;
|
sct->sct_type = SCT_MOUNT;
|
||||||
sct->sct_elev = total;
|
sct->sct_elev = total;
|
||||||
sct->sct_newtype = sct->sct_type;
|
sct->sct_newtype = sct->sct_type;
|
||||||
|
sct->sct_dterr = own[sct->sct_x][y] + 1;
|
||||||
if (ORE)
|
if (ORE)
|
||||||
add_resources(sct);
|
add_resources(sct);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue