mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r1448) -Fix: The current_order of a vehicle is now correctly saved (caused
massive desyncs) Warning: savegames which are made with the nightly of 08-01-2005 will NO LONGER work!!
This commit is contained in:
parent
55e6b4f928
commit
97479f9613
|
@ -139,9 +139,6 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SLE_VAR(t,i,c) 0 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c
|
#define SLE_VAR(t,i,c) 0 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c
|
||||||
#if _MSC_VER == 1200 /* XXX workaround for MSVC6 */
|
|
||||||
#define SLE_VAR2(t0,i0, t1, i1, c) 0 | ((offsetof(t0, i0) + offsetof(t1, i1)) & 0xF), (offsetof(t0, i0) + offsetof(t1, i1)) >> 4, c
|
|
||||||
#endif
|
|
||||||
#define SLE_REF(t,i,c) 0x10 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c
|
#define SLE_REF(t,i,c) 0x10 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c
|
||||||
#define SLE_ARR(t,i,c,l) 0x20 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c, l
|
#define SLE_ARR(t,i,c,l) 0x20 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c, l
|
||||||
#define SLE_CONDVAR(t,i,c,from,to) 0x40 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c, from, to
|
#define SLE_CONDVAR(t,i,c,from,to) 0x40 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c, from, to
|
||||||
|
|
34
vehicle.c
34
vehicle.c
|
@ -1511,7 +1511,7 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
// turn the last engine in a multiheaded train if needed
|
// turn the last engine in a multiheaded train if needed
|
||||||
if ( v->next == NULL && rvi->flags & RVI_MULTIHEAD && v->spritenum == rvi->image_index )
|
if ( v->next == NULL && rvi->flags & RVI_MULTIHEAD && v->spritenum == rvi->image_index )
|
||||||
v->spritenum++;
|
v->spritenum++;
|
||||||
|
|
||||||
v->cargo_type = rvi->cargo_type;
|
v->cargo_type = rvi->cargo_type;
|
||||||
v->cargo_cap = rvi->capacity;
|
v->cargo_cap = rvi->capacity;
|
||||||
v->max_speed = rvi->max_speed;
|
v->max_speed = rvi->max_speed;
|
||||||
|
@ -1834,12 +1834,18 @@ const byte _common_veh_desc[] = {
|
||||||
|
|
||||||
SLE_VAR(Vehicle,cur_order_index, SLE_UINT8),
|
SLE_VAR(Vehicle,cur_order_index, SLE_UINT8),
|
||||||
SLE_VAR(Vehicle,num_orders, SLE_UINT8),
|
SLE_VAR(Vehicle,num_orders, SLE_UINT8),
|
||||||
SLE_VAR(Vehicle,current_order, SLE_UINT8), /* XXX hack to avoid version bump */
|
|
||||||
#if _MSC_VER != 1200
|
/* This next line is for version 4 and prior compatibility.. it temporarily reads
|
||||||
SLE_VAR(Vehicle,current_order.station, SLE_UINT8),
|
type and flags (which were both 4 bits) into type. Later on this is
|
||||||
#else /* XXX workaround for MSVC6 */
|
converted correctly */
|
||||||
SLE_VAR2(Vehicle, current_order, Order, station, SLE_UINT8),
|
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, type), SLE_UINT8, 0, 4),
|
||||||
#endif
|
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, 255),
|
||||||
|
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, flags), SLE_UINT8, 5, 255),
|
||||||
|
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station), SLE_UINT16, 5, 255),
|
||||||
|
|
||||||
SLE_REF(Vehicle,schedule_ptr, REF_SCHEDULE),
|
SLE_REF(Vehicle,schedule_ptr, REF_SCHEDULE),
|
||||||
|
|
||||||
SLE_VAR(Vehicle,age, SLE_UINT16),
|
SLE_VAR(Vehicle,age, SLE_UINT16),
|
||||||
|
@ -1986,11 +1992,8 @@ static const byte _disaster_desc[] = {
|
||||||
SLE_VAR(Vehicle,z_height, SLE_UINT8),
|
SLE_VAR(Vehicle,z_height, SLE_UINT8),
|
||||||
SLE_VAR(Vehicle,owner, SLE_UINT8),
|
SLE_VAR(Vehicle,owner, SLE_UINT8),
|
||||||
SLE_VAR(Vehicle,vehstatus, SLE_UINT8),
|
SLE_VAR(Vehicle,vehstatus, SLE_UINT8),
|
||||||
#if _MSC_VER != 1200
|
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
|
||||||
SLE_VAR(Vehicle,current_order.station, SLE_UINT8),
|
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station), SLE_UINT16, 5, 255),
|
||||||
#else /* XXX workaround for MSVC6 */
|
|
||||||
SLE_VAR2(Vehicle, current_order, Order, station, SLE_UINT8),
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SLE_VAR(Vehicle,cur_image, SLE_UINT16),
|
SLE_VAR(Vehicle,cur_image, SLE_UINT16),
|
||||||
SLE_VAR(Vehicle,age, SLE_UINT16),
|
SLE_VAR(Vehicle,age, SLE_UINT16),
|
||||||
|
@ -2045,6 +2048,13 @@ static void Load_VEHS()
|
||||||
/* Old savegames used 'last_station_visited = 0xFF', should be 0xFFFF */
|
/* Old savegames used 'last_station_visited = 0xFF', should be 0xFFFF */
|
||||||
if (_sl.version < 5 && v->last_station_visited == 0xFF)
|
if (_sl.version < 5 && v->last_station_visited == 0xFF)
|
||||||
v->last_station_visited = 0xFFFF;
|
v->last_station_visited = 0xFFFF;
|
||||||
|
|
||||||
|
if (_sl.version < 5) {
|
||||||
|
/* Convert the current_order.type (which is a mix of type and flags, because
|
||||||
|
in those versions, they both were 4 bits big) to type and flags */
|
||||||
|
v->current_order.flags = (v->current_order.type & 0xF0) >> 4;
|
||||||
|
v->current_order.type = v->current_order.type & 0x0F;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate through trains and set first_engine appropriately.
|
// Iterate through trains and set first_engine appropriately.
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
|
|
||||||
#include "vehicle_gui.h"
|
#include "vehicle_gui.h"
|
||||||
|
|
||||||
|
/* If you change this, keep in mind that it is saved on 3 places:
|
||||||
|
- Load_ORDR, all the global orders
|
||||||
|
- Vehicle -> current_order
|
||||||
|
- REF_SHEDULE (all REFs are currently limited to 16 bits!!) */
|
||||||
typedef struct Order {
|
typedef struct Order {
|
||||||
uint8 type;
|
uint8 type;
|
||||||
uint8 flags;
|
uint8 flags;
|
||||||
|
|
Loading…
Reference in New Issue