src/roadveh_cmd.cpp
changeset 8091 f24d360b6ba1
parent 8089 a172d415e963
child 8138 7dc73953c47e
equal deleted inserted replaced
8090:454ea60f6414 8091:f24d360b6ba1
   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