# HG changeset patch # User frosch # Date 2014-01-20 22:34:22 # Node ID 56d4d70bc4907c6cfe91fd1700012648792c1362 # Parent ef9d2bbf11a168ec1c92e0047863c58112e8fd81 (svn r26270) -Fix-ish: If ScriptTown::FoundTown fails to generate a new random town name, don't bother sending a command, but fail immediately. diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp --- 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); }