summaryrefslogtreecommitdiff
path: root/src/industry_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-11-23 16:34:27 +0000
committerfrosch <frosch@openttd.org>2008-11-23 16:34:27 +0000
commitaaf21df68bf49072e13866eb62701ef8050dafc7 (patch)
treee32bca90e69b2ab9b11a41d95f5e55ad36172f05 /src/industry_cmd.cpp
parente50a4f20539b07475e73c88cc510456f2057f483 (diff)
downloadopenttd-aaf21df68bf49072e13866eb62701ef8050dafc7.tar.xz
(svn r14613) -Fix [FS#2420]: When building industries, clear the tiles as OWNER_TOWN instead of the founder to take care of protected buildings and to not get stressed by town ratings.
Diffstat (limited to 'src/industry_cmd.cpp')
-rw-r--r--src/industry_cmd.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 28049348b..a9a837dbe 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1266,9 +1266,22 @@ static bool CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable
_error_message = STR_030D_CAN_ONLY_BE_BUILT_IN_TOWNS;
return false;
}
- if (CmdFailed(DoCommand(cur_tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR))) return false;
+
+ /* Clear the tiles as OWNER_TOWN to not affect town rating, and to not clear protected buildings */
+ CompanyID old_company = _current_company;
+ _current_company = OWNER_TOWN;
+ bool not_clearable = CmdFailed(DoCommand(cur_tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR));
+ _current_company = old_company;
+
+ if (not_clearable) return false;
} else if ((ind_behav & INDUSTRYBEH_ONLY_NEARTOWN) == 0 || !IsTileType(cur_tile, MP_HOUSE)) {
- if (CmdFailed(DoCommand(cur_tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR))) return false;
+ /* Clear the tiles as OWNER_TOWN to not affect town rating, and to not clear protected buildings */
+ CompanyID old_company = _current_company;
+ _current_company = OWNER_TOWN;
+ bool not_clearable = CmdFailed(DoCommand(cur_tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR));
+ _current_company = old_company;
+
+ if (not_clearable) return false;
}
}
} while ((++it)->ti.x != -0x80);
@@ -1540,6 +1553,9 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const Ind
i->prod_level = PRODLEVEL_DEFAULT;
+ /* Clear the tiles as OWNER_TOWN, to not affect town rating, and to not clear protected buildings */
+ CompanyID old_company = _current_company;
+ _current_company = OWNER_TOWN;
do {
TileIndex cur_tile = tile + ToTileIndexDiff(it->ti);
@@ -1568,6 +1584,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const Ind
if (its->animation_info != 0xFFFF) AddAnimatedTile(cur_tile);
}
} while ((++it)->ti.x != -0x80);
+ _current_company = old_company;
i->width++;
i->height++;