(svn r1451) Fix some of the signed/unsigned comparison warnings

This commit is contained in:
tron 2005-01-09 21:25:44 +00:00
parent c6c86abeee
commit 49584082a0
20 changed files with 39 additions and 33 deletions

2
ai.c
View File

@ -425,7 +425,7 @@ static Industry *AiFindRandomIndustry() {
static void AiFindSubsidyIndustryRoute(FoundRoute *fr) static void AiFindSubsidyIndustryRoute(FoundRoute *fr)
{ {
int i; uint i;
byte cargo; byte cargo;
Subsidy *s; Subsidy *s;
Industry *from, *to_ind; Industry *from, *to_ind;

View File

@ -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 // 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) { static void AyStar_AiPathFinder_FoundEndNode(AyStar *aystar, OpenListNode *current) {
Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target; Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
int i = 0; uint i = 0;
PathNode *parent = &current->path; PathNode *parent = &current->path;
do { do {
@ -168,7 +168,10 @@ static void AyStar_AiPathFinder_FoundEndNode(AyStar *aystar, OpenListNode *curre
// What tiles are around us. // What tiles are around us.
static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *current) { 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; Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
aystar->num_neighbours = 0; aystar->num_neighbours = 0;

View File

@ -101,7 +101,7 @@ int AyStarMain_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *pare
// Check if this item is already in the OpenList // Check if this item is already in the OpenList
if ((check = AyStarMain_OpenList_IsInList(aystar, current)) != NULL) { if ((check = AyStarMain_OpenList_IsInList(aystar, current)) != NULL) {
int i; uint i;
// Yes, check if this g value is lower.. // Yes, check if this g value is lower..
if (new_g > check->g) return AYSTAR_DONE; if (new_g > check->g) return AYSTAR_DONE;
aystar->OpenListQueue.del(&aystar->OpenListQueue, check, 0); aystar->OpenListQueue.del(&aystar->OpenListQueue, check, 0);

View File

@ -313,11 +313,11 @@ static CommandProc * const _command_proc_table[] = {
}; };
/* This function range-checks a cmd, and checks if the cmd is not NULL */ /* 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; 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 false;
return true; return true;

View File

@ -182,7 +182,7 @@ enum {
int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc); 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); int32 DoCommandByTile(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
bool IsValidCommand(int cmd); bool IsValidCommand(uint cmd);
int32 GetAvailableMoneyForCommand(); int32 GetAvailableMoneyForCommand();
#endif /* COMMAND_H */ #endif /* COMMAND_H */

View File

@ -1058,9 +1058,9 @@ void IConsoleCmdExec(const char* cmdstr)
bool valid_token; bool valid_token;
bool skip_lt_change; bool skip_lt_change;
int c; uint c;
int i; uint i;
int l; uint l;
if (_stdlib_con_developer) if (_stdlib_con_developer)
IConsolePrintF(_iconsole_color_debug, "CONDEBUG: execution_cmdline: %s", cmdstr); IConsolePrintF(_iconsole_color_debug, "CONDEBUG: execution_cmdline: %s", cmdstr);

View File

@ -486,7 +486,7 @@ void RunTileLoop()
void InitializeLandscape() void InitializeLandscape()
{ {
uint map_size = MapSize(); uint map_size = MapSize();
int i; uint i;
memset(_map_owner, OWNER_NONE, map_size); memset(_map_owner, OWNER_NONE, map_size);
memset(_map2, 0, map_size * sizeof(uint16)); memset(_map2, 0, map_size * sizeof(uint16));

6
misc.c
View File

@ -184,7 +184,7 @@ void ConvertGroundTilesIntoWaterTiles();
void InitializeGame() void InitializeGame()
{ {
// Initialize the autoreplace array. Needs to be cleared between each game // Initialize the autoreplace array. Needs to be cleared between each game
int i; uint i;
for (i = 0; i < lengthof(_autoreplace_array); i++) for (i = 0; i < lengthof(_autoreplace_array); i++)
_autoreplace_array[i] = i; _autoreplace_array[i] = i;
@ -608,7 +608,9 @@ static const uint16 _autosave_months[] = {
void IncreaseDate() void IncreaseDate()
{ {
const int vehicles_per_day = (1 << (sizeof(_date_fract) * 8)) / 885; const int vehicles_per_day = (1 << (sizeof(_date_fract) * 8)) / 885;
int i,ctr,t; uint i;
VehicleID ctr;
int t;
YearMonthDay ymd; YearMonthDay ymd;
if (_game_mode == GM_MENU) { if (_game_mode == GM_MENU) {

View File

@ -213,7 +213,7 @@ static void AboutWindowProc(Window *w, WindowEvent *e)
case WE_PAINT: { case WE_PAINT: {
const char *str; const char *str;
char buffer[100]; char buffer[100];
int i; uint i;
int y = WP(w, general_d).j; int y = WP(w, general_d).j;
DrawWindowWidgets(w); DrawWindowWidgets(w);

View File

@ -306,7 +306,8 @@ static byte MakeFinnishTownName(byte *buf, uint32 seed)
static byte MakePolishTownName(byte *buf, uint32 seed) static byte MakePolishTownName(byte *buf, uint32 seed)
{ {
int i, j; uint i;
uint j;
//null terminates the string for strcat //null terminates the string for strcat
strcpy(buf, ""); strcpy(buf, "");
@ -402,7 +403,7 @@ static byte MakeNorwegianTownName(byte *buf, uint32 seed)
static byte MakeHungarianTownName(byte *buf, uint32 seed) static byte MakeHungarianTownName(byte *buf, uint32 seed)
{ {
int i; uint i;
//null terminates the string for strcat //null terminates the string for strcat
strcpy(buf, ""); strcpy(buf, "");

View File

@ -620,7 +620,7 @@ static void NetworkAcceptClients(void)
#else #else
LONG sin_len; // for some reason we need a 'LONG' under MorphOS LONG sin_len; // for some reason we need a 'LONG' under MorphOS
#endif #endif
int i; uint i;
bool banned; bool banned;
// Should never ever happen.. is it possible?? // Should never ever happen.. is it possible??
@ -878,7 +878,7 @@ void NetworkAddServer(const byte *b)
* by the function that generates the config file. */ * by the function that generates the config file. */
void NetworkRebuildHostList() void NetworkRebuildHostList()
{ {
int i = 0; uint i = 0;
NetworkGameList *item = _network_game_list; NetworkGameList *item = _network_game_list;
while (item != NULL && i != lengthof(_network_host_list)) { while (item != NULL && i != lengthof(_network_host_list)) {
if (item->manually) if (item->manually)

View File

@ -144,7 +144,7 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_COMMAND)(CommandPacket *cp)
// uint8: CallBackID (see callback_table.c) // uint8: CallBackID (see callback_table.c)
// //
int i; uint i;
char *dparam_char; char *dparam_char;
Packet *p = NetworkSend_Init(PACKET_CLIENT_COMMAND); 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) DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMMAND)
{ {
int i; uint i;
char *dparam_char; char *dparam_char;
CommandPacket *cp = malloc(sizeof(CommandPacket)); CommandPacket *cp = malloc(sizeof(CommandPacket));
cp->player = NetworkRecv_uint8(MY_CLIENT, p); cp->player = NetworkRecv_uint8(MY_CLIENT, p);

View File

@ -451,7 +451,7 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_COMMAND)(NetworkClientState *cs, Com
// uint32: Frame of execution // uint32: Frame of execution
// //
int i; uint i;
char *dparam_char; char *dparam_char;
Packet *p = NetworkSend_Init(PACKET_SERVER_COMMAND); 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) DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)
{ {
// The client has done a command and wants us to handle it // The client has done a command and wants us to handle it
int i; uint i;
byte callback; byte callback;
NetworkClientState *new_cs; NetworkClientState *new_cs;
NetworkClientInfo *ci; NetworkClientInfo *ci;

View File

@ -1377,7 +1377,7 @@ bool LoadOldSaveGame(const char *file)
LoadSavegameState lss; LoadSavegameState lss;
OldMain *m; OldMain *m;
uint map_size; uint map_size;
int i; uint i;
_cur_state = &lss; _cur_state = &lss;
memset(&lss, 0, sizeof(lss)); memset(&lss, 0, sizeof(lss));

View File

@ -399,7 +399,7 @@ int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
goto do_clear; goto do_clear;
/* only allow roads pertendicular to bridge */ /* only allow roads pertendicular to bridge */
if ((pieces & 5) == (ti.map5 & 0x01)) if ((pieces & 5U) == (ti.map5 & 0x01U))
goto do_clear; goto do_clear;
/* check if clear land under bridge */ /* check if clear land under bridge */

View File

@ -1006,7 +1006,7 @@ void ConsoleSetPatchSetting(char *name, char *value)
const PatchPage *page; const PatchPage *page;
const PatchEntry *pe = NULL; const PatchEntry *pe = NULL;
bool found = false; bool found = false;
int i; uint i;
unsigned int j; unsigned int j;
int val; int val;
@ -1066,7 +1066,7 @@ void ConsoleGetPatchSetting(char *name)
const PatchEntry *pe = NULL; const PatchEntry *pe = NULL;
char value[50]; char value[50];
bool found = false; bool found = false;
int i; uint i;
unsigned int j; unsigned int j;
/* Search for the name in the patch-settings */ /* Search for the name in the patch-settings */

View File

@ -271,7 +271,7 @@ static void DrawTile_Trees(TileInfo *ti)
{ {
uint16 tmp = ti->x; uint16 tmp = ti->x;
int index; uint index;
tmp = (tmp >> 2) | (tmp << 14); tmp = (tmp >> 2) | (tmp << 14);
tmp -= ti->y; tmp -= ti->y;

4
ttd.c
View File

@ -267,7 +267,7 @@ void LoadDriver(int driver, const char *name)
ttd_strlcpy(buffer, name, sizeof(buffer)); ttd_strlcpy(buffer, name, sizeof(buffer));
parm = strchr(buffer, ':'); parm = strchr(buffer, ':');
if (parm) { if (parm) {
int np = 0; uint np = 0;
// Tokenize the parm. // Tokenize the parm.
do { do {
*parm++ = 0; *parm++ = 0;
@ -1243,7 +1243,7 @@ void UpdateCurrencies()
// even though they should have. This is fixed by this function // even though they should have. This is fixed by this function
void UpdateVoidTiles() void UpdateVoidTiles()
{ {
int i; uint i;
// create void tiles on the border // create void tiles on the border
for (i = 0; i != MapMaxY(); i++) for (i = 0; i != MapMaxY(); i++)
_map_type_and_height[ i * MapSizeX() + MapMaxY() ] = MP_VOID << 4; _map_type_and_height[ i * MapSizeX() + MapMaxY() ] = MP_VOID << 4;

View File

@ -1311,14 +1311,14 @@ static uint32 GetTileTrackStatus_TunnelBridge(uint tile, TransportType mode)
if ((m5 & 0xF0) == 0) { if ((m5 & 0xF0) == 0) {
/* This is a tunnel */ /* This is a tunnel */
if (((m5 & 0xC) >> 2) == mode) { if (((m5 & 0xCU) >> 2) == mode) {
/* Tranport in the tunnel is compatible */ /* Tranport in the tunnel is compatible */
return m5&1 ? 0x202 : 0x101; return m5&1 ? 0x202 : 0x101;
} }
} else if (m5 & 0x80) { } else if (m5 & 0x80) {
/* This is a bridge */ /* This is a bridge */
result = 0; result = 0;
if (((m5 & 0x6) >> 1) == mode) { if (((m5 & 0x6U) >> 1) == mode) {
/* Transport over the bridge is compatible */ /* Transport over the bridge is compatible */
result = m5&1 ? 0x202 : 0x101; result = m5&1 ? 0x202 : 0x101;
} }
@ -1334,7 +1334,7 @@ static uint32 GetTileTrackStatus_TunnelBridge(uint tile, TransportType mode)
return result; return result;
} else { } else {
/* Transport underneath */ /* Transport underneath */
if ((m5 & 0x18) >> 3 != mode) if ((m5 & 0x18U) >> 3 != mode)
/* Incompatible transport underneath */ /* Incompatible transport underneath */
return result; return result;
} }

View File

@ -407,7 +407,7 @@ Window *AllocateWindow(
w->resize.step_height = 1; w->resize.step_height = 1;
{ {
int i; uint i;
for (i=0;i<lengthof(w->custom);i++) for (i=0;i<lengthof(w->custom);i++)
w->custom[i] = 0; w->custom[i] = 0;
} }