mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 23:50:25 +00:00
(svn r16944) -Codechange: remove needlessly complex way of getting the offset of items within a struct that are within a struct
This commit is contained in:
parent
d11ec2d1af
commit
7a24fba918
@ -46,7 +46,7 @@ static const SaveLoad _industry_desc[] = {
|
||||
SLE_CONDVAR(Industry, last_cargo_accepted_at, SLE_INT32, 70, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Industry, selected_layout, SLE_UINT8, 73, SL_MAX_VERSION),
|
||||
|
||||
SLE_CONDARRX(cpp_offsetof(Industry, psa) + cpp_offsetof(Industry::PersistentStorage, storage), SLE_UINT32, 16, 76, SL_MAX_VERSION),
|
||||
SLE_CONDARR(Industry, psa.storage, SLE_UINT32, 16, 76, SL_MAX_VERSION),
|
||||
|
||||
SLE_CONDVAR(Industry, random_triggers, SLE_UINT8, 82, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Industry, random, SLE_UINT16, 82, SL_MAX_VERSION),
|
||||
|
@ -225,18 +225,8 @@ typedef SaveLoad SaveLoadGlobVarList;
|
||||
/* Translate values ingame to different values in the savegame and vv */
|
||||
#define SLE_WRITEBYTE(base, variable, value) SLE_GENERAL(SL_WRITEBYTE, base, variable, 0, 0, value, value)
|
||||
|
||||
/* The same as the ones at the top, only the offset is given directly; used for unions */
|
||||
#define SLE_GENERALX(cmd, offset, type, length, param1, param2) {false, cmd, type, length, param1, param2, (void*)(offset)}
|
||||
#define SLE_CONDVARX(offset, type, from, to) SLE_GENERALX(SL_VAR, offset, type, 0, from, to)
|
||||
#define SLE_CONDARRX(offset, type, length, from, to) SLE_GENERALX(SL_ARR, offset, type, length, from, to)
|
||||
#define SLE_CONDREFX(offset, type, from, to) SLE_GENERALX(SL_REF, offset, type, 0, from, to)
|
||||
|
||||
#define SLE_VARX(offset, type) SLE_CONDVARX(offset, type, 0, SL_MAX_VERSION)
|
||||
#define SLE_REFX(offset, type) SLE_CONDREFX(offset, type, 0, SL_MAX_VERSION)
|
||||
|
||||
#define SLE_WRITEBYTEX(offset, something) SLE_GENERALX(SL_WRITEBYTE, offset, 0, 0, something, 0)
|
||||
#define SLE_VEH_INCLUDEX() SLE_GENERALX(SL_VEH_INCLUDE, 0, 0, 0, 0, SL_MAX_VERSION)
|
||||
#define SLE_ST_INCLUDEX() SLE_GENERALX(SL_ST_INCLUDE, 0, 0, 0, 0, SL_MAX_VERSION)
|
||||
#define SLE_VEH_INCLUDE() {false, SL_VEH_INCLUDE, 0, 0, 0, SL_MAX_VERSION, NULL}
|
||||
#define SLE_ST_INCLUDE() {false, SL_ST_INCLUDE, 0, 0, 0, SL_MAX_VERSION, NULL}
|
||||
|
||||
/* End marker */
|
||||
#define SLE_END() {false, SL_END, 0, 0, 0, 0, NULL}
|
||||
|
@ -297,7 +297,7 @@ static const SaveLoad _base_station_desc[] = {
|
||||
|
||||
static const SaveLoad _station_desc[] = {
|
||||
SLE_WRITEBYTE(Station, facilities, FACIL_NONE),
|
||||
SLE_ST_INCLUDEX(),
|
||||
SLE_ST_INCLUDE(),
|
||||
|
||||
SLE_VAR(Station, train_tile, SLE_UINT32),
|
||||
SLE_VAR(Station, trainst_w, SLE_UINT8),
|
||||
@ -323,7 +323,7 @@ static const SaveLoad _station_desc[] = {
|
||||
|
||||
static const SaveLoad _waypoint_desc[] = {
|
||||
SLE_WRITEBYTE(Waypoint, facilities, FACIL_WAYPOINT),
|
||||
SLE_ST_INCLUDEX(),
|
||||
SLE_ST_INCLUDE(),
|
||||
|
||||
SLE_VAR(Waypoint, town_cn, SLE_UINT16),
|
||||
|
||||
|
@ -453,21 +453,21 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
|
||||
/* 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(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, type), SLE_UINT8, 0, 4),
|
||||
SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, dest), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
|
||||
SLE_CONDVAR(Vehicle, current_order.type, SLE_UINT8, 0, 4),
|
||||
SLE_CONDVAR(Vehicle, current_order.dest, SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
|
||||
|
||||
/* Orders for version 5 and on */
|
||||
SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, type), SLE_UINT8, 5, SL_MAX_VERSION),
|
||||
SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, flags), SLE_UINT8, 5, SL_MAX_VERSION),
|
||||
SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, dest), SLE_UINT16, 5, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Vehicle, current_order.type, SLE_UINT8, 5, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Vehicle, current_order.flags, SLE_UINT8, 5, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Vehicle, current_order.dest, SLE_UINT16, 5, SL_MAX_VERSION),
|
||||
|
||||
/* Refit in current order */
|
||||
SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, refit_cargo), SLE_UINT8, 36, SL_MAX_VERSION),
|
||||
SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, refit_subtype), SLE_UINT8, 36, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Vehicle, current_order.refit_cargo, SLE_UINT8, 36, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Vehicle, current_order.refit_subtype, SLE_UINT8, 36, SL_MAX_VERSION),
|
||||
|
||||
/* Timetable in current order */
|
||||
SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, wait_time), SLE_UINT16, 67, SL_MAX_VERSION),
|
||||
SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, travel_time), SLE_UINT16, 67, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Vehicle, current_order.wait_time, SLE_UINT16, 67, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Vehicle, current_order.travel_time, SLE_UINT16, 67, SL_MAX_VERSION),
|
||||
|
||||
SLE_CONDREF(Vehicle, orders, REF_ORDER, 0, 104),
|
||||
SLE_CONDREF(Vehicle, orders, REF_ORDERLIST, 105, SL_MAX_VERSION),
|
||||
@ -524,7 +524,7 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
|
||||
|
||||
static const SaveLoad _train_desc[] = {
|
||||
SLE_WRITEBYTE(Vehicle, type, VEH_TRAIN),
|
||||
SLE_VEH_INCLUDEX(),
|
||||
SLE_VEH_INCLUDE(),
|
||||
SLE_VAR(Train, crash_anim_pos, SLE_UINT16),
|
||||
SLE_VAR(Train, force_proceed, SLE_UINT8),
|
||||
SLE_VAR(Train, railtype, SLE_UINT8),
|
||||
@ -543,7 +543,7 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
|
||||
|
||||
static const SaveLoad _roadveh_desc[] = {
|
||||
SLE_WRITEBYTE(Vehicle, type, VEH_ROAD),
|
||||
SLE_VEH_INCLUDEX(),
|
||||
SLE_VEH_INCLUDE(),
|
||||
SLE_VAR(RoadVehicle, state, SLE_UINT8),
|
||||
SLE_VAR(RoadVehicle, frame, SLE_UINT8),
|
||||
SLE_VAR(RoadVehicle, blocked_ctr, SLE_UINT16),
|
||||
@ -563,7 +563,7 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
|
||||
|
||||
static const SaveLoad _ship_desc[] = {
|
||||
SLE_WRITEBYTE(Vehicle, type, VEH_SHIP),
|
||||
SLE_VEH_INCLUDEX(),
|
||||
SLE_VEH_INCLUDE(),
|
||||
SLE_VAR(Ship, state, SLE_UINT8),
|
||||
|
||||
/* reserve extra space in savegame here. (currently 16 bytes) */
|
||||
@ -574,7 +574,7 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
|
||||
|
||||
static const SaveLoad _aircraft_desc[] = {
|
||||
SLE_WRITEBYTE(Vehicle, type, VEH_AIRCRAFT),
|
||||
SLE_VEH_INCLUDEX(),
|
||||
SLE_VEH_INCLUDE(),
|
||||
SLE_VAR(Aircraft, crashed_counter, SLE_UINT16),
|
||||
SLE_VAR(Aircraft, pos, SLE_UINT8),
|
||||
|
||||
@ -642,8 +642,8 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
|
||||
SLE_CONDNULL(5, 0, 57),
|
||||
SLE_VAR(Vehicle, owner, SLE_UINT8),
|
||||
SLE_VAR(Vehicle, vehstatus, SLE_UINT8),
|
||||
SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, dest), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
|
||||
SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, dest), SLE_UINT16, 5, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Vehicle, current_order.dest, SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
|
||||
SLE_CONDVAR(Vehicle, current_order.dest, 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),
|
||||
|
Loading…
Reference in New Issue
Block a user