diff options
author | rubidium <rubidium@openttd.org> | 2008-04-23 20:56:08 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-04-23 20:56:08 +0000 |
commit | 6939569362a8c3e2c1b5174962309d0d73152845 (patch) | |
tree | a6906b106143841dcbc6aea392d11baa75492e05 /src/town_cmd.cpp | |
parent | 1ba6e3deebf4c26896491842df51dc26f29a1c5d (diff) | |
download | openttd-6939569362a8c3e2c1b5174962309d0d73152845.tar.xz |
(svn r12855) -Codechange: do not use autoptr's for testing whether certain objects can be build, but check it directly in the pool so we do not have to call destructors in the testing phase. Stations still use the autoptr though.
Diffstat (limited to 'src/town_cmd.cpp')
-rw-r--r-- | src/town_cmd.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 8bbe05377..1f6c2bd61 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -31,7 +31,6 @@ #include "newgrf_house.h" #include "newgrf_commons.h" #include "newgrf_townname.h" -#include "misc/autoptr.hpp" #include "autoslope.h" #include "waypoint.h" #include "transparency.h" @@ -1538,16 +1537,14 @@ CommandCost CmdBuildTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) return_cmd_error(STR_023A_TOO_MANY_TOWNS); /* Allocate town struct */ - Town *t = new Town(tile); - if (t == NULL) return_cmd_error(STR_023A_TOO_MANY_TOWNS); - AutoPtrT<Town> t_auto_delete = t; + if (!Town::CanAllocateItem()) return_cmd_error(STR_023A_TOO_MANY_TOWNS); /* Create the town */ if (flags & DC_EXEC) { + Town *t = new Town(tile); _generating_world = true; DoCreateTown(t, tile, townnameparts, (TownSizeMode)p2, p1); _generating_world = false; - t_auto_delete.Detach(); } return CommandCost(); } |