MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SetName

Method SetName

src/script/api/script_group.cpp:58–70  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

56}
57
58/* static */ bool ScriptGroup::SetName(GroupID group_id, Text *name)
59{
60 ScriptObjectRef counter(name);
61
62 EnforceCompanyModeValid(false);
63 EnforcePrecondition(false, IsValidGroup(group_id));
64 EnforcePrecondition(false, name != nullptr);
65 const std::string &text = name->GetDecodedText();
66 EnforcePreconditionEncodedText(false, text);
67 EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_GROUP_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
68
69 return ScriptObject::Command<CMD_ALTER_GROUP>::Do(AlterGroupMode::Rename, group_id, ::GroupID::Invalid(), text);
70}
71
72/* static */ std::optional<std::string> ScriptGroup::GetName(GroupID group_id)
73{

Callers

nothing calls this directly

Calls 3

Utf8StringLengthFunction · 0.85
InvalidFunction · 0.85
GetDecodedTextMethod · 0.80

Tested by

no test coverage detected