Mercurial > hg > openttd
comparison src/roadveh_cmd.cpp @ 7595:bb5f187ff5a7 draft
(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.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Mon, 17 Sep 2007 04:23:03 +0000 |
parents | 200598005e58 |
children | 610b2a5d634a |
comparison
equal
deleted
inserted
replaced
7594:94099ceec9e0 | 7595:bb5f187ff5a7 |
---|---|
177 if (!IsTileDepotType(tile, TRANSPORT_ROAD)) return CMD_ERROR; | 177 if (!IsTileDepotType(tile, TRANSPORT_ROAD)) return CMD_ERROR; |
178 if (!IsTileOwner(tile, _current_player)) return CMD_ERROR; | 178 if (!IsTileOwner(tile, _current_player)) return CMD_ERROR; |
179 | 179 |
180 if (HASBIT(GetRoadTypes(tile), ROADTYPE_TRAM) != HASBIT(EngInfo(p1)->misc_flags, EF_ROAD_TRAM)) return_cmd_error(STR_DEPOT_WRONG_DEPOT_TYPE); | 180 if (HASBIT(GetRoadTypes(tile), ROADTYPE_TRAM) != HASBIT(EngInfo(p1)->misc_flags, EF_ROAD_TRAM)) return_cmd_error(STR_DEPOT_WRONG_DEPOT_TYPE); |
181 | 181 |
182 uint num_vehicles = 1 + CountArticulatedParts(p1); | 182 uint num_vehicles = 1 + CountArticulatedParts(p1, false); |
183 | 183 |
184 /* Allow for the front and the articulated parts. */ | 184 /* Allow for the front and the articulated parts, plus one to "terminate" the list. */ |
185 Vehicle **vl = (Vehicle**)alloca(sizeof(*vl) * num_vehicles); | 185 Vehicle **vl = (Vehicle**)alloca(sizeof(*vl) * (num_vehicles + 1)); |
186 memset(vl, 0, sizeof(*vl) * num_vehicles); | 186 memset(vl, 0, sizeof(*vl) * (num_vehicles + 1)); |
187 | 187 |
188 if (!Vehicle::AllocateList(vl, num_vehicles)) { | 188 if (!Vehicle::AllocateList(vl, num_vehicles)) { |
189 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); | 189 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
190 } | 190 } |
191 | 191 |