mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r19263) -Fix (r19184): some specific industry creation errors got replaced by 'site unsuitable'.
This commit is contained in:
parent
0f6d82df7e
commit
425ac1ec1f
@ -1320,7 +1320,6 @@ bool IsSlopeRefused(Slope current, Slope refused)
|
|||||||
*/
|
*/
|
||||||
static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, uint itspec_index, int type, bool *custom_shape_check = NULL)
|
static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, uint itspec_index, int type, bool *custom_shape_check = NULL)
|
||||||
{
|
{
|
||||||
CommandCost ret = CommandCost(STR_ERROR_SITE_UNSUITABLE);
|
|
||||||
bool refused_slope = false;
|
bool refused_slope = false;
|
||||||
bool custom_shape = false;
|
bool custom_shape = false;
|
||||||
|
|
||||||
@ -1329,28 +1328,28 @@ static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTil
|
|||||||
TileIndex cur_tile = TileAddWrap(tile, it->ti.x, it->ti.y);
|
TileIndex cur_tile = TileAddWrap(tile, it->ti.x, it->ti.y);
|
||||||
|
|
||||||
if (!IsValidTile(cur_tile)) {
|
if (!IsValidTile(cur_tile)) {
|
||||||
return ret;
|
return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gfx == GFX_WATERTILE_SPECIALCHECK) {
|
if (gfx == GFX_WATERTILE_SPECIALCHECK) {
|
||||||
if (!IsTileType(cur_tile, MP_WATER) ||
|
if (!IsTileType(cur_tile, MP_WATER) ||
|
||||||
GetTileSlope(cur_tile, NULL) != SLOPE_FLAT) {
|
GetTileSlope(cur_tile, NULL) != SLOPE_FLAT) {
|
||||||
return ret;
|
return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!EnsureNoVehicleOnGround(cur_tile)) return ret;
|
if (!EnsureNoVehicleOnGround(cur_tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
|
||||||
if (MayHaveBridgeAbove(cur_tile) && IsBridgeAbove(cur_tile)) return ret;
|
if (MayHaveBridgeAbove(cur_tile) && IsBridgeAbove(cur_tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
|
||||||
|
|
||||||
const IndustryTileSpec *its = GetIndustryTileSpec(gfx);
|
const IndustryTileSpec *its = GetIndustryTileSpec(gfx);
|
||||||
|
|
||||||
IndustryBehaviour ind_behav = GetIndustrySpec(type)->behaviour;
|
IndustryBehaviour ind_behav = GetIndustrySpec(type)->behaviour;
|
||||||
|
|
||||||
/* Perform land/water check if not disabled */
|
/* Perform land/water check if not disabled */
|
||||||
if (!HasBit(its->slopes_refused, 5) && (IsWaterTile(cur_tile) == !(ind_behav & INDUSTRYBEH_BUILT_ONWATER))) return ret;
|
if (!HasBit(its->slopes_refused, 5) && (IsWaterTile(cur_tile) == !(ind_behav & INDUSTRYBEH_BUILT_ONWATER))) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
|
||||||
|
|
||||||
if (HasBit(its->callback_mask, CBM_INDT_SHAPE_CHECK)) {
|
if (HasBit(its->callback_mask, CBM_INDT_SHAPE_CHECK)) {
|
||||||
custom_shape = true;
|
custom_shape = true;
|
||||||
if (!PerformIndustryTileSlopeCheck(tile, cur_tile, its, type, gfx, itspec_index)) return ret;
|
if (!PerformIndustryTileSlopeCheck(tile, cur_tile, its, type, gfx, itspec_index)) return_cmd_error(_error_message);
|
||||||
} else {
|
} else {
|
||||||
Slope tileh = GetTileSlope(cur_tile, NULL);
|
Slope tileh = GetTileSlope(cur_tile, NULL);
|
||||||
refused_slope |= IsSlopeRefused(tileh, its->slopes_refused);
|
refused_slope |= IsSlopeRefused(tileh, its->slopes_refused);
|
||||||
@ -1365,15 +1364,15 @@ static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTil
|
|||||||
/* Clear the tiles as OWNER_TOWN to not affect town rating, and to not clear protected buildings */
|
/* Clear the tiles as OWNER_TOWN to not affect town rating, and to not clear protected buildings */
|
||||||
CompanyID old_company = _current_company;
|
CompanyID old_company = _current_company;
|
||||||
_current_company = OWNER_TOWN;
|
_current_company = OWNER_TOWN;
|
||||||
bool not_clearable = DoCommand(cur_tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR).Failed();
|
CommandCost ret = DoCommand(cur_tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR).Failed();
|
||||||
_current_company = old_company;
|
_current_company = old_company;
|
||||||
|
|
||||||
if (not_clearable) return ret;
|
if (ret.Failed()) return ret;
|
||||||
} else {
|
} else {
|
||||||
/* Clear the tiles, but do not affect town ratings */
|
/* Clear the tiles, but do not affect town ratings */
|
||||||
bool not_clearable = DoCommand(cur_tile, 0, 0, DC_AUTO | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, CMD_LANDSCAPE_CLEAR).Failed();
|
CommandCost ret = DoCommand(cur_tile, 0, 0, DC_AUTO | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, CMD_LANDSCAPE_CLEAR);
|
||||||
|
|
||||||
if (not_clearable) return ret;
|
if (ret.Failed()) return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while ((++it)->ti.x != -0x80);
|
} while ((++it)->ti.x != -0x80);
|
||||||
@ -1386,7 +1385,7 @@ static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTil
|
|||||||
if (!refused_slope || (_settings_game.game_creation.land_generator == LG_TERRAGENESIS && _generating_world && !custom_shape && !_ignore_restrictions)) {
|
if (!refused_slope || (_settings_game.game_creation.land_generator == LG_TERRAGENESIS && _generating_world && !custom_shape && !_ignore_restrictions)) {
|
||||||
return CommandCost();
|
return CommandCost();
|
||||||
}
|
}
|
||||||
return ret;
|
return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Is the industry allowed to be built at this place for the town?
|
/** Is the industry allowed to be built at this place for the town?
|
||||||
|
Loading…
Reference in New Issue
Block a user