Changeset - r26981:c0aee015e2dd
[Not reviewed]
master
0 2 0
glx22 - 15 months ago 2023-03-04 16:45:19
glx@openttd.org
Codechange: Use SQInteger for generic numbers in script_objecttype
2 files changed with 8 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/script/api/script_objecttype.cpp
Show inline comments
 
@@ -30,25 +30,26 @@
 
	return GetString(ObjectSpec::Get(object_type)->name);
 
}
 

	
 
/* static */ uint8 ScriptObjectType::GetViews(ObjectType object_type)
 
/* static */ SQInteger ScriptObjectType::GetViews(ObjectType object_type)
 
{
 
	EnforcePrecondition(0, IsValidObjectType(object_type));
 

	
 
	return ObjectSpec::Get(object_type)->views;
 
}
 

	
 
/* static */ bool ScriptObjectType::BuildObject(ObjectType object_type, uint8 view, TileIndex tile)
 
/* static */ bool ScriptObjectType::BuildObject(ObjectType object_type, SQInteger view, TileIndex tile)
 
{
 
	EnforcePrecondition(false, IsValidObjectType(object_type));
 
	EnforcePrecondition(false, view >= 0 && view < GetViews(object_type));
 
	EnforcePrecondition(false, ScriptMap::IsValidTile(tile));
 

	
 
	return ScriptObject::Command<CMD_BUILD_OBJECT>::Do(tile, object_type, view);
 
}
 

	
 
/* static */ ObjectType ScriptObjectType::ResolveNewGRFID(uint32 grfid, uint16 grf_local_id)
 
/* static */ ObjectType ScriptObjectType::ResolveNewGRFID(SQInteger grfid, SQInteger grf_local_id)
 
{
 
	EnforcePrecondition(INVALID_OBJECT_TYPE, IsInsideBS(grf_local_id, 0x00, NUM_OBJECTS_PER_GRF));
 

	
 
	grfid = BSWAP32(grfid); // Match people's expectations.
 
	grfid = BSWAP32(GB(grfid, 0, 32)); // Match people's expectations.
 
	return _object_mngr.GetID(grf_local_id, grfid);
 
}
src/script/api/script_objecttype.hpp
Show inline comments
 
@@ -41,7 +41,7 @@ public:
 
	 * @pre IsValidObjectType(object_type).
 
	 * @return The number of views for an object.
 
	 */
 
	static uint8 GetViews(ObjectType object_type);
 
	static SQInteger GetViews(ObjectType object_type);
 

	
 
	/**
 
	 * Build an object of the specified type.
 
@@ -51,7 +51,7 @@ public:
 
	 * @pre IsValidObjectType(object_type).
 
	 * @return True if the object was successfully build.
 
	 */
 
	static bool BuildObject(ObjectType object_type, uint8 view, TileIndex tile);
 
	static bool BuildObject(ObjectType object_type, SQInteger view, TileIndex tile);
 

	
 
	/**
 
	 * Get a specific object-type from a grf.
 
@@ -60,7 +60,7 @@ public:
 
	 * @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);
 
	static ObjectType ResolveNewGRFID(SQInteger grfid, SQInteger grf_local_id);
 
};
 

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