(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 */
|
||||
u_char lnd_rad_max; /* max radius for this unit */
|
||||
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_ptime; /* how many etus remain in this stage */
|
||||
short lnd_land; /* pointer to transporting unit */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue