(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
|
@ -93,7 +93,7 @@ struct shpstr {
|
|||
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 */
|
||||
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_ptime; /* how many etus remain in this stage */
|
||||
time_t shp_access; /* Last time mob was updated (MOB_ACCESS) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue