diff options
author | belugas <belugas@openttd.org> | 2008-01-09 18:35:18 +0000 |
---|---|---|
committer | belugas <belugas@openttd.org> | 2008-01-09 18:35:18 +0000 |
commit | 6375ea065b32e6dc79cd05c5d137c4c8c17f32e8 (patch) | |
tree | 596f635fed780207511966ec62866f11edb8ba65 /src | |
parent | f67b5798a00cdf9a76c10fa52e59b49c49b77bc8 (diff) | |
download | openttd-6375ea065b32e6dc79cd05c5d137c4c8c17f32e8.tar.xz |
(svn r11798) -Codechange: add comments and give a more representative function's name
Diffstat (limited to 'src')
-rw-r--r-- | src/industry_cmd.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 5a8e9b1c9..2074f7a0a 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -1377,31 +1377,36 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, uint32 flags, const } -static bool CheckIfTooCloseToIndustry(TileIndex tile, int type) +static bool CheckIfFarEnoughFromIndustry(TileIndex tile, int type) { const IndustrySpec *indspec = GetIndustrySpec(type); const Industry *i; - /* accepting industries won't be close, not even with patch */ if (_patches.same_industry_close && indspec->accepts_cargo[0] == CT_INVALID) + /* Allow primary industries to be placed close to any other industry */ return true; FOR_ALL_INDUSTRIES(i) { + /* Within 14 tiles from another industry is considered close */ + bool in_low_distance = DistanceMax(tile, i->xy) <= 14; + /* check if an industry that accepts the same goods is nearby */ - if (DistanceMax(tile, i->xy) <= 14 && - indspec->accepts_cargo[0] != CT_INVALID && + if (in_low_distance && + indspec->accepts_cargo[0] != CT_INVALID && // not a primary industry? indspec->accepts_cargo[0] == i->accepts_cargo[0] && ( - _game_mode != GM_EDITOR || - !_patches.same_industry_close || - !_patches.multiple_industry_per_town - )) { + /* at least one of those options must be true */ + _game_mode != GM_EDITOR || // editor must not be stopped + !_patches.same_industry_close || + !_patches.multiple_industry_per_town)) { _error_message = STR_INDUSTRY_TOO_CLOSE; return false; } - /* check "not close to" field. */ - if ((i->type == indspec->conflicting[0] || i->type == indspec->conflicting[1] || i->type == indspec->conflicting[2]) && - DistanceMax(tile, i->xy) <= 14) { + /* check if there are any conflicting industry types around */ + if ((i->type == indspec->conflicting[0] || + i->type == indspec->conflicting[1] || + i->type == indspec->conflicting[2]) && + in_low_distance) { _error_message = STR_INDUSTRY_TOO_CLOSE; return false; } @@ -1558,7 +1563,7 @@ static Industry *CreateNewIndustryHelper(TileIndex tile, IndustryType type, uint } if (!custom_shape_check && _patches.land_generator == LG_TERRAGENESIS && _generating_world && !_ignore_restrictions && !CheckIfCanLevelIndustryPlatform(tile, 0, it, type)) return NULL; - if (!CheckIfTooCloseToIndustry(tile, type)) return NULL; + if (!CheckIfFarEnoughFromIndustry(tile, type)) return NULL; const Town *t = CheckMultipleIndustryInTown(tile, type); if (t == NULL) return NULL; |