From 102f811d0277afefe5c90762c0c4cc11ab69713c Mon Sep 17 00:00:00 2001 From: truebrain Date: Mon, 19 Dec 2011 21:06:06 +0000 Subject: (svn r23636) -Add: introduce ScriptText in parameters where it can be used --- src/script/api/script_group.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/script/api/script_group.cpp') diff --git a/src/script/api/script_group.cpp b/src/script/api/script_group.cpp index 4f9ce8a2a..63c022e90 100644 --- a/src/script/api/script_group.cpp +++ b/src/script/api/script_group.cpp @@ -49,13 +49,17 @@ return (ScriptVehicle::VehicleType)((::VehicleType)::Group::Get(group_id)->vehicle_type); } -/* static */ bool ScriptGroup::SetName(GroupID group_id, const char *name) +/* static */ bool ScriptGroup::SetName(GroupID group_id, Text *name) { + CCountedPtr counter(name); + EnforcePrecondition(false, IsValidGroup(group_id)); - EnforcePrecondition(false, !::StrEmpty(name)); - EnforcePreconditionCustomError(false, ::Utf8StringLength(name) < MAX_LENGTH_GROUP_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_GROUP_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); - return ScriptObject::DoCommand(0, group_id, 0, CMD_RENAME_GROUP, name); + return ScriptObject::DoCommand(0, group_id, 0, CMD_RENAME_GROUP, text); } /* static */ char *ScriptGroup::GetName(GroupID group_id) -- cgit v1.2.3-54-g00ecf