summaryrefslogtreecommitdiff
path: root/src/town_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-01-09 14:59:02 +0000
committerrubidium <rubidium@openttd.org>2009-01-09 14:59:02 +0000
commitf0b0691bfe603e362cd5760240582cec410876ff (patch)
treec50b9279882186f1767a0a6d05f3b4df148a5c93 /src/town_cmd.cpp
parent331b8dd7d4c95266aae579171064879d847ea8aa (diff)
downloadopenttd-f0b0691bfe603e362cd5760240582cec410876ff.tar.xz
(svn r14933) -Codechange: check the whether a pool item can be constructed instead of trying to make it and check for NULL.
Diffstat (limited to 'src/town_cmd.cpp')
-rw-r--r--src/town_cmd.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index c666442c7..4b9de5618 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -1576,6 +1576,8 @@ CommandCost CmdBuildTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, con
Town *CreateRandomTown(uint attempts, TownSizeMode mode, uint size)
{
+ if (!Town::CanAllocateItem()) return NULL;
+
do {
/* Generate a tile index not too close from the edge */
TileIndex tile = RandomTile();
@@ -1603,7 +1605,6 @@ Town *CreateRandomTown(uint attempts, TownSizeMode mode, uint size)
/* Allocate a town struct */
Town *t = new Town(tile);
- if (t == NULL) break;
DoCreateTown(t, tile, townnameparts, mode, size);
return t;