Changeset - r15134:5ef57529e923
[Not reviewed]
master
0 6 0
yexo - 14 years ago 2010-05-09 15:59:30
yexo@openttd.org
(svn r19773) -Add: [NoAI] AIIndustry::GetIndustryID(TileIndex)
6 files changed with 22 insertions and 0 deletions:
0 comments (0 inline, 0 general)
bin/ai/regression/regression.nut
Show inline comments
 
@@ -605,6 +605,8 @@ function Regression::Industry()
 
	}
 
	print("  Valid Industries:    " + j);
 
	print("  GetIndustryCount():  " + AIIndustry.GetIndustryCount());
 
	print("  GetIndustryID():     " + AIIndustry.GetIndustryID(19694));
 
	print("  GetIndustryID():     " + AIIndustry.GetIndustryID(19695));
 
}
 

	
 
function Regression::IndustryList()
bin/ai/regression/regression.txt
Show inline comments
 
@@ -6548,6 +6548,8 @@ ERROR: IsEnd() is invalid as Begin() is 
 
	   GetStockpiledCargo():      0
 
  Valid Industries:    71
 
  GetIndustryCount():  71
 
  GetIndustryID():     65535
 
  GetIndustryID():     0
 

	
 
--IndustryList--
 
  Count():             71
src/ai/api/ai_changelog.hpp
Show inline comments
 
@@ -20,6 +20,7 @@
 
 *
 
 * API additions:
 
 * \li IsEnd for all lists.
 
 * \li AIIndustry::GetIndustryID
 
 * \li AIRail::GetMaxSpeed
 
 *
 
 * API removals:
src/ai/api/ai_industry.cpp
Show inline comments
 
@@ -27,6 +27,12 @@
 
	return ::Industry::IsValidID(industry_id);
 
}
 

	
 
/* static */ IndustryID AIIndustry::GetIndustryID(TileIndex tile)
 
{
 
	if (!::IsValidTile(tile) || !::IsTileType(tile, MP_INDUSTRY)) return INVALID_INDUSTRY;
 
	return ::GetIndustryIndex(tile);
 
}
 

	
 
/* static */ char *AIIndustry::GetName(IndustryID industry_id)
 
{
 
	if (!IsValidIndustry(industry_id)) return NULL;
src/ai/api/ai_industry.hpp
Show inline comments
 
@@ -37,6 +37,16 @@ public:
 
	static bool IsValidIndustry(IndustryID industry_id);
 

	
 
	/**
 
	 * Get the IndustryID of a tile, if there is an industry.
 
	 * @param tile The tile to find the IndustryID of.
 
	 * @return IndustryID of the industry.
 
	 * @post Use IsValidIndustry() to see if the industry is valid.
 
	 * @note GetIndustryID will return an invalid IndustryID for the
 
	 *   station tile of industries with a dock/heliport.
 
	 */
 
	static IndustryID GetIndustryID(TileIndex tile);
 

	
 
	/**
 
	 * Get the name of the industry.
 
	 * @param industry_id The industry to get the name of.
 
	 * @pre IsValidIndustry(industry_id).
src/ai/api/ai_industry.hpp.sq
Show inline comments
 
@@ -28,6 +28,7 @@ void SQAIIndustry_Register(Squirrel *eng
 

	
 
	SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetIndustryCount,                  "GetIndustryCount",                  1, ".");
 
	SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::IsValidIndustry,                   "IsValidIndustry",                   2, ".i");
 
	SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetIndustryID,                     "GetIndustryID",                     2, ".i");
 
	SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetName,                           "GetName",                           2, ".i");
 
	SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::IsCargoAccepted,                   "IsCargoAccepted",                   3, ".ii");
 
	SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetStockpiledCargo,                "GetStockpiledCargo",                3, ".ii");
0 comments (0 inline, 0 general)