mirror of https://github.com/OpenTTD/OpenTTD
(svn r24513) -Add: [Script] ScriptIndustryType::IsProcessingIndustry.
parent
8aa27f09fe
commit
bcac3d16b6
|
@ -2722,8 +2722,17 @@ void InitializeIndustries()
|
||||||
*/
|
*/
|
||||||
bool IndustrySpec::IsRawIndustry() const
|
bool IndustrySpec::IsRawIndustry() const
|
||||||
{
|
{
|
||||||
/* Lumber mills are extractive/organic, but can always be built like a non-raw industry */
|
return (this->life_type & (INDUSTRYLIFE_EXTRACTIVE | INDUSTRYLIFE_ORGANIC)) != 0;
|
||||||
return (this->life_type & (INDUSTRYLIFE_EXTRACTIVE | INDUSTRYLIFE_ORGANIC)) != 0 &&
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is an industry with the spec a processing industry?
|
||||||
|
* @return true if it should be handled as a processing industry
|
||||||
|
*/
|
||||||
|
bool IndustrySpec::IsProcessingIndustry() const
|
||||||
|
{
|
||||||
|
/* Lumber mills are neither raw nor processing */
|
||||||
|
return (this->life_type & INDUSTRYLIFE_PROCESSING) != 0 &&
|
||||||
(this->behaviour & INDUSTRYBEH_CUT_TREES) == 0;
|
(this->behaviour & INDUSTRYBEH_CUT_TREES) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,7 @@ struct IndustrySpec {
|
||||||
GRFFileProps grf_prop; ///< properties related to the grf file
|
GRFFileProps grf_prop; ///< properties related to the grf file
|
||||||
|
|
||||||
bool IsRawIndustry() const;
|
bool IsRawIndustry() const;
|
||||||
|
bool IsProcessingIndustry() const;
|
||||||
Money GetConstructionCost() const;
|
Money GetConstructionCost() const;
|
||||||
Money GetRemovalCost() const;
|
Money GetRemovalCost() const;
|
||||||
bool UsesSmoothEconomy() const;
|
bool UsesSmoothEconomy() const;
|
||||||
|
|
|
@ -29,6 +29,7 @@ void SQAIIndustryType_Register(Squirrel *engine)
|
||||||
SQAIIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::GetProducedCargo, "GetProducedCargo", 2, ".i");
|
SQAIIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::GetProducedCargo, "GetProducedCargo", 2, ".i");
|
||||||
SQAIIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::GetAcceptedCargo, "GetAcceptedCargo", 2, ".i");
|
SQAIIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::GetAcceptedCargo, "GetAcceptedCargo", 2, ".i");
|
||||||
SQAIIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::IsRawIndustry, "IsRawIndustry", 2, ".i");
|
SQAIIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::IsRawIndustry, "IsRawIndustry", 2, ".i");
|
||||||
|
SQAIIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::IsProcessingIndustry, "IsProcessingIndustry", 2, ".i");
|
||||||
SQAIIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::ProductionCanIncrease, "ProductionCanIncrease", 2, ".i");
|
SQAIIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::ProductionCanIncrease, "ProductionCanIncrease", 2, ".i");
|
||||||
SQAIIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::GetConstructionCost, "GetConstructionCost", 2, ".i");
|
SQAIIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::GetConstructionCost, "GetConstructionCost", 2, ".i");
|
||||||
SQAIIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::CanBuildIndustry, "CanBuildIndustry", 2, ".i");
|
SQAIIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::CanBuildIndustry, "CanBuildIndustry", 2, ".i");
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
* API additions:
|
* API additions:
|
||||||
* \li AIEventExclusiveTransportRights
|
* \li AIEventExclusiveTransportRights
|
||||||
* \li AIEventRoadReconstruction
|
* \li AIEventRoadReconstruction
|
||||||
|
* \li AIIndustryType::IsProcessingIndustry
|
||||||
* \li AIStation::IsAirportClosed
|
* \li AIStation::IsAirportClosed
|
||||||
* \li AIStation::OpenCloseAirport
|
* \li AIStation::OpenCloseAirport
|
||||||
*
|
*
|
||||||
|
|
|
@ -29,6 +29,7 @@ void SQGSIndustryType_Register(Squirrel *engine)
|
||||||
SQGSIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::GetProducedCargo, "GetProducedCargo", 2, ".i");
|
SQGSIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::GetProducedCargo, "GetProducedCargo", 2, ".i");
|
||||||
SQGSIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::GetAcceptedCargo, "GetAcceptedCargo", 2, ".i");
|
SQGSIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::GetAcceptedCargo, "GetAcceptedCargo", 2, ".i");
|
||||||
SQGSIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::IsRawIndustry, "IsRawIndustry", 2, ".i");
|
SQGSIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::IsRawIndustry, "IsRawIndustry", 2, ".i");
|
||||||
|
SQGSIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::IsProcessingIndustry, "IsProcessingIndustry", 2, ".i");
|
||||||
SQGSIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::ProductionCanIncrease, "ProductionCanIncrease", 2, ".i");
|
SQGSIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::ProductionCanIncrease, "ProductionCanIncrease", 2, ".i");
|
||||||
SQGSIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::GetConstructionCost, "GetConstructionCost", 2, ".i");
|
SQGSIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::GetConstructionCost, "GetConstructionCost", 2, ".i");
|
||||||
SQGSIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::CanBuildIndustry, "CanBuildIndustry", 2, ".i");
|
SQGSIndustryType.DefSQStaticMethod(engine, &ScriptIndustryType::CanBuildIndustry, "CanBuildIndustry", 2, ".i");
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
* \li GSEventExclusiveTransportRights
|
* \li GSEventExclusiveTransportRights
|
||||||
* \li GSEventRoadReconstruction
|
* \li GSEventRoadReconstruction
|
||||||
* \li GSNews::NT_ACCIDENT, GSNews::NT_COMPANY_INFO, GSNews::NT_ADVICE, GSNews::NT_ACCEPTANCE
|
* \li GSNews::NT_ACCIDENT, GSNews::NT_COMPANY_INFO, GSNews::NT_ADVICE, GSNews::NT_ACCEPTANCE
|
||||||
|
* \li GSIndustryType::IsProcessingIndustry
|
||||||
* \li GSStation::IsAirportClosed
|
* \li GSStation::IsAirportClosed
|
||||||
* \li GSStation::OpenCloseAirport
|
* \li GSStation::OpenCloseAirport
|
||||||
*
|
*
|
||||||
|
|
|
@ -32,6 +32,13 @@
|
||||||
return ::GetIndustrySpec(industry_type)->IsRawIndustry();
|
return ::GetIndustrySpec(industry_type)->IsRawIndustry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */ bool ScriptIndustryType::IsProcessingIndustry(IndustryType industry_type)
|
||||||
|
{
|
||||||
|
if (!IsValidIndustryType(industry_type)) return false;
|
||||||
|
|
||||||
|
return ::GetIndustrySpec(industry_type)->IsProcessingIndustry();
|
||||||
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptIndustryType::ProductionCanIncrease(IndustryType industry_type)
|
/* static */ bool ScriptIndustryType::ProductionCanIncrease(IndustryType industry_type)
|
||||||
{
|
{
|
||||||
if (!IsValidIndustryType(industry_type)) return false;
|
if (!IsValidIndustryType(industry_type)) return false;
|
||||||
|
|
|
@ -65,12 +65,32 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this industry type a raw industry?
|
* Is this industry type a raw industry?
|
||||||
|
* Raw industries usually produce cargo without any prerequisites.
|
||||||
|
* ("Usually" means that advanced NewGRF industry concepts might not fit the "raw"/"processing"
|
||||||
|
* classification, so it's up to the interpretation of the NewGRF author.)
|
||||||
* @param industry_type The type of the industry.
|
* @param industry_type The type of the industry.
|
||||||
* @pre IsValidIndustryType(industry_type).
|
* @pre IsValidIndustryType(industry_type).
|
||||||
* @return True if it should be handled as a raw industry.
|
* @return True if it should be handled as a raw industry.
|
||||||
|
* @note Industries might be neither raw nor processing.
|
||||||
|
* This is usually the case for industries which produce nothing (e.g. power plants),
|
||||||
|
* but also for weird industries like temperate banks and tropic lumber mills.
|
||||||
*/
|
*/
|
||||||
static bool IsRawIndustry(IndustryType industry_type);
|
static bool IsRawIndustry(IndustryType industry_type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this industry type a processing industry?
|
||||||
|
* Processing industries usually produce cargo when delivered with input cargo.
|
||||||
|
* ("Usually" means that advanced NewGRF industry concepts might not fit the "raw"/"processing"
|
||||||
|
* classification, so it's up to the interpretation of the NewGRF author.)
|
||||||
|
* @param industry_type The type of the industry.
|
||||||
|
* @pre IsValidIndustryType(industry_type).
|
||||||
|
* @return True if it is a processing industry.
|
||||||
|
* @note Industries might be neither raw nor processing.
|
||||||
|
* This is usually the case for industries which produce nothing (e.g. power plants),
|
||||||
|
* but also for weird industries like temperate banks and tropic lumber mills.
|
||||||
|
*/
|
||||||
|
static bool IsProcessingIndustry(IndustryType industry_type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can the production of this industry increase?
|
* Can the production of this industry increase?
|
||||||
* @param industry_type The type of the industry.
|
* @param industry_type The type of the industry.
|
||||||
|
|
Loading…
Reference in New Issue