# HG changeset patch # User rubidium # Date 1224009531 0 # Node ID 50afe9dd466e9827b4c393e4fd8424c7662453dc # Parent 531716190738d137f51797f8bfd8ee8dfd7e14c8 (svn r14464) -Codechange: replace (uint)-1 with UINT_MAX (PhilSophus) diff -r 531716190738 -r 50afe9dd466e src/ai/default/default.cpp --- a/src/ai/default/default.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/ai/default/default.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -2158,9 +2158,9 @@ arf.depth = 0; arf.recursive_mode = 0; arf.best_ptr = NULL; - arf.cur_best_dist = (uint)-1; + arf.cur_best_dist = UINT_MAX; arf.cur_best_depth = 0xff; - arf.best_dist = (uint)-1; + arf.best_dist = UINT_MAX; arf.best_depth = 0xff; arf.cur_best_tile = 0; arf.best_tile = 0; @@ -2855,7 +2855,7 @@ } } arf->recursive_mode = 0; - arf->cur_best_dist = (uint)-1; + arf->cur_best_dist = UINT_MAX; arf->cur_best_depth = 0xff; return better; @@ -2892,7 +2892,7 @@ TrackdirBits bits = TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, ROADTYPES_ROAD)) & DiagdirReachesTrackdirs(dir); if (bits == TRACKDIR_BIT_NONE) return false; - are.best_dist = (uint)-1; + are.best_dist = UINT_MAX; while (bits != TRACKDIR_BIT_NONE) { Trackdir trackdir = RemoveFirstTrackdir(&bits); @@ -3058,9 +3058,9 @@ arf.depth = 0; arf.recursive_mode = 0; arf.best_ptr = NULL; - arf.cur_best_dist = (uint)-1; + arf.cur_best_dist = UINT_MAX; arf.cur_best_depth = 0xff; - arf.best_dist = (uint)-1; + arf.best_dist = UINT_MAX; arf.best_depth = 0xff; arf.cur_best_tile = 0; arf.best_tile = 0; diff -r 531716190738 -r 50afe9dd466e src/company_cmd.cpp --- a/src/company_cmd.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/company_cmd.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -287,7 +287,7 @@ SetDParam(1, owner); } } else { - const Town *t = ClosestTownFromTile(tile, (uint)-1); + const Town *t = ClosestTownFromTile(tile, UINT_MAX); SetDParam(0, STR_TOWN); SetDParam(1, t->index); @@ -333,7 +333,7 @@ tile = c->last_build_coordinate; if (tile == 0) return; - t = ClosestTownFromTile(tile, (uint)-1); + t = ClosestTownFromTile(tile, UINT_MAX); if (t->name == NULL && IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1)) { str = t->townnametype - SPECSTR_TOWNNAME_START + SPECSTR_PLAYERNAME_START; diff -r 531716190738 -r 50afe9dd466e src/disaster_cmd.cpp --- a/src/disaster_cmd.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/disaster_cmd.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -602,7 +602,7 @@ } } - t = ClosestTownFromTile(v->dest_tile, (uint)-1); + t = ClosestTownFromTile(v->dest_tile, UINT_MAX); SetDParam(0, t->index); AddNewsItem(STR_B004_UFO_LANDS_NEAR, NS_ACCIDENT_TILE, diff -r 531716190738 -r 50afe9dd466e src/economy.cpp --- a/src/economy.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/economy.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -993,7 +993,7 @@ { Town *from,*to; - fr->distance = (uint)-1; + fr->distance = UINT_MAX; fr->from = from = GetRandomTown(); if (from == NULL || from->population < 400) return; @@ -1011,7 +1011,7 @@ int trans, total; CargoID cargo; - fr->distance = (uint)-1; + fr->distance = UINT_MAX; fr->from = i = GetRandomIndustry(); if (i == NULL) return; diff -r 531716190738 -r 50afe9dd466e src/genworld.h --- a/src/genworld.h Tue Oct 14 12:07:14 2008 +0000 +++ b/src/genworld.h Tue Oct 14 18:38:51 2008 +0000 @@ -15,7 +15,7 @@ LG_ORIGINAL = 0, ///< The original landscape generator LG_TERRAGENESIS = 1, ///< TerraGenesis Perlin landscape generator - GENERATE_NEW_SEED = (uint)-1, ///< Create a new random seed + GENERATE_NEW_SEED = UINT_MAX, ///< Create a new random seed }; /* Modes for GenerateWorld */ diff -r 531716190738 -r 50afe9dd466e src/industry_cmd.cpp --- a/src/industry_cmd.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/industry_cmd.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -1190,7 +1190,7 @@ const Town *t; const Industry *i; - t = ClosestTownFromTile(tile, (uint)-1); + t = ClosestTownFromTile(tile, UINT_MAX); if (_settings_game.economy.multiple_industry_per_town) return t; diff -r 531716190738 -r 50afe9dd466e src/newgrf_industries.cpp --- a/src/newgrf_industries.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/newgrf_industries.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -512,7 +512,7 @@ ind.width = 0; ind.type = type; ind.selected_layout = itspec_index; - ind.town = ClosestTownFromTile(tile, (uint)-1); + ind.town = ClosestTownFromTile(tile, UINT_MAX); NewIndustryResolver(&object, tile, &ind, type); object.GetVariable = IndustryLocationGetVariable; diff -r 531716190738 -r 50afe9dd466e src/newgrf_industrytiles.cpp --- a/src/newgrf_industrytiles.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/newgrf_industrytiles.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -79,7 +79,7 @@ case 0x41 : return GetTerrainType(tile); /* Current town zone of the tile in the nearest town */ - case 0x42 : return GetTownRadiusGroup(ClosestTownFromTile(tile, (uint)-1), tile); + case 0x42 : return GetTownRadiusGroup(ClosestTownFromTile(tile, UINT_MAX), tile); /* Relative position */ case 0x43 : return GetRelativePosition(tile, inds->xy); diff -r 531716190738 -r 50afe9dd466e src/npf.cpp --- a/src/npf.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/npf.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -910,8 +910,8 @@ } /* Initialize result */ - result.best_bird_dist = (uint)-1; - result.best_path_dist = (uint)-1; + result.best_bird_dist = UINT_MAX; + result.best_path_dist = UINT_MAX; result.best_trackdir = INVALID_TRACKDIR; result.node.tile = INVALID_TILE; result.res_okay = false; @@ -1000,7 +1000,7 @@ */ Queue depots; int r; - NPFFoundTargetData best_result = {(uint)-1, (uint)-1, INVALID_TRACKDIR, {INVALID_TILE, 0, {0, 0}}, false}; + NPFFoundTargetData best_result = {UINT_MAX, UINT_MAX, INVALID_TRACKDIR, {INVALID_TILE, 0, {0, 0}}, false}; NPFFoundTargetData result; NPFFindStationOrTileData target; AyStarNode start; @@ -1046,8 +1046,8 @@ /* Initialize Result */ _npf_aystar.user_path = &result; - best_result.best_path_dist = (uint)-1; - best_result.best_bird_dist = (uint)-1; + best_result.best_path_dist = UINT_MAX; + best_result.best_bird_dist = UINT_MAX; /* Just iterate the depots in order of increasing distance */ while ((current = (Depot*)depots.pop(&depots))) { @@ -1067,8 +1067,8 @@ _npf_aystar.addstart(&_npf_aystar, &start, 0); /* Initialize result */ - result.best_bird_dist = (uint)-1; - result.best_path_dist = (uint)-1; + result.best_bird_dist = UINT_MAX; + result.best_path_dist = UINT_MAX; result.best_trackdir = INVALID_TRACKDIR; /* Initialize target */ diff -r 531716190738 -r 50afe9dd466e src/npf.h --- a/src/npf.h Tue Oct 14 12:07:14 2008 +0000 +++ b/src/npf.h Tue Oct 14 18:38:51 2008 +0000 @@ -78,7 +78,7 @@ /* Meant to be stored in AyStar.userpath */ struct NPFFoundTargetData { uint best_bird_dist; ///< The best heuristic found. Is 0 if the target was found - uint best_path_dist; ///< The shortest path. Is (uint)-1 if no path is found + uint best_path_dist; ///< The shortest path. Is UINT_MAX if no path is found Trackdir best_trackdir; ///< The trackdir that leads to the shortest path/closest birds dist AyStarNode node; ///< The node within the target the search led us to bool res_okay; ///< True if a path reservation could be made diff -r 531716190738 -r 50afe9dd466e src/openttd.cpp --- a/src/openttd.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/openttd.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -1431,7 +1431,7 @@ AfterLoadTown(); /* make sure there is a town in the game */ - if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, (uint)-1)) { + if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, UINT_MAX)) { SetSaveLoadError(STR_NO_TOWN_IN_SCENARIO); return false; } @@ -1561,13 +1561,13 @@ switch (GetTileType(t)) { case MP_HOUSE: _m[t].m4 = _m[t].m2; - SetTownIndex(t, CalcClosestTownFromTile(t, (uint)-1)->index); + SetTownIndex(t, CalcClosestTownFromTile(t, UINT_MAX)->index); break; case MP_ROAD: _m[t].m4 |= (_m[t].m2 << 4); if ((GB(_m[t].m5, 4, 2) == ROAD_TILE_CROSSING ? (Owner)_m[t].m3 : GetTileOwner(t)) == OWNER_TOWN) { - SetTownIndex(t, CalcClosestTownFromTile(t, (uint)-1)->index); + SetTownIndex(t, CalcClosestTownFromTile(t, UINT_MAX)->index); } else { SetTownIndex(t, 0); } @@ -1694,7 +1694,7 @@ GetRailType(t) ); } else { - TownID town = IsTileOwner(t, OWNER_TOWN) ? ClosestTownFromTile(t, (uint)-1)->index : 0; + TownID town = IsTileOwner(t, OWNER_TOWN) ? ClosestTownFromTile(t, UINT_MAX)->index : 0; MakeRoadNormal( t, @@ -2142,7 +2142,7 @@ if (CheckSavegameVersion(52)) { for (TileIndex t = 0; t < map_size; t++) { if (IsStatueTile(t)) { - _m[t].m2 = CalcClosestTownFromTile(t, (uint)-1)->index; + _m[t].m2 = CalcClosestTownFromTile(t, UINT_MAX)->index; } } } diff -r 531716190738 -r 50afe9dd466e src/rail_cmd.cpp --- a/src/rail_cmd.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/rail_cmd.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -809,7 +809,7 @@ MakeRailDepot(tile, _current_company, dir, (RailType)p1); MarkTileDirtyByTile(tile); - d->town_index = ClosestTownFromTile(tile, (uint)-1)->index; + d->town_index = ClosestTownFromTile(tile, UINT_MAX)->index; AddSideToSignalBuffer(tile, INVALID_DIAGDIR, _current_company); YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir)); @@ -968,7 +968,7 @@ if (IsPbsSignal(sigtype)) { /* PBS signals should show red unless they are on a reservation. */ uint mask = GetPresentSignals(tile) & SignalOnTrack(track); - SetSignalStates(tile, (GetSignalStates(tile) & ~mask) | ((HasBit(GetTrackReservation(tile), track) ? (uint)-1 : 0) & mask)); + SetSignalStates(tile, (GetSignalStates(tile) & ~mask) | ((HasBit(GetTrackReservation(tile), track) ? UINT_MAX : 0) & mask)); } MarkTileDirtyByTile(tile); AddTrackToSignalBuffer(tile, track, _current_company); diff -r 531716190738 -r 50afe9dd466e src/road_cmd.cpp --- a/src/road_cmd.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/road_cmd.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -881,7 +881,7 @@ if (flags & DC_EXEC) { Depot *dep = new Depot(tile); - dep->town_index = ClosestTownFromTile(tile, (uint)-1)->index; + dep->town_index = ClosestTownFromTile(tile, UINT_MAX)->index; MakeRoadDepot(tile, _current_company, dir, rt); MarkTileDirtyByTile(tile); @@ -1331,7 +1331,7 @@ if (IsRoadDepot(tile)) return; - const Town *t = ClosestTownFromTile(tile, (uint)-1); + const Town *t = ClosestTownFromTile(tile, UINT_MAX); if (!HasRoadWorks(tile)) { HouseZonesBits grp = HZB_TOWN_EDGE; diff -r 531716190738 -r 50afe9dd466e src/ship_cmd.cpp --- a/src/ship_cmd.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/ship_cmd.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -409,8 +409,8 @@ do { i = RemoveFirstTrack(&bits); - pfs.best_bird_dist = (uint)-1; - pfs.best_length = (uint)-1; + pfs.best_bird_dist = UINT_MAX; + pfs.best_length = UINT_MAX; FollowTrack(tile, PATHFIND_FLAGS_SHIP_MODE | PATHFIND_FLAGS_DISABLE_TILE_HASH, TRANSPORT_WATER, 0, (DiagDirection)_ship_search_directions[i][dir], (TPFEnumProc*)ShipTrackFollower, NULL, &pfs); diff -r 531716190738 -r 50afe9dd466e src/spritecache.cpp --- a/src/spritecache.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/spritecache.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -425,7 +425,7 @@ /* Display an error message and die, in case we found no sprite at all. * This shouldn't really happen, unless all sprites are locked. */ - if (best == (uint)-1) error("Out of sprite memory"); + if (best == UINT_MAX) error("Out of sprite memory"); /* Mark the block as free (the block must be in use) */ s = (MemBlock*)GetSpriteCache(best)->ptr - 1; diff -r 531716190738 -r 50afe9dd466e src/town_cmd.cpp --- a/src/town_cmd.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/town_cmd.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -95,7 +95,7 @@ case MP_ROAD: case MP_TUNNELBRIDGE: if (IsTileOwner(tile, OWNER_TOWN) && - ClosestTownFromTile(tile, (uint)-1) == this) + ClosestTownFromTile(tile, UINT_MAX) == this) DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); break; diff -r 531716190738 -r 50afe9dd466e src/train_cmd.cpp --- a/src/train_cmd.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/train_cmd.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -2205,7 +2205,7 @@ bool Train::FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse) { TrainFindDepotData tfdd = FindClosestTrainDepot(this, 0); - if (tfdd.best_length == (uint)-1) return false; + if (tfdd.best_length == UINT_MAX) return false; if (location != NULL) *location = tfdd.tile; if (destination != NULL) *destination = GetDepotByTile(tfdd.tile)->index; @@ -4376,7 +4376,7 @@ TrainFindDepotData tfdd = FindClosestTrainDepot(v, MAX_ACCEPTABLE_DEPOT_DIST); /* Only go to the depot if it is not too far out of our way. */ - if (tfdd.best_length == (uint)-1 || tfdd.best_length > MAX_ACCEPTABLE_DEPOT_DIST) { + if (tfdd.best_length == UINT_MAX || tfdd.best_length > MAX_ACCEPTABLE_DEPOT_DIST) { if (v->current_order.IsType(OT_GOTO_DEPOT)) { /* If we were already heading for a depot but it has * suddenly moved farther away, we continue our normal diff -r 531716190738 -r 50afe9dd466e src/tree_cmd.cpp --- a/src/tree_cmd.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/tree_cmd.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -333,7 +333,7 @@ if (p2 >= MapSize()) return CMD_ERROR; /* Check the tree type. It can be random or some valid value within the current climate */ - if (p1 != (uint)-1 && p1 - _tree_base_by_landscape[_settings_game.game_creation.landscape] >= _tree_count_by_landscape[_settings_game.game_creation.landscape]) return CMD_ERROR; + if (p1 != UINT_MAX && p1 - _tree_base_by_landscape[_settings_game.game_creation.landscape] >= _tree_count_by_landscape[_settings_game.game_creation.landscape]) return CMD_ERROR; // make sure sx,sy are smaller than ex,ey ex = TileX(tile); diff -r 531716190738 -r 50afe9dd466e src/tunnelbridge_cmd.cpp --- a/src/tunnelbridge_cmd.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/tunnelbridge_cmd.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -610,7 +610,7 @@ _build_tunnel_endtile = endtile; if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { - t = ClosestTownFromTile(tile, (uint)-1); // town penalty rating + t = ClosestTownFromTile(tile, UINT_MAX); // town penalty rating /* Check if you are allowed to remove the tunnel owned by a town * Removal depends on difficulty settings */ @@ -676,7 +676,7 @@ delta = TileOffsByDiagDir(direction); if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { - t = ClosestTownFromTile(tile, (uint)-1); // town penalty rating + t = ClosestTownFromTile(tile, UINT_MAX); // town penalty rating /* Check if you are allowed to remove the bridge owned by a town * Removal depends on difficulty settings */ diff -r 531716190738 -r 50afe9dd466e src/vehicle.cpp --- a/src/vehicle.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/vehicle.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -970,7 +970,7 @@ Vehicle *CheckClickOnVehicle(const ViewPort *vp, int x, int y) { Vehicle *found = NULL, *v; - uint dist, best_dist = (uint)-1; + uint dist, best_dist = UINT_MAX; if ((uint)(x -= vp->left) >= (uint)vp->width || (uint)(y -= vp->top) >= (uint)vp->height) return NULL; diff -r 531716190738 -r 50afe9dd466e src/water_cmd.cpp --- a/src/water_cmd.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/water_cmd.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -222,7 +222,7 @@ if (flags & DC_EXEC) { Depot *depot = new Depot(tile); - depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; + depot->town_index = ClosestTownFromTile(tile, UINT_MAX)->index; MakeShipDepot(tile, _current_company, DEPOT_NORTH, axis, wc1); MakeShipDepot(tile2, _current_company, DEPOT_SOUTH, axis, wc2); diff -r 531716190738 -r 50afe9dd466e src/waypoint.cpp --- a/src/waypoint.cpp Tue Oct 14 12:07:14 2008 +0000 +++ b/src/waypoint.cpp Tue Oct 14 18:38:51 2008 +0000 @@ -85,7 +85,7 @@ uint32 next = 0; // first waypoint number in the bitmap WaypointID idx = 0; // index where we will stop - wp->town_index = ClosestTownFromTile(wp->xy, (uint)-1)->index; + wp->town_index = ClosestTownFromTile(wp->xy, UINT_MAX)->index; /* Find first unused waypoint number belonging to this town. This can never fail, * as long as there can be at most 65535 waypoints in total. @@ -472,7 +472,7 @@ /* Convert the old 'town_or_string', to 'string' / 'town' / 'town_cn' */ FOR_ALL_WAYPOINTS(wp) { - wp->town_index = ClosestTownFromTile(wp->xy, (uint)-1)->index; + wp->town_index = ClosestTownFromTile(wp->xy, UINT_MAX)->index; wp->town_cn = 0; if (wp->string & 0xC000) { wp->town_cn = wp->string & 0x3F;