summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2014-01-20 22:34:22 +0000
committerfrosch <frosch@openttd.org>2014-01-20 22:34:22 +0000
commitf36d084db551452b68c417e526c8184b9de1c1b9 (patch)
tree670c1e6da301b12f9be1ac628623cbfc5d9c9e91
parentefe6adba6ab6c07bd7bb51bbc79fef5078a0b20a (diff)
downloadopenttd-f36d084db551452b68c417e526c8184b9de1c1b9.tar.xz
(svn r26270) -Fix-ish: If ScriptTown::FoundTown fails to generate a new random town name, don't bother sending a command, but fail immediately.
-rw-r--r--src/script/api/script_town.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp
index 4a0b9aefe..725c7d0a6 100644
--- a/src/script/api/script_town.cpp
+++ b/src/script/api/script_town.cpp
@@ -298,7 +298,10 @@
EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_TOWN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
}
uint32 townnameparts;
- GenerateTownName(&townnameparts);
+ if (!GenerateTownName(&townnameparts)) {
+ ScriptObject::SetLastError(ScriptError::ERR_NAME_IS_NOT_UNIQUE);
+ return false;
+ }
return ScriptObject::DoCommand(tile, size | (city ? 1 << 2 : 0) | layout << 3, townnameparts, CMD_FOUND_TOWN, text);
}