(sct_pstage, sct_ptime, shp_pstage, shp_ptime, lnd_pstage, lnd_ptime):

Use `short' instead of `unsigned short'.  With variables, plague stage
and time were stored unsigned and used signed, which worked.  Removal
of variables dropped the conversion to signed, which broke
plague_people() (plague.c rev. 1.6): stage didn't progress correctly
due to catastrophic underflow of time.
This commit is contained in:
Ron Koenderink 2004-12-12 19:39:35 +00:00
parent 03c96f90d8
commit 4a6346b0df
8 changed files with 17 additions and 17 deletions

View file

@ -71,8 +71,8 @@ struct lndstr {
u_char lnd_rad_max; /* max radius for this unit */ u_char lnd_rad_max; /* max radius for this unit */
u_char lnd_scar; /* how experienced the unit is (not used) */ u_char lnd_scar; /* how experienced the unit is (not used) */
short lnd_item[I_MAX+1]; /* amount of items on board */ short lnd_item[I_MAX+1]; /* amount of items on board */
u_short lnd_pstage; /* plague stage */ short lnd_pstage; /* plague stage */
u_short lnd_ptime; /* how many etus remain in this stage */ short lnd_ptime; /* how many etus remain in this stage */
short lnd_land; /* pointer to transporting unit */ short lnd_land; /* pointer to transporting unit */
u_char lnd_nland; u_char lnd_nland;
time_t lnd_access; /* Last time mob was updated (MOB_ACCESS) */ time_t lnd_access; /* Last time mob was updated (MOB_ACCESS) */

View file

@ -589,7 +589,7 @@ extern s_char *nxtitemp(struct nstr_item *, int);
extern struct sctstr *nxtsctp(register struct nstr_sect *); extern struct sctstr *nxtsctp(register struct nstr_sect *);
/* plague.c */ /* plague.c */
extern void do_plague(struct sctstr *, struct natstr *, int); extern void do_plague(struct sctstr *, struct natstr *, int);
extern int plague_people(struct natstr *, short *, u_short *, u_short *, int); extern int plague_people(struct natstr *, short *, int *, int *, int);
/* plane.c */ /* plane.c */
extern int prod_plane(int, int, int *, int); extern int prod_plane(int, int, int *, int);
/* populace.c */ /* populace.c */

View file

@ -75,8 +75,8 @@ struct sctstr {
short sct_del[I_MAX+1]; /* delivieries */ short sct_del[I_MAX+1]; /* delivieries */
short sct_dist[I_MAX+1]; /* distribution thresholds */ short sct_dist[I_MAX+1]; /* distribution thresholds */
short sct_mines; /* number of mines */ short sct_mines; /* number of mines */
u_short sct_pstage; /* plague stage */ short sct_pstage; /* plague stage */
u_short sct_ptime; /* how many etus remain in this stage */ short sct_ptime; /* how many etus remain in this stage */
u_char sct_che; /* number of guerrillas */ u_char sct_che; /* number of guerrillas */
natid sct_che_target; /* nation targeted by che */ natid sct_che_target; /* nation targeted by che */
u_short sct_fallout; u_short sct_fallout;

View file

@ -87,8 +87,8 @@ struct shpstr {
short shp_lend[TMAX]; /* How much do we pick up at the end */ short shp_lend[TMAX]; /* How much do we pick up at the end */
u_char shp_autonav; /* autonavigation flags */ u_char shp_autonav; /* autonavigation flags */
short shp_item[I_MAX+1]; /* amount of items on board */ short shp_item[I_MAX+1]; /* amount of items on board */
u_short shp_pstage; /* plague stage */ short shp_pstage; /* plague stage */
u_short shp_ptime; /* how many etus remain in this stage */ short shp_ptime; /* how many etus remain in this stage */
time_t shp_access; /* Last time mob was updated (MOB_ACCESS) */ time_t shp_access; /* Last time mob was updated (MOB_ACCESS) */
time_t shp_timestamp; /* Last time this ship was touched. */ time_t shp_timestamp; /* Last time this ship was touched. */
u_char shp_mobquota; /* mobility quota */ u_char shp_mobquota; /* mobility quota */

View file

@ -103,8 +103,8 @@ struct castr sect_ca[] = {
NSC_IVEC(fldoff(sctstr, sct_dist), "_dist"), NSC_IVEC(fldoff(sctstr, sct_dist), "_dist"),
NSC_IVEC(fldoff(sctstr, sct_del), "_del"), NSC_IVEC(fldoff(sctstr, sct_del), "_del"),
{NSC_SHORT, NSC_DEITY, 0, fldoff(sctstr, sct_mines), "mines"}, {NSC_SHORT, NSC_DEITY, 0, fldoff(sctstr, sct_mines), "mines"},
{NSC_USHORT, NSC_DEITY, 0, fldoff(sctstr, sct_pstage), "pstage"}, {NSC_SHORT, NSC_DEITY, 0, fldoff(sctstr, sct_pstage), "pstage"},
{NSC_USHORT, NSC_DEITY, 0, fldoff(sctstr, sct_ptime), "ptime"}, {NSC_SHORT, NSC_DEITY, 0, fldoff(sctstr, sct_ptime), "ptime"},
{NSC_UCHAR, NSC_DEITY, 0, fldoff(sctstr, sct_che), "che"}, {NSC_UCHAR, NSC_DEITY, 0, fldoff(sctstr, sct_che), "che"},
{NSC_NATID, NSC_DEITY, 0, fldoff(sctstr, sct_che_target), "che_target"}, {NSC_NATID, NSC_DEITY, 0, fldoff(sctstr, sct_che_target), "che_target"},
{NSC_USHORT, 0, 0, fldoff(sctstr, sct_fallout), "fallout"}, {NSC_USHORT, 0, 0, fldoff(sctstr, sct_fallout), "fallout"},
@ -146,8 +146,8 @@ struct castr ship_ca[] = {
{NSC_SHORT, 0, TMAX, fldoff(shpstr, shp_lend), "amtend"}, {NSC_SHORT, 0, TMAX, fldoff(shpstr, shp_lend), "amtend"},
{NSC_UCHAR, 0, 0, fldoff(shpstr, shp_autonav), "autonav"}, {NSC_UCHAR, 0, 0, fldoff(shpstr, shp_autonav), "autonav"},
NSC_IVEC(fldoff(shpstr, shp_item), ""), NSC_IVEC(fldoff(shpstr, shp_item), ""),
{NSC_USHORT, NSC_DEITY, 0, fldoff(shpstr, shp_pstage), "pstage"}, {NSC_SHORT, NSC_DEITY, 0, fldoff(shpstr, shp_pstage), "pstage"},
{NSC_USHORT, NSC_DEITY, 0, fldoff(shpstr, shp_ptime), "ptime"}, {NSC_SHORT, NSC_DEITY, 0, fldoff(shpstr, shp_ptime), "ptime"},
{NSC_TIME, 0, 0, fldoff(shpstr, shp_access), "access"}, {NSC_TIME, 0, 0, fldoff(shpstr, shp_access), "access"},
{NSC_TIME, NSC_EXTRA, 0, fldoff(shpstr, shp_timestamp), "timestamp"}, {NSC_TIME, NSC_EXTRA, 0, fldoff(shpstr, shp_timestamp), "timestamp"},
{NSC_UCHAR, 0, 0, fldoff(shpstr, shp_mobquota), "mobquota"}, {NSC_UCHAR, 0, 0, fldoff(shpstr, shp_mobquota), "mobquota"},
@ -195,8 +195,8 @@ struct castr land_ca[] = {
{NSC_STRINGY, 0, RET_LEN, fldoff(lndstr, lnd_rpath), "rpath"}, {NSC_STRINGY, 0, RET_LEN, fldoff(lndstr, lnd_rpath), "rpath"},
{NSC_UCHAR, 0, 0, fldoff(lndstr, lnd_rad_max), "react"}, {NSC_UCHAR, 0, 0, fldoff(lndstr, lnd_rad_max), "react"},
NSC_IVEC(fldoff(lndstr, lnd_item), ""), NSC_IVEC(fldoff(lndstr, lnd_item), ""),
{NSC_USHORT, NSC_DEITY, 0, fldoff(lndstr, lnd_pstage), "pstage"}, {NSC_SHORT, NSC_DEITY, 0, fldoff(lndstr, lnd_pstage), "pstage"},
{NSC_USHORT, NSC_DEITY, 0, fldoff(lndstr, lnd_ptime), "ptime"}, {NSC_SHORT, NSC_DEITY, 0, fldoff(lndstr, lnd_ptime), "ptime"},
{NSC_SHORT, 0, 0, fldoff(lndstr, lnd_land), "land"}, {NSC_SHORT, 0, 0, fldoff(lndstr, lnd_land), "land"},
{NSC_UCHAR, NSC_EXTRA, 0, fldoff(lndstr, lnd_nland), "nland"}, {NSC_UCHAR, NSC_EXTRA, 0, fldoff(lndstr, lnd_nland), "nland"},
{NSC_TIME, 0, 0, fldoff(lndstr, lnd_access), "access"}, {NSC_TIME, 0, 0, fldoff(lndstr, lnd_access), "access"},

View file

@ -115,7 +115,7 @@ upd_land(struct lndstr *lp, int etus,
/* build = 1, maintain = 0 */ /* build = 1, maintain = 0 */
{ {
struct lchrstr *lcp; struct lchrstr *lcp;
u_short pstage, ptime; int pstage, ptime;
int n; int n;
int min = morale_base - (int)np->nat_level[NAT_HLEV]; int min = morale_base - (int)np->nat_level[NAT_HLEV];
int mult; int mult;

View file

@ -52,7 +52,7 @@ static int infect_people(struct natstr *, struct sctstr *);
void void
do_plague(struct sctstr *sp, struct natstr *np, int etu) do_plague(struct sctstr *sp, struct natstr *np, int etu)
{ {
u_short pstage, ptime; int pstage, ptime;
int n; int n;
if (opt_NO_PLAGUE) /* no plague nothing to do */ if (opt_NO_PLAGUE) /* no plague nothing to do */
@ -152,7 +152,7 @@ infect_people(struct natstr *np, struct sctstr *sp)
*/ */
int int
plague_people(struct natstr *np, short *vec, plague_people(struct natstr *np, short *vec,
u_short *pstage, u_short *ptime, int *pstage, int *ptime,
int etus) int etus)
{ {
int stage; int stage;

View file

@ -115,7 +115,7 @@ upd_ship(struct shpstr *sp, int etus,
{ {
struct sctstr *sectp; struct sctstr *sectp;
struct mchrstr *mp; struct mchrstr *mp;
u_short pstage, ptime; int pstage, ptime;
int oil_gained; int oil_gained;
int max_oil; int max_oil;
int max_food; int max_food;