diff options
author | rubidium <rubidium@openttd.org> | 2010-12-05 22:23:50 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-12-05 22:23:50 +0000 |
commit | 9a1805064654d5f0e348f8a7b990532bfb66921a (patch) | |
tree | c4f696f86b410ab76a0c9eb224d4cd9b7bf82fd4 /src/company_cmd.cpp | |
parent | 66c7f00b607666df05849e66f6911dac9b426bd4 (diff) | |
download | openttd-9a1805064654d5f0e348f8a7b990532bfb66921a.tar.xz |
(svn r21408) -Codechange: limit president name by amount of characters, not bytes
Diffstat (limited to 'src/company_cmd.cpp')
-rw-r--r-- | src/company_cmd.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index e5eeea939..d44f4c4ab 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -468,16 +468,16 @@ restart:; /* Reserve space for extra unicode character. We need to do this to be able * to detect too long president name. */ - char buffer[MAX_LENGTH_PRESIDENT_NAME_BYTES + MAX_CHAR_LENGTH]; + char buffer[(MAX_LENGTH_PRESIDENT_NAME_CHARS + 1) * MAX_CHAR_LENGTH]; SetDParam(0, c->index); GetString(buffer, STR_PRESIDENT_NAME, lastof(buffer)); - if (strlen(buffer) >= MAX_LENGTH_PRESIDENT_NAME_BYTES) continue; + if (Utf8StringLength(buffer) >= MAX_LENGTH_PRESIDENT_NAME_CHARS) continue; Company *cc; FOR_ALL_COMPANIES(cc) { if (c != cc) { /* Reserve extra space so even overlength president names can be compared. */ - char buffer2[MAX_LENGTH_PRESIDENT_NAME_BYTES + MAX_CHAR_LENGTH]; + char buffer2[(MAX_LENGTH_PRESIDENT_NAME_CHARS + 1) * MAX_CHAR_LENGTH]; SetDParam(0, cc->index); GetString(buffer2, STR_PRESIDENT_NAME, lastof(buffer2)); if (strcmp(buffer2, buffer) == 0) goto restart; @@ -1094,7 +1094,7 @@ CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32 p1, u bool reset = StrEmpty(text); if (!reset) { - if (strlen(text) >= MAX_LENGTH_PRESIDENT_NAME_BYTES) return CMD_ERROR; + if (Utf8StringLength(text) >= MAX_LENGTH_PRESIDENT_NAME_CHARS) return CMD_ERROR; if (!IsUniquePresidentName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE); } |