Changeset - r26160:04b069238def
[Not reviewed]
master
0 4 0
Andy - 2 years ago 2022-01-20 21:33:37
andy@teamrubber.com
Add: [Script] ObjectType::ResolveNewGRFID to resolve object id from grfid and grf_local_id
4 files changed with 21 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/script/api/ai_changelog.hpp
Show inline comments
 
@@ -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:
src/script/api/game_changelog.hpp
Show inline comments
 
@@ -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:
src/script/api/script_objecttype.cpp
Show inline comments
 
@@ -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);
 
}
src/script/api/script_objecttype.hpp
Show inline comments
 
@@ -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 */
0 comments (0 inline, 0 general)