summaryrefslogtreecommitdiff
path: root/src/industry_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-09-14 22:27:40 +0000
committerrubidium <rubidium@openttd.org>2007-09-14 22:27:40 +0000
commitfef64185b87e4517b7760e017171d646eaa1eb69 (patch)
tree66f89fc328e49813581c22632a0a9cb21d7c2eb8 /src/industry_cmd.cpp
parent5647bd5157b623348feb202623057fd84eb9c3c5 (diff)
downloadopenttd-fef64185b87e4517b7760e017171d646eaa1eb69.tar.xz
(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.
Diffstat (limited to 'src/industry_cmd.cpp')
-rw-r--r--src/industry_cmd.cpp25
1 files changed, 25 insertions, 0 deletions
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
}