summaryrefslogtreecommitdiff
path: root/src/industry_cmd.cpp
diff options
context:
space:
mode:
authorplanetmaker <planetmaker@openttd.org>2011-02-07 20:47:58 +0000
committerplanetmaker <planetmaker@openttd.org>2011-02-07 20:47:58 +0000
commit68d03b66e3a85e714bbcce3f3a53b55cfb597ab4 (patch)
treeee56bb15e782a389a59693cd29539ea54698ccb2 /src/industry_cmd.cpp
parent44495f8dba07184a2364b030ad257ac933e8ae36 (diff)
downloadopenttd-68d03b66e3a85e714bbcce3f3a53b55cfb597ab4.tar.xz
(svn r22012) -Add: [NewGRF] Test all industry layouts also when prospecting
Diffstat (limited to 'src/industry_cmd.cpp')
-rw-r--r--src/industry_cmd.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 98e75cbd8..5e76c3de9 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1759,6 +1759,8 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
randomizer.SetSeed(p2);
uint16 random_initial_bits = GB(p2, 0, 16);
uint32 random_var8f = randomizer.Next();
+ int num_layouts = indspec->num_table;
+ CommandCost ret = CommandCost(STR_ERROR_SITE_UNSUITABLE);
Industry *ind = NULL;
if (_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && indspec->IsRawIndustry()) {
@@ -1774,18 +1776,23 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
* because parameter evaluation order is not guaranteed in the c++ standard
*/
tile = RandomTile();
- CommandCost ret = CreateNewIndustryHelper(tile, it, flags, indspec, RandomRange(indspec->num_table), random_var8f, random_initial_bits, cur_company.GetOriginalValue(), IACT_PROSPECTCREATION, &ind);
+ /* Start with a random layout */
+ int layout = RandomRange(num_layouts);
+ /* Check now each layout, starting with the random one */
+ for (int j = 0; j < num_layouts; j++) {
+ layout = (layout + 1) % num_layouts;
+ ret = CreateNewIndustryHelper(tile, it, flags, indspec, layout, random_var8f, random_initial_bits, cur_company.GetOriginalValue(), IACT_PROSPECTCREATION, &ind);
+ if (ret.Succeeded()) break;
+ }
if (ret.Succeeded()) break;
}
}
cur_company.Restore();
}
} else {
- int num_layouts = indspec->num_table;
int layout = GB(p1, 8, 8);
if (layout >= num_layouts) return CMD_ERROR;
- CommandCost ret = CommandCost(STR_ERROR_SITE_UNSUITABLE);
/* Check subsequently each layout, starting with the given layout in p1 */
for (int i = 0; i < num_layouts; i++) {
layout = (layout + 1) % num_layouts;