(sctstr, shpstr, lndstr): Use short' instead of
unsigned short' for
item storage. Rationale: Permitted values are 0..M, where M depends on the container. The largest M is ITEM_MAX (9999). Benign overflow/underflow occurs at those limits. Catastrophic overflow/underflow occurs at the limits of the underlying data type. For `unsigned short', any underflow is catastrophic. For `short', benign undeflow happens long before catastrophic underflow. Moreover, unsigned arithmetic tends to trip up unwary programmers.
This commit is contained in:
parent
58e93c0ea3
commit
9989c5b3ec
3 changed files with 5 additions and 5 deletions
|
@ -71,7 +71,7 @@ struct lndstr {
|
||||||
s_char lnd_rpath[RET_LEN]; /* retreat path */
|
s_char lnd_rpath[RET_LEN]; /* retreat path */
|
||||||
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) */
|
||||||
u_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 */
|
u_short lnd_pstage; /* plague stage */
|
||||||
u_short lnd_ptime; /* how many etus remain in this stage */
|
u_short lnd_ptime; /* how many etus remain in this stage */
|
||||||
short lnd_land; /* pointer to transporting unit */
|
short lnd_land; /* pointer to transporting unit */
|
||||||
|
|
|
@ -71,9 +71,9 @@ struct sctstr {
|
||||||
natid sct_oldown; /* old owner of sector (for liberation) */
|
natid sct_oldown; /* old owner of sector (for liberation) */
|
||||||
u_char sct_updated; /* Has this sect been updated? */
|
u_char sct_updated; /* Has this sect been updated? */
|
||||||
u_char sct_off; /* Should this sector produce? */
|
u_char sct_off; /* Should this sector produce? */
|
||||||
u_short sct_item[I_MAX+1]; /* amount of items stored here */
|
short sct_item[I_MAX+1]; /* amount of items stored here */
|
||||||
u_short sct_del[I_MAX+1]; /* delivieries */
|
short sct_del[I_MAX+1]; /* delivieries */
|
||||||
u_short sct_dist[I_MAX+1]; /* distribution thresholds */
|
short sct_dist[I_MAX+1]; /* distribution thresholds */
|
||||||
u_short sct_mines; /* number of mines */
|
u_short sct_mines; /* number of mines */
|
||||||
u_short sct_pstage; /* plague stage */
|
u_short sct_pstage; /* plague stage */
|
||||||
u_short sct_ptime; /* how many etus remain in this stage */
|
u_short sct_ptime; /* how many etus remain in this stage */
|
||||||
|
|
|
@ -93,7 +93,7 @@ struct shpstr {
|
||||||
short shp_lstart[TMAX]; /* How much do we pick up at the start */
|
short shp_lstart[TMAX]; /* How much do we pick up at the start */
|
||||||
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 */
|
||||||
u_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 */
|
u_short shp_pstage; /* plague stage */
|
||||||
u_short shp_ptime; /* how many etus remain in this stage */
|
u_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) */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue