From f0be7b6192f06e6d8549c0a500e718db218bbe14 Mon Sep 17 00:00:00 2001 From: tron Date: Mon, 10 Jan 2005 22:14:35 +0000 Subject: [PATCH] (svn r1475) Fix some more signed/unsigned comparison warnings --- ai_pathfinder.c | 6 +++--- graph_gui.c | 2 +- map.h | 2 +- pathfind.c | 7 +++++-- viewport.c | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ai_pathfinder.c b/ai_pathfinder.c index 86e391d308..7e9efc4a76 100644 --- a/ai_pathfinder.c +++ b/ai_pathfinder.c @@ -189,11 +189,11 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr if (!PathFinderInfo->rail_or_road && AI_PATHFINDER_IS_ROAD(current->path.node.tile + TileOffsByDir(i))) { if (IS_TILETYPE(current->path.node.tile + TileOffsByDir(i), MP_TUNNELBRIDGE)) { // An existing bridge... let's test the direction ;) - if ((_map5[current->path.node.tile + TileOffsByDir(i)] & 1) != (i & 1)) continue; + if ((_map5[current->path.node.tile + TileOffsByDir(i)] & 1U) != (i & 1)) continue; // This problem only is valid for tunnels: // When the last tile was not yet a tunnel, check if we enter from the right side.. if (!IS_TILETYPE(current->path.node.tile, MP_TUNNELBRIDGE) && (_map5[current->path.node.tile + TileOffsByDir(i)] & 0x80) == 0) { - if (i != (_map5[current->path.node.tile + TileOffsByDir(i)] & 3)) continue; + if (i != (_map5[current->path.node.tile + TileOffsByDir(i)] & 3U)) continue; } } } @@ -201,7 +201,7 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr if (!PathFinderInfo->rail_or_road && AI_PATHFINDER_IS_ROAD(current->path.node.tile)) { if (IS_TILETYPE(current->path.node.tile, MP_TUNNELBRIDGE)) { // An existing bridge/tunnel... let's test the direction ;) - if ((_map5[current->path.node.tile] & 1) != (i & 1)) continue; + if ((_map5[current->path.node.tile] & 1U) != (i & 1)) continue; } } diff --git a/graph_gui.c b/graph_gui.c index c8d0b63e4a..c9b5d1377b 100644 --- a/graph_gui.c +++ b/graph_gui.c @@ -558,7 +558,7 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e) // Bah, player gone :( w->disabled_state += 1 << (i+13); // Is this player selected? If so, select first player (always save? :s) - if (w->click_state == 1 << (i+13)) + if (w->click_state == 1U << (i + 13)) w->click_state = 1 << 13; // We need a repaint SetWindowDirty(w); diff --git a/map.h b/map.h index ba69cfb8ac..489cb025c0 100644 --- a/map.h +++ b/map.h @@ -4,7 +4,7 @@ #define TILE_FROM_XY(x,y) (int)((((y) >> 4) << MapLogX()) + ((x) >> 4)) #define TILE_XY(x,y) (int)(((y) << MapLogX()) + (x)) -#define TILE_MASK(x) (int)((x) & ((1 << (MapLogX() + MapLogY())) - 1)) +#define TILE_MASK(x) ((x) & ((1 << (MapLogX() + MapLogY())) - 1)) extern byte _map_type_and_height[]; extern byte _map5[]; diff --git a/pathfind.c b/pathfind.c index befb45f4c6..337bdcff72 100644 --- a/pathfind.c +++ b/pathfind.c @@ -450,7 +450,7 @@ typedef struct { HashLink *new_link; uint num_links_left; - int nstack; + uint nstack; StackedItem stack[256]; // priority queue of stacked items uint16 hash_head[0x400]; // hash heads. 0 means unused. 0xFFC0 = length, 0x3F = type @@ -484,7 +484,10 @@ static inline void HeapifyDown(NewTrackPathFinder *tpf) { StackedItem si; int i = 1, j; - int n = --tpf->nstack; + int n; + + assert(tpf->nstack > 0); + n = --tpf->nstack; if (n == 0) return; // heap is empty so nothing to do? diff --git a/viewport.c b/viewport.c index b7d338a759..d33ff6a3e0 100644 --- a/viewport.c +++ b/viewport.c @@ -1186,7 +1186,7 @@ void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom // This assert should never happen (because the length of the parent_list // is checked) - assert(vd.parent_list - parent_list <= lengthof(parent_list)); + assert(vd.parent_list <= endof(parent_list)); if (vd.first_tile != NULL) ViewportDrawTileSprites(vd.first_tile);