mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-05 13:57:01 +00:00
(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.
This commit is contained in:
parent
c4179d4ea9
commit
e35be92a3a
@ -1266,9 +1266,22 @@ static bool CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable
|
|||||||
_error_message = STR_030D_CAN_ONLY_BE_BUILT_IN_TOWNS;
|
_error_message = STR_030D_CAN_ONLY_BE_BUILT_IN_TOWNS;
|
||||||
return false;
|
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)) {
|
} 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);
|
} 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;
|
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 {
|
do {
|
||||||
TileIndex cur_tile = tile + ToTileIndexDiff(it->ti);
|
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);
|
if (its->animation_info != 0xFFFF) AddAnimatedTile(cur_tile);
|
||||||
}
|
}
|
||||||
} while ((++it)->ti.x != -0x80);
|
} while ((++it)->ti.x != -0x80);
|
||||||
|
_current_company = old_company;
|
||||||
|
|
||||||
i->width++;
|
i->width++;
|
||||||
i->height++;
|
i->height++;
|
||||||
|
@ -556,7 +556,10 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32
|
|||||||
|
|
||||||
/* slope of end tile must be complementary to the slope of the start tile */
|
/* slope of end tile must be complementary to the slope of the start tile */
|
||||||
if (end_tileh != ComplementSlope(start_tileh)) {
|
if (end_tileh != ComplementSlope(start_tileh)) {
|
||||||
/* Check if there is a structure on the terraformed tile. Do not add the cost, that will be done by the terraforming */
|
/* Check if there is a structure on the terraformed tile. Do not add the cost, that will be done by the terraforming
|
||||||
|
* Note: Currently the town rating is also affected by this clearing-test. So effectivly the player is punished twice for clearing
|
||||||
|
* the tree on end_tile.
|
||||||
|
*/
|
||||||
ret = DoCommand(end_tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR);
|
ret = DoCommand(end_tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR);
|
||||||
if (CmdFailed(ret)) return_cmd_error(STR_5005_UNABLE_TO_EXCAVATE_LAND);
|
if (CmdFailed(ret)) return_cmd_error(STR_5005_UNABLE_TO_EXCAVATE_LAND);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user