summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-01-26 22:27:11 +0000
committersmatz <smatz@openttd.org>2009-01-26 22:27:11 +0000
commit3ac080425a5a2fff14e7b518b501fd5b3dbb930c (patch)
tree1573f85d1916703b2bd19208c0d5ba0ca555330e /src
parent659989af457fef67348fb1f2145ba7ff66c92d4d (diff)
downloadopenttd-3ac080425a5a2fff14e7b518b501fd5b3dbb930c.tar.xz
(svn r15279) -Fix: deadlock (with wide fonts) or desync when generating manager name
Diffstat (limited to 'src')
-rw-r--r--src/company_cmd.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index b40e3a5ea..6cc2fe0d4 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -384,26 +384,23 @@ static byte GenerateCompanyColour()
static void GeneratePresidentName(Company *c)
{
- Company *cc;
- char buffer[100], buffer2[40];
-
for (;;) {
restart:;
-
c->president_name_2 = Random();
c->president_name_1 = SPECSTR_PRESIDENT_NAME;
+ char buffer[MAX_LENGTH_PRESIDENT_NAME_BYTES + 1];
SetDParam(0, c->index);
GetString(buffer, STR_PRESIDENT_NAME, lastof(buffer));
- if (strlen(buffer) >= 32 || GetStringBoundingBox(buffer).width >= 94)
- continue;
+ if (strlen(buffer) >= MAX_LENGTH_PRESIDENT_NAME_BYTES) continue;
+ Company *cc;
FOR_ALL_COMPANIES(cc) {
if (c != cc) {
+ char buffer2[MAX_LENGTH_PRESIDENT_NAME_BYTES + 2];
SetDParam(0, cc->index);
GetString(buffer2, STR_PRESIDENT_NAME, lastof(buffer2));
- if (strcmp(buffer2, buffer) == 0)
- goto restart;
+ if (strcmp(buffer2, buffer) == 0) goto restart;
}
}
return;