From fef64185b87e4517b7760e017171d646eaa1eb69 Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 14 Sep 2007 22:27:40 +0000 Subject: (svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch. --- src/industry_cmd.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/industry_cmd.cpp') diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 97adbb84e..f1800ef40 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -36,6 +36,7 @@ #include "newgrf_industrytiles.h" #include "newgrf_callbacks.h" #include "misc/autoptr.hpp" +#include "autoslope.h" void ShowIndustryViewWindow(int industry); void BuildOilRig(TileIndex tile); @@ -1974,6 +1975,30 @@ Money IndustrySpec::GetConstructionCost() const static CommandCost TerraformTile_Industry(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new) { + if (AutoslopeEnabled()) { + /* We imitate here TTDP's behaviour: + * - Both new and old slope must not be steep. + * - TileMaxZ must not be changed. + * - Allow autoslope by default. + * - Disallow autoslope if callback succeeds and returns non-zero. + */ + Slope tileh_old = GetTileSlope(tile, NULL); + /* TileMaxZ must not be changed. Slopes must not be steep. */ + if (!IsSteepSlope(tileh_old) && !IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new))) { + const IndustryGfx gfx = GetIndustryGfx(tile); + const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx); + + /* Call callback 3C 'disable autosloping for industry tiles'. */ + if (HASBIT(itspec->callback_flags, CBM_INDT_AUTOSLOPE)) { + /* If the callback fails, allow autoslope. */ + uint16 res = GetIndustryTileCallback(CBID_INDUSTRY_AUTOSLOPE, 0, 0, gfx, GetIndustryByTile(tile), tile); + if ((res == 0) || (res == CALLBACK_FAILED)) return _price.terraform; + } else { + // allow autoslope + return _price.terraform; + } + } + } return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); // funny magic bulldozer } -- cgit v1.2.3-54-g00ecf