]> git.pond.sub.org Git - empserver/commitdiff
Make sector types signed
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 22 Feb 2008 19:58:37 +0000 (20:58 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 25 Feb 2008 20:50:21 +0000 (21:50 +0100)
get_empobj_chr() and emp_obj_chr_name() access struct sctstr member
sct_type through struct empobj member type.  This is technically
non-portable, because the two differ in signedness.  It was also
undocumented.  Fix by making sct_type signed.  sct_newtype as well,
for consistency.

map_char() uses unsigned char for a sector type argument.  Change that
to int.  Matches how this is done elsewhere.

include/empobj.h
include/sect.h
src/lib/global/nsc.c
src/lib/subs/maps.c

index 2d46022f94716929cdb8df70de972760e9add1ae..59df1367f42b0100fab53f4502eb1d46ababc2b8 100644 (file)
@@ -56,7 +56,8 @@ struct empobj {
     short uid;
     coord x;           /* is valid if EFF_XY      is set in table def. */
     coord y;           /* is valid if EFF_XY      is set in table def. */
-    signed char type;
+    signed char type;  /* is valid for sectors and units */
+    /* remaining are valid for units */
     signed char effic;
     signed char mobil;
     unsigned char off;
index 18610e49b9c15a980620ea3caf3524ae6b654634..a960706ee500c88c7a53cfd091effdcc4179cc6f 100644 (file)
@@ -48,8 +48,8 @@ struct sctstr {
     short sct_elev;            /* elevation/depth */
     coord sct_x;               /* x coord of sector */
     coord sct_y;               /* y coord of sector */
+    signed char sct_type;      /* sector type */
     /* end of part matching struct empobj */
-    unsigned char sct_type;    /* sector type */
     unsigned char sct_effic;   /* 0% to 100% */
     short sct_mobil;           /* mobility units */
     unsigned char sct_loyal;   /* updates until civilans "converted" */
@@ -65,7 +65,7 @@ struct sctstr {
     short sct_fill;            /* gunk */
     unsigned char sct_work;    /* pct of civ actually working */
     unsigned char sct_coastal; /* is this a coastal sector? */
-    unsigned char sct_newtype; /* for changing designations */
+    signed char sct_newtype;   /* for changing designations */
     unsigned char sct_min;     /* ease of mining ore */
     unsigned char sct_gmin;    /* amount of gold ore */
     unsigned char sct_fertil;  /* fertility of soil */
index a088976323d4d48761d67e75b85754725e20315f..0c20baaead474c8e8f0c05bed4b4dec4c6afadb5 100644 (file)
@@ -108,7 +108,7 @@ struct castr sect_ca[] = {
     {NSC_SHORT, NSC_DEITY, 0, fldoff(sctstr, sct_elev), "elev", EF_BAD},
     {NSC_XCOORD, NSC_CONST, 0, fldoff(sctstr, sct_x), "xloc", EF_BAD},
     {NSC_YCOORD, NSC_CONST, 0, fldoff(sctstr, sct_y), "yloc", EF_BAD},
-    {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_type), "des", EF_SECTOR_CHR},
+    {NSC_CHAR, 0, 0, fldoff(sctstr, sct_type), "des", EF_SECTOR_CHR},
     {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_effic), "effic", EF_BAD},
     {NSC_SHORT, 0, 0, fldoff(sctstr, sct_mobil), "mobil", EF_BAD},
     {NSC_UCHAR, NSC_DEITY, 0, fldoff(sctstr, sct_loyal), "loyal", EF_BAD},
@@ -123,7 +123,7 @@ struct castr sect_ca[] = {
     {NSC_SHORT, 0, 0, fldoff(sctstr, sct_avail), "avail", EF_BAD},
     {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_work), "work", EF_BAD},
     {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_coastal), "coastal", EF_BAD},
-    {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_newtype), "newdes", EF_SECTOR_CHR},
+    {NSC_CHAR, 0, 0, fldoff(sctstr, sct_newtype), "newdes", EF_SECTOR_CHR},
     {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_min), "min", EF_BAD},
     {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_gmin), "gold", EF_BAD},
     {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_fertil), "fert", EF_BAD},
index b60d5d670d85a614b359901f026606a8fb0aa902..4990e5ab758d724fb08a6edb0dfe9fcb68375bbe 100644 (file)
@@ -54,7 +54,7 @@
 #include "xy.h"
 
 static int bmnxtsct(struct nstr_sect *);
-static char map_char(unsigned char type, natid own, int owner_or_god);
+static char map_char(int type, natid own, int owner_or_god);
 
 int
 do_map(int bmap, int unit_type, char *arg, char *map_flags_arg)
@@ -330,7 +330,7 @@ bmnxtsct(struct nstr_sect *np)
  * If OWNER_OR_GOD, the map is for the sector's owner or a deity.
  */
 static char
-map_char(unsigned char type, natid own, int owner_or_god)
+map_char(int type, natid own, int owner_or_god)
 {
     if (CANT_HAPPEN(type > SCT_TYPE_MAX || !dchr[type].d_mnem))
        return '?';