]> git.pond.sub.org Git - empserver/commitdiff
(sctstr, shpstr, lndstr): Use `short' instead of `unsigned short' for
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 5 Mar 2004 07:56:50 +0000 (07:56 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Fri, 5 Mar 2004 07:56:50 +0000 (07:56 +0000)
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.

include/land.h
include/sect.h
include/ship.h

index 10fb3fe0a91aceb65585da1e340d99b12100899d..7ee2e2583b5386ad9a12418d8760801e3e5cf958 100644 (file)
@@ -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 */
index 5750796dea9b6cc9d6e1d03873bff7796199c024..6daa05ae48b7de9f9f81d0ae7cd354bbee340300 100644 (file)
@@ -71,9 +71,9 @@ struct sctstr {
     natid sct_oldown;          /* old owner of sector (for liberation) */
     u_char sct_updated;                /* Has this sect been updated? */
     u_char sct_off;            /* Should this sector produce? */
-    u_short sct_item[I_MAX+1]; /* amount of items stored here */
-    u_short sct_del[I_MAX+1];  /* delivieries */
-    u_short sct_dist[I_MAX+1]; /* distribution thresholds */
+    short sct_item[I_MAX+1];   /* amount of items stored here */
+    short sct_del[I_MAX+1];    /* delivieries */
+    short sct_dist[I_MAX+1];   /* distribution thresholds */
     u_short sct_mines;         /* number of mines */
     u_short sct_pstage;                /* plague stage */
     u_short sct_ptime;         /* how many etus remain in this stage */
index 4a5c9703143397efb225677350db7b671bd3269f..1ccb8ee168f50dd805f6185d2b8aa844fd87b417 100644 (file)
@@ -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) */