Add station cargo history save/load support
This commit is contained in:
@@ -151,6 +151,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
|||||||
{ XSLFI_WATER_FLOODING, XSCF_NULL, 2, 2, "water_flooding", nullptr, nullptr, nullptr },
|
{ XSLFI_WATER_FLOODING, XSCF_NULL, 2, 2, "water_flooding", nullptr, nullptr, nullptr },
|
||||||
{ XSLFI_MORE_HOUSES, XSCF_NULL, 2, 2, "more_houses", nullptr, nullptr, nullptr },
|
{ XSLFI_MORE_HOUSES, XSCF_NULL, 2, 2, "more_houses", nullptr, nullptr, nullptr },
|
||||||
{ XSLFI_CUSTOM_TOWN_ZONE, XSCF_IGNORABLE_UNKNOWN, 1, 1, "custom_town_zone", nullptr, nullptr, nullptr },
|
{ XSLFI_CUSTOM_TOWN_ZONE, XSCF_IGNORABLE_UNKNOWN, 1, 1, "custom_town_zone", nullptr, nullptr, nullptr },
|
||||||
|
{ XSLFI_STATION_CARGO_HISTORY, XSCF_NULL, 1, 1, "station_cargo_history", nullptr, nullptr, nullptr },
|
||||||
{ XSLFI_NULL, XSCF_NULL, 0, 0, nullptr, nullptr, nullptr, nullptr },// This is the end marker
|
{ XSLFI_NULL, XSCF_NULL, 0, 0, nullptr, nullptr, nullptr, nullptr },// This is the end marker
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ enum SlXvFeatureIndex {
|
|||||||
XSLFI_WATER_FLOODING, ///< Water flooding map bit
|
XSLFI_WATER_FLOODING, ///< Water flooding map bit
|
||||||
XSLFI_MORE_HOUSES, ///< More house types
|
XSLFI_MORE_HOUSES, ///< More house types
|
||||||
XSLFI_CUSTOM_TOWN_ZONE, ///< Custom town zones
|
XSLFI_CUSTOM_TOWN_ZONE, ///< Custom town zones
|
||||||
|
XSLFI_STATION_CARGO_HISTORY, ///< Station waiting cargo history
|
||||||
|
|
||||||
XSLFI_RIFF_HEADER_60_BIT, ///< Size field in RIFF chunk header is 60 bit
|
XSLFI_RIFF_HEADER_60_BIT, ///< Size field in RIFF chunk header is 60 bit
|
||||||
XSLFI_HEIGHT_8_BIT, ///< Map tile height is 8 bit instead of 4 bit, but savegame version may be before this became true in trunk
|
XSLFI_HEIGHT_8_BIT, ///< Map tile height is 8 bit instead of 4 bit, but savegame version may be before this became true in trunk
|
||||||
|
|||||||
@@ -459,6 +459,7 @@ static const SaveLoad _station_desc[] = {
|
|||||||
SLE_CONDVAR(Station, always_accepted, SLE_FILE_U32 | SLE_VAR_U64, SLV_127, SLV_EXTEND_CARGOTYPES),
|
SLE_CONDVAR(Station, always_accepted, SLE_FILE_U32 | SLE_VAR_U64, SLV_127, SLV_EXTEND_CARGOTYPES),
|
||||||
SLE_CONDVAR(Station, always_accepted, SLE_UINT64, SLV_EXTEND_CARGOTYPES, SL_MAX_VERSION),
|
SLE_CONDVAR(Station, always_accepted, SLE_UINT64, SLV_EXTEND_CARGOTYPES, SL_MAX_VERSION),
|
||||||
SLE_CONDNULL_X(32 * 24, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_JOKERPP, SL_JOKER_1_22)),
|
SLE_CONDNULL_X(32 * 24, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_JOKERPP, SL_JOKER_1_22)),
|
||||||
|
SLE_CONDVAR_X(Station, station_cargo_history_cargoes, SLE_UINT64, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_STATION_CARGO_HISTORY)),
|
||||||
|
|
||||||
SLE_END()
|
SLE_END()
|
||||||
};
|
};
|
||||||
@@ -547,6 +548,17 @@ static void RealSave_STNN(BaseStation *bst)
|
|||||||
SlObjectSaveFiltered(const_cast<StationCargoPacketMap::value_type *>(&(*it)), _cargo_list_desc); // _cargo_list_desc has no conditionals
|
SlObjectSaveFiltered(const_cast<StationCargoPacketMap::value_type *>(&(*it)), _cargo_list_desc); // _cargo_list_desc has no conditionals
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(st->station_cargo_history.size() == CountBits(st->station_cargo_history_cargoes));
|
||||||
|
dumper->CheckBytes(st->station_cargo_history.size() * MAX_STATION_CARGO_HISTORY_DAYS * 2);
|
||||||
|
for (const auto &history : st->station_cargo_history) {
|
||||||
|
uint i = st->station_cargo_history_offset;
|
||||||
|
do {
|
||||||
|
dumper->RawWriteUint16(history[i]);
|
||||||
|
i++;
|
||||||
|
if (i == MAX_STATION_CARGO_HISTORY_DAYS) i = 0;
|
||||||
|
} while (i != st->station_cargo_history_offset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint i = 0; i < bst->num_specs; i++) {
|
for (uint i = 0; i < bst->num_specs; i++) {
|
||||||
@@ -656,6 +668,15 @@ static void Load_STNN()
|
|||||||
}
|
}
|
||||||
if (SlXvIsFeatureMissing(XSLFI_ST_LAST_VEH_TYPE)) st->goods[i].last_vehicle_type = _old_last_vehicle_type;
|
if (SlXvIsFeatureMissing(XSLFI_ST_LAST_VEH_TYPE)) st->goods[i].last_vehicle_type = _old_last_vehicle_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
st->station_cargo_history.resize(CountBits(st->station_cargo_history_cargoes));
|
||||||
|
buffer->CheckBytes(st->station_cargo_history.size() * MAX_STATION_CARGO_HISTORY_DAYS * 2);
|
||||||
|
for (auto &history : st->station_cargo_history) {
|
||||||
|
for (uint16 &amount : history) {
|
||||||
|
amount = buffer->RawReadUint16();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
st->station_cargo_history_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bst->num_specs != 0) {
|
if (bst->num_specs != 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user