summaryrefslogtreecommitdiff
path: root/src/script/api/script_company.cpp
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-12-19 21:06:06 +0000
committertruebrain <truebrain@openttd.org>2011-12-19 21:06:06 +0000
commit102f811d0277afefe5c90762c0c4cc11ab69713c (patch)
tree1c7343e8031eab2c764cff974bd9df9a814c3dd9 /src/script/api/script_company.cpp
parentb0ac529a6ff4e087520a14d2a0169f445952e7e0 (diff)
downloadopenttd-102f811d0277afefe5c90762c0c4cc11ab69713c.tar.xz
(svn r23636) -Add: introduce ScriptText in parameters where it can be used
Diffstat (limited to 'src/script/api/script_company.cpp')
-rw-r--r--src/script/api/script_company.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/script/api/script_company.cpp b/src/script/api/script_company.cpp
index efc2848a5..d4bc5d3e7 100644
--- a/src/script/api/script_company.cpp
+++ b/src/script/api/script_company.cpp
@@ -39,12 +39,16 @@
return ResolveCompanyID(company) == ResolveCompanyID(COMPANY_SELF);
}
-/* static */ bool ScriptCompany::SetName(const char *name)
+/* static */ bool ScriptCompany::SetName(Text *name)
{
- EnforcePrecondition(false, !::StrEmpty(name));
- EnforcePreconditionCustomError(false, ::Utf8StringLength(name) < MAX_LENGTH_COMPANY_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
+ CCountedPtr<Text> counter(name);
- return ScriptObject::DoCommand(0, 0, 0, CMD_RENAME_COMPANY, name);
+ EnforcePrecondition(false, name != NULL);
+ const char *text = name->GetEncodedText();
+ EnforcePrecondition(false, !::StrEmpty(text));
+ EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_COMPANY_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
+
+ return ScriptObject::DoCommand(0, 0, 0, CMD_RENAME_COMPANY, text);
}
/* static */ char *ScriptCompany::GetName(ScriptCompany::CompanyID company)
@@ -60,11 +64,15 @@
return company_name;
}
-/* static */ bool ScriptCompany::SetPresidentName(const char *name)
+/* static */ bool ScriptCompany::SetPresidentName(Text *name)
{
- EnforcePrecondition(false, !::StrEmpty(name));
+ CCountedPtr<Text> counter(name);
+
+ EnforcePrecondition(false, name != NULL);
+ const char *text = name->GetEncodedText();
+ EnforcePrecondition(false, !::StrEmpty(text));
- return ScriptObject::DoCommand(0, 0, 0, CMD_RENAME_PRESIDENT, name);
+ return ScriptObject::DoCommand(0, 0, 0, CMD_RENAME_PRESIDENT, text);
}
/* static */ char *ScriptCompany::GetPresidentName(ScriptCompany::CompanyID company)