Add: [Script] IndustryType::ResolveNewGRFID to resolve industry id from grfid and grf_local_id

pull/363/head
Andy 2 years ago committed by Michael Lutz
parent 26ac0c48f0
commit b8a8891a86

@ -17,6 +17,7 @@
* *
* This version is not yet released. The following changes are not set in stone yet. * This version is not yet released. The following changes are not set in stone yet.
* *
* \li AIIndustryType::ResolveNewGRFID
* \li AIObjectType::ResolveNewGRFID * \li AIObjectType::ResolveNewGRFID
* *
* \b 12.0 * \b 12.0

@ -17,6 +17,7 @@
* *
* This version is not yet released. The following changes are not set in stone yet. * This version is not yet released. The following changes are not set in stone yet.
* *
* \li GSIndustryType::ResolveNewGRFID
* \li GSObjectType::ResolveNewGRFID * \li GSObjectType::ResolveNewGRFID
* *
* \b 12.0 * \b 12.0

@ -154,3 +154,11 @@
return (::GetIndustrySpec(industry_type)->behaviour & INDUSTRYBEH_AI_AIRSHIP_ROUTES) != 0; 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);
}

@ -181,6 +181,15 @@ public:
* @return True when this type has a dock. * @return True when this type has a dock.
*/ */
static bool HasDock(IndustryType industry_type); 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 */ #endif /* SCRIPT_INDUSTRYTYPE_HPP */

Loading…
Cancel
Save