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/group_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/group_cmd.cpp')
-rw-r--r-- | src/group_cmd.cpp | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index 17d82129c..685a9e53b 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -12,7 +12,6 @@ #include "train.h" #include "aircraft.h" #include "vehicle_gui.h" -#include "misc/autoptr.hpp" #include "strings_func.h" #include "functions.h" #include "window_func.h" @@ -94,20 +93,14 @@ CommandCost CmdCreateGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) VehicleType vt = (VehicleType)p1; if (!IsPlayerBuildableVehicleType(vt)) return CMD_ERROR; - AutoPtrT<Group> g_auto_delete; - - Group *g = new Group(_current_player); - if (g == NULL) return CMD_ERROR; - - g_auto_delete = g; + if (!Group::CanAllocateItem()) return CMD_ERROR; if (flags & DC_EXEC) { + Group *g = new Group(_current_player); g->replace_protection = false; g->vehicle_type = vt; InvalidateWindowData(GetWCForVT(vt), (vt << 11) | VLW_GROUP_LIST | _current_player); - - g_auto_delete.Detach(); } return CommandCost(); |