Changeset - r18247:d176683304d1
[Not reviewed]
master
0 18 0
rubidium - 13 years ago 2011-11-04 10:22:27
rubidium@openttd.org
(svn r23093) -Codechange: add a default NULL for the Z of GetTileSlope and use it
18 files changed with 66 insertions and 66 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_tile.cpp
Show inline comments
 
@@ -142,7 +142,7 @@
 
{
 
	if (!::IsValidTile(tile)) return SLOPE_INVALID;
 

	
 
	return (Slope)::GetTilePixelSlope(tile, NULL);
 
	return (Slope)::GetTileSlope(tile);
 
}
 

	
 
/* static */ AITile::Slope AITile::GetComplementSlope(Slope slope)
src/dock_gui.cpp
Show inline comments
 
@@ -212,7 +212,7 @@ struct BuildDocksToolbarWindow : Window 
 
				CommandContainer cmdcont = { tile, _ctrl_pressed, p2, CMD_BUILD_DOCK | CMD_MSG(STR_ERROR_CAN_T_BUILD_DOCK_HERE), CcBuildDocks, "" };
 

	
 
				/* Determine the watery part of the dock. */
 
				DiagDirection dir = GetInclinedSlopeDirection(GetTilePixelSlope(tile, NULL));
 
				DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile));
 
				TileIndex tile_to = (dir != INVALID_DIAGDIR ? TileAddByDiagDir(tile, ReverseDiagDir(dir)) : tile);
 

	
 
				ShowSelectStationIfNeeded(cmdcont, TileArea(tile, tile_to));
 
@@ -276,7 +276,7 @@ struct BuildDocksToolbarWindow : Window 
 
		if (this->last_clicked_widget == DTW_BUILD_AQUEDUCT) {
 
			GetOtherAqueductEnd(tile_from, &tile_to);
 
		} else {
 
			DiagDirection dir = GetInclinedSlopeDirection(GetTilePixelSlope(tile_from, NULL));
 
			DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile_from));
 
			if (IsValidDiagDirection(dir)) {
 
				/* Locks and docks always select the tile "down" the slope. */
 
				tile_to = TileAddByDiagDir(tile_from, ReverseDiagDir(dir));
src/elrail.cpp
Show inline comments
 
@@ -317,9 +317,9 @@ static void DrawCatenaryRailway(const Ti
 
		TileIndex neighbour = ti->tile + TileOffsByDiagDir(i);
 
		byte elevation = GetPCPElevation(ti->tile, i);
 

	
 
		/* Here's one of the main headaches. GetTilePixelSlope does not correct for possibly
 
		/* Here's one of the main headaches. GetTileSlope does not correct for possibly
 
		 * existing foundataions, so we do have to do that manually later on.*/
 
		tileh[TS_NEIGHBOUR] = GetTilePixelSlope(neighbour, NULL);
 
		tileh[TS_NEIGHBOUR] = GetTileSlope(neighbour);
 
		trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, NULL);
 
		wireconfig[TS_NEIGHBOUR] = MaskWireBits(neighbour, trackconfig[TS_NEIGHBOUR]);
 
		if (IsTunnelTile(neighbour) && i != GetTunnelBridgeDirection(neighbour)) wireconfig[TS_NEIGHBOUR] = trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE;
src/industry_cmd.cpp
Show inline comments
 
@@ -1359,7 +1359,7 @@ static CommandCost CheckIfIndustryTilesA
 

	
 
		if (gfx == GFX_WATERTILE_SPECIALCHECK) {
 
			if (!IsTileType(cur_tile, MP_WATER) ||
 
					GetTilePixelSlope(cur_tile, NULL) != SLOPE_FLAT) {
 
					GetTileSlope(cur_tile) != SLOPE_FLAT) {
 
				return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
 
			}
 
		} else {
 
@@ -1379,7 +1379,7 @@ static CommandCost CheckIfIndustryTilesA
 
				CommandCost ret = PerformIndustryTileSlopeCheck(tile, cur_tile, its, type, gfx, itspec_index, initial_random_bits, founder, creation_type);
 
				if (ret.Failed()) return ret;
 
			} else {
 
				Slope tileh = GetTilePixelSlope(cur_tile, NULL);
 
				Slope tileh = GetTileSlope(cur_tile);
 
				refused_slope |= IsSlopeRefused(tileh, its->slopes_refused);
 
			}
 

	
 
@@ -2724,7 +2724,7 @@ static CommandCost TerraformTile_Industr
 
		 *  - Allow autoslope by default.
 
		 *  - Disallow autoslope if callback succeeds and returns non-zero.
 
		 */
 
		Slope tileh_old = GetTilePixelSlope(tile, NULL);
 
		Slope tileh_old = GetTileSlope(tile);
 
		/* TileMaxZ must not be changed. Slopes must not be steep. */
 
		if (!IsSteepSlope(tileh_old) && !IsSteepSlope(tileh_new) && (GetTileMaxPixelZ(tile) == z_new + GetSlopeMaxPixelZ(tileh_new))) {
 
			const IndustryGfx gfx = GetIndustryGfx(tile);
src/landscape.cpp
Show inline comments
 
@@ -964,7 +964,7 @@ static bool FindSpring(TileIndex tile, v
 
static bool MakeLake(TileIndex tile, void *user_data)
 
{
 
	uint height = *(uint*)user_data;
 
	if (!IsValidTile(tile) || TileHeight(tile) != height || GetTilePixelSlope(tile, NULL) != SLOPE_FLAT) return false;
 
	if (!IsValidTile(tile) || TileHeight(tile) != height || GetTileSlope(tile) != SLOPE_FLAT) return false;
 
	if (_settings_game.game_creation.landscape == LT_TROPIC && GetTropicZone(tile) == TROPICZONE_DESERT) return false;
 

	
 
	for (DiagDirection d = DIAGDIR_BEGIN; d < DIAGDIR_END; d++) {
 
@@ -1113,7 +1113,7 @@ static bool FlowRiver(bool *marks, TileI
 
		queue.pop_front();
 

	
 
		uint height2 = TileHeight(end);
 
		if (GetTilePixelSlope(end, NULL) == SLOPE_FLAT && (height2 < height || (height2 == height && IsWaterTile(end)))) {
 
		if (GetTileSlope(end) == SLOPE_FLAT && (height2 < height || (height2 == height && IsWaterTile(end)))) {
 
			found = true;
 
			break;
 
		}
 
@@ -1140,7 +1140,7 @@ static bool FlowRiver(bool *marks, TileI
 

	
 
		if (IsValidTile(lakeCenter) &&
 
				/* A river, or lake, can only be built on flat slopes. */
 
				GetTilePixelSlope(lakeCenter, NULL) == SLOPE_FLAT &&
 
				GetTileSlope(lakeCenter) == SLOPE_FLAT &&
 
				/* We want the lake to be built at the height of the river. */
 
				TileHeight(begin) == TileHeight(lakeCenter) &&
 
				/* We don't want the lake at the entry of the valley. */
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -295,7 +295,7 @@ CommandCost PerformIndustryTileSlopeChec
 

	
 
	uint16 callback_res = GetIndustryTileCallback(CBID_INDTILE_SHAPE_CHECK, 0, creation_type << 8 | itspec_index, gfx, &ind, ind_tile);
 
	if (callback_res == CALLBACK_FAILED) {
 
		if (!IsSlopeRefused(GetTilePixelSlope(ind_tile, NULL), its->slopes_refused)) return CommandCost();
 
		if (!IsSlopeRefused(GetTileSlope(ind_tile), its->slopes_refused)) return CommandCost();
 
		return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
 
	}
 
	if (its->grf_prop.grffile->grf_version < 7) {
src/newgrf_object.cpp
Show inline comments
 
@@ -289,7 +289,7 @@ static uint32 ObjectGetVariable(const Re
 
		}
 

	
 
		/* Tile information. */
 
		case 0x41: return GetTilePixelSlope(tile, NULL) << 8 | GetTerrainType(tile);
 
		case 0x41: return GetTileSlope(tile) << 8 | GetTerrainType(tile);
 

	
 
		/* Construction date */
 
		case 0x42: return o->build_date;
src/newgrf_station.cpp
Show inline comments
 
@@ -293,7 +293,7 @@ static uint32 StationGetVariable(const R
 
				if (object->u.station.axis != INVALID_AXIS && tile != INVALID_TILE) {
 
					if (parameter != 0) tile = GetNearbyTile(parameter, tile, true, object->u.station.axis); // only perform if it is required
 

	
 
					Slope tileh = GetTilePixelSlope(tile, NULL);
 
					Slope tileh = GetTileSlope(tile);
 
					bool swap = (object->u.station.axis == AXIS_Y && HasBit(tileh, CORNER_W) != HasBit(tileh, CORNER_E));
 

	
 
					return GetNearbyTileInformation(tile) ^ (swap ? SLOPE_EW : 0);
 
@@ -350,7 +350,7 @@ static uint32 StationGetVariable(const R
 

	
 
			if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required
 

	
 
			Slope tileh = GetTilePixelSlope(tile, NULL);
 
			Slope tileh = GetTileSlope(tile);
 
			bool swap = (axis == AXIS_Y && HasBit(tileh, CORNER_W) != HasBit(tileh, CORNER_E));
 

	
 
			return GetNearbyTileInformation(tile) ^ (swap ? SLOPE_EW : 0);
 
@@ -678,7 +678,7 @@ uint16 GetStationCallback(CallbackID cal
 
CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_tile, const StationSpec *statspec, Axis axis, byte plat_len, byte numtracks)
 
{
 
	TileIndexDiff diff = cur_tile - north_tile;
 
	Slope slope = GetTilePixelSlope(cur_tile, NULL);
 
	Slope slope = GetTileSlope(cur_tile);
 

	
 
	ResolverObject object;
 
	NewStationResolver(&object, statspec, NULL, cur_tile);
src/object_cmd.cpp
Show inline comments
 
@@ -236,7 +236,7 @@ CommandCost CmdBuildObject(TileIndex til
 
			uint16 callback = CALLBACK_FAILED;
 
			if (HasBit(spec->callback_mask, CBM_OBJ_SLOPE_CHECK)) {
 
				TileIndex diff = t - tile;
 
				callback = GetObjectCallback(CBID_OBJECT_LAND_SLOPE_CHECK, GetTilePixelSlope(t, NULL), TileY(diff) << 4 | TileX(diff), spec, NULL, t, view);
 
				callback = GetObjectCallback(CBID_OBJECT_LAND_SLOPE_CHECK, GetTileSlope(t), TileY(diff) << 4 | TileX(diff), spec, NULL, t, view);
 
			}
 

	
 
			if (callback == CALLBACK_FAILED) {
 
@@ -276,7 +276,7 @@ CommandCost CmdBuildObject(TileIndex til
 
	switch (type) {
 
		case OBJECT_TRANSMITTER:
 
		case OBJECT_LIGHTHOUSE:
 
			if (GetTilePixelSlope(tile, NULL) != SLOPE_FLAT) return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
 
			if (GetTileSlope(tile) != SLOPE_FLAT) return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
 
			break;
 

	
 
		case OBJECT_OWNED_LAND:
 
@@ -731,7 +731,7 @@ static CommandCost TerraformTile_Object(
 
		 *  - Allow autoslope by default.
 
		 *  - Disallow autoslope if callback succeeds and returns non-zero.
 
		 */
 
		Slope tileh_old = GetTilePixelSlope(tile, NULL);
 
		Slope tileh_old = GetTileSlope(tile);
 
		/* TileMaxZ must not be changed. Slopes must not be steep. */
 
		if (!IsSteepSlope(tileh_old) && !IsSteepSlope(tileh_new) && (GetTileMaxPixelZ(tile) == z_new + GetSlopeMaxPixelZ(tileh_new))) {
 
			const ObjectSpec *spec = ObjectSpec::Get(type);
src/pathfinder/yapf/yapf_costbase.hpp
Show inline comments
 
@@ -27,13 +27,13 @@ struct CYapfCostBase {
 
				/* it is bridge ramp, check if we are entering the bridge */
 
				if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(td)) return false; // no, we are leaving it, no penalty
 
				/* we are entering the bridge */
 
				Slope tile_slope = GetTilePixelSlope(tile, NULL);
 
				Slope tile_slope = GetTileSlope(tile);
 
				Axis axis = DiagDirToAxis(GetTunnelBridgeDirection(tile));
 
				return !HasBridgeFlatRamp(tile_slope, axis);
 
			} else {
 
				/* not bridge ramp */
 
				if (IsTunnelTile(tile)) return false; // tunnel entry/exit doesn't slope
 
				Slope tile_slope = GetTilePixelSlope(tile, NULL);
 
				Slope tile_slope = GetTileSlope(tile);
 
				return IsUphillTrackdir(tile_slope, td); // slopes uphill => apply penalty
 
			}
 
		}
src/rail_cmd.cpp
Show inline comments
 
@@ -381,7 +381,7 @@ CommandCost CmdBuildSingleRail(TileIndex
 

	
 
	if (!ValParamRailtype(railtype) || !ValParamTrackOrientation(track)) return CMD_ERROR;
 

	
 
	Slope tileh = GetTilePixelSlope(tile, NULL);
 
	Slope tileh = GetTileSlope(tile);
 
	TrackBits trackbit = TrackToTrackBits(track);
 

	
 
	switch (GetTileType(tile)) {
 
@@ -590,7 +590,7 @@ CommandCost CmdRemoveSingleRail(TileInde
 
				owner = GetTileOwner(tile);
 
				present ^= trackbit;
 
				if (present == 0) {
 
					Slope tileh = GetTilePixelSlope(tile, NULL);
 
					Slope tileh = GetTileSlope(tile);
 
					/* If there is flat water on the lower halftile, convert the tile to shore so the water remains */
 
					if (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh)) {
 
						MakeShore(tile);
 
@@ -649,7 +649,7 @@ bool FloodHalftile(TileIndex t)
 
	bool flooded = false;
 
	if (GetRailGroundType(t) == RAIL_GROUND_WATER) return flooded;
 

	
 
	Slope tileh = GetTilePixelSlope(t, NULL);
 
	Slope tileh = GetTileSlope(t);
 
	TrackBits rail_bits = GetTrackBits(t);
 

	
 
	if (IsSlopeWithOneCornerRaised(tileh)) {
 
@@ -861,7 +861,7 @@ CommandCost CmdBuildTrainDepot(TileIndex
 
	RailType railtype = Extract<RailType, 0, 4>(p1);
 
	if (!ValParamRailtype(railtype)) return CMD_ERROR;
 

	
 
	Slope tileh = GetTilePixelSlope(tile, NULL);
 
	Slope tileh = GetTileSlope(tile);
 

	
 
	DiagDirection dir = Extract<DiagDirection, 0, 2>(p2);
 

	
 
@@ -1637,7 +1637,7 @@ static CommandCost ClearTile_Track(TileI
 
	switch (GetRailTileType(tile)) {
 
		case RAIL_TILE_SIGNALS:
 
		case RAIL_TILE_NORMAL: {
 
			Slope tileh = GetTilePixelSlope(tile, NULL);
 
			Slope tileh = GetTileSlope(tile);
 
			/* Is there flat water on the lower halftile that gets cleared expensively? */
 
			bool water_ground = (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh));
 

	
src/road_cmd.cpp
Show inline comments
 
@@ -254,7 +254,7 @@ static CommandCost RemoveRoad(TileIndex 
 

	
 
	switch (GetRoadTileType(tile)) {
 
		case ROAD_TILE_NORMAL: {
 
			Slope tileh = GetTilePixelSlope(tile, NULL);
 
			Slope tileh = GetTileSlope(tile);
 

	
 
			/* Steep slopes behave the same as slopes with one corner raised. */
 
			if (IsSteepSlope(tileh)) {
 
@@ -467,7 +467,7 @@ CommandCost CmdBuildRoad(TileIndex tile,
 

	
 
	DisallowedRoadDirections toggle_drd = Extract<DisallowedRoadDirections, 6, 2>(p1);
 

	
 
	Slope tileh = GetTilePixelSlope(tile, NULL);
 
	Slope tileh = GetTileSlope(tile);
 

	
 
	bool need_to_clear = false;
 
	switch (GetTileType(tile)) {
 
@@ -636,7 +636,7 @@ do_clear:;
 

	
 
			/* Check if new road bits will have the same foundation as other existing road types */
 
			if (IsNormalRoad(tile)) {
 
				Slope slope = GetTilePixelSlope(tile, NULL);
 
				Slope slope = GetTileSlope(tile);
 
				Foundation found_new = GetRoadFoundation(slope, pieces | existing);
 

	
 
				/* Test if all other roadtypes can be built at that foundation */
 
@@ -909,7 +909,7 @@ CommandCost CmdBuildRoadDepot(TileIndex 
 

	
 
	if (!IsValidRoadType(rt) || !ValParamRoadType(rt)) return CMD_ERROR;
 

	
 
	Slope tileh = GetTilePixelSlope(tile, NULL);
 
	Slope tileh = GetTileSlope(tile);
 
	if (tileh != SLOPE_FLAT && (
 
				!_settings_game.construction.build_on_slopes ||
 
				!CanBuildDepotByTileh(dir, tileh)
src/saveload/afterload.cpp
Show inline comments
 
@@ -77,7 +77,7 @@ void SetWaterClassDependingOnSurrounding
 
{
 
	/* If the slope is not flat, we always assume 'land' (if allowed). Also for one-corner-raised-shores.
 
	 * Note: Wrt. autosloping under industry tiles this is the most fool-proof behaviour. */
 
	if (GetTilePixelSlope(t, NULL) != SLOPE_FLAT) {
 
	if (GetTileSlope(t) != SLOPE_FLAT) {
 
		if (include_invalid_water_class) {
 
			SetWaterClass(t, WATER_CLASS_INVALID);
 
			return;
 
@@ -1060,7 +1060,7 @@ bool AfterLoadGame()
 
						if (GB(_m[t].m5, 3, 2) == 0) {
 
							MakeClear(t, CLEAR_GRASS, 3);
 
						} else {
 
							if (GetTilePixelSlope(t, NULL) != SLOPE_FLAT) {
 
							if (GetTileSlope(t) != SLOPE_FLAT) {
 
								MakeShore(t);
 
							} else {
 
								if (GetTileOwner(t) == OWNER_WATER) {
 
@@ -1670,7 +1670,7 @@ bool AfterLoadGame()
 
		 * on its neighbouring tiles. Done after river and canal updates to
 
		 * ensure neighbours are correct. */
 
		for (TileIndex t = 0; t < map_size; t++) {
 
			if (GetTilePixelSlope(t, NULL) != SLOPE_FLAT) continue;
 
			if (GetTileSlope(t) != SLOPE_FLAT) continue;
 

	
 
			if (IsTileType(t, MP_WATER) && IsLock(t)) SetWaterClassDependingOnSurroundings(t, false);
 
			if (IsTileType(t, MP_STATION) && (IsDock(t) || IsBuoy(t))) SetWaterClassDependingOnSurroundings(t, false);
 
@@ -2355,7 +2355,7 @@ bool AfterLoadGame()
 
	if (IsSavegameVersionBefore(149)) {
 
		for (TileIndex t = 0; t < map_size; t++) {
 
			if (!IsTileType(t, MP_STATION)) continue;
 
			if (!IsBuoy(t) && !IsOilRig(t) && !(IsDock(t) && GetTilePixelSlope(t, NULL) == SLOPE_FLAT)) {
 
			if (!IsBuoy(t) && !IsOilRig(t) && !(IsDock(t) && GetTileSlope(t) == SLOPE_FLAT)) {
 
				SetWaterClass(t, WATER_CLASS_INVALID);
 
			}
 
		}
src/station_cmd.cpp
Show inline comments
 
@@ -2347,7 +2347,7 @@ CommandCost CmdBuildDock(TileIndex tile,
 

	
 
	if (distant_join && (!_settings_game.station.distant_join_stations || !Station::IsValidID(station_to_join))) return CMD_ERROR;
 

	
 
	DiagDirection direction = GetInclinedSlopeDirection(GetTilePixelSlope(tile, NULL));
 
	DiagDirection direction = GetInclinedSlopeDirection(GetTileSlope(tile));
 
	if (direction == INVALID_DIAGDIR) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
 
	direction = ReverseDiagDir(direction);
 

	
 
@@ -2364,7 +2364,7 @@ CommandCost CmdBuildDock(TileIndex tile,
 

	
 
	TileIndex tile_cur = tile + TileOffsByDiagDir(direction);
 

	
 
	if (!IsTileType(tile_cur, MP_WATER) || GetTilePixelSlope(tile_cur, NULL) != SLOPE_FLAT) {
 
	if (!IsTileType(tile_cur, MP_WATER) || GetTileSlope(tile_cur) != SLOPE_FLAT) {
 
		return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
 
	}
 

	
 
@@ -2377,7 +2377,7 @@ CommandCost CmdBuildDock(TileIndex tile,
 
	if (ret.Failed()) return ret;
 

	
 
	tile_cur += TileOffsByDiagDir(direction);
 
	if (!IsTileType(tile_cur, MP_WATER) || GetTilePixelSlope(tile_cur, NULL) != SLOPE_FLAT) {
 
	if (!IsTileType(tile_cur, MP_WATER) || GetTileSlope(tile_cur) != SLOPE_FLAT) {
 
		return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
 
	}
 

	
 
@@ -2898,7 +2898,7 @@ static void TileLoop_Station(TileIndex t
 
			break;
 

	
 
		case STATION_DOCK:
 
			if (GetTilePixelSlope(tile, NULL) != SLOPE_FLAT) break; // only handle water part
 
			if (GetTileSlope(tile) != SLOPE_FLAT) break; // only handle water part
 
			/* FALL THROUGH */
 
		case STATION_OILRIG: //(station part)
 
		case STATION_BUOY:
src/town_cmd.cpp
Show inline comments
 
@@ -787,7 +787,7 @@ static bool IsRoadAllowedHere(Town *t, T
 
		}
 
	}
 

	
 
	Slope cur_slope = _settings_game.construction.build_on_slopes ? GetFoundationPixelSlope(tile, NULL) : GetTilePixelSlope(tile, NULL);
 
	Slope cur_slope = _settings_game.construction.build_on_slopes ? GetFoundationPixelSlope(tile, NULL) : GetTileSlope(tile);
 
	bool ret = !IsNeighborRoadTile(tile, dir, t->layout == TL_ORIGINAL ? 1 : 2);
 
	if (cur_slope == SLOPE_FLAT) return ret;
 

	
 
@@ -828,7 +828,7 @@ static void LevelTownLand(TileIndex tile
 

	
 
	/* Don't terraform if land is plain or if there's a house there. */
 
	if (IsTileType(tile, MP_HOUSE)) return;
 
	Slope tileh = GetTilePixelSlope(tile, NULL);
 
	Slope tileh = GetTileSlope(tile);
 
	if (tileh == SLOPE_FLAT) return;
 

	
 
	/* First try up, then down */
 
@@ -871,7 +871,7 @@ static RoadBits GetTownRoadGridElement(T
 

	
 
	RoadBits rb_template;
 

	
 
	switch (GetTilePixelSlope(tile, NULL)) {
 
	switch (GetTileSlope(tile)) {
 
		default:       rb_template = ROAD_ALL; break;
 
		case SLOPE_W:  rb_template = ROAD_NW | ROAD_SW; break;
 
		case SLOPE_SW: rb_template = ROAD_Y  | ROAD_SW; break;
 
@@ -970,7 +970,7 @@ static bool GrowTownWithBridge(const Tow
 
{
 
	assert(bridge_dir < DIAGDIR_END);
 

	
 
	const Slope slope = GetTilePixelSlope(tile, NULL);
 
	const Slope slope = GetTileSlope(tile);
 

	
 
	/* Make sure the direction is compatible with the slope.
 
	 * Well we check if the slope has an up bit set in the
 
@@ -1337,7 +1337,7 @@ static bool GrowTown(Town *t)
 
		tile = t->xy;
 
		for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) {
 
			/* Only work with plain land that not already has a house */
 
			if (!IsTileType(tile, MP_HOUSE) && GetTilePixelSlope(tile, NULL) == SLOPE_FLAT) {
 
			if (!IsTileType(tile, MP_HOUSE) && GetTileSlope(tile) == SLOPE_FLAT) {
 
				if (DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR).Succeeded()) {
 
					DoCommand(tile, GenRandomRoadBits(), t->index, DC_EXEC | DC_AUTO, CMD_BUILD_ROAD);
 
					cur_company.Restore();
 
@@ -1500,7 +1500,7 @@ static CommandCost TownCanBePlacedHere(T
 
	}
 

	
 
	/* Can only build on clear flat areas, possibly with trees. */
 
	if ((!IsTileType(tile, MP_CLEAR) && !IsTileType(tile, MP_TREES)) || GetTilePixelSlope(tile, NULL) != SLOPE_FLAT) {
 
	if ((!IsTileType(tile, MP_CLEAR) && !IsTileType(tile, MP_TREES)) || GetTileSlope(tile) != SLOPE_FLAT) {
 
		return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
 
	}
 

	
 
@@ -1697,7 +1697,7 @@ static bool FindFurthestFromWater(TileIn
 
	uint dist = GetClosestWaterDistance(tile, true);
 

	
 
	if (IsTileType(tile, MP_CLEAR) &&
 
			GetTilePixelSlope(tile, NULL) == SLOPE_FLAT &&
 
			GetTileSlope(tile) == SLOPE_FLAT &&
 
			IsTileAlignedToGrid(tile, sp->layout) &&
 
			dist > sp->max_dist) {
 
		sp->tile = tile;
 
@@ -1907,7 +1907,7 @@ static void MakeTownHouse(TileIndex t, T
 
static inline bool CanBuildHouseHere(TileIndex tile, TownID town, bool noslope)
 
{
 
	/* cannot build on these slopes... */
 
	Slope slope = GetTilePixelSlope(tile, NULL);
 
	Slope slope = GetTileSlope(tile);
 
	if ((noslope && slope != SLOPE_FLAT) || IsSteepSlope(slope)) return false;
 

	
 
	/* building under a bridge? */
 
@@ -2525,7 +2525,7 @@ static CommandCost TownActionRoadRebuild
 
static bool SearchTileForStatue(TileIndex tile, void *user_data)
 
{
 
	/* Statues can be build on slopes, just like houses. Only the steep slopes is a no go. */
 
	if (IsSteepSlope(GetTilePixelSlope(tile, NULL))) return false;
 
	if (IsSteepSlope(GetTileSlope(tile))) return false;
 
	/* Don't build statues under bridges. */
 
	if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return false;
 

	
src/tree_cmd.cpp
Show inline comments
 
@@ -70,7 +70,7 @@ static bool CanPlantTreesOnTile(TileInde
 
{
 
	switch (GetTileType(tile)) {
 
		case MP_WATER:
 
			return !IsBridgeAbove(tile) && IsCoast(tile) && !IsSlopeWithOneCornerRaised(GetTilePixelSlope(tile, NULL));
 
			return !IsBridgeAbove(tile) && IsCoast(tile) && !IsSlopeWithOneCornerRaised(GetTileSlope(tile));
 

	
 
		case MP_CLEAR:
 
			return !IsBridgeAbove(tile) && !IsClearGround(tile, CLEAR_FIELDS) && GetRawClearGround(tile) != CLEAR_ROCKS &&
 
@@ -363,7 +363,7 @@ CommandCost CmdPlantTree(TileIndex tile,
 
				break;
 

	
 
			case MP_WATER:
 
				if (!IsCoast(tile) || IsSlopeWithOneCornerRaised(GetTilePixelSlope(tile, NULL))) {
 
				if (!IsCoast(tile) || IsSlopeWithOneCornerRaised(GetTileSlope(tile))) {
 
					msg = STR_ERROR_CAN_T_BUILD_ON_WATER;
 
					continue;
 
				}
src/water_cmd.cpp
Show inline comments
 
@@ -106,7 +106,7 @@ CommandCost CmdBuildShipDepot(TileIndex 
 
	if ((MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) ||
 
		(MayHaveBridgeAbove(tile2) && IsBridgeAbove(tile2))) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
 

	
 
	if (GetTilePixelSlope(tile, NULL) != SLOPE_FLAT || GetTilePixelSlope(tile2, NULL) != SLOPE_FLAT) {
 
	if (GetTileSlope(tile) != SLOPE_FLAT || GetTileSlope(tile2) != SLOPE_FLAT) {
 
		/* Prevent depots on rapids */
 
		return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
 
	}
 
@@ -220,7 +220,7 @@ static CommandCost DoBuildLock(TileIndex
 
		cost.AddCost(ret);
 
		cost.AddCost(_price[PR_BUILD_CANAL]);
 
	}
 
	if (GetTilePixelSlope(tile - delta, NULL) != SLOPE_FLAT) {
 
	if (GetTileSlope(tile - delta) != SLOPE_FLAT) {
 
		return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
 
	}
 

	
 
@@ -233,7 +233,7 @@ static CommandCost DoBuildLock(TileIndex
 
		cost.AddCost(ret);
 
		cost.AddCost(_price[PR_BUILD_CANAL]);
 
	}
 
	if (GetTilePixelSlope(tile + delta, NULL) != SLOPE_FLAT) {
 
	if (GetTileSlope(tile + delta) != SLOPE_FLAT) {
 
		return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
 
	}
 

	
 
@@ -299,7 +299,7 @@ static CommandCost RemoveLock(TileIndex 
 
 */
 
CommandCost CmdBuildLock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	DiagDirection dir = GetInclinedSlopeDirection(GetTilePixelSlope(tile, NULL));
 
	DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile));
 
	if (dir == INVALID_DIAGDIR) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
 

	
 
	/* Disallow building of locks on river rapids */
 
@@ -341,7 +341,7 @@ CommandCost CmdBuildCanal(TileIndex tile
 
	TILE_AREA_LOOP(tile, ta) {
 
		CommandCost ret;
 

	
 
		Slope slope = GetTilePixelSlope(tile, NULL);
 
		Slope slope = GetTileSlope(tile);
 
		if (slope != SLOPE_FLAT && (wc != WATER_CLASS_RIVER || !IsInclinedSlope(slope))) {
 
			return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
 
		}
 
@@ -419,7 +419,7 @@ static CommandCost ClearTile_Water(TileI
 
		}
 

	
 
		case WATER_TILE_COAST: {
 
			Slope slope = GetTilePixelSlope(tile, NULL);
 
			Slope slope = GetTileSlope(tile);
 

	
 
			/* Make sure no vehicle is on the tile */
 
			CommandCost ret = EnsureNoVehicleOnGround(tile);
 
@@ -477,7 +477,7 @@ static bool IsWateredTile(TileIndex tile
 
				case WATER_TILE_LOCK: return DiagDirToAxis(GetLockDirection(tile)) == DiagDirToAxis(DirToDiagDir(from));
 

	
 
				case WATER_TILE_COAST:
 
					switch (GetTilePixelSlope(tile, NULL)) {
 
					switch (GetTileSlope(tile)) {
 
						case SLOPE_W: return (from == DIR_SE) || (from == DIR_E) || (from == DIR_NE);
 
						case SLOPE_S: return (from == DIR_NE) || (from == DIR_N) || (from == DIR_NW);
 
						case SLOPE_E: return (from == DIR_NW) || (from == DIR_W) || (from == DIR_SW);
 
@@ -489,7 +489,7 @@ static bool IsWateredTile(TileIndex tile
 
		case MP_RAILWAY:
 
			if (GetRailGroundType(tile) == RAIL_GROUND_WATER) {
 
				assert(IsPlainRail(tile));
 
				switch (GetTilePixelSlope(tile, NULL)) {
 
				switch (GetTileSlope(tile)) {
 
					case SLOPE_W: return (from == DIR_SE) || (from == DIR_E) || (from == DIR_NE);
 
					case SLOPE_S: return (from == DIR_NE) || (from == DIR_N) || (from == DIR_NW);
 
					case SLOPE_E: return (from == DIR_NW) || (from == DIR_W) || (from == DIR_SW);
 
@@ -509,7 +509,7 @@ static bool IsWateredTile(TileIndex tile
 

	
 
				return IsTileOnWater(tile);
 
			}
 
			return (IsDock(tile) && GetTilePixelSlope(tile, NULL) == SLOPE_FLAT) || IsBuoy(tile);
 
			return (IsDock(tile) && GetTileSlope(tile) == SLOPE_FLAT) || IsBuoy(tile);
 

	
 
		case MP_INDUSTRY: {
 
			/* Do not draw waterborders inside of industries.
 
@@ -931,7 +931,7 @@ FloodingBehaviour GetFloodingBehaviour(T
 
	switch (GetTileType(tile)) {
 
		case MP_WATER:
 
			if (IsCoast(tile)) {
 
				Slope tileh = GetTilePixelSlope(tile, NULL);
 
				Slope tileh = GetTileSlope(tile);
 
				return (IsSlopeWithOneCornerRaised(tileh) ? FLOOD_ACTIVE : FLOOD_DRYUP);
 
			}
 
			/* FALL THROUGH */
 
@@ -942,7 +942,7 @@ FloodingBehaviour GetFloodingBehaviour(T
 

	
 
		case MP_RAILWAY:
 
			if (GetRailGroundType(tile) == RAIL_GROUND_WATER) {
 
				return (IsSlopeWithOneCornerRaised(GetTilePixelSlope(tile, NULL)) ? FLOOD_ACTIVE : FLOOD_DRYUP);
 
				return (IsSlopeWithOneCornerRaised(GetTileSlope(tile)) ? FLOOD_ACTIVE : FLOOD_DRYUP);
 
			}
 
			return FLOOD_NONE;
 

	
 
@@ -965,7 +965,7 @@ void DoFloodTile(TileIndex target)
 

	
 
	Backup<CompanyByte> cur_company(_current_company, OWNER_WATER, FILE_LINE);
 

	
 
	Slope tileh = GetTilePixelSlope(target, NULL);
 
	Slope tileh = GetTileSlope(target);
 
	if (tileh != SLOPE_FLAT) {
 
		/* make coast.. */
 
		switch (GetTileType(target)) {
 
@@ -1133,7 +1133,7 @@ void ConvertGroundTilesIntoWaterTiles()
 
					uint dir;
 
					FOR_EACH_SET_BIT(dir, _flood_from_dirs[slope & ~SLOPE_STEEP]) {
 
						TileIndex dest = TILE_ADD(tile, TileOffsByDir((Direction)dir));
 
						Slope slope_dest = GetTilePixelSlope(dest, NULL) & ~SLOPE_STEEP;
 
						Slope slope_dest = GetTileSlope(dest) & ~SLOPE_STEEP;
 
						if (slope_dest == SLOPE_FLAT || IsSlopeWithOneCornerRaised(slope_dest)) {
 
							MakeShore(tile);
 
							break;
 
@@ -1154,8 +1154,8 @@ static TrackStatus GetTileTrackStatus_Wa
 
	if (mode != TRANSPORT_WATER) return 0;
 

	
 
	switch (GetWaterTileType(tile)) {
 
		case WATER_TILE_CLEAR: ts = (GetTilePixelSlope(tile, NULL) == SLOPE_FLAT) ? TRACK_BIT_ALL : TRACK_BIT_NONE; break;
 
		case WATER_TILE_COAST: ts = (TrackBits)coast_tracks[GetTilePixelSlope(tile, NULL) & 0xF]; break;
 
		case WATER_TILE_CLEAR: ts = (GetTileSlope(tile) == SLOPE_FLAT) ? TRACK_BIT_ALL : TRACK_BIT_NONE; break;
 
		case WATER_TILE_COAST: ts = (TrackBits)coast_tracks[GetTileSlope(tile) & 0xF]; break;
 
		case WATER_TILE_LOCK:  ts = DiagDirToDiagTrackBits(GetLockDirection(tile)); break;
 
		case WATER_TILE_DEPOT: ts = AxisToTrackBits(GetShipDepotAxis(tile)); break;
 
		default: return 0;
src/waypoint_cmd.cpp
Show inline comments
 
@@ -124,7 +124,7 @@ static CommandCost IsValidTileForWaypoin
 
	if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile);
 
	if (ret.Failed()) return ret;
 

	
 
	Slope tileh = GetTilePixelSlope(tile, NULL);
 
	Slope tileh = GetTileSlope(tile);
 
	if (tileh != SLOPE_FLAT &&
 
			(!_settings_game.construction.build_on_slopes || IsSteepSlope(tileh) || !(tileh & (0x3 << axis)) || !(tileh & ~(0x3 << axis)))) {
 
		return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
 
@@ -285,7 +285,7 @@ CommandCost CmdBuildBuoy(TileIndex tile,
 
	if (tile == 0 || !HasTileWaterGround(tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
 
	if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
 

	
 
	if (GetTilePixelSlope(tile, NULL) != SLOPE_FLAT) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
 
	if (GetTileSlope(tile) != SLOPE_FLAT) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
 

	
 
	/* Check if there is an already existing, deleted, waypoint close to us that we can reuse. */
 
	Waypoint *wp = FindDeletedWaypointCloseTo(tile, STR_SV_STNAME_BUOY, OWNER_NONE);
0 comments (0 inline, 0 general)