|
@@ -36,49 +36,49 @@
|
|
|
/* static */ bool ScriptGroup::DeleteGroup(GroupID group_id)
|
|
|
{
|
|
|
EnforcePrecondition(false, IsValidGroup(group_id));
|
|
|
|
|
|
return ScriptObject::DoCommand(0, group_id, 0, CMD_DELETE_GROUP);
|
|
|
}
|
|
|
|
|
|
/* static */ ScriptVehicle::VehicleType ScriptGroup::GetVehicleType(GroupID group_id)
|
|
|
{
|
|
|
if (!IsValidGroup(group_id)) return ScriptVehicle::VT_INVALID;
|
|
|
|
|
|
return (ScriptVehicle::VehicleType)((::VehicleType)::Group::Get(group_id)->vehicle_type);
|
|
|
}
|
|
|
|
|
|
/* static */ bool ScriptGroup::SetName(GroupID group_id, Text *name)
|
|
|
{
|
|
|
CCountedPtr<Text> counter(name);
|
|
|
|
|
|
EnforcePrecondition(false, IsValidGroup(group_id));
|
|
|
EnforcePrecondition(false, name != NULL);
|
|
|
const char *text = name->GetDecodedText();
|
|
|
EnforcePreconditionEncodedText(false, text);
|
|
|
EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_GROUP_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
|
|
|
|
|
|
return ScriptObject::DoCommand(0, group_id, 0, CMD_RENAME_GROUP, text);
|
|
|
return ScriptObject::DoCommand(0, group_id, 0, CMD_ALTER_GROUP, text);
|
|
|
}
|
|
|
|
|
|
/* static */ char *ScriptGroup::GetName(GroupID group_id)
|
|
|
{
|
|
|
if (!IsValidGroup(group_id)) return NULL;
|
|
|
|
|
|
::SetDParam(0, group_id);
|
|
|
return GetString(STR_GROUP_NAME);
|
|
|
}
|
|
|
|
|
|
/* static */ bool ScriptGroup::EnableAutoReplaceProtection(GroupID group_id, bool enable)
|
|
|
{
|
|
|
EnforcePrecondition(false, IsValidGroup(group_id));
|
|
|
|
|
|
return ScriptObject::DoCommand(0, group_id, enable ? 1 : 0, CMD_SET_GROUP_REPLACE_PROTECTION);
|
|
|
}
|
|
|
|
|
|
/* static */ bool ScriptGroup::GetAutoReplaceProtection(GroupID group_id)
|
|
|
{
|
|
|
if (!IsValidGroup(group_id)) return false;
|
|
|
|
|
|
return ::Group::Get(group_id)->replace_protection;
|
|
|
}
|
|
|
|