Merge branch 'master' into save_ext

# Conflicts:
#	src/saveload/saveload.cpp
#	src/table/settings.h.preamble
This commit is contained in:
Jonathan G Rennison
2018-07-02 18:41:39 +01:00
171 changed files with 3349 additions and 1011 deletions

View File

@@ -351,7 +351,8 @@ static const SaveLoad _company_economy_desc[] = {
SLE_CONDVAR(CompanyEconomyEntry, company_value, SLE_INT64, 2, SL_MAX_VERSION),
SLE_CONDVAR(CompanyEconomyEntry, delivered_cargo[NUM_CARGO - 1], SLE_INT32, 0, 169),
SLE_CONDARR(CompanyEconomyEntry, delivered_cargo, SLE_UINT32, NUM_CARGO, 170, SL_MAX_VERSION),
SLE_CONDARR(CompanyEconomyEntry, delivered_cargo, SLE_UINT32, 32, 170, 198),
SLE_CONDARR(CompanyEconomyEntry, delivered_cargo, SLE_UINT32, NUM_CARGO, 199, SL_MAX_VERSION),
SLE_VAR(CompanyEconomyEntry, performance_history, SLE_INT32),
SLE_END()
@@ -499,7 +500,6 @@ static void Check_PLYR()
int index;
while ((index = SlIterateArray()) != -1) {
CompanyProperties *cprops = new CompanyProperties();
memset(cprops, 0, sizeof(*cprops));
SaveLoad_PLYR_common(NULL, cprops);
/* We do not load old custom names */

View File

@@ -29,7 +29,7 @@ static void Load_PRIC()
/** Cargo payment rates in pre 126 savegames */
static void Load_CAPR()
{
uint num_cargo = IsSavegameVersionBefore(55) ? 12 : NUM_CARGO;
uint num_cargo = IsSavegameVersionBefore(55) ? 12 : IsSavegameVersionBefore(199) ? 32 : NUM_CARGO;
int vt = IsSavegameVersionBefore(65) ? SLE_FILE_I32 : SLE_FILE_I64;
SlArray(NULL, num_cargo, vt | SLE_VAR_NULL);
SlArray(NULL, num_cargo, SLE_FILE_U16 | SLE_VAR_NULL);

View File

@@ -272,8 +272,9 @@
* 196 27778 1.7.x
* 197 27978 1.8.x
* 198
* 199
*/
extern const uint16 SAVEGAME_VERSION = 198; ///< Current savegame version of OpenTTD.
extern const uint16 SAVEGAME_VERSION = 199; ///< Current savegame version of OpenTTD.
const uint16 SAVEGAME_VERSION_EXT = 0x8000; ///< Savegame extension indicator mask
SavegameType _savegame_type; ///< type of savegame we are loading

View File

@@ -571,7 +571,7 @@ typedef SaveLoad SaveLoadGlobVarList;
* @param variable Name of the global variable.
* @param type Storage of the data in memory and in the savegame.
*/
#define SLEG_STR(variable, type) SLEG_CONDSTR(variable, type, lengthof(variable), 0, SL_MAX_VERSION)
#define SLEG_STR(variable, type) SLEG_CONDSTR(variable, type, sizeof(variable), 0, SL_MAX_VERSION)
/**
* Storage of a global list in every savegame version.

View File

@@ -329,6 +329,7 @@ static void Load_STNS()
_cargo_days = 0;
_cargo_feeder_share = 0;
uint num_cargo = IsSavegameVersionBefore(55) ? 12 : IsSavegameVersionBefore(199) ? 32 : NUM_CARGO;
int index;
while ((index = SlIterateArray()) != -1) {
Station *st = new (index) Station();
@@ -337,7 +338,6 @@ static void Load_STNS()
_waiting_acceptance = 0;
uint num_cargo = IsSavegameVersionBefore(55) ? 12 : NUM_CARGO;
for (CargoID i = 0; i < num_cargo; i++) {
GoodsEntry *ge = &st->goods[i];
SlObject(ge, GetGoodsDesc());
@@ -377,10 +377,11 @@ static void Ptrs_STNS()
/* Don't run when savegame version is higher than or equal to 123. */
if (!IsSavegameVersionBefore(123)) return;
uint num_cargo = IsSavegameVersionBefore(199) ? 32 : NUM_CARGO;
Station *st;
FOR_ALL_STATIONS(st) {
if (!IsSavegameVersionBefore(68)) {
for (CargoID i = 0; i < NUM_CARGO; i++) {
for (CargoID i = 0; i < num_cargo; i++) {
GoodsEntry *ge = &st->goods[i];
SwapPackets(ge);
SlObject(ge, GetGoodsDesc());
@@ -440,7 +441,8 @@ static const SaveLoad _station_desc[] = {
SLE_VAR(Station, last_vehicle_type, SLE_UINT8),
SLE_VAR(Station, had_vehicle_of_type, SLE_UINT8),
SLE_LST(Station, loading_vehicles, REF_VEHICLE),
SLE_CONDVAR(Station, always_accepted, SLE_UINT32, 127, SL_MAX_VERSION),
SLE_CONDVAR(Station, always_accepted, SLE_FILE_U32 | SLE_VAR_U64, 127, 198),
SLE_CONDVAR(Station, always_accepted, SLE_UINT64, 199, SL_MAX_VERSION),
SLE_END()
};
@@ -520,6 +522,7 @@ static void Load_STNN()
{
_num_flows = 0;
uint num_cargo = IsSavegameVersionBefore(199) ? 32 : NUM_CARGO;
int index;
while ((index = SlIterateArray()) != -1) {
bool waypoint = (SlReadByte() & FACIL_WAYPOINT) != 0;
@@ -538,7 +541,7 @@ static void Load_STNN()
memcpy(st->airport.psa->storage, _old_st_persistent_storage.storage, sizeof(st->airport.psa->storage));
}
for (CargoID i = 0; i < NUM_CARGO; i++) {
for (CargoID i = 0; i < num_cargo; i++) {
SlObject(&st->goods[i], GetGoodsDesc());
FlowSaveLoad flow;
FlowStat *fs = NULL;
@@ -580,9 +583,10 @@ static void Ptrs_STNN()
/* Don't run when savegame version lower than 123. */
if (IsSavegameVersionBefore(123)) return;
uint num_cargo = IsSavegameVersionBefore(199) ? 32 : NUM_CARGO;
Station *st;
FOR_ALL_STATIONS(st) {
for (CargoID i = 0; i < NUM_CARGO; i++) {
for (CargoID i = 0; i < num_cargo; i++) {
GoodsEntry *ge = &st->goods[i];
if (IsSavegameVersionBefore(183)) {
SwapPackets(ge);

View File

@@ -192,7 +192,8 @@ static const SaveLoad _town_desc[] = {
SLE_CONDLST(Town, psa_list, REF_STORAGE, 161, SL_MAX_VERSION),
SLE_CONDVAR(Town, cargo_produced, SLE_UINT32, 166, SL_MAX_VERSION),
SLE_CONDVAR(Town, cargo_produced, SLE_FILE_U32 | SLE_VAR_U64, 166, 198),
SLE_CONDVAR(Town, cargo_produced, SLE_UINT64, 199, SL_MAX_VERSION),
/* reserve extra space in savegame here. (currently 30 bytes) */
SLE_CONDNULL(30, 2, SL_MAX_VERSION),
@@ -274,12 +275,13 @@ static void Save_TOWN()
static void Load_TOWN()
{
int index;
uint num_cargo = IsSavegameVersionBefore(199) ? 32 : NUM_CARGO;
while ((index = SlIterateArray()) != -1) {
Town *t = new (index) Town();
SlObject(t, _town_desc);
for (CargoID i = 0; i < NUM_CARGO; i++) {
for (CargoID i = 0; i < num_cargo; i++) {
SlObject(&t->supplied[i], _town_supplied_desc);
}
for (int i = TE_BEGIN; i < TE_END; i++) {