Changeset - r26161:98df3643a152
[Not reviewed]
master
0 4 0
Andy - 2 years ago 2022-01-22 12:39:55
andy@teamrubber.com
Add: [Script] IndustryType::ResolveNewGRFID to resolve industry id from grfid and grf_local_id
4 files changed with 19 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/script/api/ai_changelog.hpp
Show inline comments
 
@@ -17,6 +17,7 @@
 
 *
 
 * This version is not yet released. The following changes are not set in stone yet.
 
 *
 
 * \li AIIndustryType::ResolveNewGRFID
 
 * \li AIObjectType::ResolveNewGRFID
 
 *
 
 * \b 12.0
src/script/api/game_changelog.hpp
Show inline comments
 
@@ -17,6 +17,7 @@
 
 *
 
 * This version is not yet released. The following changes are not set in stone yet.
 
 *
 
 * \li GSIndustryType::ResolveNewGRFID
 
 * \li GSObjectType::ResolveNewGRFID
 
 *
 
 * \b 12.0
src/script/api/script_industrytype.cpp
Show inline comments
 
@@ -154,3 +154,11 @@
 

	
 
	return (::GetIndustrySpec(industry_type)->behaviour & INDUSTRYBEH_AI_AIRSHIP_ROUTES) != 0;
 
}
 

	
 
/* static */ IndustryType ScriptIndustryType::ResolveNewGRFID(uint32 grfid, uint16 grf_local_id)
 
{
 
	EnforcePrecondition(INVALID_INDUSTRYTYPE, IsInsideBS(grf_local_id, 0x00, NUM_INDUSTRYTYPES_PER_GRF));
 

	
 
	grfid = BSWAP32(grfid); // Match people's expectations.
 
	return _industry_mngr.GetID(grf_local_id, grfid);
 
}
src/script/api/script_industrytype.hpp
Show inline comments
 
@@ -181,6 +181,15 @@ public:
 
	 * @return True when this type has a dock.
 
	 */
 
	static bool HasDock(IndustryType industry_type);
 

	
 
	/**
 
	 * Get a specific industry-type from a grf.
 
	 * @param grf_id The ID of the NewGRF.
 
	 * @param grf_local_id The ID of the industry, local to the NewGRF.
 
	 * @pre 0x00 <= grf_local_id < NUM_INDUSTRYTYPES_PER_GRF.
 
	 * @return the industry-type ID, local to the current game (this diverges from the grf_local_id).
 
	 */
 
	static IndustryType ResolveNewGRFID(uint32 grfid, uint16 grf_local_id);
 
};
 

	
 
#endif /* SCRIPT_INDUSTRYTYPE_HPP */
0 comments (0 inline, 0 general)