summaryrefslogtreecommitdiff
path: root/src/roadveh_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-09-17 04:23:03 +0000
committerrubidium <rubidium@openttd.org>2007-09-17 04:23:03 +0000
commit257fdb38e6dde17a1d3546d83c67679ccba7160b (patch)
tree7b1861fb2f716b857d3f3e5cc617f04cc8d36524 /src/roadveh_cmd.cpp
parentf3491cb062a5854b6a8c713520c6af3ca2b36335 (diff)
downloadopenttd-257fdb38e6dde17a1d3546d83c67679ccba7160b.tar.xz
(svn r11122) -Fix [FS#1234]: crash when building a NewGRF vehicle when the articulated build vehicle callback returneed a different value for the purchase window than the normal build. Thanks for Dalestan and _minime_ for pointers to possible causes.
Diffstat (limited to 'src/roadveh_cmd.cpp')
-rw-r--r--src/roadveh_cmd.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 9f7b31630..a7416f525 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -179,11 +179,11 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (HASBIT(GetRoadTypes(tile), ROADTYPE_TRAM) != HASBIT(EngInfo(p1)->misc_flags, EF_ROAD_TRAM)) return_cmd_error(STR_DEPOT_WRONG_DEPOT_TYPE);
- uint num_vehicles = 1 + CountArticulatedParts(p1);
+ uint num_vehicles = 1 + CountArticulatedParts(p1, false);
- /* Allow for the front and the articulated parts. */
- Vehicle **vl = (Vehicle**)alloca(sizeof(*vl) * num_vehicles);
- memset(vl, 0, sizeof(*vl) * num_vehicles);
+ /* Allow for the front and the articulated parts, plus one to "terminate" the list. */
+ Vehicle **vl = (Vehicle**)alloca(sizeof(*vl) * (num_vehicles + 1));
+ memset(vl, 0, sizeof(*vl) * (num_vehicles + 1));
if (!Vehicle::AllocateList(vl, num_vehicles)) {
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);