Changeset - r2609:598e8e448bec
[Not reviewed]
master
0 1 0
peter1138 - 19 years ago 2005-11-06 12:39:30
peter1138@openttd.org
(svn r3146) Avoid use of variable size declared arrays when allocating articulated rail vehicles.
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
train_cmd.c
Show inline comments
 
@@ -512,13 +512,13 @@ static int32 CmdBuildRailWagon(EngineID 
 
	rvi = RailVehInfo(engine);
 
	value = (rvi->base_cost * _price.build_railwagon) >> 8;
 

	
 
	num_vehicles = 1 + CountArticulatedParts(rvi, engine);
 

	
 
	if (!(flags & DC_QUERY_COST)) {
 
		Vehicle *vl[num_vehicles];
 
		Vehicle *vl[11]; // Allow for wagon and upto 10 artic parts.
 

	
 
		if (!AllocateVehicles(vl, num_vehicles))
 
			return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
 

	
 
		if (flags & DC_EXEC) {
 
			byte img = rvi->image_index;
 
@@ -698,13 +698,13 @@ int32 CmdBuildRailVehicle(int x, int y, 
 
		value /= 2;
 

	
 
	num_vehicles = (rvi->flags & RVI_MULTIHEAD && HASBIT(p2, 0)) ? 2 : 1;
 
	num_vehicles += CountArticulatedParts(rvi, p1);
 

	
 
	if (!(flags & DC_QUERY_COST)) {
 
		Vehicle *vl[num_vehicles];
 
		Vehicle *vl[12]; // Allow for upto 10 artic parts and dual-heads
 
		if (!AllocateVehicles(vl, num_vehicles) || IsOrderPoolFull())
 
			return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
 

	
 
		v = vl[0];
 

	
 
		unit_num = GetFreeUnitNumber(VEH_Train);
0 comments (0 inline, 0 general)