summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/saveload.cpp14
-rw-r--r--src/saveload.h4
-rw-r--r--src/vehicle.cpp12
3 files changed, 3 insertions, 27 deletions
diff --git a/src/saveload.cpp b/src/saveload.cpp
index 420e5e98a..26dc7df51 100644
--- a/src/saveload.cpp
+++ b/src/saveload.cpp
@@ -744,7 +744,6 @@ size_t SlCalcObjMemberLength(const void *object, const SaveLoad *sld)
default: NOT_REACHED();
}
break;
- case SL_WRITEBYTE: return 1; // a byte is logically of size 1
case SL_INCLUDE: return SlCalcObjLength(object, _sl.includes[sld->version_from]);
default: NOT_REACHED();
}
@@ -782,19 +781,6 @@ bool SlObjectMember(void *ptr, const SaveLoad *sld)
}
break;
- /* SL_WRITEBYTE translates a value of a variable to another one upon
- * saving or loading.
- * XXX - variable renaming abuse
- * game_value: the value of the variable ingame is abused by sld->version_from
- * file_value: the value of the variable in the savegame is abused by sld->version_to */
- case SL_WRITEBYTE:
- if (_sl.save) {
- SlWriteByte(sld->version_to);
- } else {
- *(byte*)ptr = sld->version_from;
- }
- break;
-
/* SL_INCLUDE loads common code for a type
* XXX - variable renaming abuse
* include_index: common code to include from _desc_includes[], abused by sld->version_from */
diff --git a/src/saveload.h b/src/saveload.h
index 7589db5f2..24dc9f231 100644
--- a/src/saveload.h
+++ b/src/saveload.h
@@ -161,7 +161,6 @@ enum SaveLoadTypes {
SL_STR = 3,
SL_LST = 4,
// non-normal save-load types
- SL_WRITEBYTE = 8,
SL_INCLUDE = 9,
SL_END = 15
};
@@ -201,8 +200,6 @@ typedef SaveLoad SaveLoadGlobVarList;
#define SLE_CONDNULL(length, from, to) SLE_CONDARR(NullStruct, null, SLE_FILE_U8 | SLE_VAR_NULL | SLF_CONFIG_NO, length, from, to)
-/* Translate values ingame to different values in the savegame and vv */
-#define SLE_WRITEBYTE(base, variable, game_value, file_value) SLE_GENERAL(SL_WRITEBYTE, base, variable, 0, 0, game_value, file_value)
/* Load common code and put it into each struct (currently only for vehicles */
#define SLE_INCLUDE(base, variable, include_index) SLE_GENERAL(SL_INCLUDE, base, variable, 0, 0, include_index, 0)
@@ -214,7 +211,6 @@ typedef SaveLoad SaveLoadGlobVarList;
#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, something, 0)
#define SLE_INCLUDEX(offset, type) SLE_GENERALX(SL_INCLUDE, offset, type, 0, SL_MAX_VERSION)
/* End marker */
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index daae5c0c9..66d0ac6a0 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -2714,7 +2714,6 @@ extern const SaveLoad _common_veh_desc[] = {
static const SaveLoad _train_desc[] = {
- SLE_WRITEBYTE(Vehicle, type, VEH_TRAIN, 0), // Train type. VEH_TRAIN in mem, 0 in file.
SLE_INCLUDEX(0, INC_VEHICLE_COMMON),
SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRail, crash_anim_pos), SLE_UINT16),
SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRail, force_proceed), SLE_UINT8),
@@ -2732,7 +2731,6 @@ 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_INCLUDEX(0, INC_VEHICLE_COMMON),
SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRoad, state), SLE_UINT8),
SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRoad, frame), SLE_UINT8),
@@ -2752,7 +2750,6 @@ static const SaveLoad _roadveh_desc[] = {
};
static const SaveLoad _ship_desc[] = {
- SLE_WRITEBYTE(Vehicle, type, VEH_SHIP, 2), // Ship type. VEH_SHIP in mem, 2 in file.
SLE_INCLUDEX(0, INC_VEHICLE_COMMON),
SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleShip, state), SLE_UINT8),
@@ -2763,7 +2760,6 @@ 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_INCLUDEX(0, INC_VEHICLE_COMMON),
SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleAir, crashed_counter), SLE_UINT16),
SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleAir, pos), SLE_UINT8),
@@ -2782,8 +2778,6 @@ 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),
@@ -2810,8 +2804,6 @@ 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),
@@ -2864,6 +2856,7 @@ static void Save_VEHS()
/* Write the vehicles */
FOR_ALL_VEHICLES(v) {
SlSetArrayIndex(v->index);
+ SlWriteByte(v->type);
SlObject(v, (SaveLoad*)_veh_descs[v->type]);
}
}
@@ -2881,7 +2874,8 @@ static void Load_VEHS()
error("Vehicles: failed loading savegame: too many vehicles");
v = GetVehicle(index);
- SlObject(v, (SaveLoad*)_veh_descs[SlReadByte()]);
+ v->type = (VehicleType)SlReadByte();
+ SlObject(v, (SaveLoad*)_veh_descs[v->type]);
switch (v->type) {
case VEH_TRAIN: v = new (v) Train(); break;