mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r20748) -Fix: overbuilding an object tile with sea under it with a canal didn't take the cost for clearing the sea into account
This commit is contained in:
parent
323c526a4d
commit
0e250f2bdf
@ -293,6 +293,7 @@ enum DoCommandFlag {
|
|||||||
DC_AUTOREPLACE = 0x080, ///< autoreplace/autorenew is in progress, this shall disable vehicle limits when building, and ignore certain restrictions when undoing things (like vehicle attach callback)
|
DC_AUTOREPLACE = 0x080, ///< autoreplace/autorenew is in progress, this shall disable vehicle limits when building, and ignore certain restrictions when undoing things (like vehicle attach callback)
|
||||||
DC_ALL_TILES = 0x100, ///< allow this command also on MP_VOID tiles
|
DC_ALL_TILES = 0x100, ///< allow this command also on MP_VOID tiles
|
||||||
DC_NO_MODIFY_TOWN_RATING = 0x200, ///< do not change town rating
|
DC_NO_MODIFY_TOWN_RATING = 0x200, ///< do not change town rating
|
||||||
|
DC_FORCE_CLEAR_TILE = 0x400, ///< do not only remove the object on the tile, but also clear any water left on it
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_AS_BIT_SET(DoCommandFlag)
|
DECLARE_ENUM_AS_BIT_SET(DoCommandFlag)
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "core/random_func.hpp"
|
#include "core/random_func.hpp"
|
||||||
#include "object_base.h"
|
#include "object_base.h"
|
||||||
#include "water_map.h"
|
#include "water_map.h"
|
||||||
|
#include "economy_func.h"
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
@ -606,6 +607,13 @@ void ClearSnowLine()
|
|||||||
*/
|
*/
|
||||||
CommandCost CmdLandscapeClear(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
CommandCost CmdLandscapeClear(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||||
{
|
{
|
||||||
|
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||||
|
bool do_clear = false;
|
||||||
|
if ((flags & DC_FORCE_CLEAR_TILE) && HasTileWaterClass(tile) && IsTileOnWater(tile)) {
|
||||||
|
if ((flags & DC_AUTO) && GetWaterClass(tile) == WATER_CLASS_CANAL) return_cmd_error(STR_ERROR_MUST_DEMOLISH_CANAL_FIRST);
|
||||||
|
do_clear = true;
|
||||||
|
cost.AddCost(GetWaterClass(tile) == WATER_CLASS_CANAL ? _price[PR_CLEAR_CANAL] : _price[PR_CLEAR_WATER]);
|
||||||
|
}
|
||||||
for (uint i = 0; i < _cleared_object_areas.Length(); i++) {
|
for (uint i = 0; i < _cleared_object_areas.Length(); i++) {
|
||||||
/* If this tile was the first tile which caused object destruction, always
|
/* If this tile was the first tile which caused object destruction, always
|
||||||
* pass it on to the tile_type_proc. That way multiple test runs and the exec run stay consistent. */
|
* pass it on to the tile_type_proc. That way multiple test runs and the exec run stay consistent. */
|
||||||
@ -619,10 +627,12 @@ CommandCost CmdLandscapeClear(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
|
|||||||
if ((flags & DC_NO_WATER) && HasTileWaterClass(tile) && IsTileOnWater(tile)) {
|
if ((flags & DC_NO_WATER) && HasTileWaterClass(tile) && IsTileOnWater(tile)) {
|
||||||
return_cmd_error(STR_ERROR_CAN_T_BUILD_ON_WATER);
|
return_cmd_error(STR_ERROR_CAN_T_BUILD_ON_WATER);
|
||||||
}
|
}
|
||||||
return CommandCost();
|
return cost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags);
|
cost.AddCost(_tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags));
|
||||||
|
if (do_clear && (flags & DC_EXEC)) DoClearSquare(tile);
|
||||||
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -640,8 +640,6 @@ static CommandCost TerraformTile_Object(TileIndex tile, DoCommandFlag flags, uin
|
|||||||
{
|
{
|
||||||
ObjectType type = GetObjectType(tile);
|
ObjectType type = GetObjectType(tile);
|
||||||
|
|
||||||
if (GetWaterClass(tile) == WATER_CLASS_CANAL) return_cmd_error(STR_ERROR_MUST_DEMOLISH_CANAL_FIRST);
|
|
||||||
|
|
||||||
if (type == OBJECT_OWNED_LAND) {
|
if (type == OBJECT_OWNED_LAND) {
|
||||||
/* Owned land remains unsold */
|
/* Owned land remains unsold */
|
||||||
CommandCost ret = CheckTileOwnership(tile);
|
CommandCost ret = CheckTileOwnership(tile);
|
||||||
|
@ -318,7 +318,7 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
|||||||
/* Check tiletype-specific things, and add extra-cost */
|
/* Check tiletype-specific things, and add extra-cost */
|
||||||
const bool curr_gen = _generating_world;
|
const bool curr_gen = _generating_world;
|
||||||
if (_game_mode == GM_EDITOR) _generating_world = true; // used to create green terraformed land
|
if (_game_mode == GM_EDITOR) _generating_world = true; // used to create green terraformed land
|
||||||
CommandCost cost = _tile_type_procs[GetTileType(tile)]->terraform_tile_proc(tile, flags | DC_AUTO, z_min * TILE_HEIGHT, tileh);
|
CommandCost cost = _tile_type_procs[GetTileType(tile)]->terraform_tile_proc(tile, flags | DC_AUTO | DC_FORCE_CLEAR_TILE, z_min * TILE_HEIGHT, tileh);
|
||||||
_generating_world = curr_gen;
|
_generating_world = curr_gen;
|
||||||
if (cost.Failed()) {
|
if (cost.Failed()) {
|
||||||
_terraform_err_tile = tile;
|
_terraform_err_tile = tile;
|
||||||
|
@ -332,7 +332,7 @@ CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||||||
/* can't make water of water! */
|
/* can't make water of water! */
|
||||||
if (IsTileType(tile, MP_WATER) && (!IsTileOwner(tile, OWNER_WATER) || wc == WATER_CLASS_SEA)) continue;
|
if (IsTileType(tile, MP_WATER) && (!IsTileOwner(tile, OWNER_WATER) || wc == WATER_CLASS_SEA)) continue;
|
||||||
|
|
||||||
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
ret = DoCommand(tile, 0, 0, flags | DC_FORCE_CLEAR_TILE, CMD_LANDSCAPE_CLEAR);
|
||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
cost.AddCost(ret);
|
cost.AddCost(ret);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user