summaryrefslogtreecommitdiff
path: root/src/script/api/script_industrytype.cpp
diff options
context:
space:
mode:
authorzuu <zuu@openttd.org>2012-10-22 18:56:21 +0000
committerzuu <zuu@openttd.org>2012-10-22 18:56:21 +0000
commit082699482118e2a00f5c873d8820fad0e05a7ec2 (patch)
tree6774f47c9fb13d6721d17dce6f9b88e3e83001c1 /src/script/api/script_industrytype.cpp
parent59847550dc7a0e58307e548c05894e795424fa37 (diff)
downloadopenttd-082699482118e2a00f5c873d8820fad0e05a7ec2.tar.xz
(svn r24623) -Feature: Allow GameScripts to construct and prospect industries without having a sponsor
Diffstat (limited to 'src/script/api/script_industrytype.cpp')
-rw-r--r--src/script/api/script_industrytype.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/script/api/script_industrytype.cpp b/src/script/api/script_industrytype.cpp
index 7db905829..bbfca99a4 100644
--- a/src/script/api/script_industrytype.cpp
+++ b/src/script/api/script_industrytype.cpp
@@ -94,7 +94,9 @@
{
if (!IsValidIndustryType(industry_type)) return false;
- if (::GetIndustryProbabilityCallback(industry_type, IACT_USERCREATION, 1) == 0) return false;
+ const bool deity = ScriptObject::GetCompany() == OWNER_DEITY;
+ if (::GetIndustryProbabilityCallback(industry_type, deity ? IACT_RANDOMCREATION : IACT_USERCREATION, 1) == 0) return false;
+ if (deity) return true;
if (!::GetIndustrySpec(industry_type)->IsRawIndustry()) return true;
/* raw_industry_construction == 1 means "Build as other industries" */
@@ -105,26 +107,25 @@
{
if (!IsValidIndustryType(industry_type)) return false;
- if (!::GetIndustrySpec(industry_type)->IsRawIndustry()) return false;
- if (::GetIndustryProbabilityCallback(industry_type, IACT_USERCREATION, 1) == 0) return false;
+ const bool deity = ScriptObject::GetCompany() == OWNER_DEITY;
+ if (!deity && !::GetIndustrySpec(industry_type)->IsRawIndustry()) return false;
+ if (::GetIndustryProbabilityCallback(industry_type, deity ? IACT_RANDOMCREATION : IACT_USERCREATION, 1) == 0) return false;
/* raw_industry_construction == 2 means "prospect" */
- return _settings_game.construction.raw_industry_construction == 2;
+ return deity || _settings_game.construction.raw_industry_construction == 2;
}
/* static */ bool ScriptIndustryType::BuildIndustry(IndustryType industry_type, TileIndex tile)
{
- EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
EnforcePrecondition(false, CanBuildIndustry(industry_type));
EnforcePrecondition(false, ScriptMap::IsValidTile(tile));
uint32 seed = ::InteractiveRandom();
- return ScriptObject::DoCommand(tile, (::InteractiveRandomRange(::GetIndustrySpec(industry_type)->num_table) << 8) | industry_type, seed, CMD_BUILD_INDUSTRY);
+ return ScriptObject::DoCommand(tile, (1 << 16) | (::InteractiveRandomRange(::GetIndustrySpec(industry_type)->num_table) << 8) | industry_type, seed, CMD_BUILD_INDUSTRY);
}
/* static */ bool ScriptIndustryType::ProspectIndustry(IndustryType industry_type)
{
- EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
EnforcePrecondition(false, CanProspectIndustry(industry_type));
uint32 seed = ::InteractiveRandom();