summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-03-16 00:20:33 +0000
committerDarkvater <darkvater@openttd.org>2006-03-16 00:20:33 +0000
commitd9ee10d3b835e713a117df6f8ffae20e3bf3b27e (patch)
treeac6cdd2863b4bb080d7d84f5549642dad620393f
parent61bb1d5b9af4e8a5d49fc8b70b2749e35f4861d1 (diff)
downloadopenttd-d9ee10d3b835e713a117df6f8ffae20e3bf3b27e.tar.xz
(svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
- Also add this capability to settings
-rw-r--r--engine.c2
-rw-r--r--industry_cmd.c2
-rw-r--r--order_cmd.c2
-rw-r--r--players.c7
-rw-r--r--saveload.h8
-rw-r--r--settings.c8
-rw-r--r--station_cmd.c8
-rw-r--r--town_cmd.c4
-rw-r--r--vehicle.c16
9 files changed, 34 insertions, 23 deletions
diff --git a/engine.c b/engine.c
index 00b29b45a..17a7f1088 100644
--- a/engine.c
+++ b/engine.c
@@ -681,7 +681,7 @@ static const SaveLoad _engine_desc[] = {
SLE_VAR(Engine,player_avail, SLE_UINT8),
// reserve extra space in savegame here. (currently 16 bytes)
- SLE_CONDARR(NullStruct,null,SLE_FILE_U64 | SLE_VAR_NULL, 2, 2, SL_MAX_VERSION),
+ SLE_CONDNULL(16, 2, SL_MAX_VERSION),
SLE_END()
};
diff --git a/industry_cmd.c b/industry_cmd.c
index daa23e65c..4026f7c4d 100644
--- a/industry_cmd.c
+++ b/industry_cmd.c
@@ -1935,7 +1935,7 @@ static const SaveLoad _industry_desc[] = {
SLE_VAR(Industry,was_cargo_delivered,SLE_UINT8),
// reserve extra space in savegame here. (currently 32 bytes)
- SLE_CONDARR(NullStruct,null,SLE_FILE_U64 | SLE_VAR_NULL, 4, 2, SL_MAX_VERSION),
+ SLE_CONDNULL(32, 2, SL_MAX_VERSION),
SLE_END()
};
diff --git a/order_cmd.c b/order_cmd.c
index 38a2b8d80..620639342 100644
--- a/order_cmd.c
+++ b/order_cmd.c
@@ -1100,7 +1100,7 @@ static const SaveLoad _order_desc[] = {
SLE_REF(Order,next, REF_ORDER),
// reserve extra space in savegame here. (currently 10 bytes)
- SLE_CONDARR(NullStruct,null,SLE_FILE_U8 | SLE_VAR_NULL, 10, 5, SL_MAX_VERSION),
+ SLE_CONDNULL(10, 5, SL_MAX_VERSION),
SLE_END()
};
diff --git a/players.c b/players.c
index b08ac3e4f..2a39ed685 100644
--- a/players.c
+++ b/players.c
@@ -1150,7 +1150,7 @@ static const SaveLoad _player_desc[] = {
SLE_CONDVAR(Player,is_active, SLE_UINT8, 4, SL_MAX_VERSION),
// Engine renewal settings
- SLE_CONDARR(NullStruct,null,SLE_FILE_U16 | SLE_VAR_NULL, 256, 16, 18),
+ SLE_CONDNULL(512, 16, 18),
SLE_CONDREF(Player,engine_renew_list, REF_ENGINE_RENEWS, 19, SL_MAX_VERSION),
SLE_CONDVAR(Player,engine_renew, SLE_UINT8, 16, SL_MAX_VERSION),
SLE_CONDVAR(Player,engine_renew_months, SLE_INT16, 16, SL_MAX_VERSION),
@@ -1158,8 +1158,7 @@ static const SaveLoad _player_desc[] = {
SLE_CONDVAR(Player,renew_keep_length, SLE_UINT8, 2, SL_MAX_VERSION), // added with 16.1, but was blank since 2
// reserve extra space in savegame here. (currently 63 bytes)
- SLE_CONDARR(NullStruct,null,SLE_FILE_U8 | SLE_VAR_NULL, 7, 2, SL_MAX_VERSION),
- SLE_CONDARR(NullStruct,null,SLE_FILE_U64 | SLE_VAR_NULL, 7, 2, SL_MAX_VERSION),
+ SLE_CONDNULL(63, 2, SL_MAX_VERSION),
SLE_END()
};
@@ -1219,7 +1218,7 @@ static const SaveLoad _player_ai_desc[] = {
SLE_ARR(PlayerAI,order_list_blocks, SLE_UINT8, 20),
SLE_ARR(PlayerAI,banned_tiles, SLE_UINT16, 16),
- SLE_CONDARR(NullStruct,null,SLE_FILE_U64 | SLE_VAR_NULL, 8, 2, SL_MAX_VERSION),
+ SLE_CONDNULL(64, 2, SL_MAX_VERSION),
SLE_END()
};
diff --git a/saveload.h b/saveload.h
index 077f3c84c..95a839fcc 100644
--- a/saveload.h
+++ b/saveload.h
@@ -179,6 +179,8 @@ typedef SaveLoad SaveLoadGlobVarList;
#define SLE_ARR(base, variable, type, length) SLE_CONDARR(base, variable, type, length, 0, SL_MAX_VERSION)
#define SLE_STR(base, variable, type, length) SLE_CONDSTR(base, variable, type, length, 0, SL_MAX_VERSION)
+#define SLE_CONDNULL(length, from, to) SLE_CONDARR(NullStruct, null, SLE_FILE_U8 | SLE_VAR_NULL, 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 */
@@ -208,8 +210,10 @@ typedef SaveLoad SaveLoadGlobVarList;
#define SLEG_VAR(variable, type) SLEG_CONDVAR(variable, type, 0, SL_MAX_VERSION)
#define SLEG_REF(variable, type) SLEG_CONDREF(variable, type, 0, SL_MAX_VERSION)
-#define SLEG_ARR(variable, type) SLEG_CONDARR(variable, type, lengthof(variable), SL_MAX_VERSION)
-#define SLEG_STR(variable, type) SLEG_CONDSTR(variable, type, lengthof(variable), SL_MAX_VERSION)
+#define SLEG_ARR(variable, type) SLEG_CONDARR(variable, type, lengthof(variable), 0, SL_MAX_VERSION)
+#define SLEG_STR(variable, type) SLEG_CONDSTR(variable, type, lengthof(variable), 0, SL_MAX_VERSION)
+
+#define SLEG_CONDNULL(length, from, to) {SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL, length, from, to, (void*)NULL}
#define SLEG_END() {SL_END, 0, 0, 0, 0, NULL}
diff --git a/settings.c b/settings.c
index e6271b960..879c9ec7c 100644
--- a/settings.c
+++ b/settings.c
@@ -615,6 +615,7 @@ static void ini_load_settings(IniFile *ini, const SettingDesc *sd, const char *g
const SaveLoad *sld = &sd->save;
if (!SlIsObjectCurrentlyValid(sld->version_from, sld->version_to)) continue;
+ if (sd->desc.name == NULL) continue;
// XXX - wtf is this?? (group override?)
s = strchr(sdb->name, '.');
@@ -682,6 +683,7 @@ static void ini_save_settings(IniFile *ini, const SettingDesc *sd, const char *g
* file, just continue with the next setting */
if (!SlIsObjectCurrentlyValid(sld->version_from, sld->version_to)) continue;
if (sld->conv & SLF_CONFIG_NO) continue;
+ if (sd->desc.name == NULL) continue;
// XXX - wtf is this?? (group override?)
s = strchr(sdb->name, '.');
@@ -879,6 +881,9 @@ static void ini_save_setting_list(IniFile *ini, const char *grpname, char **list
#define SDTG_MMANY(name, type, flags, guiflags, var, def, full, str, proc)\
SDTG_CONDMMANY(name, type, flags, guiflags, var, def, full, str, proc, 0, SL_MAX_VERSION)
+#define SDTG_CONDNULL(length, from, to)\
+ {{NULL, NULL, 0, 0, 0, 0, NULL, STR_NULL, NULL}, SLEG_CONDNULL(length, from, to)}
+
#define SDTG_END() {{NULL, NULL, 0, 0, 0, 0, NULL, STR_NULL, NULL}, SLEG_END()}
/* Macros for various objects to go in the configuration file.
@@ -925,6 +930,9 @@ static void ini_save_setting_list(IniFile *ini, const char *grpname, char **list
#define SDT_MMANY(base, var, type, flags, guiflags, def, full, str, proc)\
SDT_CONDMMANY(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, full, str, proc)
+#define SDT_CONDNULL(length, from, to)\
+ {{NULL, NULL, 0, 0, 0, 0, NULL, STR_NULL, NULL}, SLE_CONDNULL(length, from, to)}
+
#define SDT_END() {{NULL, NULL, 0, 0, 0, 0, NULL, STR_NULL, NULL}, SLE_END()}
/* Shortcuts for macros below. Logically if we don't save the value
diff --git a/station_cmd.c b/station_cmd.c
index 23b63091b..edb05f6d3 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -2816,7 +2816,7 @@ static const SaveLoad _roadstop_desc[] = {
SLE_VAR(RoadStop,used, SLE_UINT8),
SLE_VAR(RoadStop,status, SLE_UINT8),
/* Index was saved in some versions, but this is not needed */
- SLE_CONDARR(NullStruct,null,SLE_FILE_U32 | SLE_VAR_NULL, 1, 0, 8),
+ SLE_CONDNULL(4, 0, 8),
SLE_VAR(RoadStop,station, SLE_UINT16),
SLE_VAR(RoadStop,type, SLE_UINT8),
@@ -2844,7 +2844,7 @@ static const SaveLoad _station_desc[] = {
SLE_CONDVAR(Station,trainst_h, SLE_UINT8, 2, SL_MAX_VERSION),
// alpha_order was stored here in savegame format 0 - 3
- SLE_CONDARR(NullStruct,null,SLE_FILE_U8 | SLE_VAR_NULL, 1, 0, 3),
+ SLE_CONDNULL(1, 0, 3),
SLE_VAR(Station,string_id, SLE_STRINGID),
SLE_VAR(Station,had_vehicle_of_type,SLE_UINT16),
@@ -2875,8 +2875,8 @@ static const SaveLoad _station_desc[] = {
SLE_CONDREF(Station,bus_stops, REF_ROADSTOPS, 6, SL_MAX_VERSION),
SLE_CONDREF(Station,truck_stops, REF_ROADSTOPS, 6, SL_MAX_VERSION),
- // reserve extra space in savegame here. (currently 28 bytes)
- SLE_CONDARR(NullStruct,null,SLE_FILE_U8 | SLE_VAR_NULL, 32, 2, SL_MAX_VERSION),
+ // reserve extra space in savegame here. (currently 32 bytes)
+ SLE_CONDNULL(32, 2, SL_MAX_VERSION),
SLE_END()
};
diff --git a/town_cmd.c b/town_cmd.c
index ce4498f5f..73102547b 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -1979,7 +1979,7 @@ static const SaveLoad _town_desc[] = {
SLE_VAR(Town,statues, SLE_UINT8),
// sort_index_obsolete was stored here in savegame format 0 - 1
- SLE_CONDARR(NullStruct,null,SLE_FILE_U8 | SLE_VAR_NULL, 1, 0, 1),
+ SLE_CONDNULL(1, 0, 1),
SLE_VAR(Town,have_ratings,SLE_UINT8),
SLE_ARR(Town,ratings, SLE_INT16, 8),
@@ -2021,7 +2021,7 @@ static const SaveLoad _town_desc[] = {
SLE_VAR(Town,exclusivity, SLE_UINT8),
SLE_VAR(Town,exclusive_counter, SLE_UINT8),
// reserve extra space in savegame here. (currently 30 bytes)
- SLE_CONDARR(NullStruct,null,SLE_FILE_U8 | SLE_VAR_NULL, 30, 2, SL_MAX_VERSION),
+ SLE_CONDNULL(30, 2, SL_MAX_VERSION),
SLE_END()
};
diff --git a/vehicle.c b/vehicle.c
index d737350f2..2c7c7aae6 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -2158,7 +2158,7 @@ const SaveLoad _common_veh_desc[] = {
SLE_REF(Vehicle,prev_shared, REF_VEHICLE),
// reserve extra space in savegame here. (currently 10 bytes)
- SLE_CONDARR(NullStruct,null,SLE_FILE_U8 | SLE_VAR_NULL, 10, 2, SL_MAX_VERSION),
+ SLE_CONDNULL(10, 2, SL_MAX_VERSION),
SLE_END()
};
@@ -2175,9 +2175,9 @@ static const SaveLoad _train_desc[] = {
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_CONDARR(NullStruct, null, SLE_FILE_U8 | SLE_VAR_NULL, 2, 2, 19),
+ SLE_CONDNULL(2, 2, 19),
// reserve extra space in savegame here. (currently 11 bytes)
- SLE_CONDARR(NullStruct, null, SLE_FILE_U8 | SLE_VAR_NULL, 11, 2, SL_MAX_VERSION),
+ SLE_CONDNULL(11, 2, SL_MAX_VERSION),
SLE_END()
};
@@ -2197,7 +2197,7 @@ static const SaveLoad _roadveh_desc[] = {
SLE_CONDVARX(offsetof(Vehicle,u)+offsetof(VehicleRoad,slotindex), SLE_UINT8, 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_CONDARR(NullStruct,null,SLE_FILE_U64 | SLE_VAR_NULL, 2, 2, SL_MAX_VERSION),
+ SLE_CONDNULL(16, 2, SL_MAX_VERSION),
SLE_END()
};
@@ -2208,7 +2208,7 @@ static const SaveLoad _ship_desc[] = {
SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleShip,state), SLE_UINT8),
// reserve extra space in savegame here. (currently 16 bytes)
- SLE_CONDARR(NullStruct,null,SLE_FILE_U64 | SLE_VAR_NULL, 2, 2, SL_MAX_VERSION),
+ SLE_CONDNULL(16, 2, SL_MAX_VERSION),
SLE_END()
};
@@ -2227,7 +2227,7 @@ static const SaveLoad _aircraft_desc[] = {
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_CONDARR(NullStruct,null,SLE_FILE_U8 | SLE_VAR_NULL, 15, 2, SL_MAX_VERSION),
+ SLE_CONDNULL(15, 2, SL_MAX_VERSION),
SLE_END()
};
@@ -2259,7 +2259,7 @@ static const SaveLoad _special_desc[] = {
SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleSpecial,unk2), SLE_UINT8),
// reserve extra space in savegame here. (currently 16 bytes)
- SLE_CONDARR(NullStruct,null,SLE_FILE_U64 | SLE_VAR_NULL, 2, 2, SL_MAX_VERSION),
+ SLE_CONDNULL(16, 2, SL_MAX_VERSION),
SLE_END()
};
@@ -2301,7 +2301,7 @@ static const SaveLoad _disaster_desc[] = {
SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleDisaster,unk2), SLE_UINT16),
// reserve extra space in savegame here. (currently 16 bytes)
- SLE_CONDARR(NullStruct,null,SLE_FILE_U64 | SLE_VAR_NULL, 2, 2, SL_MAX_VERSION),
+ SLE_CONDNULL(16, 2, SL_MAX_VERSION),
SLE_END()
};