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

Method BuildSign

src/script/api/script_sign.cpp:73–88  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

71}
72
73/* static */ SignID ScriptSign::BuildSign(TileIndex location, Text *name)
74{
75 ScriptObjectRef counter(name);
76
77 EnforceDeityOrCompanyModeValid(SignID::Invalid());
78 EnforcePrecondition(SignID::Invalid(), ::IsValidTile(location));
79 EnforcePrecondition(SignID::Invalid(), name != nullptr);
80 const std::string &text = name->GetDecodedText();
81 EnforcePreconditionEncodedText(SignID::Invalid(), text);
82 EnforcePreconditionCustomError(SignID::Invalid(), ::Utf8StringLength(text) < MAX_LENGTH_SIGN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
83
84 if (!ScriptObject::Command<CMD_PLACE_SIGN>::Do(&ScriptInstance::DoCommandReturnSignID, location, text)) return SignID::Invalid();
85
86 /* In case of test-mode, we return SignID 0 */
87 return SignID::Begin();
88}

Callers

nothing calls this directly

Calls 5

InvalidFunction · 0.85
IsValidTileFunction · 0.85
Utf8StringLengthFunction · 0.85
BeginFunction · 0.85
GetDecodedTextMethod · 0.80

Tested by

no test coverage detected