|
@@ -226,26 +226,26 @@ CommandCost CmdBuildObject(TileIndex til
|
|
|
for (TileIndex t : ta) {
|
|
|
if (!IsValidTile(t)) return_cmd_error(STR_ERROR_TOO_CLOSE_TO_EDGE_OF_MAP_SUB); // Might be off the map
|
|
|
}
|
|
|
|
|
|
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));
|
|
|
cost.AddCost(DoCommand(flags, CMD_LANDSCAPE_CLEAR, tile, 0, 0));
|
|
|
} else {
|
|
|
/* Check the surface to build on. At this time we can't actually execute the
|
|
|
* the CLEAR_TILE commands since the newgrf callback later on can check
|
|
|
* some information about the tiles. */
|
|
|
bool allow_water = (spec->flags & (OBJECT_FLAG_BUILT_ON_WATER | OBJECT_FLAG_NOT_ON_LAND)) != 0;
|
|
|
bool allow_ground = (spec->flags & OBJECT_FLAG_NOT_ON_LAND) == 0;
|
|
|
for (TileIndex t : ta) {
|
|
|
if (HasTileWaterGround(t)) {
|
|
|
if (!allow_water) return_cmd_error(STR_ERROR_CAN_T_BUILD_ON_WATER);
|
|
|
if (!IsWaterTile(t)) {
|
|
|
/* Normal water tiles don't have to be cleared. For all other tile types clear
|
|
|
* the tile but leave the water. */
|
|
|
cost.AddCost(DoCommand(t, 0, 0, flags & ~DC_NO_WATER & ~DC_EXEC, CMD_LANDSCAPE_CLEAR));
|
|
|
cost.AddCost(DoCommand(flags & ~DC_NO_WATER & ~DC_EXEC, CMD_LANDSCAPE_CLEAR, t, 0, 0));
|
|
|
} else {
|
|
|
/* Can't build on water owned by another company. */
|
|
|
Owner o = GetTileOwner(t);
|
|
|
if (o != OWNER_NONE && o != OWNER_WATER) cost.AddCost(CheckOwnership(o, t));
|
|
|
|
|
|
/* However, the tile has to be clear of vehicles. */
|
|
@@ -257,13 +257,13 @@ CommandCost CmdBuildObject(TileIndex til
|
|
|
|
|
|
/* When relocating HQ, allow it to be relocated (partial) on itself. */
|
|
|
if (!(type == OBJECT_HQ &&
|
|
|
IsTileType(t, MP_OBJECT) &&
|
|
|
IsTileOwner(t, _current_company) &&
|
|
|
IsObjectType(t, OBJECT_HQ))) {
|
|
|
cost.AddCost(DoCommand(t, 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR));
|
|
|
cost.AddCost(DoCommand(flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR, t, 0, 0));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* So, now the surface is checked... check the slope of said surface. */
|
|
|
int allowed_z;
|
|
@@ -289,16 +289,16 @@ CommandCost CmdBuildObject(TileIndex til
|
|
|
if (flags & DC_EXEC) {
|
|
|
/* This is basically a copy of the loop above with the exception that we now
|
|
|
* execute the commands and don't check for errors, since that's already done. */
|
|
|
for (TileIndex t : ta) {
|
|
|
if (HasTileWaterGround(t)) {
|
|
|
if (!IsWaterTile(t)) {
|
|
|
DoCommand(t, 0, 0, (flags & ~DC_NO_WATER) | DC_NO_MODIFY_TOWN_RATING, CMD_LANDSCAPE_CLEAR);
|
|
|
DoCommand((flags & ~DC_NO_WATER) | DC_NO_MODIFY_TOWN_RATING, CMD_LANDSCAPE_CLEAR, t, 0, 0);
|
|
|
}
|
|
|
} else {
|
|
|
DoCommand(t, 0, 0, flags | DC_NO_MODIFY_TOWN_RATING, CMD_LANDSCAPE_CLEAR);
|
|
|
DoCommand(flags | DC_NO_MODIFY_TOWN_RATING, CMD_LANDSCAPE_CLEAR, t, 0, 0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (cost.Failed()) return cost;
|
|
|
|
|
@@ -844,13 +844,13 @@ static CommandCost TerraformTile_Object(
|
|
|
/* allow autoslope */
|
|
|
return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
|
|
return DoCommand(flags, CMD_LANDSCAPE_CLEAR, tile, 0, 0);
|
|
|
}
|
|
|
|
|
|
extern const TileTypeProcs _tile_type_object_procs = {
|
|
|
DrawTile_Object, // draw_tile_proc
|
|
|
GetSlopePixelZ_Object, // get_slope_z_proc
|
|
|
ClearTile_Object, // clear_tile_proc
|