mirror of https://github.com/OpenTTD/OpenTTD.git
Change: Allow GS access to ScriptGroup functions
This commit is contained in:
parent
f225f36c3d
commit
f8b5661d28
|
@ -30,7 +30,7 @@ def check_mode_enforcement(path):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if re.match(
|
if re.match(
|
||||||
r"\t(EnforceDeityMode|EnforceCompanyModeValid|EnforceDeityOrCompanyModeValid|EnforceDeityOrCompanyModeValid_Void)\(",
|
r"\t(EnforceDeityMode|EnforceCompanyModeValid|EnforceCompanyModeValid_Void|EnforceDeityOrCompanyModeValid|EnforceDeityOrCompanyModeValid_Void)\(",
|
||||||
line,
|
line,
|
||||||
):
|
):
|
||||||
# Mode enforcement macro found
|
# Mode enforcement macro found
|
||||||
|
|
|
@ -45,6 +45,35 @@
|
||||||
* \li GSCompany::SetAutoRenewMonths
|
* \li GSCompany::SetAutoRenewMonths
|
||||||
* \li GSCompany::SetAutoRenewMoney
|
* \li GSCompany::SetAutoRenewMoney
|
||||||
* \li GSGameSettings::IsDisabledVehicleType
|
* \li GSGameSettings::IsDisabledVehicleType
|
||||||
|
* \li GSGroup::GroupID
|
||||||
|
* \li GSGroup::IsValidGroup
|
||||||
|
* \li GSGroup::CreateGroup
|
||||||
|
* \li GSGroup::DeleteGroup
|
||||||
|
* \li GSGroup::GetVehicleType
|
||||||
|
* \li GSGroup::SetName
|
||||||
|
* \li GSGroup::GetName
|
||||||
|
* \li GSGroup::SetParent
|
||||||
|
* \li GSGroup::GetParent
|
||||||
|
* \li GSGroup::EnableAutoReplaceProtection
|
||||||
|
* \li GSGroup::GetAutoReplaceProtection
|
||||||
|
* \li GSGroup::GetNumEngines
|
||||||
|
* \li GSGroup::GetNumVehicles
|
||||||
|
* \li GSGroup::MoveVehicle
|
||||||
|
* \li GSGroup::EnableWagonRemoval
|
||||||
|
* \li GSGroup::HasWagonRemoval
|
||||||
|
* \li GSGroup::SetAutoReplace
|
||||||
|
* \li GSGroup::GetEngineReplacement
|
||||||
|
* \li GSGroup::StopAutoReplace
|
||||||
|
* \li GSGroup::GetProfitThisYear
|
||||||
|
* \li GSGroup::GetProfitLastYear
|
||||||
|
* \li GSGroup::GetCurrentUsage
|
||||||
|
* \li GSGroup::SetPrimaryColour
|
||||||
|
* \li GSGroup::SetSecondaryColour
|
||||||
|
* \li GSGroup::GetPrimaryColour
|
||||||
|
* \li GSGroup::GetSecondaryColour
|
||||||
|
* \li GSGroupList
|
||||||
|
* \li GSVehicleList_Group
|
||||||
|
* \li GSVehicleList_DefaultGroup
|
||||||
*
|
*
|
||||||
* API removals:
|
* API removals:
|
||||||
* \li GSError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, that error is never returned anymore.
|
* \li GSError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, that error is never returned anymore.
|
||||||
|
|
|
@ -55,6 +55,15 @@
|
||||||
#define EnforceCompanyModeValid(returnval) \
|
#define EnforceCompanyModeValid(returnval) \
|
||||||
EnforcePreconditionCustomError(returnval, ScriptCompanyMode::IsValid(), ScriptError::ERR_PRECONDITION_INVALID_COMPANY)
|
EnforcePreconditionCustomError(returnval, ScriptCompanyMode::IsValid(), ScriptError::ERR_PRECONDITION_INVALID_COMPANY)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper to enforce the precondition that the company mode is valid.
|
||||||
|
*/
|
||||||
|
#define EnforceCompanyModeValid_Void() \
|
||||||
|
if (!ScriptCompanyMode::IsValid()) { \
|
||||||
|
ScriptObject::SetLastError(ScriptError::ERR_PRECONDITION_INVALID_COMPANY); \
|
||||||
|
return; \
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to enforce the precondition that we are in a deity mode.
|
* Helper to enforce the precondition that we are in a deity mode.
|
||||||
* @param returnval The value to return on failure.
|
* @param returnval The value to return on failure.
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that handles all group related functions.
|
* Class that handles all group related functions.
|
||||||
* @api ai
|
* @api ai game
|
||||||
*/
|
*/
|
||||||
class ScriptGroup : public ScriptObject {
|
class ScriptGroup : public ScriptObject {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
ScriptGroupList::ScriptGroupList()
|
ScriptGroupList::ScriptGroupList()
|
||||||
{
|
{
|
||||||
EnforceDeityOrCompanyModeValid_Void();
|
EnforceCompanyModeValid_Void();
|
||||||
for (const Group *g : Group::Iterate()) {
|
for (const Group *g : Group::Iterate()) {
|
||||||
if (g->owner == ScriptObject::GetCompany()) this->AddItem(g->index);
|
if (g->owner == ScriptObject::GetCompany()) this->AddItem(g->index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,14 @@
|
||||||
/**
|
/**
|
||||||
* Creates a list of groups of which you are the owner.
|
* Creates a list of groups of which you are the owner.
|
||||||
* @note Neither ScriptGroup::GROUP_ALL nor ScriptGroup::GROUP_DEFAULT is in this list.
|
* @note Neither ScriptGroup::GROUP_ALL nor ScriptGroup::GROUP_DEFAULT is in this list.
|
||||||
* @api ai
|
* @api ai game
|
||||||
* @ingroup ScriptList
|
* @ingroup ScriptList
|
||||||
*/
|
*/
|
||||||
class ScriptGroupList : public ScriptList {
|
class ScriptGroupList : public ScriptList {
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @game @pre ScriptCompanyMode::IsValid().
|
||||||
|
*/
|
||||||
ScriptGroupList();
|
ScriptGroupList();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ ScriptVehicleList_SharedOrders::ScriptVehicleList_SharedOrders(VehicleID vehicle
|
||||||
|
|
||||||
ScriptVehicleList_Group::ScriptVehicleList_Group(GroupID group_id)
|
ScriptVehicleList_Group::ScriptVehicleList_Group(GroupID group_id)
|
||||||
{
|
{
|
||||||
EnforceDeityOrCompanyModeValid_Void();
|
EnforceCompanyModeValid_Void();
|
||||||
if (!ScriptGroup::IsValidGroup((ScriptGroup::GroupID)group_id)) return;
|
if (!ScriptGroup::IsValidGroup((ScriptGroup::GroupID)group_id)) return;
|
||||||
|
|
||||||
for (const Vehicle *v : Vehicle::Iterate()) {
|
for (const Vehicle *v : Vehicle::Iterate()) {
|
||||||
|
@ -115,7 +115,7 @@ ScriptVehicleList_Group::ScriptVehicleList_Group(GroupID group_id)
|
||||||
|
|
||||||
ScriptVehicleList_DefaultGroup::ScriptVehicleList_DefaultGroup(ScriptVehicle::VehicleType vehicle_type)
|
ScriptVehicleList_DefaultGroup::ScriptVehicleList_DefaultGroup(ScriptVehicle::VehicleType vehicle_type)
|
||||||
{
|
{
|
||||||
EnforceDeityOrCompanyModeValid_Void();
|
EnforceCompanyModeValid_Void();
|
||||||
if (vehicle_type < ScriptVehicle::VT_RAIL || vehicle_type > ScriptVehicle::VT_AIR) return;
|
if (vehicle_type < ScriptVehicle::VT_RAIL || vehicle_type > ScriptVehicle::VT_AIR) return;
|
||||||
|
|
||||||
for (const Vehicle *v : Vehicle::Iterate()) {
|
for (const Vehicle *v : Vehicle::Iterate()) {
|
||||||
|
|
|
@ -69,26 +69,28 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a list of vehicles that are in a group.
|
* Creates a list of vehicles that are in a group.
|
||||||
* @api ai
|
* @api ai game
|
||||||
* @ingroup ScriptList
|
* @ingroup ScriptList
|
||||||
*/
|
*/
|
||||||
class ScriptVehicleList_Group : public ScriptList {
|
class ScriptVehicleList_Group : public ScriptList {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @param group_id The ID of the group the vehicles are in.
|
* @param group_id The ID of the group the vehicles are in.
|
||||||
|
* @game @pre ScriptCompanyMode::IsValid().
|
||||||
*/
|
*/
|
||||||
ScriptVehicleList_Group(GroupID group_id);
|
ScriptVehicleList_Group(GroupID group_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a list of vehicles that are in the default group.
|
* Creates a list of vehicles that are in the default group.
|
||||||
* @api ai
|
* @api ai game
|
||||||
* @ingroup ScriptList
|
* @ingroup ScriptList
|
||||||
*/
|
*/
|
||||||
class ScriptVehicleList_DefaultGroup : public ScriptList {
|
class ScriptVehicleList_DefaultGroup : public ScriptList {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @param vehicle_type The VehicleType to get the list of vehicles for.
|
* @param vehicle_type The VehicleType to get the list of vehicles for.
|
||||||
|
* @game @pre ScriptCompanyMode::IsValid().
|
||||||
*/
|
*/
|
||||||
ScriptVehicleList_DefaultGroup(ScriptVehicle::VehicleType vehicle_type);
|
ScriptVehicleList_DefaultGroup(ScriptVehicle::VehicleType vehicle_type);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue