From f36d084db551452b68c417e526c8184b9de1c1b9 Mon Sep 17 00:00:00 2001 From: frosch Date: Mon, 20 Jan 2014 22:34:22 +0000 Subject: (svn r26270) -Fix-ish: If ScriptTown::FoundTown fails to generate a new random town name, don't bother sending a command, but fail immediately. --- src/script/api/script_town.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/script/api/script_town.cpp') 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); } -- cgit v1.2.3-54-g00ecf