Changeset - r18255:a991a3ab7037
[Not reviewed]
master
0 3 0
rubidium - 13 years ago 2011-11-04 10:31:13
rubidium@openttd.org
(svn r23101) -Codechange: remove pointless multiplications by TILE_HEIGHT from the station/object building code
3 files changed with 9 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/object_cmd.cpp
Show inline comments
 
@@ -227,13 +227,13 @@ CommandCost CmdBuildObject(TileIndex til
 
				cost.AddCost(DoCommand(t, 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR));
 
			}
 
		}
 

	
 
		/* So, now the surface is checked... check the slope of said surface. */
 
		int allowed_z;
 
		if (GetTilePixelSlope(tile, (uint*)&allowed_z) != SLOPE_FLAT) allowed_z += TILE_HEIGHT;
 
		if (GetTileSlope(tile, (uint*)&allowed_z) != SLOPE_FLAT) allowed_z++;
 

	
 
		TILE_AREA_LOOP(t, ta) {
 
			uint16 callback = CALLBACK_FAILED;
 
			if (HasBit(spec->callback_mask, CBM_OBJ_SLOPE_CHECK)) {
 
				TileIndex diff = t - tile;
 
				callback = GetObjectCallback(CBID_OBJECT_LAND_SLOPE_CHECK, GetTileSlope(t), TileY(diff) << 4 | TileX(diff), spec, NULL, t, view);
 
@@ -640,13 +640,13 @@ void GenerateObjects()
 
	SetGeneratingWorldProgress(GWP_OBJECT, radiotower_to_build + lighthouses_to_build);
 

	
 
	for (uint i = ScaleByMapSize(1000); i != 0 && Object::CanAllocateItem(); i--) {
 
		TileIndex tile = RandomTile();
 

	
 
		uint h;
 
		if (IsTileType(tile, MP_CLEAR) && GetTilePixelSlope(tile, &h) == SLOPE_FLAT && h >= TILE_HEIGHT * 4 && !IsBridgeAbove(tile)) {
 
		if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == SLOPE_FLAT && h >= 4 && !IsBridgeAbove(tile)) {
 
			TileIndex t = tile;
 
			if (CircularTileSearch(&t, 9, HasTransmitter, NULL)) continue;
 

	
 
			BuildObject(OBJECT_TRANSMITTER, tile);
 
			IncreaseGeneratingWorldProgress(GWP_OBJECT);
 
			if (--radiotower_to_build == 0) break;
 
@@ -677,13 +677,13 @@ void GenerateObjects()
 

	
 
		/* Only build lighthouses at tiles where the border is sea. */
 
		if (!IsTileType(tile, MP_WATER)) continue;
 

	
 
		for (int j = 0; j < 19; j++) {
 
			uint h;
 
			if (IsTileType(tile, MP_CLEAR) && GetTilePixelSlope(tile, &h) == SLOPE_FLAT && h <= TILE_HEIGHT * 2 && !IsBridgeAbove(tile)) {
 
			if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == SLOPE_FLAT && h <= 2 && !IsBridgeAbove(tile)) {
 
				BuildObject(OBJECT_LIGHTHOUSE, tile);
 
				IncreaseGeneratingWorldProgress(GWP_OBJECT);
 
				lighthouses_to_build--;
 
				assert(tile < MapSize());
 
				break;
 
			}
src/station_cmd.cpp
Show inline comments
 
@@ -303,14 +303,14 @@ static StringID GenerateStationName(Stat
 
				CountMapSquareAround(tile, IsTileForestIndustry) >= 2)
 
			) {
 
		return _settings_game.game_creation.landscape == LT_TROPIC ? STR_SV_STNAME_FOREST : STR_SV_STNAME_WOODS;
 
	}
 

	
 
	/* check elevation compared to town */
 
	uint z = GetTilePixelZ(tile);
 
	uint z2 = GetTilePixelZ(t->xy);
 
	uint z = GetTileZ(tile);
 
	uint 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) {
 
		if (HasBit(free_names, M(STR_SV_STNAME_HEIGHTS))) return STR_SV_STNAME_HEIGHTS;
 
	}
 

	
 
@@ -662,25 +662,25 @@ CommandCost CheckBuildableTile(TileIndex
 
	}
 

	
 
	CommandCost ret = EnsureNoVehicleOnGround(tile);
 
	if (ret.Failed()) return ret;
 

	
 
	uint z;
 
	Slope tileh = GetTilePixelSlope(tile, &z);
 
	Slope tileh = GetTileSlope(tile, &z);
 

	
 
	/* Prohibit building if
 
	 *   1) The tile is "steep" (i.e. stretches two height levels).
 
	 *   2) The tile is non-flat and the build_on_slopes switch is disabled.
 
	 */
 
	if ((!allow_steep && IsSteepSlope(tileh)) ||
 
			((!_settings_game.construction.build_on_slopes) && tileh != SLOPE_FLAT)) {
 
		return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
 
	}
 

	
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	int flat_z = z + GetSlopeMaxPixelZ(tileh);
 
	int flat_z = z + GetSlopeMaxZ(tileh);
 
	if (tileh != SLOPE_FLAT) {
 
		/* Forbid building if the tile faces a slope in a invalid direction. */
 
		for (DiagDirection dir = DIAGDIR_BEGIN; dir != DIAGDIR_END; dir++) {
 
			if (HasBit(invalid_dirs, dir) && !CanBuildDepotByTileh(dir, tileh)) {
 
				return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
 
			}
src/town_cmd.cpp
Show inline comments
 
@@ -1932,13 +1932,13 @@ static inline bool CanBuildHouseHere(Til
 
 */
 
static inline bool CheckBuildHouseSameZ(TileIndex tile, TownID town, uint z, bool noslope)
 
{
 
	if (!CanBuildHouseHere(tile, town, noslope)) return false;
 

	
 
	/* if building on slopes is allowed, there will be flattening foundation (to tile max z) */
 
	if (GetTileMaxPixelZ(tile) != z) return false;
 
	if (GetTileMaxZ(tile) != z) return false;
 

	
 
	return true;
 
}
 

	
 

	
 
/**
 
@@ -2136,13 +2136,13 @@ static bool BuildTownHouse(Town *t, Tile
 
		uint cur_prob = (_loaded_newgrf_features.has_newhouses ? hs->probability : 1);
 
		probability_max += cur_prob;
 
		probs[num] = cur_prob;
 
		houses[num++] = (HouseID)i;
 
	}
 

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

	
 
	while (probability_max > 0) {
 
		/* Building a multitile building can change the location of tile.
 
		 * The building would still be built partially on that tile, but
 
		 * its nothern tile would be elsewere. However, if the callback
0 comments (0 inline, 0 general)