summaryrefslogtreecommitdiff
path: root/src/ai/api
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-04-23 21:47:03 +0000
committerfrosch <frosch@openttd.org>2010-04-23 21:47:03 +0000
commitca9a015984fa7c0c49ddb587635cd65b594c723a (patch)
tree66ef604573811953ed924662d2d2ce13653b8c4c /src/ai/api
parent7a56196d98656a2080f5918699d37773ba294d69 (diff)
downloadopenttd-ca9a015984fa7c0c49ddb587635cd65b594c723a.tar.xz
(svn r19701) -Fix [FS#3787]: Check for industry availability more thoroughly and cancel object placement when selecting not available industries.
Diffstat (limited to 'src/ai/api')
-rw-r--r--src/ai/api/ai_industrytype.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/ai/api/ai_industrytype.cpp b/src/ai/api/ai_industrytype.cpp
index 993a88993..8973d7688 100644
--- a/src/ai/api/ai_industrytype.cpp
+++ b/src/ai/api/ai_industrytype.cpp
@@ -14,6 +14,7 @@
#include "../../command_type.h"
#include "../../strings_func.h"
#include "../../industry.h"
+#include "../../newgrf_industries.h"
#include "../../core/random_func.hpp"
/* static */ bool AIIndustryType::IsValidIndustryType(IndustryType industry_type)
@@ -88,6 +89,8 @@
/* static */ bool AIIndustryType::CanBuildIndustry(IndustryType industry_type)
{
if (!IsValidIndustryType(industry_type)) return false;
+
+ if (!::CheckIfCallBackAllowsAvailability(industry_type, IACT_USERCREATION)) return false;
if (!::GetIndustrySpec(industry_type)->IsRawIndustry()) return true;
/* raw_industry_construction == 1 means "Build as other industries" */
@@ -97,7 +100,9 @@
/* static */ bool AIIndustryType::CanProspectIndustry(IndustryType industry_type)
{
if (!IsValidIndustryType(industry_type)) return false;
+
if (!::GetIndustrySpec(industry_type)->IsRawIndustry()) return false;
+ if (!::CheckIfCallBackAllowsAvailability(industry_type, IACT_USERCREATION)) return false;
/* raw_industry_construction == 2 means "prospect" */
return _settings_game.construction.raw_industry_construction == 2;