mirror of https://github.com/OpenTTD/OpenTTD
Codefix: restore _generating_world and nearest town cache when failing to fund a random town (#13042)
parent
883be19865
commit
9dae626237
|
@ -2170,17 +2170,19 @@ std::tuple<CommandCost, Money, TownID> CmdFoundTown(DoCommandFlag flags, TileInd
|
||||||
Town *t;
|
Town *t;
|
||||||
if (random_location) {
|
if (random_location) {
|
||||||
t = CreateRandomTown(20, townnameparts, size, city, layout);
|
t = CreateRandomTown(20, townnameparts, size, city, layout);
|
||||||
if (t == nullptr) return { CommandCost(STR_ERROR_NO_SPACE_FOR_TOWN), 0, INVALID_TOWN };
|
|
||||||
} else {
|
} else {
|
||||||
t = new Town(tile);
|
t = new Town(tile);
|
||||||
DoCreateTown(t, tile, townnameparts, size, city, layout, true);
|
DoCreateTown(t, tile, townnameparts, size, city, layout, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
new_town = t->index;
|
|
||||||
UpdateNearestTownForRoadTiles(false);
|
UpdateNearestTownForRoadTiles(false);
|
||||||
old_generating_world.Restore();
|
old_generating_world.Restore();
|
||||||
|
|
||||||
if (t != nullptr && !text.empty()) {
|
if (t == nullptr) return { CommandCost(STR_ERROR_NO_SPACE_FOR_TOWN), 0, INVALID_TOWN };
|
||||||
|
|
||||||
|
new_town = t->index;
|
||||||
|
|
||||||
|
if (!text.empty()) {
|
||||||
t->name = text;
|
t->name = text;
|
||||||
t->UpdateVirtCoord();
|
t->UpdateVirtCoord();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue