summaryrefslogtreecommitdiff
path: root/src/industry_cmd.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
commit6939569362a8c3e2c1b5174962309d0d73152845 (patch)
treea6906b106143841dcbc6aea392d11baa75492e05 /src/industry_cmd.cpp
parent1ba6e3deebf4c26896491842df51dc26f29a1c5d (diff)
downloadopenttd-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/industry_cmd.cpp')
-rw-r--r--src/industry_cmd.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 75b7c3ca0..8a33c20d1 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -26,7 +26,6 @@
#include "newgrf_industries.h"
#include "newgrf_industrytiles.h"
#include "newgrf_callbacks.h"
-#include "misc/autoptr.hpp"
#include "autoslope.h"
#include "transparency.h"
#include "water.h"
@@ -1592,17 +1591,19 @@ static Industry *CreateNewIndustryHelper(TileIndex tile, IndustryType type, uint
if (!CheckIfIndustryIsAllowed(tile, type, t)) return NULL;
if (!CheckSuitableIndustryPos(tile)) return NULL;
- Industry *i = new Industry(tile);
- if (i == NULL) return NULL;
- AutoPtrT<Industry> i_auto_delete = i;
+ if (!Industry::CanAllocateItem()) return NULL;
if (flags & DC_EXEC) {
+ Industry *i = new Industry(tile);
if (!custom_shape_check) CheckIfCanLevelIndustryPlatform(tile, DC_EXEC, it, type);
DoCreateNewIndustry(i, tile, type, it, itspec_index, t, OWNER_NONE);
- i_auto_delete.Detach();
+
+ return i;
}
- return i;
+ /* We need to return a non-NULL pointer to tell we have created an industry.
+ * However, we haven't created a real one (no DC_EXEC), so return a fake one. */
+ return GetIndustry(0);
}
/** Build/Fund an industry