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

Method SetName

src/script/api/script_vehicle.cpp:249–261  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

247}
248
249/* static */ bool ScriptVehicle::SetName(VehicleID vehicle_id, Text *name)
250{
251 ScriptObjectRef counter(name);
252
253 EnforceCompanyModeValid(false);
254 EnforcePrecondition(false, IsPrimaryVehicle(vehicle_id));
255 EnforcePrecondition(false, name != nullptr);
256 const std::string &text = name->GetDecodedText();
257 EnforcePreconditionEncodedText(false, text);
258 EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_VEHICLE_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
259
260 return ScriptObject::Command<CMD_RENAME_VEHICLE>::Do(vehicle_id, text);
261}
262
263/* static */ TileIndex ScriptVehicle::GetLocation(VehicleID vehicle_id)
264{

Callers

nothing calls this directly

Calls 2

Utf8StringLengthFunction · 0.85
GetDecodedTextMethod · 0.80

Tested by

no test coverage detected