|
|
|
@ -2040,12 +2040,13 @@ CommandCost CmdBuildIndustry(DoCommandFlag flags, TileIndex tile, IndustryType i
|
|
|
|
|
Industry *ind = nullptr;
|
|
|
|
|
if (deity_prospect || (_game_mode != GM_EDITOR && _current_company != OWNER_DEITY && _settings_game.construction.raw_industry_construction == 2 && indspec->IsRawIndustry())) {
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
|
|
/* Prospected industries are build as OWNER_TOWN to not e.g. be build on owned land of the founder */
|
|
|
|
|
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
|
|
|
|
/* Prospecting has a chance to fail, however we cannot guarantee that something can
|
|
|
|
|
* be built on the map, so the chance gets lower when the map is fuller, but there
|
|
|
|
|
* is nothing we can really do about that. */
|
|
|
|
|
if (deity_prospect || Random() <= indspec->prospecting_chance) {
|
|
|
|
|
bool prospect_success = deity_prospect || Random() <= indspec->prospecting_chance;
|
|
|
|
|
if (prospect_success) {
|
|
|
|
|
/* Prospected industries are build as OWNER_TOWN to not e.g. be build on owned land of the founder */
|
|
|
|
|
Backup<CompanyID> cur_company(_current_company, OWNER_TOWN, FILE_LINE);
|
|
|
|
|
for (int i = 0; i < 5000; i++) {
|
|
|
|
|
/* We should not have more than one Random() in a function call
|
|
|
|
|
* because parameter evaluation order is not guaranteed in the c++ standard
|
|
|
|
@ -2061,8 +2062,15 @@ CommandCost CmdBuildIndustry(DoCommandFlag flags, TileIndex tile, IndustryType i
|
|
|
|
|
}
|
|
|
|
|
if (ret.Succeeded()) break;
|
|
|
|
|
}
|
|
|
|
|
cur_company.Restore();
|
|
|
|
|
}
|
|
|
|
|
if (ret.Failed()) {
|
|
|
|
|
if (prospect_success) {
|
|
|
|
|
ShowErrorMessage(STR_ERROR_CAN_T_PROSPECT_INDUSTRY, STR_ERROR_NO_SUITABLE_PLACES_FOR_PROSPECTING, WL_INFO);
|
|
|
|
|
} else {
|
|
|
|
|
ShowErrorMessage(STR_ERROR_CAN_T_PROSPECT_INDUSTRY, STR_ERROR_PROSPECTING_WAS_UNLUCKY, WL_INFO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cur_company.Restore();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
size_t layout = first_layout;
|
|
|
|
|