Changeset - r11301:9a3a26bbf491
[Not reviewed]
master
0 1 0
michi_cc - 16 years ago 2009-03-09 19:14:36
michi_cc@openttd.org
(svn r15655) -Codechange: Initialise vehicle vars only after a placement new so possible default constructors don't overwrite the values.
1 file changed with 20 insertions and 19 deletions:
0 comments (0 inline, 0 general)
src/articulated_vehicles.cpp
Show inline comments
 
@@ -261,31 +261,13 @@ void AddArticulatedParts(Vehicle **vl, V
 
		EngineID engine_type = GetNewEngineID(GetEngineGRF(v->engine_type), type, GB(callback, 0, 7));
 
		bool flip_image = HasBit(callback, 7);
 

	
 
		/* get common values from first engine */
 
		u->direction = v->direction;
 
		u->owner = v->owner;
 
		u->tile = v->tile;
 
		u->x_pos = v->x_pos;
 
		u->y_pos = v->y_pos;
 
		u->z_pos = v->z_pos;
 
		u->build_year = v->build_year;
 
		u->vehstatus = v->vehstatus & ~VS_STOPPED;
 

	
 
		u->cargo_subtype = 0;
 
		u->max_speed = 0;
 
		u->max_age = 0;
 
		u->engine_type = engine_type;
 
		u->value = 0;
 
		u->subtype = 0;
 
		u->cur_image = 0xAC2;
 
		u->random_bits = VehicleRandomBits();
 

	
 
		const Engine *e_artic = GetEngine(engine_type);
 
		switch (type) {
 
			default: NOT_REACHED();
 

	
 
			case VEH_TRAIN:
 
				u = new (u) Train();
 
				u->subtype = 0;
 
				previous->SetNext(u);
 
				u->u.rail.track = v->u.rail.track;
 
				u->u.rail.railtype = v->u.rail.railtype;
 
@@ -305,6 +287,7 @@ void AddArticulatedParts(Vehicle **vl, V
 

	
 
			case VEH_ROAD:
 
				u = new (u) RoadVehicle();
 
				u->subtype = 0;
 
				previous->SetNext(u);
 
				u->u.road.first_engine = v->engine_type;
 
				u->u.road.cached_veh_length = 8; // Callback is called when the consist is finished
 
@@ -326,6 +309,24 @@ void AddArticulatedParts(Vehicle **vl, V
 
				break;
 
		}
 

	
 
		/* get common values from first engine */
 
		u->direction = v->direction;
 
		u->owner = v->owner;
 
		u->tile = v->tile;
 
		u->x_pos = v->x_pos;
 
		u->y_pos = v->y_pos;
 
		u->z_pos = v->z_pos;
 
		u->build_year = v->build_year;
 
		u->vehstatus = v->vehstatus & ~VS_STOPPED;
 

	
 
		u->cargo_subtype = 0;
 
		u->max_speed = 0;
 
		u->max_age = 0;
 
		u->engine_type = engine_type;
 
		u->value = 0;
 
		u->cur_image = 0xAC2;
 
		u->random_bits = VehicleRandomBits();
 

	
 
		if (flip_image) u->spritenum++;
 

	
 
		VehiclePositionChanged(u);
0 comments (0 inline, 0 general)