summaryrefslogtreecommitdiff
path: root/src/articulated_vehicles.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
commitd19706013714c4b1f5b833ce7377118047f31a7c (patch)
treec50b9279882186f1767a0a6d05f3b4df148a5c93 /src/articulated_vehicles.cpp
parentde9413454ee70662e1309b49bfd894ca1cf19063 (diff)
downloadopenttd-d19706013714c4b1f5b833ce7377118047f31a7c.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/articulated_vehicles.cpp')
-rw-r--r--src/articulated_vehicles.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp
index 9f2e05bc0..bb21b49f8 100644
--- a/src/articulated_vehicles.cpp
+++ b/src/articulated_vehicles.cpp
@@ -17,6 +17,10 @@ uint CountArticulatedParts(EngineID engine_type, bool purchase_window)
{
if (!HasBit(EngInfo(engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return 0;
+ /* If we can't allocate a vehicle now, we can't allocate it in the command
+ * either, so it doesn't matter how many articulated parts there are. */
+ if (!Vehicle::CanAllocateItem()) return 0;
+
Vehicle *v = NULL;;
if (!purchase_window) {
v = new InvalidVehicle();