From e08bc4d6e3f28b6bee1902621345420cb61e897e Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Tue, 28 May 2024 17:35:47 -0400 Subject: [PATCH] Codefix: CmdFoundTown should always return TownID if successful --- src/town_cmd.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index cc8364b0a1..686d4e6960 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2158,15 +2158,13 @@ std::tuple CmdFoundTown(DoCommandFlag flags, TileInd Town *t; if (random_location) { t = CreateRandomTown(20, townnameparts, size, city, layout); - if (t == nullptr) { - cost = CommandCost(STR_ERROR_NO_SPACE_FOR_TOWN); - } else { - new_town = t->index; - } + if (t == nullptr) return { CommandCost(STR_ERROR_NO_SPACE_FOR_TOWN), 0, INVALID_TOWN }; } else { t = new Town(tile); DoCreateTown(t, tile, townnameparts, size, city, layout, true); } + + new_town = t->index; UpdateNearestTownForRoadTiles(false); old_generating_world.Restore();