Changeset - r18262:3bc00eb1e3da
[Not reviewed]
master
0 17 0
rubidium - 13 years ago 2011-11-04 11:52:19
rubidium@openttd.org
(svn r23108) -Codechange: more uint -> int / byte -> int conversions for Z related variables
17 files changed with 47 insertions and 47 deletions:
0 comments (0 inline, 0 general)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -38,10 +38,10 @@
 

	
 
#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 uint HELI_FLIGHT_ALTITUDE   = 184;  ///< Normal flight altitude of helicopters.
 
static const int PLANE_HOLDING_ALTITUDE = 150;  ///< Altitude of planes in holding pattern (= lowest flight altitude).
 
static const int HELI_FLIGHT_ALTITUDE   = 184;  ///< Normal flight altitude of helicopters.
 

	
 

	
 
void Aircraft::UpdateDeltaXY(Direction direction)
 
@@ -930,7 +930,7 @@ static bool AircraftController(Aircraft 
 
		if (amd.flag & (AMED_TAKEOFF | AMED_SLOWTURN | AMED_LAND)) v->tile = 0;
 

	
 
		/* Adjust Z for land or takeoff? */
 
		uint z = v->z_pos;
 
		int z = v->z_pos;
 

	
 
		if (amd.flag & AMED_TAKEOFF) {
 
			z = min(z + 2, GetAircraftFlyingAltitude(v));
 
@@ -950,7 +950,7 @@ static bool AircraftController(Aircraft 
 
				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? */
 
			assert(curz <= z);
 
@@ -966,7 +966,7 @@ static bool AircraftController(Aircraft 
 

	
 
		/* We've landed. Decrease speed when we're reaching end of runway. */
 
		if (amd.flag & AMED_BRAKE) {
 
			uint curz = GetSlopePixelZ(x, y) + 1;
 
			int curz = GetSlopePixelZ(x, y) + 1;
 

	
 
			if (z > curz) {
 
				z--;
src/disaster_cmd.cpp
Show inline comments
 
@@ -133,7 +133,7 @@ static void DisasterVehicleUpdateImage(D
 
 * Initialize a disaster vehicle. These vehicles are of type VEH_DISASTER, are unclickable
 
 * 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->y_pos = y;
 
@@ -152,7 +152,7 @@ static void InitializeDisasterVehicle(Di
 
	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->y_pos = y;
 
@@ -249,7 +249,7 @@ static bool DisasterTick_Zeppeliner(Disa
 

	
 
	int x = v->x_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;
 
	SetDisasterVehiclePos(v, x, y, z);
 

	
 
@@ -344,7 +344,7 @@ static bool DisasterTick_Ufo(DisasterVeh
 
		v->direction = GetDirectionTowards(v, u->x_pos, u->y_pos);
 
		GetNewVehiclePosResult gp = GetNewVehiclePos(v);
 

	
 
		byte z = v->z_pos;
 
		int z = v->z_pos;
 
		if (dist <= TILE_SIZE && z > u->z_pos) z--;
 
		SetDisasterVehiclePos(v, gp.x, gp.y, z);
 

	
 
@@ -509,7 +509,7 @@ static bool DisasterTick_Big_Ufo(Disaste
 
			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) {
 
			SetDisasterVehiclePos(v, v->x_pos, v->y_pos, v->z_pos - 1);
 
			return true;
src/elrail.cpp
Show inline comments
 
@@ -209,7 +209,7 @@ static void AdjustTileh(TileIndex tile, 
 
 * @param PCPpos The PCP of the tile.
 
 * @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.
 
	 * PCPs are always on a tile edge.
 
@@ -225,7 +225,7 @@ static byte GetPCPElevation(TileIndex ti
 
	 * 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);
 
}
 

	
src/ground_vehicle.hpp
Show inline comments
 
@@ -143,7 +143,7 @@ struct GroundVehicle : public Specialize
 
			 * direction it is sloped, we get the 'z' at the center of
 
			 * the tile (middle_z) and the edge of the tile (old_z),
 
			 * 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) {
 
				SetBit(this->gv_flags, (middle_z > this->z_pos) ? GVF_GOINGUP_BIT : GVF_GOINGDOWN_BIT);
src/industry_cmd.cpp
Show inline comments
 
@@ -698,7 +698,7 @@ static void CreateChimneySmoke(TileIndex
 
{
 
	uint x = TileX(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);
 
}
src/newgrf_canal.cpp
Show inline comments
 
@@ -48,7 +48,7 @@ static uint32 CanalGetVariable(const Res
 
	switch (variable) {
 
		/* Height of tile */
 
		case 0x80: {
 
			uint z = GetTileZ(tile);
 
			int z = GetTileZ(tile);
 
			/* Return consistent height within locks */
 
			if (IsTileType(tile, MP_WATER) && IsLock(tile) && GetLockPart(tile) == LOCK_PART_UPPER) z--;
 
			return z;
src/rail_cmd.cpp
Show inline comments
 
@@ -1774,7 +1774,7 @@ static void DrawTrackFence_NE_SW(const T
 
 */
 
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,
 
		ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z);
 
}
 
@@ -1784,7 +1784,7 @@ static void DrawTrackFence_NS_1(const Ti
 
 */
 
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,
 
		ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z);
 
}
 
@@ -1794,7 +1794,7 @@ static void DrawTrackFence_NS_2(const Ti
 
 */
 
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,
 
		ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z);
 
}
 
@@ -1804,7 +1804,7 @@ static void DrawTrackFence_WE_1(const Ti
 
 */
 
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,
 
		ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z);
 
}
 
@@ -2787,7 +2787,7 @@ static VehicleEnterTileStatus VehicleEnt
 
 * @param tileh_new New TileSlope.
 
 * @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);
 

	
src/road_cmd.cpp
Show inline comments
 
@@ -1112,7 +1112,7 @@ static void DrawRoadDetail(SpriteID img,
 
{
 
	int x = ti->x | dx;
 
	int y = ti->y | dy;
 
	byte z = ti->z;
 
	int z = ti->z;
 
	if (ti->tileh != SLOPE_FLAT) z = GetSlopePixelZ(x, y);
 
	AddSortableSpriteToDraw(img, PAL_NONE, x, y, 2, 2, h, z);
 
}
src/sound.cpp
Show inline comments
 
@@ -255,7 +255,7 @@ void SndPlayTileFx(SoundID sound, TileIn
 
	/* emits sound from center of the tile */
 
	int x = min(MapMaxX() - 1, TileX(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);
 
	y += 2 * TILE_SIZE;
 
	Point pt2 = RemapCoords(x, y, GetSlopePixelZ(x, y));
src/station_cmd.cpp
Show inline comments
 
@@ -306,8 +306,8 @@ static StringID GenerateStationName(Stat
 
	}
 

	
 
	/* check elevation compared to town */
 
	uint z = GetTileZ(tile);
 
	uint z2 = GetTileZ(t->xy);
 
	int z = GetTileZ(tile);
 
	int z2 = GetTileZ(t->xy);
 
	if (z < z2) {
 
		if (HasBit(free_names, M(STR_SV_STNAME_VALLEY))) return STR_SV_STNAME_VALLEY;
 
	} else if (z > z2) {
src/town_cmd.cpp
Show inline comments
 
@@ -1930,7 +1930,7 @@ static inline bool CanBuildHouseHere(Til
 
 * @return true iff house can be built here
 
 * @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;
 

	
 
@@ -1950,7 +1950,7 @@ static inline bool CheckBuildHouseSameZ(
 
 * @return true iff house can be built
 
 * @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 */
 
	if (!CheckBuildHouseSameZ(tile, town, z, noslope)) return false;
 
@@ -2039,7 +2039,7 @@ static inline bool TownLayoutAllows2x2Ho
 
 * @param noslope are slopes forbidden?
 
 * @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 */
 

	
 
@@ -2064,7 +2064,7 @@ static bool CheckTownBuild2House(TileInd
 
 * @param maxz all tiles should have the same height
 
 * @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;
 

	
 
@@ -2139,7 +2139,7 @@ static bool BuildTownHouse(Town *t, Tile
 
		houses[num++] = (HouseID)i;
 
	}
 

	
 
	uint maxz = GetTileMaxZ(tile);
 
	int maxz = GetTileMaxZ(tile);
 
	TileIndex baseTile = tile;
 

	
 
	while (probability_max > 0) {
src/train_cmd.cpp
Show inline comments
 
@@ -2696,7 +2696,7 @@ static const RailtypeSlowdownParams _rai
 
};
 

	
 
/** 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;
 

	
 
@@ -3160,7 +3160,7 @@ static void TrainController(Train *v, Ve
 
		v->y_pos = gp.y;
 

	
 
		/* 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) {
 
			/* This is the first vehicle in the train */
src/tree_cmd.cpp
Show inline comments
 
@@ -493,7 +493,7 @@ static void DrawTile_Trees(TileInfo *ti)
 
	}
 

	
 
	/* 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--) {
 
		uint min = te[0].x + te[0].y;
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -1144,7 +1144,7 @@ static void DrawTile_TunnelBridge(TileIn
 

	
 
			if (HasBit(rts, ROADTYPE_TRAM)) {
 
				uint offset = tunnelbridge_direction;
 
				uint z = ti->z;
 
				int z = ti->z;
 
				if (ti->tileh != SLOPE_FLAT) {
 
					offset = (offset + 1) & 1;
 
					z += TILE_HEIGHT;
 
@@ -1278,7 +1278,7 @@ void DrawBridgeMiddle(const TileInfo *ti
 
	int x = ti->x;
 
	int y = ti->y;
 
	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. */
 
	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(TileIn
 
			/* 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.
 
			 * (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())) {
 
				SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert);
 
				MarkTileDirtyByTile(tile);
src/vehicle.cpp
Show inline comments
 
@@ -415,7 +415,7 @@ bool HasVehicleOnPos(TileIndex tile, voi
 
 */
 
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->z_pos > z) return NULL;
 
@@ -430,7 +430,7 @@ static Vehicle *EnsureNoVehicleProcZ(Veh
 
 */
 
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
 
	 * error message only (which may be different for different machines).
src/viewport.cpp
Show inline comments
 
@@ -369,7 +369,7 @@ static Point TranslateXYToTileCoord(cons
 
{
 
	Point pt;
 
	int a, b;
 
	uint z;
 
	int z;
 

	
 
	if ( (uint)(x -= vp->left) >= (uint)vp->width ||
 
				(uint)(y -= vp->top) >= (uint)vp->height) {
 
@@ -400,12 +400,12 @@ static Point TranslateXYToTileCoord(cons
 

	
 
	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 (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 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;
 

	
 
	pt.x = Clamp(a + (int)z, min_coord, MapMaxX() * TILE_SIZE - 1);
 
	pt.y = Clamp(b + (int)z, min_coord, MapMaxY() * TILE_SIZE - 1);
 
	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 (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 + z, min_coord, MapMaxX() * TILE_SIZE - 1), Clamp(b + z, min_coord, MapMaxY() * TILE_SIZE - 1)) / 2;
 

	
 
	pt.x = Clamp(a + z, min_coord, MapMaxX() * TILE_SIZE - 1);
 
	pt.y = Clamp(b + z, min_coord, MapMaxY() * TILE_SIZE - 1);
 

	
 
	return pt;
 
}
src/water_cmd.cpp
Show inline comments
 
@@ -875,7 +875,7 @@ static Vehicle *FloodVehicleProc(Vehicle
 

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

	
 
	if (IsAirportTile(tile)) {
 
		const Station *st = Station::GetByTile(tile);
0 comments (0 inline, 0 general)