Changeset - r15065:d125439c4426
[Not reviewed]
master
0 3 0
frosch - 14 years ago 2010-04-23 21:47:03
frosch@openttd.org
(svn r19701) -Fix [FS#3787]: Check for industry availability more thoroughly and cancel object placement when selecting not available industries.
3 files changed with 13 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_industrytype.cpp
Show inline comments
 
@@ -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;
src/industry_cmd.cpp
Show inline comments
 
@@ -1764,6 +1764,10 @@ CommandCost CmdBuildIndustry(TileIndex t
 
		return CMD_ERROR;
 
	}
 

	
 
	if (_game_mode != GM_EDITOR && !CheckIfCallBackAllowsAvailability(it, IACT_USERCREATION)) {
 
		return CMD_ERROR;
 
	}
 

	
 
	Industry *ind = NULL;
 
	if (_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && indspec->IsRawIndustry()) {
 
		if (flags & DC_EXEC) {
src/industry_gui.cpp
Show inline comments
 
@@ -463,8 +463,10 @@ public:
 

	
 
					this->SetDirty();
 

	
 
					if ((_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && indsp != NULL && indsp->IsRawIndustry()) ||
 
							this->selected_type == INVALID_INDUSTRYTYPE) {
 
					if (GetCallbackWnd() == this &&
 
							((_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && indsp != NULL && indsp->IsRawIndustry()) ||
 
							this->selected_type == INVALID_INDUSTRYTYPE ||
 
							!this->enabled[this->selected_index])) {
 
						/* Reset the button state if going to prospecting or "build many industries" */
 
						this->RaiseButtons();
 
						ResetObjectToPlace();
0 comments (0 inline, 0 general)