mirror of https://github.com/OpenTTD/OpenTTD
(svn r19476) -Codechange: simplify the 'is conflicting industry nearby' check a bit
parent
81ca76a655
commit
aab8849661
|
@ -1527,19 +1527,19 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlag flags,
|
||||||
static CommandCost CheckIfFarEnoughFromIndustry(TileIndex tile, int type)
|
static CommandCost CheckIfFarEnoughFromIndustry(TileIndex tile, int type)
|
||||||
{
|
{
|
||||||
const IndustrySpec *indspec = GetIndustrySpec(type);
|
const IndustrySpec *indspec = GetIndustrySpec(type);
|
||||||
const Industry *i;
|
|
||||||
|
|
||||||
if (_settings_game.economy.same_industry_close && indspec->IsRawIndustry())
|
if (_settings_game.economy.same_industry_close && indspec->IsRawIndustry()) {
|
||||||
/* Allow primary industries to be placed close to any other industry */
|
/* Allow primary industries to be placed close to any other industry */
|
||||||
return CommandCost();
|
return CommandCost();
|
||||||
|
}
|
||||||
|
|
||||||
|
const Industry *i;
|
||||||
FOR_ALL_INDUSTRIES(i) {
|
FOR_ALL_INDUSTRIES(i) {
|
||||||
/* Within 14 tiles from another industry is considered close */
|
/* Within 14 tiles from another industry is considered close */
|
||||||
bool in_low_distance = DistanceMax(tile, i->location.tile) <= 14;
|
if (DistanceMax(tile, i->location.tile) > 14) continue;
|
||||||
|
|
||||||
/* check if an industry that accepts the same goods is nearby */
|
/* check if an industry that accepts the same goods is nearby */
|
||||||
if (in_low_distance &&
|
if (!indspec->IsRawIndustry() && // not a primary industry?
|
||||||
!indspec->IsRawIndustry() && // not a primary industry?
|
|
||||||
indspec->accepts_cargo[0] == i->accepts_cargo[0] && (
|
indspec->accepts_cargo[0] == i->accepts_cargo[0] && (
|
||||||
/* at least one of those options must be true */
|
/* at least one of those options must be true */
|
||||||
_game_mode != GM_EDITOR || // editor must not be stopped
|
_game_mode != GM_EDITOR || // editor must not be stopped
|
||||||
|
@ -1549,10 +1549,9 @@ static CommandCost CheckIfFarEnoughFromIndustry(TileIndex tile, int type)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if there are any conflicting industry types around */
|
/* check if there are any conflicting industry types around */
|
||||||
if ((i->type == indspec->conflicting[0] ||
|
if (i->type == indspec->conflicting[0] ||
|
||||||
i->type == indspec->conflicting[1] ||
|
i->type == indspec->conflicting[1] ||
|
||||||
i->type == indspec->conflicting[2]) &&
|
i->type == indspec->conflicting[2]) {
|
||||||
in_low_distance) {
|
|
||||||
return_cmd_error(STR_ERROR_INDUSTRY_TOO_CLOSE);
|
return_cmd_error(STR_ERROR_INDUSTRY_TOO_CLOSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue