Changeset - r11300:51e8aa1a6d07
[Not reviewed]
master
0 2 0
frosch - 16 years ago 2009-03-09 18:56:50
frosch@openttd.org
(svn r15654) -Fix: Only ever call any vehicle callbacks after the whole articulated engine has been built. (except 0x16)
2 files changed with 4 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/articulated_vehicles.cpp
Show inline comments
 
@@ -304,13 +304,13 @@ void AddArticulatedParts(Vehicle **vl, V
 
				break;
 

	
 
			case VEH_ROAD:
 
				u = new (u) RoadVehicle();
 
				previous->SetNext(u);
 
				u->u.road.first_engine = v->engine_type;
 
				u->u.road.cached_veh_length = GetRoadVehLength(u);
 
				u->u.road.cached_veh_length = 8; // Callback is called when the consist is finished
 
				u->u.road.state = RVSB_IN_DEPOT;
 

	
 
				u->u.road.roadtype = v->u.road.roadtype;
 
				u->u.road.compatible_roadtypes = v->u.road.compatible_roadtypes;
 

	
 
				u->spritenum = e_artic->u.road.image_index;
src/roadveh_cmd.cpp
Show inline comments
 
@@ -251,23 +251,24 @@ CommandCost CmdBuildRoadVeh(TileIndex ti
 
		v->cur_image = 0xC15;
 
		v->random_bits = VehicleRandomBits();
 
		SetRoadVehFront(v);
 

	
 
		v->u.road.roadtype = HasBit(EngInfo(v->engine_type)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD;
 
		v->u.road.compatible_roadtypes = RoadTypeToRoadTypes(v->u.road.roadtype);
 
		v->u.road.cached_veh_length = GetRoadVehLength(v);
 
		v->u.road.cached_veh_length = 8;
 

	
 
		v->vehicle_flags = 0;
 
		if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
 

	
 
		v->cargo_cap = rvi->capacity;
 

	
 
		AddArticulatedParts(vl, VEH_ROAD);
 

	
 
		/* Call callback 36s after the whole consist has been constructed */
 
		/* Call various callbacks after the whole consist has been constructed */
 
		for (Vehicle *u = v; u != NULL; u = u->Next()) {
 
			u->u.road.cached_veh_length = GetRoadVehLength(u);
 
			/* Cargo capacity is zero if and only if the vehicle cannot carry anything */
 
			if (u->cargo_cap != 0) u->cargo_cap = GetVehicleProperty(u, 0x0F, u->cargo_cap);
 
		}
 

	
 
		VehiclePositionChanged(v);
 

	
0 comments (0 inline, 0 general)