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

Method SetName

src/script/api/script_basestation.cpp:44–60  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

42}
43
44/* static */ bool ScriptBaseStation::SetName(StationID station_id, Text *name)
45{
46 ScriptObjectRef counter(name);
47
48 EnforceCompanyModeValid(false);
49 EnforcePrecondition(false, IsValidBaseStation(station_id));
50 EnforcePrecondition(false, name != nullptr);
51 const std::string &text = name->GetDecodedText();
52 EnforcePreconditionEncodedText(false, text);
53 EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_STATION_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
54
55 if (::Station::IsValidID(station_id)) {
56 return ScriptObject::Command<CMD_RENAME_STATION>::Do(station_id, text);
57 } else {
58 return ScriptObject::Command<CMD_RENAME_WAYPOINT>::Do(station_id, text);
59 }
60}
61
62/* static */ TileIndex ScriptBaseStation::GetLocation(StationID station_id)
63{

Callers

nothing calls this directly

Calls 2

Utf8StringLengthFunction · 0.85
GetDecodedTextMethod · 0.80

Tested by

no test coverage detected