mirror of https://github.com/OpenTTD/OpenTTD
(svn r22011) -Codechange: Rename a few variables and enhance code clearity
parent
64280e63fb
commit
44495f8dba
|
@ -1781,17 +1781,19 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int count = indspec->num_table;
|
int num_layouts = indspec->num_table;
|
||||||
int num = GB(p1, 8, 8);
|
int layout = GB(p1, 8, 8);
|
||||||
if (num >= count) return CMD_ERROR;
|
if (layout >= num_layouts) return CMD_ERROR;
|
||||||
|
|
||||||
CommandCost ret = CommandCost(STR_ERROR_SITE_UNSUITABLE);
|
CommandCost ret = CommandCost(STR_ERROR_SITE_UNSUITABLE);
|
||||||
do {
|
/* Check subsequently each layout, starting with the given layout in p1 */
|
||||||
if (--count < 0) return ret;
|
for (int i = 0; i < num_layouts; i++) {
|
||||||
if (--num < 0) num = indspec->num_table - 1;
|
layout = (layout + 1) % num_layouts;
|
||||||
ret = CreateNewIndustryHelper(tile, it, flags, indspec, num, random_var8f, random_initial_bits, _current_company, IACT_USERCREATION, &ind);
|
ret = CreateNewIndustryHelper(tile, it, flags, indspec, layout, random_var8f, random_initial_bits, _current_company, IACT_USERCREATION, &ind);
|
||||||
} while (ret.Failed());
|
if (ret.Succeeded()) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If it still failed, there's no suitable layout to build here, return the error */
|
||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue