(svn r20641) -Codechange: remove the "require flat land" flag

pull/155/head
rubidium 14 years ago
parent b79c5b5f84
commit a3b1abc83d

@ -31,18 +31,17 @@ enum ObjectFlags {
OBJECT_FLAG_NOT_ON_LAND = 1 << 9, ///< Object can not be on land, implicitly sets #OBJECT_FLAG_BUILT_ON_WATER.
OBJECT_FLAG_DRAW_WATER = 1 << 10, ///< Object wants to be drawn on water.
OBJECT_FLAG_ALLOW_UNDER_BRIDGE = 1 << 11, ///< Object can built under a bridge.
OBJECT_FLAG_REQUIRE_FLAT = 1 << 12, ///< Object can only be build of flat land, i.e. not on foundations!
};
DECLARE_ENUM_AS_BIT_SET(ObjectFlags)
/** An object that isn't use for transport, industries or houses. */
struct ObjectSpec {
StringID name; ///< The name for this object.
uint8 size; ///< The size of this objects; low nibble for X, high nibble for Y.
uint8 build_cost_multiplier; ///< Build cost multiplier per tile.
uint8 clear_cost_multiplier; ///< Clear cost multiplier per tile.
ObjectFlags flags; ///< Flags/settings related to the object.
StringID name; ///< The name for this object.
uint8 size; ///< The size of this objects; low nibble for X, high nibble for Y.
uint8 build_cost_multiplier; ///< Build cost multiplier per tile.
uint8 clear_cost_multiplier; ///< Clear cost multiplier per tile.
ObjectFlags flags; ///< Flags/settings related to the object.
/**
* Get the cost for building a structure of this type.

@ -134,18 +134,9 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
int size_y = GB(spec->size, 4, 4);
TileArea ta(tile, size_x, size_y);
if (spec->flags & OBJECT_FLAG_REQUIRE_FLAT) {
TILE_AREA_LOOP(tile_cur, ta) {
if (GetTileSlope(tile, NULL) != SLOPE_FLAT) return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
}
}
/* If we require flat land, we've already tested that.
* So we only need to check for clear land. */
if (spec->flags & (OBJECT_FLAG_HAS_NO_FOUNDATION | OBJECT_FLAG_REQUIRE_FLAT)) {
TILE_AREA_LOOP(tile_cur, ta) {
cost.AddCost(DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR));
}
if (type != OBJECT_OWNED_LAND) {
/* Owned land is special as it can be placed on any slope. */
cost.AddCost(DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR));
} else {
cost.AddCost(CheckFlatLand(ta, flags));
}
@ -153,6 +144,11 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
int hq_score = 0;
switch (type) {
case OBJECT_TRANSMITTER:
case OBJECT_LIGHTHOUSE:
if (GetTileSlope(tile, NULL) != SLOPE_FLAT) return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
break;
case OBJECT_OWNED_LAND:
if (IsTileType(tile, MP_OBJECT) &&
IsTileOwner(tile, _current_company) &&
@ -522,18 +518,12 @@ static void ChangeTileOwner_Object(TileIndex tile, Owner old_owner, Owner new_ow
static CommandCost TerraformTile_Object(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
{
ObjectType type = GetObjectType(tile);
const ObjectSpec *spec = ObjectSpec::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)) {
if (type == OBJECT_OWNED_LAND) {
/* Owned land remains unsold */
CommandCost ret = CheckTileOwnership(tile);
if (ret.Succeeded()) return CommandCost();
} else if (AutoslopeEnabled()) {
} else if (AutoslopeEnabled() && type != OBJECT_TRANSMITTER && type != OBJECT_LIGHTHOUSE) {
if (!IsSteepSlope(tileh_new) && (z_new + GetSlopeMaxZ(tileh_new) == GetTileMaxZ(tile))) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
}

@ -125,8 +125,8 @@ static const DrawTileSprites _object_hq[] = {
/** Specification of the original object structures. */
extern const ObjectSpec _original_objects[] = {
{ STR_LAI_OBJECT_DESCRIPTION_TRANSMITTER, 0x11, 0, 0, OBJECT_FLAG_CANNOT_REMOVE | OBJECT_FLAG_REQUIRE_FLAT | OBJECT_FLAG_ONLY_IN_SCENEDIT },
{ STR_LAI_OBJECT_DESCRIPTION_LIGHTHOUSE, 0x11, 0, 0, OBJECT_FLAG_CANNOT_REMOVE | OBJECT_FLAG_REQUIRE_FLAT | OBJECT_FLAG_ONLY_IN_SCENEDIT },
{ STR_LAI_OBJECT_DESCRIPTION_TRANSMITTER, 0x11, 0, 0, OBJECT_FLAG_CANNOT_REMOVE | OBJECT_FLAG_ONLY_IN_SCENEDIT },
{ STR_LAI_OBJECT_DESCRIPTION_LIGHTHOUSE, 0x11, 0, 0, OBJECT_FLAG_CANNOT_REMOVE | OBJECT_FLAG_ONLY_IN_SCENEDIT },
{ STR_TOWN_BUILDING_NAME_STATUE_1, 0x11, 0, 0, OBJECT_FLAG_CANNOT_REMOVE | OBJECT_FLAG_ONLY_IN_GAME | OBJECT_FLAG_ONLY_IN_SCENEDIT }, // Yes, we disallow building this everywhere. Happens in "special" case!
{ STR_LAI_OBJECT_DESCRIPTION_COMPANY_OWNED_LAND, 0x11, 10, 2, OBJECT_FLAG_AUTOREMOVE | OBJECT_FLAG_ONLY_IN_GAME | OBJECT_FLAG_CLEAR_INCOME | OBJECT_FLAG_HAS_NO_FOUNDATION | OBJECT_FLAG_ALLOW_UNDER_BRIDGE },
{ STR_LAI_OBJECT_DESCRIPTION_COMPANY_HEADQUARTERS, 0x22, 0, 0, OBJECT_FLAG_CANNOT_REMOVE | OBJECT_FLAG_ONLY_IN_GAME },

Loading…
Cancel
Save