fix gcc errors, mostly reading unsigned values.

This commit is contained in:
Enno Rehling 2013-12-31 10:25:25 +01:00
parent 77ab9133c2
commit 07a57fadaa
9 changed files with 32 additions and 17 deletions

View File

@ -10,6 +10,8 @@ CHECK_SYMBOL_EXISTS (_Bool "stdbool.h" HAVE__BOOL)
CHECK_INCLUDE_FILES (strings.h HAVE_STRINGS_H) CHECK_INCLUDE_FILES (strings.h HAVE_STRINGS_H)
CHECK_SYMBOL_EXISTS (strdup "string.h" HAVE_STRDUP) CHECK_SYMBOL_EXISTS (strdup "string.h" HAVE_STRDUP)
CHECK_SYMBOL_EXISTS (_strdup "string.h" HAVE__STRDUP) CHECK_SYMBOL_EXISTS (_strdup "string.h" HAVE__STRDUP)
CHECK_SYMBOL_EXISTS (mkdir "sys/stat.h" HAVE_MKDIR)
CHECK_SYMBOL_EXISTS (_mkdir "direct.h" HAVE__MKDIR)
CONFIGURE_FILE ( CONFIGURE_FILE (
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in

View File

@ -3,3 +3,5 @@
#cmakedefine HAVE_STRINGS_H 1 #cmakedefine HAVE_STRINGS_H 1
#cmakedefine HAVE_STRDUP 1 #cmakedefine HAVE_STRDUP 1
#cmakedefine HAVE__STRDUP 1 #cmakedefine HAVE__STRDUP 1
#cmakedefine HAVE_MKDIR 1
#cmakedefine HAVE__MKDIR 1

View File

@ -633,7 +633,7 @@ int read_borders(struct storage *store)
READ_TOK(store, zText, sizeof(zText)); READ_TOK(store, zText, sizeof(zText));
if (!strcmp(zText, "end")) if (!strcmp(zText, "end"))
break; break;
READ_INT(store, &bid); READ_UINT(store, &bid);
if (global.data_version < UIDHASH_VERSION) { if (global.data_version < UIDHASH_VERSION) {
int fx, fy, tx, ty; int fx, fy, tx, ty;
READ_INT(store, &fx); READ_INT(store, &fx);
@ -644,8 +644,8 @@ int read_borders(struct storage *store)
to = findregion(tx, ty); to = findregion(tx, ty);
} else { } else {
unsigned int fid, tid; unsigned int fid, tid;
READ_INT(store, &fid); READ_UINT(store, &fid);
READ_INT(store, &tid); READ_UINT(store, &tid);
from = findregionbyid(fid); from = findregionbyid(fid);
to = findregionbyid(tid); to = findregionbyid(tid);
} }

View File

@ -187,13 +187,14 @@ int curse_read(attrib * a, void *owner, struct storage *store)
curse *c = (curse *) a->data.v; curse *c = (curse *) a->data.v;
int ur; int ur;
char cursename[64]; char cursename[64];
unsigned int n, flags; int n;
unsigned int flags;
float flt; float flt;
READ_INT(store, &c->no); READ_INT(store, &c->no);
chash(c); chash(c);
READ_TOK(store, cursename, sizeof(cursename)); READ_TOK(store, cursename, sizeof(cursename));
READ_INT(store, &flags); READ_UINT(store, &flags);
READ_INT(store, &c->duration); READ_INT(store, &c->duration);
if (global.data_version >= CURSEVIGOURISFLOAT_VERSION) { if (global.data_version >= CURSEVIGOURISFLOAT_VERSION) {
READ_FLT(store, &flt); READ_FLT(store, &flt);

View File

@ -78,6 +78,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* libc includes */ /* libc includes */
#include <string.h> #include <string.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
@ -441,7 +442,7 @@ static void read_alliances(struct storage *store)
READ_STR(store, aname, sizeof(aname)); READ_STR(store, aname, sizeof(aname));
al = makealliance(id, aname); al = makealliance(id, aname);
if (global.data_version >= OWNER_2_VERSION) { if (global.data_version >= OWNER_2_VERSION) {
READ_INT(store, &al->flags); READ_UINT(store, &al->flags);
} }
if (global.data_version >= ALLIANCELEADER_VERSION) { if (global.data_version >= ALLIANCELEADER_VERSION) {
read_reference(&al->_leader, store, read_faction_reference, read_reference(&al->_leader, store, read_faction_reference,
@ -513,7 +514,7 @@ static void read_owner(struct gamedata *data, region_owner ** powner)
owner->since_turn = since_turn; owner->since_turn = since_turn;
READ_INT(data->store, &owner->morale_turn); READ_INT(data->store, &owner->morale_turn);
if (data->version >= MOURNING_VERSION) { if (data->version >= MOURNING_VERSION) {
READ_INT(data->store, &owner->flags); READ_UINT(data->store, &owner->flags);
} else { } else {
owner->flags = 0; owner->flags = 0;
} }
@ -699,7 +700,7 @@ unit *read_unit(struct gamedata *data)
READ_INT(data->store, &n); READ_INT(data->store, &n);
setstatus(u, n); setstatus(u, n);
READ_INT(data->store, &u->flags); READ_UINT(data->store, &u->flags);
u->flags &= UFL_SAVEMASK; u->flags &= UFL_SAVEMASK;
if ((u->flags & UFL_ANON_FACTION) && !rule_stealth_faction()) { if ((u->flags & UFL_ANON_FACTION) && !rule_stealth_faction()) {
/* if this rule is broken, then fix broken units */ /* if this rule is broken, then fix broken units */
@ -848,7 +849,7 @@ static region *readregion(struct gamedata *data, int x, int y)
int n; int n;
if (data->version >= UID_VERSION) { if (data->version >= UID_VERSION) {
READ_INT(data->store, &uid); READ_UINT(data->store, &uid);
} }
if (r == NULL) { if (r == NULL) {
@ -896,7 +897,7 @@ static region *readregion(struct gamedata *data, int x, int y)
} }
} }
r->terrain = terrain; r->terrain = terrain;
READ_INT(data->store, &r->flags); READ_UINT(data->store, &r->flags);
READ_INT(data->store, &n); READ_INT(data->store, &n);
r->age = (unsigned short)n; r->age = (unsigned short)n;
@ -1269,7 +1270,7 @@ faction *readfaction(struct gamedata * data)
READ_INT(data->store, &n); READ_INT(data->store, &n);
} }
READ_INT(data->store, &f->flags); READ_UINT(data->store, &f->flags);
if (f->no == 0) { if (f->no == 0) {
f->flags |= FFL_NPC; f->flags |= FFL_NPC;
} }
@ -1465,7 +1466,7 @@ int readgame(const char *filename, int backup)
rng_init(turn); rng_init(turn);
++global.cookie; ++global.cookie;
READ_INT(&store, &n); /* max_unique_id = ignore */ READ_INT(&store, &n); /* max_unique_id = ignore */
READ_INT(&store, &nextborder); READ_UINT(&store, &nextborder);
/* Planes */ /* Planes */
planes = NULL; planes = NULL;
@ -1490,7 +1491,7 @@ int readgame(const char *filename, int backup)
READ_INT(&store, &pl->maxx); READ_INT(&store, &pl->maxx);
READ_INT(&store, &pl->miny); READ_INT(&store, &pl->miny);
READ_INT(&store, &pl->maxy); READ_INT(&store, &pl->maxy);
READ_INT(&store, &pl->flags); READ_UINT(&store, &pl->flags);
/* read watchers */ /* read watchers */
if (gdata.version < FIX_WATCHERS_VERSION) { if (gdata.version < FIX_WATCHERS_VERSION) {
@ -1628,7 +1629,7 @@ int readgame(const char *filename, int backup)
READ_INT(&store, &sh->size); READ_INT(&store, &sh->size);
READ_INT(&store, &sh->damage); READ_INT(&store, &sh->damage);
if (gdata.version >= FOSS_VERSION) { if (gdata.version >= FOSS_VERSION) {
READ_INT(&store, &sh->flags); READ_UINT(&store, &sh->flags);
} }
/* Attribute rekursiv einlesen */ /* Attribute rekursiv einlesen */

View File

@ -156,7 +156,6 @@ typedef struct stat stat_type;
/* Microsoft Visual C */ /* Microsoft Visual C */
#ifdef _MSC_VER #ifdef _MSC_VER
# include <direct.h>
# include <string.h> /* must be included here so strdup is not redefined */ # include <string.h> /* must be included here so strdup is not redefined */
# define R_OK 4 # define R_OK 4
# define HAVE_INLINE # define HAVE_INLINE
@ -258,4 +257,13 @@ typedef struct _stat stat_type;
# endif # endif
#endif #endif
#if defined(HAVE__MKDIR)
# include <direct.h>
#else
# if defined(HAVE_MKDIR)
# include <sys/stat.h>
# define _mkdir(s) mkdir(s, 0777)
# endif
#endif
#endif #endif

View File

@ -23,6 +23,7 @@ extern "C" {
#endif #endif
struct gamedata; struct gamedata;
struct storage;
typedef void (*afun) (void); typedef void (*afun) (void);
typedef struct attrib { typedef struct attrib {

View File

@ -65,7 +65,7 @@ static int cw_read(attrib * a, void *target, storage * store)
curse_read(a, store, target); curse_read(a, store, target);
br->self = c; br->self = c;
READ_INT(store, &br->id); READ_UINT(store, &br->id);
var.i = br->id; var.i = br->id;
ur_add(var, &wc->wall, resolve_borderid); ur_add(var, &wc->wall, resolve_borderid);

@ -1 +1 @@
Subproject commit 6746f58d52d7386391b49a512d3d42b6d2dc0678 Subproject commit 515fa364569752f0494422762b27bc443dd1a0c4