mirror of https://github.com/OpenTTD/OpenTTD
Add: [Script] ObjectType::ResolveNewGRFID to resolve object id from grfid and grf_local_id
parent
f6775a2d55
commit
26ac0c48f0
|
@ -17,6 +17,8 @@
|
|||
*
|
||||
* This version is not yet released. The following changes are not set in stone yet.
|
||||
*
|
||||
* \li AIObjectType::ResolveNewGRFID
|
||||
*
|
||||
* \b 12.0
|
||||
*
|
||||
* API additions:
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
*
|
||||
* This version is not yet released. The following changes are not set in stone yet.
|
||||
*
|
||||
* \li GSObjectType::ResolveNewGRFID
|
||||
*
|
||||
* \b 12.0
|
||||
*
|
||||
* API additions:
|
||||
|
|
|
@ -44,3 +44,11 @@
|
|||
|
||||
return ScriptObject::Command<CMD_BUILD_OBJECT>::Do(tile, object_type, view);
|
||||
}
|
||||
|
||||
/* static */ ObjectType ScriptObjectType::ResolveNewGRFID(uint32 grfid, uint16 grf_local_id)
|
||||
{
|
||||
EnforcePrecondition(INVALID_OBJECT_TYPE, IsInsideBS(grf_local_id, 0x00, NUM_OBJECTS_PER_GRF));
|
||||
|
||||
grfid = BSWAP32(grfid); // Match people's expectations.
|
||||
return _object_mngr.GetID(grf_local_id, grfid);
|
||||
}
|
||||
|
|
|
@ -52,6 +52,15 @@ public:
|
|||
* @return True if the object was successfully build.
|
||||
*/
|
||||
static bool BuildObject(ObjectType object_type, uint8 view, TileIndex tile);
|
||||
|
||||
/**
|
||||
* Get a specific object-type from a grf.
|
||||
* @param grf_id The ID of the NewGRF.
|
||||
* @param grf_local_id The ID of the object, local to the NewGRF.
|
||||
* @pre 0x00 <= grf_local_id < NUM_OBJECTS_PER_GRF.
|
||||
* @return the object-type ID, local to the current game (this diverges from the grf_local_id).
|
||||
*/
|
||||
static ObjectType ResolveNewGRFID(uint32 grfid, uint16 grf_local_id);
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_OBJECTTYPE_HPP */
|
||||
|
|
Loading…
Reference in New Issue