File diff r4343:004f55fe1239 → r4344:bff007ae1fd1
vehicle.c
Show inline comments
 
@@ -1100,131 +1100,131 @@ typedef struct BubbleMovement {
 
#define ME(i) { i, 4, 0, 0 }
 

	
 
static const BubbleMovement _bubble_float_sw[] = {
 
	MK(0,0,1,0),
 
	MK(1,0,1,1),
 
	MK(0,0,1,0),
 
	MK(1,0,1,2),
 
	MK(0, 0, 1, 0),
 
	MK(1, 0, 1, 1),
 
	MK(0, 0, 1, 0),
 
	MK(1, 0, 1, 2),
 
	ME(1)
 
};
 

	
 

	
 
static const BubbleMovement _bubble_float_ne[] = {
 
	MK(0,0,1,0),
 
	MK(-1,0,1,1),
 
	MK(0,0,1,0),
 
	MK(-1,0,1,2),
 
	MK( 0, 0, 1, 0),
 
	MK(-1, 0, 1, 1),
 
	MK( 0, 0, 1, 0),
 
	MK(-1, 0, 1, 2),
 
	ME(1)
 
};
 

	
 
static const BubbleMovement _bubble_float_se[] = {
 
	MK(0,0,1,0),
 
	MK(0,1,1,1),
 
	MK(0,0,1,0),
 
	MK(0,1,1,2),
 
	MK(0, 0, 1, 0),
 
	MK(0, 1, 1, 1),
 
	MK(0, 0, 1, 0),
 
	MK(0, 1, 1, 2),
 
	ME(1)
 
};
 

	
 
static const BubbleMovement _bubble_float_nw[] = {
 
	MK(0,0,1,0),
 
	MK(0,-1,1,1),
 
	MK(0,0,1,0),
 
	MK(0,-1,1,2),
 
	MK(0,  0, 1, 0),
 
	MK(0, -1, 1, 1),
 
	MK(0,  0, 1, 0),
 
	MK(0, -1, 1, 2),
 
	ME(1)
 
};
 

	
 
static const BubbleMovement _bubble_burst[] = {
 
	MK(0,0,1,2),
 
	MK(0,0,1,7),
 
	MK(0,0,1,8),
 
	MK(0,0,1,9),
 
	MK(0, 0, 1, 2),
 
	MK(0, 0, 1, 7),
 
	MK(0, 0, 1, 8),
 
	MK(0, 0, 1, 9),
 
	ME(0)
 
};
 

	
 
static const BubbleMovement _bubble_absorb[] = {
 
	MK(0,0,1,0),
 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1, 1),
 
	MK(0, 0, 1, 0),
 
	MK(0, 0, 1, 2),
 
	MK(0, 0, 1, 0),
 
	MK(0, 0, 1, 1),
 
	MK(0, 0, 1, 0),
 
	MK(0, 0, 1, 2),
 
	MK(0, 0, 1, 0),
 
	MK(0, 0, 1, 1),
 
	MK(0, 0, 1, 0),
 
	MK(0, 0, 1, 2),
 
	MK(0, 0, 1, 0),
 
	MK(0, 0, 1, 1),
 
	MK(2, 1, 3, 0),
 
	MK(1, 1, 3, 1),
 
	MK(2, 1, 3, 0),
 
	MK(1, 1, 3, 2),
 
	MK(2, 1, 3, 0),
 
	MK(1, 1, 3, 1),
 
	MK(2, 1, 3, 0),
 
	MK(1, 0, 1, 2),
 
	MK(0, 0, 1, 0),
 
	MK(1, 0, 1, 1),
 
	MK(0, 0, 1, 0),
 
	MK(1, 0, 1, 2),
 
	MK(0, 0, 1, 0),
 
	MK(1, 0, 1, 1),
 
	MK(0, 0, 1, 0),
 
	MK(1, 0, 1, 2),
 
	ME(2),
 
	MK(0,0,0,0xA),
 
	MK(0,0,0,0xB),
 
	MK(0,0,0,0xC),
 
	MK(0,0,0,0xD),
 
	MK(0,0,0,0xE),
 
	MK(0, 0, 0, 0xA),
 
	MK(0, 0, 0, 0xB),
 
	MK(0, 0, 0, 0xC),
 
	MK(0, 0, 0, 0xD),
 
	MK(0, 0, 0, 0xE),
 
	ME(0)
 
};
 
#undef ME
 
@@ -1422,13 +1422,13 @@ void DecreaseVehicleValue(Vehicle *v)
 
}
 

	
 
static const byte _breakdown_chance[64] = {
 
	3, 3, 3, 3, 3, 3, 3, 3,
 
	4, 4, 5, 5, 6, 6, 7, 7,
 
	8, 8, 9, 9, 10, 10, 11, 11,
 
	12, 13, 13, 13, 13, 14, 15, 16,
 
	17, 19, 21, 25, 28, 31, 34, 37,
 
	40, 44, 48, 52, 56, 60, 64, 68,
 
	72, 80, 90, 100, 110, 120, 130, 140,
 
	  3,   3,   3,   3,   3,   3,   3,   3,
 
	  4,   4,   5,   5,   6,   6,   7,   7,
 
	  8,   8,   9,   9,  10,  10,  11,  11,
 
	 12,  13,  13,  13,  13,  14,  15,  16,
 
	 17,  19,  21,  25,  28,  31,  34,  37,
 
	 40,  44,  48,  52,  56,  60,  64,  68,
 
	 72,  80,  90, 100, 110, 120, 130, 140,
 
	150, 170, 190, 210, 230, 250, 250, 250,
 
};
 

	
 
@@ -2138,116 +2138,116 @@ PalSpriteID GetVehiclePalette(const Vehi
 

	
 
// Save and load of vehicles
 
const SaveLoad _common_veh_desc[] = {
 
	SLE_VAR(Vehicle,subtype,					SLE_UINT8),
 

	
 
	SLE_REF(Vehicle,next,							REF_VEHICLE_OLD),
 
	SLE_VAR(Vehicle,string_id,				SLE_STRINGID),
 
	SLE_CONDVAR(Vehicle,unitnumber,				SLE_FILE_U8 | SLE_VAR_U16, 0, 7),
 
	SLE_CONDVAR(Vehicle,unitnumber,				SLE_UINT16, 8, SL_MAX_VERSION),
 
	SLE_VAR(Vehicle,owner,						SLE_UINT8),
 
	SLE_CONDVAR(Vehicle,tile,					SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	SLE_CONDVAR(Vehicle,tile,					SLE_UINT32, 6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle,dest_tile,		SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	SLE_CONDVAR(Vehicle,dest_tile,		SLE_UINT32, 6, SL_MAX_VERSION),
 

	
 
	SLE_CONDVAR(Vehicle,x_pos,				SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	SLE_CONDVAR(Vehicle,x_pos,				SLE_UINT32, 6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle,y_pos,				SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	SLE_CONDVAR(Vehicle,y_pos,				SLE_UINT32, 6, SL_MAX_VERSION),
 
	SLE_VAR(Vehicle,z_pos,						SLE_UINT8),
 
	SLE_VAR(Vehicle,direction,				SLE_UINT8),
 

	
 
	SLE_VAR(Vehicle,cur_image,				SLE_UINT16),
 
	SLE_VAR(Vehicle,spritenum,				SLE_UINT8),
 
	SLE_VAR(Vehicle,sprite_width,			SLE_UINT8),
 
	SLE_VAR(Vehicle,sprite_height,		SLE_UINT8),
 
	SLE_VAR(Vehicle,z_height,					SLE_UINT8),
 
	SLE_VAR(Vehicle,x_offs,						SLE_INT8),
 
	SLE_VAR(Vehicle,y_offs,						SLE_INT8),
 
	SLE_VAR(Vehicle,engine_type,			SLE_UINT16),
 

	
 
	SLE_VAR(Vehicle,max_speed,				SLE_UINT16),
 
	SLE_VAR(Vehicle,cur_speed,				SLE_UINT16),
 
	SLE_VAR(Vehicle,subspeed,					SLE_UINT8),
 
	SLE_VAR(Vehicle,acceleration,			SLE_UINT8),
 
	SLE_VAR(Vehicle,progress,					SLE_UINT8),
 

	
 
	SLE_VAR(Vehicle,vehstatus,				SLE_UINT8),
 
	SLE_CONDVAR(Vehicle,last_station_visited, SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
 
	SLE_CONDVAR(Vehicle,last_station_visited, SLE_UINT16, 5, SL_MAX_VERSION),
 

	
 
	SLE_VAR(Vehicle,cargo_type,				SLE_UINT8),
 
	SLE_VAR(Vehicle,cargo_days,				SLE_UINT8),
 
	SLE_CONDVAR(Vehicle,cargo_source,			SLE_FILE_U8 | SLE_VAR_U16, 0, 6),
 
	SLE_CONDVAR(Vehicle,cargo_source,			SLE_UINT16, 7, SL_MAX_VERSION),
 
	SLE_VAR(Vehicle,cargo_cap,				SLE_UINT16),
 
	SLE_VAR(Vehicle,cargo_count,			SLE_UINT16),
 

	
 
	SLE_VAR(Vehicle,day_counter,			SLE_UINT8),
 
	SLE_VAR(Vehicle,tick_counter,			SLE_UINT8),
 

	
 
	SLE_VAR(Vehicle,cur_order_index,	SLE_UINT8),
 
	SLE_VAR(Vehicle,num_orders,				SLE_UINT8),
 
	    SLE_VAR(Vehicle, subtype,              SLE_UINT8),
 

	
 
	    SLE_REF(Vehicle, next,                 REF_VEHICLE_OLD),
 
	    SLE_VAR(Vehicle, string_id,            SLE_STRINGID),
 
	SLE_CONDVAR(Vehicle, unitnumber,           SLE_FILE_U8  | SLE_VAR_U16,  0, 7),
 
	SLE_CONDVAR(Vehicle, unitnumber,           SLE_UINT16,                  8, SL_MAX_VERSION),
 
	    SLE_VAR(Vehicle, owner,                SLE_UINT8),
 
	SLE_CONDVAR(Vehicle, tile,                 SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Vehicle, tile,                 SLE_UINT32,                  6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle, dest_tile,            SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Vehicle, dest_tile,            SLE_UINT32,                  6, SL_MAX_VERSION),
 

	
 
	SLE_CONDVAR(Vehicle, x_pos,                SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Vehicle, x_pos,                SLE_UINT32,                  6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle, y_pos,                SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Vehicle, y_pos,                SLE_UINT32,                  6, SL_MAX_VERSION),
 
	    SLE_VAR(Vehicle, z_pos,                SLE_UINT8),
 
	    SLE_VAR(Vehicle, direction,            SLE_UINT8),
 

	
 
	    SLE_VAR(Vehicle, cur_image,            SLE_UINT16),
 
	    SLE_VAR(Vehicle, spritenum,            SLE_UINT8),
 
	    SLE_VAR(Vehicle, sprite_width,         SLE_UINT8),
 
	    SLE_VAR(Vehicle, sprite_height,        SLE_UINT8),
 
	    SLE_VAR(Vehicle, z_height,             SLE_UINT8),
 
	    SLE_VAR(Vehicle, x_offs,               SLE_INT8),
 
	    SLE_VAR(Vehicle, y_offs,               SLE_INT8),
 
	    SLE_VAR(Vehicle, engine_type,          SLE_UINT16),
 

	
 
	    SLE_VAR(Vehicle, max_speed,            SLE_UINT16),
 
	    SLE_VAR(Vehicle, cur_speed,            SLE_UINT16),
 
	    SLE_VAR(Vehicle, subspeed,             SLE_UINT8),
 
	    SLE_VAR(Vehicle, acceleration,         SLE_UINT8),
 
	    SLE_VAR(Vehicle, progress,             SLE_UINT8),
 

	
 
	    SLE_VAR(Vehicle, vehstatus,            SLE_UINT8),
 
	SLE_CONDVAR(Vehicle, last_station_visited, SLE_FILE_U8  | SLE_VAR_U16,  0, 4),
 
	SLE_CONDVAR(Vehicle, last_station_visited, SLE_UINT16,                  5, SL_MAX_VERSION),
 

	
 
	    SLE_VAR(Vehicle, cargo_type,           SLE_UINT8),
 
	    SLE_VAR(Vehicle, cargo_days,           SLE_UINT8),
 
	SLE_CONDVAR(Vehicle, cargo_source,         SLE_FILE_U8  | SLE_VAR_U16,  0, 6),
 
	SLE_CONDVAR(Vehicle, cargo_source,         SLE_UINT16,                  7, SL_MAX_VERSION),
 
	    SLE_VAR(Vehicle, cargo_cap,            SLE_UINT16),
 
	    SLE_VAR(Vehicle, cargo_count,          SLE_UINT16),
 

	
 
	    SLE_VAR(Vehicle, day_counter,          SLE_UINT8),
 
	    SLE_VAR(Vehicle, tick_counter,         SLE_UINT8),
 

	
 
	    SLE_VAR(Vehicle, cur_order_index,      SLE_UINT8),
 
	    SLE_VAR(Vehicle, num_orders,           SLE_UINT8),
 

	
 
	/* This next line is for version 4 and prior compatibility.. it temporarily reads
 
	    type and flags (which were both 4 bits) into type. Later on this is
 
	    converted correctly */
 
	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, type),    SLE_UINT8,  0, 4),
 
	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, type),    SLE_UINT8,                 0, 4),
 
	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
 

	
 
	/* Orders for version 5 and on */
 
	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, type),    SLE_UINT8,  5, SL_MAX_VERSION),
 
	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, flags),   SLE_UINT8,  5, SL_MAX_VERSION),
 
	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station), SLE_UINT16, 5, SL_MAX_VERSION),
 

	
 
	SLE_REF(Vehicle,orders,						REF_ORDER),
 

	
 
	SLE_CONDVAR(Vehicle,age,					SLE_FILE_U16 | SLE_VAR_I32, 0, 30),
 
	SLE_CONDVAR(Vehicle,age,					SLE_INT32, 31, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle,max_age,			SLE_FILE_U16 | SLE_VAR_I32, 0, 30),
 
	SLE_CONDVAR(Vehicle,max_age,			SLE_INT32, 31, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle,date_of_last_service,	SLE_FILE_U16 | SLE_VAR_I32, 0, 30),
 
	SLE_CONDVAR(Vehicle,date_of_last_service,	SLE_INT32, 31, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle,service_interval,			SLE_FILE_U16 | SLE_VAR_I32, 0, 30),
 
	SLE_CONDVAR(Vehicle,service_interval,			SLE_INT32, 31, SL_MAX_VERSION),
 
	SLE_VAR(Vehicle,reliability,			SLE_UINT16),
 
	SLE_VAR(Vehicle,reliability_spd_dec,SLE_UINT16),
 
	SLE_VAR(Vehicle,breakdown_ctr,		SLE_UINT8),
 
	SLE_VAR(Vehicle,breakdown_delay,	SLE_UINT8),
 
	SLE_VAR(Vehicle,breakdowns_since_last_service,	SLE_UINT8),
 
	SLE_VAR(Vehicle,breakdown_chance,	SLE_UINT8),
 
	SLE_CONDVAR(Vehicle,build_year,		SLE_FILE_U8 | SLE_VAR_I32, 0, 30),
 
	SLE_CONDVAR(Vehicle,build_year,		SLE_INT32, 31, SL_MAX_VERSION),
 

	
 
	SLE_VAR(Vehicle,load_unload_time_rem,	SLE_UINT16),
 

	
 
	SLE_VAR(Vehicle,profit_this_year,	SLE_INT32),
 
	SLE_VAR(Vehicle,profit_last_year,	SLE_INT32),
 
	SLE_VAR(Vehicle,value,						SLE_UINT32),
 

	
 
	SLE_VAR(Vehicle,random_bits,       SLE_UINT8),
 
	SLE_VAR(Vehicle,waiting_triggers,  SLE_UINT8),
 

	
 
	SLE_REF(Vehicle,next_shared,				REF_VEHICLE),
 
	SLE_REF(Vehicle,prev_shared,				REF_VEHICLE),
 
	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, type),    SLE_UINT8,                 5, SL_MAX_VERSION),
 
	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, flags),   SLE_UINT8,                 5, SL_MAX_VERSION),
 
	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station), SLE_UINT16,                5, SL_MAX_VERSION),
 

	
 
	    SLE_REF(Vehicle, orders,               REF_ORDER),
 

	
 
	SLE_CONDVAR(Vehicle, age,                  SLE_FILE_U16 | SLE_VAR_I32,  0, 30),
 
	SLE_CONDVAR(Vehicle, age,                  SLE_INT32,                  31, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle, max_age,              SLE_FILE_U16 | SLE_VAR_I32,  0, 30),
 
	SLE_CONDVAR(Vehicle, max_age,              SLE_INT32,                  31, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle, date_of_last_service, SLE_FILE_U16 | SLE_VAR_I32,  0, 30),
 
	SLE_CONDVAR(Vehicle, date_of_last_service, SLE_INT32,                  31, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle, service_interval,     SLE_FILE_U16 | SLE_VAR_I32,  0, 30),
 
	SLE_CONDVAR(Vehicle, service_interval,     SLE_INT32,                  31, SL_MAX_VERSION),
 
	    SLE_VAR(Vehicle, reliability,          SLE_UINT16),
 
	    SLE_VAR(Vehicle, reliability_spd_dec,  SLE_UINT16),
 
	    SLE_VAR(Vehicle, breakdown_ctr,        SLE_UINT8),
 
	    SLE_VAR(Vehicle, breakdown_delay,      SLE_UINT8),
 
	    SLE_VAR(Vehicle, breakdowns_since_last_service, SLE_UINT8),
 
	    SLE_VAR(Vehicle, breakdown_chance,     SLE_UINT8),
 
	SLE_CONDVAR(Vehicle, build_year,           SLE_FILE_U8 | SLE_VAR_I32,  0, 30),
 
	SLE_CONDVAR(Vehicle, build_year,           SLE_INT32,                 31, SL_MAX_VERSION),
 

	
 
	    SLE_VAR(Vehicle, load_unload_time_rem, SLE_UINT16),
 

	
 
	    SLE_VAR(Vehicle, profit_this_year,     SLE_INT32),
 
	    SLE_VAR(Vehicle, profit_last_year,     SLE_INT32),
 
	    SLE_VAR(Vehicle, value,                SLE_UINT32),
 

	
 
	    SLE_VAR(Vehicle, random_bits,          SLE_UINT8),
 
	    SLE_VAR(Vehicle, waiting_triggers,     SLE_UINT8),
 

	
 
	    SLE_REF(Vehicle, next_shared,          REF_VEHICLE),
 
	    SLE_REF(Vehicle, prev_shared,          REF_VEHICLE),
 

	
 
	// reserve extra space in savegame here. (currently 10 bytes)
 
	SLE_CONDNULL(10, 2, SL_MAX_VERSION),
 
	SLE_CONDNULL(10,                                                       2, SL_MAX_VERSION),
 

	
 
	SLE_END()
 
};
 

	
 

	
 
static const SaveLoad _train_desc[] = {
 
	SLE_WRITEBYTE(Vehicle,type,VEH_Train, 0), // Train type. VEH_Train in mem, 0 in file.
 
	SLE_WRITEBYTE(Vehicle, type, VEH_Train, 0), // Train type. VEH_Train in mem, 0 in file.
 
	SLE_INCLUDEX(0, INC_VEHICLE_COMMON),
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleRail,crash_anim_pos), SLE_UINT16),
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleRail,force_proceed), SLE_UINT8),
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleRail,railtype), SLE_UINT8),
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleRail,track), SLE_UINT8),
 

	
 
	SLE_CONDVARX(offsetof(Vehicle,u)+offsetof(VehicleRail,flags), SLE_UINT8, 2, SL_MAX_VERSION),
 
	SLE_CONDVARX(offsetof(Vehicle,u)+offsetof(VehicleRail,days_since_order_progr), SLE_UINT16, 2, SL_MAX_VERSION),
 
	    SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRail, crash_anim_pos),         SLE_UINT16),
 
	    SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRail, force_proceed),          SLE_UINT8),
 
	    SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRail, railtype),               SLE_UINT8),
 
	    SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRail, track),                  SLE_UINT8),
 

	
 
	SLE_CONDVARX(offsetof(Vehicle, u) + offsetof(VehicleRail, flags),                  SLE_UINT8,  2, SL_MAX_VERSION),
 
	SLE_CONDVARX(offsetof(Vehicle, u) + offsetof(VehicleRail, days_since_order_progr), SLE_UINT16, 2, SL_MAX_VERSION),
 

	
 
	SLE_CONDNULL(2, 2, 19),
 
	// reserve extra space in savegame here. (currently 11 bytes)
 
@@ -2257,29 +2257,29 @@ static const SaveLoad _train_desc[] = {
 
};
 

	
 
static const SaveLoad _roadveh_desc[] = {
 
	SLE_WRITEBYTE(Vehicle,type,VEH_Road, 1), // Road type. VEH_Road in mem, 1 in file.
 
	SLE_WRITEBYTE(Vehicle, type, VEH_Road, 1), // Road type. VEH_Road in mem, 1 in file.
 
	SLE_INCLUDEX(0, INC_VEHICLE_COMMON),
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleRoad,state),					SLE_UINT8),
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleRoad,frame),					SLE_UINT8),
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleRoad,blocked_ctr),		SLE_UINT16),
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleRoad,overtaking),		SLE_UINT8),
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleRoad,overtaking_ctr),SLE_UINT8),
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleRoad,crashed_ctr),		SLE_UINT16),
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleRoad,reverse_ctr),			SLE_UINT8),
 

	
 
	SLE_CONDREFX(offsetof(Vehicle,u)+offsetof(VehicleRoad,slot), REF_ROADSTOPS, 6, SL_MAX_VERSION),
 
	SLE_CONDNULL(1, 6, SL_MAX_VERSION),
 
	SLE_CONDVARX(offsetof(Vehicle,u)+offsetof(VehicleRoad,slot_age), SLE_UINT8, 6, SL_MAX_VERSION),
 
	    SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRoad, state),          SLE_UINT8),
 
	    SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRoad, frame),          SLE_UINT8),
 
	    SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRoad, blocked_ctr),    SLE_UINT16),
 
	    SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRoad, overtaking),     SLE_UINT8),
 
	    SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRoad, overtaking_ctr), SLE_UINT8),
 
	    SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRoad, crashed_ctr),    SLE_UINT16),
 
	    SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRoad, reverse_ctr),    SLE_UINT8),
 

	
 
	SLE_CONDREFX(offsetof(Vehicle, u) + offsetof(VehicleRoad, slot),     REF_ROADSTOPS, 6, SL_MAX_VERSION),
 
	SLE_CONDNULL(1,                                                                     6, SL_MAX_VERSION),
 
	SLE_CONDVARX(offsetof(Vehicle, u) + offsetof(VehicleRoad, slot_age), SLE_UINT8,     6, SL_MAX_VERSION),
 
	// reserve extra space in savegame here. (currently 16 bytes)
 
	SLE_CONDNULL(16, 2, SL_MAX_VERSION),
 
	SLE_CONDNULL(16,                                                                    2, SL_MAX_VERSION),
 

	
 
	SLE_END()
 
};
 

	
 
static const SaveLoad _ship_desc[] = {
 
	SLE_WRITEBYTE(Vehicle,type,VEH_Ship, 2), // Ship type. VEH_Ship in mem, 2 in file.
 
	SLE_WRITEBYTE(Vehicle, type, VEH_Ship, 2), // Ship type. VEH_Ship in mem, 2 in file.
 
	SLE_INCLUDEX(0, INC_VEHICLE_COMMON),
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleShip,state),				SLE_UINT8),
 
	SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleShip, state), SLE_UINT8),
 

	
 
	// reserve extra space in savegame here. (currently 16 bytes)
 
	SLE_CONDNULL(16, 2, SL_MAX_VERSION),
 
@@ -2288,20 +2288,20 @@ static const SaveLoad _ship_desc[] = {
 
};
 

	
 
static const SaveLoad _aircraft_desc[] = {
 
	SLE_WRITEBYTE(Vehicle,type,VEH_Aircraft, 3), // Aircraft type. VEH_Aircraft in mem, 3 in file.
 
	SLE_WRITEBYTE(Vehicle, type, VEH_Aircraft, 3), // Aircraft type. VEH_Aircraft in mem, 3 in file.
 
	SLE_INCLUDEX(0, INC_VEHICLE_COMMON),
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleAir,crashed_counter),	SLE_UINT16),
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleAir,pos),							SLE_UINT8),
 

	
 
	SLE_CONDVARX(offsetof(Vehicle,u)+offsetof(VehicleAir,targetairport),		SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
 
	SLE_CONDVARX(offsetof(Vehicle,u)+offsetof(VehicleAir,targetairport),		SLE_UINT16, 5, SL_MAX_VERSION),
 

	
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleAir,state),						SLE_UINT8),
 

	
 
	SLE_CONDVARX(offsetof(Vehicle,u)+offsetof(VehicleAir,previous_pos),			SLE_UINT8, 2, SL_MAX_VERSION),
 
	    SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleAir, crashed_counter), SLE_UINT16),
 
	    SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleAir, pos),             SLE_UINT8),
 

	
 
	SLE_CONDVARX(offsetof(Vehicle, u) + offsetof(VehicleAir, targetairport),   SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
 
	SLE_CONDVARX(offsetof(Vehicle, u) + offsetof(VehicleAir, targetairport),   SLE_UINT16,                5, SL_MAX_VERSION),
 

	
 
	    SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleAir, state),           SLE_UINT8),
 

	
 
	SLE_CONDVARX(offsetof(Vehicle, u) + offsetof(VehicleAir, previous_pos),    SLE_UINT8,                 2, SL_MAX_VERSION),
 

	
 
	// reserve extra space in savegame here. (currently 15 bytes)
 
	SLE_CONDNULL(15, 2, SL_MAX_VERSION),
 
	SLE_CONDNULL(15,                                                                                      2, SL_MAX_VERSION),
 

	
 
	SLE_END()
 
};
 
@@ -2309,28 +2309,28 @@ static const SaveLoad _aircraft_desc[] =
 
static const SaveLoad _special_desc[] = {
 
	SLE_WRITEBYTE(Vehicle,type,VEH_Special, 4),
 

	
 
	SLE_VAR(Vehicle,subtype,					SLE_UINT8),
 

	
 
	SLE_CONDVAR(Vehicle,tile,					SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	SLE_CONDVAR(Vehicle,tile,					SLE_UINT32, 6, SL_MAX_VERSION),
 

	
 
	SLE_CONDVAR(Vehicle,x_pos,				SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
 
	SLE_CONDVAR(Vehicle,x_pos,				SLE_INT32, 6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle,y_pos,				SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
 
	SLE_CONDVAR(Vehicle,y_pos,				SLE_INT32, 6, SL_MAX_VERSION),
 
	SLE_VAR(Vehicle,z_pos,						SLE_UINT8),
 

	
 
	SLE_VAR(Vehicle,cur_image,				SLE_UINT16),
 
	SLE_VAR(Vehicle,sprite_width,			SLE_UINT8),
 
	SLE_VAR(Vehicle,sprite_height,		SLE_UINT8),
 
	SLE_VAR(Vehicle,z_height,					SLE_UINT8),
 
	SLE_VAR(Vehicle,x_offs,						SLE_INT8),
 
	SLE_VAR(Vehicle,y_offs,						SLE_INT8),
 
	SLE_VAR(Vehicle,progress,					SLE_UINT8),
 
	SLE_VAR(Vehicle,vehstatus,				SLE_UINT8),
 

	
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleSpecial,unk0),	SLE_UINT16),
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleSpecial,unk2),	SLE_UINT8),
 
	    SLE_VAR(Vehicle, subtype,       SLE_UINT8),
 

	
 
	SLE_CONDVAR(Vehicle, tile,          SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	SLE_CONDVAR(Vehicle, tile,          SLE_UINT32,                 6, SL_MAX_VERSION),
 

	
 
	SLE_CONDVAR(Vehicle, x_pos,         SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
 
	SLE_CONDVAR(Vehicle, x_pos,         SLE_INT32,                  6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle, y_pos,         SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
 
	SLE_CONDVAR(Vehicle, y_pos,         SLE_INT32,                  6, SL_MAX_VERSION),
 
	    SLE_VAR(Vehicle, z_pos,         SLE_UINT8),
 

	
 
	    SLE_VAR(Vehicle, cur_image,     SLE_UINT16),
 
	    SLE_VAR(Vehicle, sprite_width,  SLE_UINT8),
 
	    SLE_VAR(Vehicle, sprite_height, SLE_UINT8),
 
	    SLE_VAR(Vehicle, z_height,      SLE_UINT8),
 
	    SLE_VAR(Vehicle, x_offs,        SLE_INT8),
 
	    SLE_VAR(Vehicle, y_offs,        SLE_INT8),
 
	    SLE_VAR(Vehicle, progress,      SLE_UINT8),
 
	    SLE_VAR(Vehicle, vehstatus,     SLE_UINT8),
 

	
 
	    SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleSpecial, unk0), SLE_UINT16),
 
	    SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleSpecial, unk2), SLE_UINT8),
 

	
 
	// reserve extra space in savegame here. (currently 16 bytes)
 
	SLE_CONDNULL(16, 2, SL_MAX_VERSION),
 
@@ -2339,43 +2339,43 @@ static const SaveLoad _special_desc[] = 
 
};
 

	
 
static const SaveLoad _disaster_desc[] = {
 
	SLE_WRITEBYTE(Vehicle,type,VEH_Disaster, 5),
 

	
 
	SLE_REF(Vehicle,next,							REF_VEHICLE_OLD),
 

	
 
	SLE_VAR(Vehicle,subtype,					SLE_UINT8),
 
	SLE_CONDVAR(Vehicle,tile,					SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	SLE_CONDVAR(Vehicle,tile,					SLE_UINT32, 6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle,dest_tile,		SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	SLE_CONDVAR(Vehicle,dest_tile,		SLE_UINT32, 6, SL_MAX_VERSION),
 

	
 
	SLE_CONDVAR(Vehicle,x_pos,				SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
 
	SLE_CONDVAR(Vehicle,x_pos,				SLE_INT32, 6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle,y_pos,				SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
 
	SLE_CONDVAR(Vehicle,y_pos,				SLE_INT32, 6, SL_MAX_VERSION),
 
	SLE_VAR(Vehicle,z_pos,						SLE_UINT8),
 
	SLE_VAR(Vehicle,direction,				SLE_UINT8),
 

	
 
	SLE_VAR(Vehicle,x_offs,						SLE_INT8),
 
	SLE_VAR(Vehicle,y_offs,						SLE_INT8),
 
	SLE_VAR(Vehicle,sprite_width,			SLE_UINT8),
 
	SLE_VAR(Vehicle,sprite_height,		SLE_UINT8),
 
	SLE_VAR(Vehicle,z_height,					SLE_UINT8),
 
	SLE_VAR(Vehicle,owner,						SLE_UINT8),
 
	SLE_VAR(Vehicle,vehstatus,				SLE_UINT8),
 
	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
 
	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station), SLE_UINT16, 5, SL_MAX_VERSION),
 

	
 
	SLE_VAR(Vehicle,cur_image,				SLE_UINT16),
 
	SLE_CONDVAR(Vehicle,age,					SLE_FILE_U16 | SLE_VAR_I32, 0, 30),
 
	SLE_CONDVAR(Vehicle,age,					SLE_INT32, 31, SL_MAX_VERSION),
 
	SLE_VAR(Vehicle,tick_counter,			SLE_UINT8),
 

	
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleDisaster,image_override),	SLE_UINT16),
 
	SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleDisaster,unk2),						SLE_UINT16),
 
	SLE_WRITEBYTE(Vehicle, type, VEH_Disaster, 5),
 

	
 
	    SLE_REF(Vehicle, next,          REF_VEHICLE_OLD),
 

	
 
	    SLE_VAR(Vehicle, subtype,       SLE_UINT8),
 
	SLE_CONDVAR(Vehicle, tile,          SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Vehicle, tile,          SLE_UINT32,                  6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle, dest_tile,     SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Vehicle, dest_tile,     SLE_UINT32,                  6, SL_MAX_VERSION),
 

	
 
	SLE_CONDVAR(Vehicle, x_pos,         SLE_FILE_I16 | SLE_VAR_I32,  0, 5),
 
	SLE_CONDVAR(Vehicle, x_pos,         SLE_INT32,                   6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Vehicle, y_pos,         SLE_FILE_I16 | SLE_VAR_I32,  0, 5),
 
	SLE_CONDVAR(Vehicle, y_pos,         SLE_INT32,                   6, SL_MAX_VERSION),
 
	    SLE_VAR(Vehicle, z_pos,         SLE_UINT8),
 
	    SLE_VAR(Vehicle, direction,     SLE_UINT8),
 

	
 
	    SLE_VAR(Vehicle, x_offs,        SLE_INT8),
 
	    SLE_VAR(Vehicle, y_offs,        SLE_INT8),
 
	    SLE_VAR(Vehicle, sprite_width,  SLE_UINT8),
 
	    SLE_VAR(Vehicle, sprite_height, SLE_UINT8),
 
	    SLE_VAR(Vehicle, z_height,      SLE_UINT8),
 
	    SLE_VAR(Vehicle, owner,         SLE_UINT8),
 
	    SLE_VAR(Vehicle, vehstatus,     SLE_UINT8),
 
	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station),     SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
 
	SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station),     SLE_UINT16,                5, SL_MAX_VERSION),
 

	
 
	    SLE_VAR(Vehicle, cur_image,     SLE_UINT16),
 
	SLE_CONDVAR(Vehicle, age,           SLE_FILE_U16 | SLE_VAR_I32,  0, 30),
 
	SLE_CONDVAR(Vehicle, age,           SLE_INT32,                  31, SL_MAX_VERSION),
 
	    SLE_VAR(Vehicle, tick_counter,  SLE_UINT8),
 

	
 
	   SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleDisaster, image_override), SLE_UINT16),
 
	   SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleDisaster, unk2),           SLE_UINT16),
 

	
 
	// reserve extra space in savegame here. (currently 16 bytes)
 
	SLE_CONDNULL(16, 2, SL_MAX_VERSION),
 
	SLE_CONDNULL(16,                                                 2, SL_MAX_VERSION),
 

	
 
	SLE_END()
 
};