1
0
Fork 0

(svn r23108) -Codechange: more uint -> int / byte -> int conversions for Z related variables

release/1.2
rubidium 2011-11-04 11:52:19 +00:00
parent 459c9523e8
commit 2a2c102b0b
17 changed files with 46 additions and 46 deletions

View File

@ -38,10 +38,10 @@
#include "table/strings.h" #include "table/strings.h"
static const uint ROTOR_Z_OFFSET = 5; ///< Z Offset between helicopter- and rotorsprite. static const int ROTOR_Z_OFFSET = 5; ///< Z Offset between helicopter- and rotorsprite.
static const uint PLANE_HOLDING_ALTITUDE = 150; ///< Altitude of planes in holding pattern (= lowest flight altitude). static const int PLANE_HOLDING_ALTITUDE = 150; ///< Altitude of planes in holding pattern (= lowest flight altitude).
static const uint HELI_FLIGHT_ALTITUDE = 184; ///< Normal flight altitude of helicopters. static const int HELI_FLIGHT_ALTITUDE = 184; ///< Normal flight altitude of helicopters.
void Aircraft::UpdateDeltaXY(Direction direction) void Aircraft::UpdateDeltaXY(Direction direction)
@ -930,7 +930,7 @@ static bool AircraftController(Aircraft *v)
if (amd.flag & (AMED_TAKEOFF | AMED_SLOWTURN | AMED_LAND)) v->tile = 0; if (amd.flag & (AMED_TAKEOFF | AMED_SLOWTURN | AMED_LAND)) v->tile = 0;
/* Adjust Z for land or takeoff? */ /* Adjust Z for land or takeoff? */
uint z = v->z_pos; int z = v->z_pos;
if (amd.flag & AMED_TAKEOFF) { if (amd.flag & AMED_TAKEOFF) {
z = min(z + 2, GetAircraftFlyingAltitude(v)); z = min(z + 2, GetAircraftFlyingAltitude(v));
@ -950,7 +950,7 @@ static bool AircraftController(Aircraft *v)
continue; continue;
} }
uint curz = GetSlopePixelZ(x + amd.x, y + amd.y) + 1; int curz = GetSlopePixelZ(x + amd.x, y + amd.y) + 1;
/* We're not flying below our destination, right? */ /* We're not flying below our destination, right? */
assert(curz <= z); assert(curz <= z);
@ -966,7 +966,7 @@ static bool AircraftController(Aircraft *v)
/* We've landed. Decrease speed when we're reaching end of runway. */ /* We've landed. Decrease speed when we're reaching end of runway. */
if (amd.flag & AMED_BRAKE) { if (amd.flag & AMED_BRAKE) {
uint curz = GetSlopePixelZ(x, y) + 1; int curz = GetSlopePixelZ(x, y) + 1;
if (z > curz) { if (z > curz) {
z--; z--;

View File

@ -133,7 +133,7 @@ static void DisasterVehicleUpdateImage(DisasterVehicle *v)
* Initialize a disaster vehicle. These vehicles are of type VEH_DISASTER, are unclickable * Initialize a disaster vehicle. These vehicles are of type VEH_DISASTER, are unclickable
* and owned by nobody * and owned by nobody
*/ */
static void InitializeDisasterVehicle(DisasterVehicle *v, int x, int y, byte z, Direction direction, byte subtype) static void InitializeDisasterVehicle(DisasterVehicle *v, int x, int y, int z, Direction direction, byte subtype)
{ {
v->x_pos = x; v->x_pos = x;
v->y_pos = y; v->y_pos = y;
@ -152,7 +152,7 @@ static void InitializeDisasterVehicle(DisasterVehicle *v, int x, int y, byte z,
MarkSingleVehicleDirty(v); MarkSingleVehicleDirty(v);
} }
static void SetDisasterVehiclePos(DisasterVehicle *v, int x, int y, byte z) static void SetDisasterVehiclePos(DisasterVehicle *v, int x, int y, int z)
{ {
v->x_pos = x; v->x_pos = x;
v->y_pos = y; v->y_pos = y;
@ -249,7 +249,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
int x = v->x_pos; int x = v->x_pos;
int y = v->y_pos; int y = v->y_pos;
byte z = GetSlopePixelZ(x, y); int z = GetSlopePixelZ(x, y);
if (z < v->z_pos) z = v->z_pos - 1; if (z < v->z_pos) z = v->z_pos - 1;
SetDisasterVehiclePos(v, x, y, z); SetDisasterVehiclePos(v, x, y, z);
@ -344,7 +344,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
v->direction = GetDirectionTowards(v, u->x_pos, u->y_pos); v->direction = GetDirectionTowards(v, u->x_pos, u->y_pos);
GetNewVehiclePosResult gp = GetNewVehiclePos(v); GetNewVehiclePosResult gp = GetNewVehiclePos(v);
byte z = v->z_pos; int z = v->z_pos;
if (dist <= TILE_SIZE && z > u->z_pos) z--; if (dist <= TILE_SIZE && z > u->z_pos) z--;
SetDisasterVehiclePos(v, gp.x, gp.y, z); SetDisasterVehiclePos(v, gp.x, gp.y, z);
@ -509,7 +509,7 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v)
return false; return false;
} }
byte z = GetSlopePixelZ(v->x_pos, v->y_pos); int z = GetSlopePixelZ(v->x_pos, v->y_pos);
if (z < v->z_pos) { if (z < v->z_pos) {
SetDisasterVehiclePos(v, v->x_pos, v->y_pos, v->z_pos - 1); SetDisasterVehiclePos(v, v->x_pos, v->y_pos, v->z_pos - 1);
return true; return true;

View File

@ -209,7 +209,7 @@ static void AdjustTileh(TileIndex tile, Slope *tileh)
* @param PCPpos The PCP of the tile. * @param PCPpos The PCP of the tile.
* @return The Z position of the PCP. * @return The Z position of the PCP.
*/ */
static byte GetPCPElevation(TileIndex tile, DiagDirection PCPpos) static int GetPCPElevation(TileIndex tile, DiagDirection PCPpos)
{ {
/* The elevation of the "pylon"-sprite should be the elevation at the PCP. /* The elevation of the "pylon"-sprite should be the elevation at the PCP.
* PCPs are always on a tile edge. * PCPs are always on a tile edge.
@ -225,7 +225,7 @@ static byte GetPCPElevation(TileIndex tile, DiagDirection PCPpos)
* Also note that the result of GetSlopePixelZ() is very special on bridge-ramps. * Also note that the result of GetSlopePixelZ() is very special on bridge-ramps.
*/ */
byte z = GetSlopePixelZ(TileX(tile) * TILE_SIZE + min(x_pcp_offsets[PCPpos], TILE_SIZE - 1), TileY(tile) * TILE_SIZE + min(y_pcp_offsets[PCPpos], TILE_SIZE - 1)); int z = GetSlopePixelZ(TileX(tile) * TILE_SIZE + min(x_pcp_offsets[PCPpos], TILE_SIZE - 1), TileY(tile) * TILE_SIZE + min(y_pcp_offsets[PCPpos], TILE_SIZE - 1));
return (z + 2) & ~3; // this means z = (z + TILE_HEIGHT / 4) / (TILE_HEIGHT / 2) * (TILE_HEIGHT / 2); return (z + 2) & ~3; // this means z = (z + TILE_HEIGHT / 4) / (TILE_HEIGHT / 2) * (TILE_HEIGHT / 2);
} }

View File

@ -143,7 +143,7 @@ struct GroundVehicle : public SpecializedVehicle<T, Type> {
* direction it is sloped, we get the 'z' at the center of * direction it is sloped, we get the 'z' at the center of
* the tile (middle_z) and the edge of the tile (old_z), * the tile (middle_z) and the edge of the tile (old_z),
* which we then can compare. */ * which we then can compare. */
byte middle_z = GetSlopePixelZ((this->x_pos & ~TILE_UNIT_MASK) | HALF_TILE_SIZE, (this->y_pos & ~TILE_UNIT_MASK) | HALF_TILE_SIZE); int middle_z = GetSlopePixelZ((this->x_pos & ~TILE_UNIT_MASK) | HALF_TILE_SIZE, (this->y_pos & ~TILE_UNIT_MASK) | HALF_TILE_SIZE);
if (middle_z != this->z_pos) { if (middle_z != this->z_pos) {
SetBit(this->gv_flags, (middle_z > this->z_pos) ? GVF_GOINGUP_BIT : GVF_GOINGDOWN_BIT); SetBit(this->gv_flags, (middle_z > this->z_pos) ? GVF_GOINGUP_BIT : GVF_GOINGDOWN_BIT);

View File

@ -698,7 +698,7 @@ static void CreateChimneySmoke(TileIndex tile)
{ {
uint x = TileX(tile) * TILE_SIZE; uint x = TileX(tile) * TILE_SIZE;
uint y = TileY(tile) * TILE_SIZE; uint y = TileY(tile) * TILE_SIZE;
uint z = GetTileMaxPixelZ(tile); int z = GetTileMaxPixelZ(tile);
CreateEffectVehicle(x + 15, y + 14, z + 59, EV_CHIMNEY_SMOKE); CreateEffectVehicle(x + 15, y + 14, z + 59, EV_CHIMNEY_SMOKE);
} }

View File

@ -48,7 +48,7 @@ static uint32 CanalGetVariable(const ResolverObject *object, byte variable, byte
switch (variable) { switch (variable) {
/* Height of tile */ /* Height of tile */
case 0x80: { case 0x80: {
uint z = GetTileZ(tile); int z = GetTileZ(tile);
/* Return consistent height within locks */ /* Return consistent height within locks */
if (IsTileType(tile, MP_WATER) && IsLock(tile) && GetLockPart(tile) == LOCK_PART_UPPER) z--; if (IsTileType(tile, MP_WATER) && IsLock(tile) && GetLockPart(tile) == LOCK_PART_UPPER) z--;
return z; return z;

View File

@ -1774,7 +1774,7 @@ static void DrawTrackFence_NE_SW(const TileInfo *ti, SpriteID base_image)
*/ */
static void DrawTrackFence_NS_1(const TileInfo *ti, SpriteID base_image) static void DrawTrackFence_NS_1(const TileInfo *ti, SpriteID base_image)
{ {
uint z = ti->z + GetSlopePixelZInCorner(RemoveHalftileSlope(ti->tileh), CORNER_W); int z = ti->z + GetSlopePixelZInCorner(RemoveHalftileSlope(ti->tileh), CORNER_W);
AddSortableSpriteToDraw(base_image + RFO_FLAT_VERT, _drawtile_track_palette, AddSortableSpriteToDraw(base_image + RFO_FLAT_VERT, _drawtile_track_palette,
ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z);
} }
@ -1784,7 +1784,7 @@ static void DrawTrackFence_NS_1(const TileInfo *ti, SpriteID base_image)
*/ */
static void DrawTrackFence_NS_2(const TileInfo *ti, SpriteID base_image) static void DrawTrackFence_NS_2(const TileInfo *ti, SpriteID base_image)
{ {
uint z = ti->z + GetSlopePixelZInCorner(RemoveHalftileSlope(ti->tileh), CORNER_E); int z = ti->z + GetSlopePixelZInCorner(RemoveHalftileSlope(ti->tileh), CORNER_E);
AddSortableSpriteToDraw(base_image + RFO_FLAT_VERT, _drawtile_track_palette, AddSortableSpriteToDraw(base_image + RFO_FLAT_VERT, _drawtile_track_palette,
ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z);
} }
@ -1794,7 +1794,7 @@ static void DrawTrackFence_NS_2(const TileInfo *ti, SpriteID base_image)
*/ */
static void DrawTrackFence_WE_1(const TileInfo *ti, SpriteID base_image) static void DrawTrackFence_WE_1(const TileInfo *ti, SpriteID base_image)
{ {
uint z = ti->z + GetSlopePixelZInCorner(RemoveHalftileSlope(ti->tileh), CORNER_N); int z = ti->z + GetSlopePixelZInCorner(RemoveHalftileSlope(ti->tileh), CORNER_N);
AddSortableSpriteToDraw(base_image + RFO_FLAT_HORZ, _drawtile_track_palette, AddSortableSpriteToDraw(base_image + RFO_FLAT_HORZ, _drawtile_track_palette,
ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z);
} }
@ -1804,7 +1804,7 @@ static void DrawTrackFence_WE_1(const TileInfo *ti, SpriteID base_image)
*/ */
static void DrawTrackFence_WE_2(const TileInfo *ti, SpriteID base_image) static void DrawTrackFence_WE_2(const TileInfo *ti, SpriteID base_image)
{ {
uint z = ti->z + GetSlopePixelZInCorner(RemoveHalftileSlope(ti->tileh), CORNER_S); int z = ti->z + GetSlopePixelZInCorner(RemoveHalftileSlope(ti->tileh), CORNER_S);
AddSortableSpriteToDraw(base_image + RFO_FLAT_HORZ, _drawtile_track_palette, AddSortableSpriteToDraw(base_image + RFO_FLAT_HORZ, _drawtile_track_palette,
ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z);
} }
@ -2787,7 +2787,7 @@ static VehicleEnterTileStatus VehicleEnter_Track(Vehicle *u, TileIndex tile, int
* @param tileh_new New TileSlope. * @param tileh_new New TileSlope.
* @param rail_bits Trackbits. * @param rail_bits Trackbits.
*/ */
static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, uint z_old, Slope tileh_old, uint z_new, Slope tileh_new, TrackBits rail_bits) static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, int z_old, Slope tileh_old, int z_new, Slope tileh_new, TrackBits rail_bits)
{ {
if (!_settings_game.construction.build_on_slopes || !AutoslopeEnabled()) return_cmd_error(STR_ERROR_MUST_REMOVE_RAILROAD_TRACK); if (!_settings_game.construction.build_on_slopes || !AutoslopeEnabled()) return_cmd_error(STR_ERROR_MUST_REMOVE_RAILROAD_TRACK);

View File

@ -1112,7 +1112,7 @@ static void DrawRoadDetail(SpriteID img, const TileInfo *ti, int dx, int dy, int
{ {
int x = ti->x | dx; int x = ti->x | dx;
int y = ti->y | dy; int y = ti->y | dy;
byte z = ti->z; int z = ti->z;
if (ti->tileh != SLOPE_FLAT) z = GetSlopePixelZ(x, y); if (ti->tileh != SLOPE_FLAT) z = GetSlopePixelZ(x, y);
AddSortableSpriteToDraw(img, PAL_NONE, x, y, 2, 2, h, z); AddSortableSpriteToDraw(img, PAL_NONE, x, y, 2, 2, h, z);
} }

View File

@ -255,7 +255,7 @@ void SndPlayTileFx(SoundID sound, TileIndex tile)
/* emits sound from center of the tile */ /* emits sound from center of the tile */
int x = min(MapMaxX() - 1, TileX(tile)) * TILE_SIZE + TILE_SIZE / 2; int x = min(MapMaxX() - 1, TileX(tile)) * TILE_SIZE + TILE_SIZE / 2;
int y = min(MapMaxY() - 1, TileY(tile)) * TILE_SIZE - TILE_SIZE / 2; int y = min(MapMaxY() - 1, TileY(tile)) * TILE_SIZE - TILE_SIZE / 2;
uint z = (y < 0 ? 0 : GetSlopePixelZ(x, y)); int z = (y < 0 ? 0 : GetSlopePixelZ(x, y));
Point pt = RemapCoords(x, y, z); Point pt = RemapCoords(x, y, z);
y += 2 * TILE_SIZE; y += 2 * TILE_SIZE;
Point pt2 = RemapCoords(x, y, GetSlopePixelZ(x, y)); Point pt2 = RemapCoords(x, y, GetSlopePixelZ(x, y));

View File

@ -306,8 +306,8 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
} }
/* check elevation compared to town */ /* check elevation compared to town */
uint z = GetTileZ(tile); int z = GetTileZ(tile);
uint z2 = GetTileZ(t->xy); int z2 = GetTileZ(t->xy);
if (z < z2) { if (z < z2) {
if (HasBit(free_names, M(STR_SV_STNAME_VALLEY))) return STR_SV_STNAME_VALLEY; if (HasBit(free_names, M(STR_SV_STNAME_VALLEY))) return STR_SV_STNAME_VALLEY;
} else if (z > z2) { } else if (z > z2) {

View File

@ -1930,7 +1930,7 @@ static inline bool CanBuildHouseHere(TileIndex tile, TownID town, bool noslope)
* @return true iff house can be built here * @return true iff house can be built here
* @see CanBuildHouseHere() * @see CanBuildHouseHere()
*/ */
static inline bool CheckBuildHouseSameZ(TileIndex tile, TownID town, uint z, bool noslope) static inline bool CheckBuildHouseSameZ(TileIndex tile, TownID town, int z, bool noslope)
{ {
if (!CanBuildHouseHere(tile, town, noslope)) return false; if (!CanBuildHouseHere(tile, town, noslope)) return false;
@ -1950,7 +1950,7 @@ static inline bool CheckBuildHouseSameZ(TileIndex tile, TownID town, uint z, boo
* @return true iff house can be built * @return true iff house can be built
* @see CheckBuildHouseSameZ() * @see CheckBuildHouseSameZ()
*/ */
static bool CheckFree2x2Area(TileIndex tile, TownID town, uint z, bool noslope) static bool CheckFree2x2Area(TileIndex tile, TownID town, int z, bool noslope)
{ {
/* we need to check this tile too because we can be at different tile now */ /* we need to check this tile too because we can be at different tile now */
if (!CheckBuildHouseSameZ(tile, town, z, noslope)) return false; if (!CheckBuildHouseSameZ(tile, town, z, noslope)) return false;
@ -2039,7 +2039,7 @@ static inline bool TownLayoutAllows2x2HouseHere(Town *t, TileIndex tile)
* @param noslope are slopes forbidden? * @param noslope are slopes forbidden?
* @param second diagdir from first tile to second tile * @param second diagdir from first tile to second tile
*/ */
static bool CheckTownBuild2House(TileIndex *tile, Town *t, uint maxz, bool noslope, DiagDirection second) static bool CheckTownBuild2House(TileIndex *tile, Town *t, int maxz, bool noslope, DiagDirection second)
{ {
/* 'tile' is already checked in BuildTownHouse() - CanBuildHouseHere() and slope test */ /* 'tile' is already checked in BuildTownHouse() - CanBuildHouseHere() and slope test */
@ -2064,7 +2064,7 @@ static bool CheckTownBuild2House(TileIndex *tile, Town *t, uint maxz, bool noslo
* @param maxz all tiles should have the same height * @param maxz all tiles should have the same height
* @param noslope are slopes forbidden? * @param noslope are slopes forbidden?
*/ */
static bool CheckTownBuild2x2House(TileIndex *tile, Town *t, uint maxz, bool noslope) static bool CheckTownBuild2x2House(TileIndex *tile, Town *t, int maxz, bool noslope)
{ {
TileIndex tile2 = *tile; TileIndex tile2 = *tile;
@ -2139,7 +2139,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile)
houses[num++] = (HouseID)i; houses[num++] = (HouseID)i;
} }
uint maxz = GetTileMaxZ(tile); int maxz = GetTileMaxZ(tile);
TileIndex baseTile = tile; TileIndex baseTile = tile;
while (probability_max > 0) { while (probability_max > 0) {

View File

@ -2696,7 +2696,7 @@ static const RailtypeSlowdownParams _railtype_slowdown[] = {
}; };
/** Modify the speed of the vehicle due to a change in altitude */ /** Modify the speed of the vehicle due to a change in altitude */
static inline void AffectSpeedByZChange(Train *v, byte old_z) static inline void AffectSpeedByZChange(Train *v, int old_z)
{ {
if (old_z == v->z_pos || _settings_game.vehicle.train_acceleration_model != AM_ORIGINAL) return; if (old_z == v->z_pos || _settings_game.vehicle.train_acceleration_model != AM_ORIGINAL) return;
@ -3160,7 +3160,7 @@ static void TrainController(Train *v, Vehicle *nomove)
v->y_pos = gp.y; v->y_pos = gp.y;
/* update the Z position of the vehicle */ /* update the Z position of the vehicle */
byte old_z = v->UpdateInclination(gp.new_tile != gp.old_tile, false); int old_z = v->UpdateInclination(gp.new_tile != gp.old_tile, false);
if (prev == NULL) { if (prev == NULL) {
/* This is the first vehicle in the train */ /* This is the first vehicle in the train */

View File

@ -493,7 +493,7 @@ static void DrawTile_Trees(TileInfo *ti)
} }
/* draw them in a sorted way */ /* draw them in a sorted way */
byte z = ti->z + GetSlopeMaxPixelZ(ti->tileh) / 2; int z = ti->z + GetSlopeMaxPixelZ(ti->tileh) / 2;
for (; trees > 0; trees--) { for (; trees > 0; trees--) {
uint min = te[0].x + te[0].y; uint min = te[0].x + te[0].y;

View File

@ -1144,7 +1144,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
if (HasBit(rts, ROADTYPE_TRAM)) { if (HasBit(rts, ROADTYPE_TRAM)) {
uint offset = tunnelbridge_direction; uint offset = tunnelbridge_direction;
uint z = ti->z; int z = ti->z;
if (ti->tileh != SLOPE_FLAT) { if (ti->tileh != SLOPE_FLAT) {
offset = (offset + 1) & 1; offset = (offset + 1) & 1;
z += TILE_HEIGHT; z += TILE_HEIGHT;
@ -1278,7 +1278,7 @@ void DrawBridgeMiddle(const TileInfo *ti)
int x = ti->x; int x = ti->x;
int y = ti->y; int y = ti->y;
uint bridge_z = GetBridgePixelHeight(rampsouth); uint bridge_z = GetBridgePixelHeight(rampsouth);
uint z = bridge_z - BRIDGE_Z_START; int z = bridge_z - BRIDGE_Z_START;
/* Add a bounding box that separates the bridge from things below it. */ /* Add a bounding box that separates the bridge from things below it. */
AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, x, y, 16, 16, 1, bridge_z - TILE_HEIGHT + BB_Z_SEPARATOR); AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, x, y, 16, 16, 1, bridge_z - TILE_HEIGHT + BB_Z_SEPARATOR);
@ -1457,7 +1457,7 @@ static void TileLoop_TunnelBridge(TileIndex tile)
/* As long as we do not have a snow density, we want to use the density /* As long as we do not have a snow density, we want to use the density
* from the entry endge. For tunnels this is the lowest point for bridges the highest point. * from the entry endge. For tunnels this is the lowest point for bridges the highest point.
* (Independent of foundations) */ * (Independent of foundations) */
uint z = IsBridge(tile) ? GetTileMaxZ(tile) : GetTileZ(tile); int z = IsBridge(tile) ? GetTileMaxZ(tile) : GetTileZ(tile);
if (snow_or_desert != (z > GetSnowLine())) { if (snow_or_desert != (z > GetSnowLine())) {
SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert); SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert);
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);

View File

@ -415,7 +415,7 @@ bool HasVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
*/ */
static Vehicle *EnsureNoVehicleProcZ(Vehicle *v, void *data) static Vehicle *EnsureNoVehicleProcZ(Vehicle *v, void *data)
{ {
byte z = *(byte*)data; int z = *(int*)data;
if (v->type == VEH_DISASTER || (v->type == VEH_AIRCRAFT && v->subtype == AIR_SHADOW)) return NULL; if (v->type == VEH_DISASTER || (v->type == VEH_AIRCRAFT && v->subtype == AIR_SHADOW)) return NULL;
if (v->z_pos > z) return NULL; if (v->z_pos > z) return NULL;
@ -430,7 +430,7 @@ static Vehicle *EnsureNoVehicleProcZ(Vehicle *v, void *data)
*/ */
CommandCost EnsureNoVehicleOnGround(TileIndex tile) CommandCost EnsureNoVehicleOnGround(TileIndex tile)
{ {
byte z = GetTileMaxPixelZ(tile); int z = GetTileMaxPixelZ(tile);
/* Value v is not safe in MP games, however, it is used to generate a local /* Value v is not safe in MP games, however, it is used to generate a local
* error message only (which may be different for different machines). * error message only (which may be different for different machines).

View File

@ -369,7 +369,7 @@ static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
{ {
Point pt; Point pt;
int a, b; int a, b;
uint z; int z;
if ( (uint)(x -= vp->left) >= (uint)vp->width || if ( (uint)(x -= vp->left) >= (uint)vp->width ||
(uint)(y -= vp->top) >= (uint)vp->height) { (uint)(y -= vp->top) >= (uint)vp->height) {
@ -400,12 +400,12 @@ static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
int min_coord = _settings_game.construction.freeform_edges ? TILE_SIZE : 0; int min_coord = _settings_game.construction.freeform_edges ? TILE_SIZE : 0;
for (int i = 0; i < 5; i++) z = GetSlopePixelZ(Clamp(a + (int)max(z, 4u) - 4, min_coord, MapMaxX() * TILE_SIZE - 1), Clamp(b + (int)max(z, 4u) - 4, min_coord, MapMaxY() * TILE_SIZE - 1)) / 2; for (int i = 0; i < 5; i++) z = GetSlopePixelZ(Clamp(a + max(z, 4) - 4, min_coord, MapMaxX() * TILE_SIZE - 1), Clamp(b + max(z, 4) - 4, min_coord, MapMaxY() * TILE_SIZE - 1)) / 2;
for (uint malus = 3; malus > 0; malus--) z = GetSlopePixelZ(Clamp(a + (int)max(z, malus) - (int)malus, min_coord, MapMaxX() * TILE_SIZE - 1), Clamp(b + (int)max(z, malus) - (int)malus, min_coord, MapMaxY() * TILE_SIZE - 1)) / 2; for (int malus = 3; malus > 0; malus--) z = GetSlopePixelZ(Clamp(a + max(z, malus) - malus, min_coord, MapMaxX() * TILE_SIZE - 1), Clamp(b + max(z, malus) - malus, min_coord, MapMaxY() * TILE_SIZE - 1)) / 2;
for (int i = 0; i < 5; i++) z = GetSlopePixelZ(Clamp(a + (int)z, min_coord, MapMaxX() * TILE_SIZE - 1), Clamp(b + (int)z, min_coord, MapMaxY() * TILE_SIZE - 1)) / 2; for (int i = 0; i < 5; i++) z = GetSlopePixelZ(Clamp(a + z, min_coord, MapMaxX() * TILE_SIZE - 1), Clamp(b + z, min_coord, MapMaxY() * TILE_SIZE - 1)) / 2;
pt.x = Clamp(a + (int)z, min_coord, MapMaxX() * TILE_SIZE - 1); pt.x = Clamp(a + z, min_coord, MapMaxX() * TILE_SIZE - 1);
pt.y = Clamp(b + (int)z, min_coord, MapMaxY() * TILE_SIZE - 1); pt.y = Clamp(b + z, min_coord, MapMaxY() * TILE_SIZE - 1);
return pt; return pt;
} }

View File

@ -875,7 +875,7 @@ static Vehicle *FloodVehicleProc(Vehicle *v, void *data)
case VEH_TRAIN: case VEH_TRAIN:
case VEH_ROAD: { case VEH_ROAD: {
byte z = *(byte*)data; int z = *(int*)data;
if (v->z_pos > z) break; if (v->z_pos > z) break;
FloodVehicle(v->First()); FloodVehicle(v->First());
break; break;
@ -892,7 +892,7 @@ static Vehicle *FloodVehicleProc(Vehicle *v, void *data)
*/ */
static void FloodVehicles(TileIndex tile) static void FloodVehicles(TileIndex tile)
{ {
byte z = 0; int z = 0;
if (IsAirportTile(tile)) { if (IsAirportTile(tile)) {
const Station *st = Station::GetByTile(tile); const Station *st = Station::GetByTile(tile);