diff options
author | truebrain <truebrain@openttd.org> | 2011-12-19 21:06:06 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2011-12-19 21:06:06 +0000 |
commit | 102f811d0277afefe5c90762c0c4cc11ab69713c (patch) | |
tree | 1c7343e8031eab2c764cff974bd9df9a814c3dd9 /src/script/api/script_vehicle.cpp | |
parent | b0ac529a6ff4e087520a14d2a0169f445952e7e0 (diff) | |
download | openttd-102f811d0277afefe5c90762c0c4cc11ab69713c.tar.xz |
(svn r23636) -Add: introduce ScriptText in parameters where it can be used
Diffstat (limited to 'src/script/api/script_vehicle.cpp')
-rw-r--r-- | src/script/api/script_vehicle.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/script/api/script_vehicle.cpp b/src/script/api/script_vehicle.cpp index 9a73e564e..13ccce518 100644 --- a/src/script/api/script_vehicle.cpp +++ b/src/script/api/script_vehicle.cpp @@ -212,14 +212,18 @@ } } -/* static */ bool ScriptVehicle::SetName(VehicleID vehicle_id, const char *name) +/* static */ bool ScriptVehicle::SetName(VehicleID vehicle_id, Text *name) { + CCountedPtr<Text> counter(name); + EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY); EnforcePrecondition(false, IsValidVehicle(vehicle_id)); - EnforcePrecondition(false, !::StrEmpty(name)); - EnforcePreconditionCustomError(false, ::Utf8StringLength(name) < MAX_LENGTH_VEHICLE_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); + EnforcePrecondition(false, name != NULL); + const char *text = name->GetEncodedText(); + EnforcePrecondition(false, !::StrEmpty(text)); + EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_VEHICLE_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); - return ScriptObject::DoCommand(0, vehicle_id, 0, CMD_RENAME_VEHICLE, name); + return ScriptObject::DoCommand(0, vehicle_id, 0, CMD_RENAME_VEHICLE, text); } /* static */ TileIndex ScriptVehicle::GetLocation(VehicleID vehicle_id) |