summaryrefslogtreecommitdiff
path: root/src/engine.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-23 20:56:08 +0000
committerrubidium <rubidium@openttd.org>2008-04-23 20:56:08 +0000
commitd56827a9a9a109b639a25514f1a6424ba9111a70 (patch)
treea6906b106143841dcbc6aea392d11baa75492e05 /src/engine.cpp
parenta204a3b70e93db0b4fab77b2a1015ebf81ca6e1f (diff)
downloadopenttd-d56827a9a9a109b639a25514f1a6424ba9111a70.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/engine.cpp')
-rw-r--r--src/engine.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 71d56d5cb..3bc0657c2 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -15,7 +15,6 @@
#include "aircraft.h"
#include "newgrf_cargo.h"
#include "group.h"
-#include "misc/autoptr.hpp"
#include "strings_func.h"
#include "gfx_func.h"
#include "functions.h"
@@ -516,19 +515,15 @@ CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, Engi
return CommandCost();
}
- er = new EngineRenew(old_engine, new_engine);
- if (er == NULL) return CMD_ERROR;
- AutoPtrT<EngineRenew> er_auto_delete = er;
-
+ if (!EngineRenew::CanAllocateItem()) return CMD_ERROR;
if (flags & DC_EXEC) {
+ er = new EngineRenew(old_engine, new_engine);
er->group_id = group;
/* Insert before the first element */
er->next = (EngineRenew *)(*erl);
*erl = (EngineRenewList)er;
-
- er_auto_delete.Detach();
}
return CommandCost();