Merge branch 'cargo_type_order' into jgrpp

# Conflicts:
#	src/pathfinder/yapf/yapf_common.hpp
#	src/saveload/extended_ver_sl.cpp
#	src/saveload/order_sl.cpp
#	src/saveload/station_sl.cpp
#	src/track_func.h
This commit is contained in:
Jonathan G Rennison
2018-07-02 21:04:06 +01:00
45 changed files with 183 additions and 145 deletions

View File

@@ -355,7 +355,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()
@@ -511,7 +512,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

@@ -72,7 +72,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_LINKGRAPH_DAY_SCALE, XSCF_NULL, 1, 1, "linkgraph_day_scale", NULL, NULL, NULL },
{ XSLFI_TEMPLATE_REPLACEMENT, XSCF_NULL, 4, 4, "template_replacement", NULL, NULL, "TRPL,TMPL" },
{ XSLFI_MORE_RAIL_TYPES, XSCF_NULL, 1, 1, "more_rail_types", NULL, NULL, NULL },
{ XSLFI_CARGO_TYPE_ORDERS, XSCF_NULL, 2, 2, "cargo_type_orders", NULL, NULL, "ORDX,VEOX" },
{ XSLFI_CARGO_TYPE_ORDERS, XSCF_NULL, 3, 3, "cargo_type_orders", NULL, NULL, "ORDX,VEOX" },
{ XSLFI_EXTENDED_GAMELOG, XSCF_NULL, 1, 1, "extended_gamelog", NULL, NULL, NULL },
{ XSLFI_STATION_CATCHMENT_INC, XSCF_NULL, 1, 1, "station_catchment_inc", NULL, NULL, NULL },
{ XSLFI_CUSTOM_BRIDGE_HEADS, XSCF_NULL, 1, 1, "custom_bridge_heads", NULL, NULL, NULL },

View File

@@ -202,9 +202,10 @@ static void Load_ORDR()
const SaveLoad *GetOrderExtraInfoDescription()
{
static const SaveLoad _order_extra_info_desc[] = {
SLE_ARR(OrderExtraInfo, cargo_type_flags, SLE_UINT8, NUM_CARGO),
SLE_CONDVAR_X(OrderExtraInfo, xflags, SLE_UINT8, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_TIMETABLE_EXTRA)),
SLE_CONDVAR_X(OrderExtraInfo, xdata, SLE_UINT32, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_ORDER_EXTRA_DATA)),
SLE_CONDARR_X(OrderExtraInfo, cargo_type_flags, SLE_UINT8, 32, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_CARGO_TYPE_ORDERS, 1, 2)),
SLE_CONDARR_X(OrderExtraInfo, cargo_type_flags, SLE_UINT8, NUM_CARGO, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_CARGO_TYPE_ORDERS, 3)),
SLE_CONDVAR_X(OrderExtraInfo, xflags, SLE_UINT8, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_TIMETABLE_EXTRA)),
SLE_CONDVAR_X(OrderExtraInfo, xdata, SLE_UINT32, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_ORDER_EXTRA_DATA)),
SLE_END()
};

View File

@@ -275,8 +275,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

@@ -573,7 +573,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

@@ -351,6 +351,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();
@@ -359,7 +360,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());
@@ -400,10 +400,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());
@@ -467,7 +468,8 @@ static const SaveLoad _station_desc[] = {
SLEG_CONDVAR_X(_old_last_vehicle_type, SLE_UINT8, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_ST_LAST_VEH_TYPE, 0, 0)),
SLE_VAR(Station, had_vehicle_of_type, SLE_UINT8),
SLE_VEC(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()
};
@@ -555,6 +557,7 @@ static void Load_STNN()
{
_num_flows = 0;
const uint num_cargo = IsSavegameVersionBefore(199) ? 32 : NUM_CARGO;
ReadBuffer *buffer = ReadBuffer::GetCurrent();
int index;
@@ -575,7 +578,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;
@@ -624,9 +627,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

@@ -193,7 +193,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),
@@ -288,12 +289,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);
}
if (SlXvIsFeaturePresent(XSLFI_SPRINGPP)) {