From 49584082a08db84344a54ae7e0a7927915261edf Mon Sep 17 00:00:00 2001 From: tron Date: Sun, 9 Jan 2005 21:25:44 +0000 Subject: [PATCH] (svn r1451) Fix some of the signed/unsigned comparison warnings --- ai.c | 2 +- ai_pathfinder.c | 7 +++++-- aystar.c | 2 +- command.c | 4 ++-- command.h | 2 +- console.c | 6 +++--- landscape.c | 2 +- misc.c | 6 ++++-- misc_gui.c | 2 +- namegen.c | 5 +++-- network.c | 4 ++-- network_client.c | 4 ++-- network_server.c | 4 ++-- oldloader.c | 2 +- road_cmd.c | 2 +- settings_gui.c | 4 ++-- tree_cmd.c | 2 +- ttd.c | 4 ++-- tunnelbridge_cmd.c | 6 +++--- window.c | 2 +- 20 files changed, 39 insertions(+), 33 deletions(-) diff --git a/ai.c b/ai.c index ac9172af0e..0bd26e46fc 100644 --- a/ai.c +++ b/ai.c @@ -425,7 +425,7 @@ static Industry *AiFindRandomIndustry() { static void AiFindSubsidyIndustryRoute(FoundRoute *fr) { - int i; + uint i; byte cargo; Subsidy *s; Industry *from, *to_ind; diff --git a/ai_pathfinder.c b/ai_pathfinder.c index d1bccb17d8..86e391d308 100644 --- a/ai_pathfinder.c +++ b/ai_pathfinder.c @@ -148,7 +148,7 @@ static int32 AyStar_AiPathFinder_CalculateH(AyStar *aystar, AyStarNode *current, // We found the end.. let's get the route back and put it in an array static void AyStar_AiPathFinder_FoundEndNode(AyStar *aystar, OpenListNode *current) { Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target; - int i = 0; + uint i = 0; PathNode *parent = ¤t->path; do { @@ -168,7 +168,10 @@ static void AyStar_AiPathFinder_FoundEndNode(AyStar *aystar, OpenListNode *curre // What tiles are around us. static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *current) { - int i, r, dir; + uint i; + int r; + int dir; + Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target; aystar->num_neighbours = 0; diff --git a/aystar.c b/aystar.c index 92e79fee38..7049220300 100644 --- a/aystar.c +++ b/aystar.c @@ -101,7 +101,7 @@ int AyStarMain_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *pare // Check if this item is already in the OpenList if ((check = AyStarMain_OpenList_IsInList(aystar, current)) != NULL) { - int i; + uint i; // Yes, check if this g value is lower.. if (new_g > check->g) return AYSTAR_DONE; aystar->OpenListQueue.del(&aystar->OpenListQueue, check, 0); diff --git a/command.c b/command.c index eff7af9061..010c461f64 100644 --- a/command.c +++ b/command.c @@ -313,11 +313,11 @@ static CommandProc * const _command_proc_table[] = { }; /* This function range-checks a cmd, and checks if the cmd is not NULL */ -bool IsValidCommand(int cmd) +bool IsValidCommand(uint cmd) { cmd = cmd & 0xFF; - if (cmd < 0 || cmd >= lengthof(_command_proc_table) || _command_proc_table[cmd] == NULL) + if (cmd >= lengthof(_command_proc_table) || _command_proc_table[cmd] == NULL) return false; return true; diff --git a/command.h b/command.h index c6c80756a3..d967d3486e 100644 --- a/command.h +++ b/command.h @@ -182,7 +182,7 @@ enum { int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc); int32 DoCommandByTile(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc); -bool IsValidCommand(int cmd); +bool IsValidCommand(uint cmd); int32 GetAvailableMoneyForCommand(); #endif /* COMMAND_H */ diff --git a/console.c b/console.c index 57f88dd6c0..1a4671593b 100644 --- a/console.c +++ b/console.c @@ -1058,9 +1058,9 @@ void IConsoleCmdExec(const char* cmdstr) bool valid_token; bool skip_lt_change; - int c; - int i; - int l; + uint c; + uint i; + uint l; if (_stdlib_con_developer) IConsolePrintF(_iconsole_color_debug, "CONDEBUG: execution_cmdline: %s", cmdstr); diff --git a/landscape.c b/landscape.c index fc085deaf3..5c762effb5 100644 --- a/landscape.c +++ b/landscape.c @@ -486,7 +486,7 @@ void RunTileLoop() void InitializeLandscape() { uint map_size = MapSize(); - int i; + uint i; memset(_map_owner, OWNER_NONE, map_size); memset(_map2, 0, map_size * sizeof(uint16)); diff --git a/misc.c b/misc.c index f439bad8b5..8e779bcb25 100644 --- a/misc.c +++ b/misc.c @@ -184,7 +184,7 @@ void ConvertGroundTilesIntoWaterTiles(); void InitializeGame() { // Initialize the autoreplace array. Needs to be cleared between each game - int i; + uint i; for (i = 0; i < lengthof(_autoreplace_array); i++) _autoreplace_array[i] = i; @@ -608,7 +608,9 @@ static const uint16 _autosave_months[] = { void IncreaseDate() { const int vehicles_per_day = (1 << (sizeof(_date_fract) * 8)) / 885; - int i,ctr,t; + uint i; + VehicleID ctr; + int t; YearMonthDay ymd; if (_game_mode == GM_MENU) { diff --git a/misc_gui.c b/misc_gui.c index 919a6675c4..ff0197c598 100644 --- a/misc_gui.c +++ b/misc_gui.c @@ -213,7 +213,7 @@ static void AboutWindowProc(Window *w, WindowEvent *e) case WE_PAINT: { const char *str; char buffer[100]; - int i; + uint i; int y = WP(w, general_d).j; DrawWindowWidgets(w); diff --git a/namegen.c b/namegen.c index 401c82c5a7..5a3df3d715 100644 --- a/namegen.c +++ b/namegen.c @@ -306,7 +306,8 @@ static byte MakeFinnishTownName(byte *buf, uint32 seed) static byte MakePolishTownName(byte *buf, uint32 seed) { - int i, j; + uint i; + uint j; //null terminates the string for strcat strcpy(buf, ""); @@ -402,7 +403,7 @@ static byte MakeNorwegianTownName(byte *buf, uint32 seed) static byte MakeHungarianTownName(byte *buf, uint32 seed) { - int i; + uint i; //null terminates the string for strcat strcpy(buf, ""); diff --git a/network.c b/network.c index 26fd3b1cea..dc26e40635 100644 --- a/network.c +++ b/network.c @@ -620,7 +620,7 @@ static void NetworkAcceptClients(void) #else LONG sin_len; // for some reason we need a 'LONG' under MorphOS #endif - int i; + uint i; bool banned; // Should never ever happen.. is it possible?? @@ -878,7 +878,7 @@ void NetworkAddServer(const byte *b) * by the function that generates the config file. */ void NetworkRebuildHostList() { - int i = 0; + uint i = 0; NetworkGameList *item = _network_game_list; while (item != NULL && i != lengthof(_network_host_list)) { if (item->manually) diff --git a/network_client.c b/network_client.c index a7b917b9ce..5b4c0f1e43 100644 --- a/network_client.c +++ b/network_client.c @@ -144,7 +144,7 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_COMMAND)(CommandPacket *cp) // uint8: CallBackID (see callback_table.c) // - int i; + uint i; char *dparam_char; Packet *p = NetworkSend_Init(PACKET_CLIENT_COMMAND); @@ -572,7 +572,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_SYNC) DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMMAND) { - int i; + uint i; char *dparam_char; CommandPacket *cp = malloc(sizeof(CommandPacket)); cp->player = NetworkRecv_uint8(MY_CLIENT, p); diff --git a/network_server.c b/network_server.c index edd2aab6b0..b7bc8b3ed7 100644 --- a/network_server.c +++ b/network_server.c @@ -451,7 +451,7 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_COMMAND)(NetworkClientState *cs, Com // uint32: Frame of execution // - int i; + uint i; char *dparam_char; Packet *p = NetworkSend_Init(PACKET_SERVER_COMMAND); @@ -749,7 +749,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_MAP_OK) DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) { // The client has done a command and wants us to handle it - int i; + uint i; byte callback; NetworkClientState *new_cs; NetworkClientInfo *ci; diff --git a/oldloader.c b/oldloader.c index c454dc97cd..296271968f 100644 --- a/oldloader.c +++ b/oldloader.c @@ -1377,7 +1377,7 @@ bool LoadOldSaveGame(const char *file) LoadSavegameState lss; OldMain *m; uint map_size; - int i; + uint i; _cur_state = &lss; memset(&lss, 0, sizeof(lss)); diff --git a/road_cmd.c b/road_cmd.c index c7ea7d08e0..2c6c56d4ba 100644 --- a/road_cmd.c +++ b/road_cmd.c @@ -399,7 +399,7 @@ int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) goto do_clear; /* only allow roads pertendicular to bridge */ - if ((pieces & 5) == (ti.map5 & 0x01)) + if ((pieces & 5U) == (ti.map5 & 0x01U)) goto do_clear; /* check if clear land under bridge */ diff --git a/settings_gui.c b/settings_gui.c index b607d2960b..120dfc363f 100644 --- a/settings_gui.c +++ b/settings_gui.c @@ -1006,7 +1006,7 @@ void ConsoleSetPatchSetting(char *name, char *value) const PatchPage *page; const PatchEntry *pe = NULL; bool found = false; - int i; + uint i; unsigned int j; int val; @@ -1066,7 +1066,7 @@ void ConsoleGetPatchSetting(char *name) const PatchEntry *pe = NULL; char value[50]; bool found = false; - int i; + uint i; unsigned int j; /* Search for the name in the patch-settings */ diff --git a/tree_cmd.c b/tree_cmd.c index 52854c9c68..d3a88aa07e 100644 --- a/tree_cmd.c +++ b/tree_cmd.c @@ -271,7 +271,7 @@ static void DrawTile_Trees(TileInfo *ti) { uint16 tmp = ti->x; - int index; + uint index; tmp = (tmp >> 2) | (tmp << 14); tmp -= ti->y; diff --git a/ttd.c b/ttd.c index 266ca8571e..ce245d8d01 100644 --- a/ttd.c +++ b/ttd.c @@ -267,7 +267,7 @@ void LoadDriver(int driver, const char *name) ttd_strlcpy(buffer, name, sizeof(buffer)); parm = strchr(buffer, ':'); if (parm) { - int np = 0; + uint np = 0; // Tokenize the parm. do { *parm++ = 0; @@ -1243,7 +1243,7 @@ void UpdateCurrencies() // even though they should have. This is fixed by this function void UpdateVoidTiles() { - int i; + uint i; // create void tiles on the border for (i = 0; i != MapMaxY(); i++) _map_type_and_height[ i * MapSizeX() + MapMaxY() ] = MP_VOID << 4; diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c index 06d398ffaa..135f7fd472 100644 --- a/tunnelbridge_cmd.c +++ b/tunnelbridge_cmd.c @@ -1311,14 +1311,14 @@ static uint32 GetTileTrackStatus_TunnelBridge(uint tile, TransportType mode) if ((m5 & 0xF0) == 0) { /* This is a tunnel */ - if (((m5 & 0xC) >> 2) == mode) { + if (((m5 & 0xCU) >> 2) == mode) { /* Tranport in the tunnel is compatible */ return m5&1 ? 0x202 : 0x101; } } else if (m5 & 0x80) { /* This is a bridge */ result = 0; - if (((m5 & 0x6) >> 1) == mode) { + if (((m5 & 0x6U) >> 1) == mode) { /* Transport over the bridge is compatible */ result = m5&1 ? 0x202 : 0x101; } @@ -1334,7 +1334,7 @@ static uint32 GetTileTrackStatus_TunnelBridge(uint tile, TransportType mode) return result; } else { /* Transport underneath */ - if ((m5 & 0x18) >> 3 != mode) + if ((m5 & 0x18U) >> 3 != mode) /* Incompatible transport underneath */ return result; } diff --git a/window.c b/window.c index 10bc0de86c..08604eb7e7 100644 --- a/window.c +++ b/window.c @@ -407,7 +407,7 @@ Window *AllocateWindow( w->resize.step_height = 1; { - int i; + uint i; for (i=0;icustom);i++) w->custom[i] = 0; }