Class that handles all group related functions. More...
#include <script_group.hpp>
Public Types | |
enum | GroupID { GROUP_ALL = ::ALL_GROUP, GROUP_DEFAULT = ::DEFAULT_GROUP, GROUP_INVALID = ::INVALID_GROUP } |
The group IDs of some special groups. More... | |
Static Public Member Functions | |
static bool | IsValidGroup (GroupID group_id) |
Checks whether the given group is valid. | |
static GroupID | CreateGroup (ScriptVehicle::VehicleType vehicle_type) |
Create a new group. | |
static bool | DeleteGroup (GroupID group_id) |
Delete the given group. | |
static ScriptVehicle::VehicleType | GetVehicleType (GroupID group_id) |
Get the vehicle type of a group. | |
static bool | SetName (GroupID group_id, Text *name) |
Set the name of a group. | |
static char * | GetName (GroupID group_id) |
Get the name of a group. | |
static bool | EnableAutoReplaceProtection (GroupID group_id, bool enable) |
Enable or disable autoreplace protected. | |
static bool | GetAutoReplaceProtection (GroupID group_id) |
Get the autoreplace protection status. | |
static int32 | GetNumEngines (GroupID group_id, EngineID engine_id) |
Get the number of engines in a given group. | |
static bool | MoveVehicle (GroupID group_id, VehicleID vehicle_id) |
Move a vehicle to a group. | |
static bool | EnableWagonRemoval (bool keep_length) |
Enable or disable the removal of wagons when a (part of a) vehicle is (auto)replaced with a longer variant (longer wagons or longer engines) If enabled, wagons are removed from the end of the vehicle until it fits in the same number of tiles as it did before. | |
static bool | HasWagonRemoval () |
Get the current status of wagon removal. | |
static bool | SetAutoReplace (GroupID group_id, EngineID engine_id_old, EngineID engine_id_new) |
Start replacing all vehicles with a specified engine with another engine. | |
static EngineID | GetEngineReplacement (GroupID group_id, EngineID engine_id) |
Get the EngineID the given EngineID is replaced with. | |
static bool | StopAutoReplace (GroupID group_id, EngineID engine_id) |
Stop replacing a certain engine in the specified group. |
Class that handles all group related functions.
ai
Definition at line 22 of file script_group.hpp.
enum ScriptGroup::GroupID |
The group IDs of some special groups.
GROUP_ALL |
All vehicles are in this group. |
GROUP_DEFAULT |
Vehicles not put in any other group are in this one. |
GROUP_INVALID |
An invalid group id. |
Definition at line 27 of file script_group.hpp.
ScriptGroup::GroupID ScriptGroup::CreateGroup | ( | ScriptVehicle::VehicleType | vehicle_type | ) | [static] |
Create a new group.
vehicle_type | The type of vehicle to create a group for. |
Definition at line 30 of file script_group.cpp.
References CMD_CREATE_GROUP, ScriptObject::DoCommand(), and ScriptInstance::DoCommandReturnGroupID().
bool ScriptGroup::DeleteGroup | ( | GroupID | group_id | ) | [static] |
Delete the given group.
When the deletion succeeds all vehicles in the given group will move to the GROUP_DEFAULT.
group_id | The group to delete. |
Definition at line 38 of file script_group.cpp.
References CMD_DELETE_GROUP, ScriptObject::DoCommand(), EnforcePrecondition, and IsValidGroup().
bool ScriptGroup::EnableAutoReplaceProtection | ( | GroupID | group_id, | |
bool | enable | |||
) | [static] |
Enable or disable autoreplace protected.
If the protection is enabled, global autoreplace won't affect vehicles in this group.
group_id | The group to change the protection for. | |
enable | True if protection should be enabled. |
Definition at line 77 of file script_group.cpp.
References CMD_SET_GROUP_REPLACE_PROTECTION, ScriptObject::DoCommand(), EnforcePrecondition, and IsValidGroup().
bool ScriptGroup::EnableWagonRemoval | ( | bool | keep_length | ) | [static] |
Enable or disable the removal of wagons when a (part of a) vehicle is (auto)replaced with a longer variant (longer wagons or longer engines) If enabled, wagons are removed from the end of the vehicle until it fits in the same number of tiles as it did before.
keep_length | If true, wagons will be removed if the a new engine is longer. |
Definition at line 106 of file script_group.cpp.
References CMD_CHANGE_COMPANY_SETTING, ScriptObject::DoCommand(), GetCompanySettingIndex(), and HasWagonRemoval().
bool ScriptGroup::GetAutoReplaceProtection | ( | GroupID | group_id | ) | [static] |
Get the autoreplace protection status.
group_id | The group to get the protection status for. |
Definition at line 84 of file script_group.cpp.
References IsValidGroup().
Get the EngineID the given EngineID is replaced with.
group_id | The group to get the replacement from. | |
engine_id | The engine that is being replaced. |
Definition at line 126 of file script_group.cpp.
References EngineReplacementForCompany(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), ScriptObject::GetCompany(), GROUP_ALL, GROUP_DEFAULT, INVALID_ENGINE, and IsValidGroup().
char * ScriptGroup::GetName | ( | GroupID | group_id | ) | [static] |
Get the name of a group.
group_id | The group to get the name of. |
Definition at line 65 of file script_group.cpp.
References IsValidGroup(), and SetDParam().
Get the number of engines in a given group.
group_id | The group to get the number of engines in. | |
engine_id | The engine id to count. |
Definition at line 91 of file script_group.cpp.
References ScriptObject::GetCompany(), GetGroupNumEngines(), GROUP_ALL, GROUP_DEFAULT, and IsValidGroup().
ScriptVehicle::VehicleType ScriptGroup::GetVehicleType | ( | GroupID | group_id | ) | [static] |
Get the vehicle type of a group.
group_id | The group to get the type from. |
Definition at line 45 of file script_group.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::Get(), and IsValidGroup().
bool ScriptGroup::HasWagonRemoval | ( | ) | [static] |
Get the current status of wagon removal.
Definition at line 113 of file script_group.cpp.
References ScriptObject::GetCompany().
Referenced by EnableWagonRemoval().
bool ScriptGroup::IsValidGroup | ( | GroupID | group_id | ) | [static] |
Checks whether the given group is valid.
group_id | The group to check. |
Definition at line 24 of file script_group.cpp.
References ScriptObject::GetCompany(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::GetIfValid(), and Group::owner.
Referenced by DeleteGroup(), EnableAutoReplaceProtection(), GetAutoReplaceProtection(), GetEngineReplacement(), GetName(), GetNumEngines(), GetVehicleType(), MoveVehicle(), ScriptVehicleList_Group::ScriptVehicleList_Group(), SetAutoReplace(), SetName(), and StopAutoReplace().
Move a vehicle to a group.
group_id | The group to move the vehicel to. | |
vehicle_id | The vehicle to move to the group. |
Definition at line 98 of file script_group.cpp.
References CMD_ADD_VEHICLE_GROUP, ScriptObject::DoCommand(), EnforcePrecondition, GROUP_DEFAULT, IsValidGroup(), and ScriptVehicle::IsValidVehicle().
bool ScriptGroup::SetAutoReplace | ( | GroupID | group_id, | |
EngineID | engine_id_old, | |||
EngineID | engine_id_new | |||
) | [static] |
Start replacing all vehicles with a specified engine with another engine.
group_id | The group to replace vehicles from. Use ALL_GROUP to replace vehicles from all groups that haven't set autoreplace protection. | |
engine_id_old | The engine id to start replacing. | |
engine_id_new | The engine id to replace with. |
Definition at line 118 of file script_group.cpp.
References CMD_SET_AUTOREPLACE, ScriptObject::DoCommand(), EnforcePrecondition, GROUP_ALL, GROUP_DEFAULT, ScriptEngine::IsBuildable(), and IsValidGroup().
Set the name of a group.
group_id | The group to set the name for. | |
name | The name for the group (can be either a raw string, or a ScriptText object). |
ScriptError::ERR_NAME_IS_NOT_UNIQUE |
Definition at line 52 of file script_group.cpp.
References CMD_RENAME_GROUP, ScriptObject::DoCommand(), EnforcePrecondition, EnforcePreconditionCustomError, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG, Text::GetEncodedText(), IsValidGroup(), MAX_LENGTH_GROUP_NAME_CHARS, StrEmpty(), and Utf8StringLength().
Stop replacing a certain engine in the specified group.
group_id | The group to stop replacing the engine in. | |
engine_id | The engine id to stop replacing with another engine. |
Definition at line 133 of file script_group.cpp.
References CMD_SET_AUTOREPLACE, ScriptObject::DoCommand(), EnforcePrecondition, GROUP_ALL, GROUP_DEFAULT, INVALID_ENGINE, and IsValidGroup().