mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r14464) -Codechange: replace (uint)-1 with UINT_MAX (PhilSophus)
This commit is contained in:
parent
03bef3fb5b
commit
272b2ef0e9
|
@ -2158,9 +2158,9 @@ static void AiBuildRailConstruct(Company *c)
|
|||
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 @@ static bool AiCheckRoadPathBetter(AiRoadFinder *arf, const byte *p)
|
|||
}
|
||||
}
|
||||
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 @@ static bool AiCheckRoadFinished(Company *c)
|
|||
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 @@ static void AiBuildRoadConstruct(Company *c)
|
|||
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;
|
||||
|
|
|
@ -287,7 +287,7 @@ void GetNameOfOwner(Owner owner, TileIndex tile)
|
|||
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 @@ static void GenerateCompanyName(Company *c)
|
|||
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;
|
||||
|
|
|
@ -602,7 +602,7 @@ static void DisasterTick_Big_Ufo(Vehicle *v)
|
|||
}
|
||||
}
|
||||
|
||||
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,
|
||||
|
|
|
@ -993,7 +993,7 @@ static void FindSubsidyPassengerRoute(FoundRoute *fr)
|
|||
{
|
||||
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 @@ static void FindSubsidyCargoRoute(FoundRoute *fr)
|
|||
int trans, total;
|
||||
CargoID cargo;
|
||||
|
||||
fr->distance = (uint)-1;
|
||||
fr->distance = UINT_MAX;
|
||||
|
||||
fr->from = i = GetRandomIndustry();
|
||||
if (i == NULL) return;
|
||||
|
|
|
@ -15,7 +15,7 @@ enum {
|
|||
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 */
|
||||
|
|
|
@ -1190,7 +1190,7 @@ static const Town *CheckMultipleIndustryInTown(TileIndex tile, int type)
|
|||
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;
|
||||
|
||||
|
|
|
@ -512,7 +512,7 @@ bool CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint itspe
|
|||
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;
|
||||
|
|
|
@ -79,7 +79,7 @@ static uint32 IndustryTileGetVariable(const ResolverObject *object, byte variabl
|
|||
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);
|
||||
|
|
14
src/npf.cpp
14
src/npf.cpp
|
@ -910,8 +910,8 @@ static NPFFoundTargetData NPFRouteInternal(AyStarNode* start1, bool ignore_start
|
|||
}
|
||||
|
||||
/* 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 @@ NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir,
|
|||
*/
|
||||
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 @@ NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir,
|
|||
|
||||
/* 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 @@ NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir,
|
|||
_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 */
|
||||
|
|
|
@ -78,7 +78,7 @@ enum NPFNodeFlag {
|
|||
/* 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
|
||||
|
|
|
@ -1431,7 +1431,7 @@ bool AfterLoadGame()
|
|||
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 @@ bool AfterLoadGame()
|
|||
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 @@ bool AfterLoadGame()
|
|||
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 @@ bool AfterLoadGame()
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -809,7 +809,7 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p
|
|||
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 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32
|
|||
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);
|
||||
|
|
|
@ -881,7 +881,7 @@ CommandCost CmdBuildRoadDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
|
|||
|
||||
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 @@ static void TileLoop_Road(TileIndex tile)
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
@ -409,8 +409,8 @@ static uint FindShipTrack(Vehicle *v, TileIndex tile, DiagDirection dir, TrackBi
|
|||
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);
|
||||
|
||||
|
|
|
@ -425,7 +425,7 @@ static void DeleteEntryFromSpriteCache()
|
|||
|
||||
/* 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;
|
||||
|
|
|
@ -95,7 +95,7 @@ Town::~Town()
|
|||
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;
|
||||
|
||||
|
|
|
@ -2205,7 +2205,7 @@ static TrainFindDepotData FindClosestTrainDepot(Vehicle *v, int max_distance)
|
|||
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 @@ static void CheckIfTrainNeedsService(Vehicle *v)
|
|||
|
||||
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
|
||||
|
|
|
@ -333,7 +333,7 @@ CommandCost CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||
|
||||
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);
|
||||
|
|
|
@ -610,7 +610,7 @@ static CommandCost DoClearTunnel(TileIndex tile, uint32 flags)
|
|||
_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 @@ static CommandCost DoClearBridge(TileIndex tile, uint32 flags)
|
|||
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 */
|
||||
|
|
|
@ -970,7 +970,7 @@ void ViewportAddVehicles(DrawPixelInfo *dpi)
|
|||
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;
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
|
|||
|
||||
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);
|
||||
|
|
|
@ -85,7 +85,7 @@ static void MakeDefaultWaypointName(Waypoint* wp)
|
|||
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 @@ void FixOldWaypoints()
|
|||
|
||||
/* 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;
|
||||
|
|
Loading…
Reference in New Issue