summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/newgrf_object.h11
-rw-r--r--src/object_cmd.cpp30
-rw-r--r--src/table/object_land.h4
3 files changed, 17 insertions, 28 deletions
diff --git a/src/newgrf_object.h b/src/newgrf_object.h
index 37b74a160..37429ab33 100644
--- a/src/newgrf_object.h
+++ b/src/newgrf_object.h
@@ -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.
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp
index 262f9142f..fc891df54 100644
--- a/src/object_cmd.cpp
+++ b/src/object_cmd.cpp
@@ -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]);
}
diff --git a/src/table/object_land.h b/src/table/object_land.h
index 1085550cb..62e797be8 100644
--- a/src/table/object_land.h
+++ b/src/table/object_land.h
@@ -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 },