File diff r15664:ed8829ca7a03 → r15665:8a1a5d5b328a
src/unmovable_cmd.cpp
Show inline comments
 
@@ -242,26 +242,39 @@ CommandCost CmdBuildUnmovable(TileIndex 
 

	
 
static Foundation GetFoundation_Unmovable(TileIndex tile, Slope tileh);
 

	
 
static void DrawTile_Unmovable(TileInfo *ti)
 
{
 
	UnmovableType type = GetUnmovableType(ti->tile);
 
	if (type != UNMOVABLE_OWNED_LAND) DrawFoundation(ti, GetFoundation_Unmovable(ti->tile, ti->tileh));
 
	const UnmovableSpec *spec = UnmovableSpec::Get(type);
 
	if ((spec->flags & OBJECT_FLAG_HAS_NO_FOUNDATION) == 0) DrawFoundation(ti, GetFoundation_Unmovable(ti->tile, ti->tileh));
 

	
 
	const DrawTileSprites *dts = NULL;
 
	Owner to = GetTileOwner(ti->tile);
 
	PaletteID palette = to == OWNER_NONE ? PAL_NONE : COMPANY_SPRITE_COLOUR(to);
 

	
 
	if (type == UNMOVABLE_HQ) {
 
		uint8 offset = GetUnmovableOffset(ti->tile);
 
		dts = &_unmovable_hq[GetCompanyHQSize(ti->tile) << 2 | GB(offset, 4, 1) << 1 | GB(offset, 0, 1)];
 
	} else {
 
		dts = &_unmovables[type];
 
	}
 

	
 
	DrawGroundSprite(dts->ground.sprite, palette);
 
	if (spec->flags & OBJECT_FLAG_HAS_NO_FOUNDATION) {
 
		/* If an object has no foundation, but tries to draw a (flat) ground
 
		 * type... we have to be nice and convert that for them. */
 
		switch (dts->ground.sprite) {
 
			case SPR_FLAT_BARE_LAND:          DrawClearLandTile(ti, 0); break;
 
			case SPR_FLAT_1_THIRD_GRASS_TILE: DrawClearLandTile(ti, 1); break;
 
			case SPR_FLAT_2_THIRD_GRASS_TILE: DrawClearLandTile(ti, 2); break;
 
			case SPR_FLAT_GRASS_TILE:         DrawClearLandTile(ti, 3); break;
 
			default: DrawGroundSprite(dts->ground.sprite, palette);     break;
 
		}
 
	} else {
 
		DrawGroundSprite(dts->ground.sprite, palette);
 
	}
 

	
 
	if (!IsInvisibilitySet(TO_STRUCTURES)) {
 
		const DrawTileSeqStruct *dtss;
 
		foreach_draw_tile_seq(dtss, dts->seq) {
 
			AddSortableSpriteToDraw(
 
				dtss->image.sprite, palette,
 
@@ -270,13 +283,13 @@ static void DrawTile_Unmovable(TileInfo 
 
				dtss->size_z, ti->z + dtss->delta_z,
 
				IsTransparencySet(TO_STRUCTURES)
 
			);
 
		}
 
	}
 

	
 
	if (type == UNMOVABLE_OWNED_LAND) DrawBridgeMiddle(ti);
 
	if (spec->flags & OBJECT_FLAG_ALLOW_UNDER_BRIDGE) DrawBridgeMiddle(ti);
 
}
 

	
 
static uint GetSlopeZ_Unmovable(TileIndex tile, uint x, uint y)
 
{
 
	if (IsOwnedLand(tile)) {
 
		uint z;
 
@@ -534,19 +547,25 @@ static void ChangeTileOwner_Unmovable(Ti
 
		DoClearSquare(tile);
 
	}
 
}
 

	
 
static CommandCost TerraformTile_Unmovable(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
 
{
 
	/* Owned land remains unsold */
 
	UnmovableType type = GetUnmovableType(tile);
 
	const UnmovableSpec *spec = UnmovableSpec::Get(type);
 

	
 
	if (spec->flags & OBJECT_FLAG_REQUIRE_FLAT) {
 
		/* If a flat tile is required by the object, then terraforming is never good. */
 
		return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
	}
 

	
 
	if (IsOwnedLand(tile)) {
 
		/* Owned land remains unsold */
 
		CommandCost ret = CheckTileOwnership(tile);
 
		if (ret.Succeeded()) return CommandCost();
 
	}
 

	
 
	if (AutoslopeEnabled() && (IsStatue(tile) || IsCompanyHQ(tile))) {
 
	} else if (AutoslopeEnabled()) {
 
		if (!IsSteepSlope(tileh_new) && (z_new + GetSlopeMaxZ(tileh_new) == GetTileMaxZ(tile))) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
 
	}
 

	
 
	return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
}