1
0
Fork 0

Add: ScriptGroup::GetOwner for Game Scripts

pull/10411/head
SamuXarick 2023-01-23 23:10:46 +00:00
parent d009bfc47b
commit 68a9f6e774
3 changed files with 17 additions and 0 deletions

View File

@ -27,6 +27,7 @@
* \li GSCargo::CC_NON_POURABLE * \li GSCargo::CC_NON_POURABLE
* \li GSCargo::CC_POTABLE * \li GSCargo::CC_POTABLE
* \li GSCargo::CC_NON_POTABLE * \li GSCargo::CC_NON_POTABLE
* \li GSGroup::GetOwner
* *
* Other changes: * Other changes:
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType * \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType

View File

@ -31,6 +31,13 @@
return g != nullptr && g->owner == ScriptObject::GetCompany(); return g != nullptr && g->owner == ScriptObject::GetCompany();
} }
/* static */ ScriptCompany::CompanyID ScriptGroup::GetOwner(GroupID group_id)
{
if (!IsValidGroup(group_id)) return ScriptCompany::COMPANY_INVALID;
return ScriptCompany::ToScriptCompanyID(::Group::Get(group_id)->owner);
}
/* static */ GroupID ScriptGroup::CreateGroup(ScriptVehicle::VehicleType vehicle_type, GroupID parent_group_id) /* static */ GroupID ScriptGroup::CreateGroup(ScriptVehicle::VehicleType vehicle_type, GroupID parent_group_id)
{ {
EnforceCompanyModeValid(GROUP_INVALID); EnforceCompanyModeValid(GROUP_INVALID);

View File

@ -31,6 +31,15 @@ public:
*/ */
static bool IsValidGroup(GroupID group_id); static bool IsValidGroup(GroupID group_id);
/**
* Get the owner of a group.
* @param group_id The group to get the owner of.
* @pre IsValidGroup(group_id).
* @return The owner the group has.
* @api -ai
*/
static ScriptCompany::CompanyID GetOwner(GroupID group_id);
/** /**
* Create a new group. * Create a new group.
* @param vehicle_type The type of vehicle to create a group for. * @param vehicle_type The type of vehicle to create a group for.