|
|
|
@ -109,7 +109,7 @@ void AfterLoadStations()
|
|
|
|
|
{
|
|
|
|
|
/* Update the speclists of all stations to point to the currently loaded custom stations. */
|
|
|
|
|
for (BaseStation *st : BaseStation::Iterate()) {
|
|
|
|
|
for (uint i = 0; i < st->num_specs; i++) {
|
|
|
|
|
for (uint i = 0; i < st->speclist.size(); i++) {
|
|
|
|
|
if (st->speclist[i].grfid == 0) continue;
|
|
|
|
|
|
|
|
|
|
st->speclist[i].spec = StationClass::GetByGrf(st->speclist[i].grfid, st->speclist[i].localidx, nullptr);
|
|
|
|
@ -201,30 +201,29 @@ public:
|
|
|
|
|
};
|
|
|
|
|
inline const static SaveLoadCompatTable compat_description = _station_spec_list_sl_compat;
|
|
|
|
|
|
|
|
|
|
static uint8 last_num_specs; ///< Number of specs of the last loaded station.
|
|
|
|
|
|
|
|
|
|
void Save(BaseStation *bst) const override
|
|
|
|
|
{
|
|
|
|
|
SlSetStructListLength(bst->num_specs);
|
|
|
|
|
for (uint i = 0; i < bst->num_specs; i++) {
|
|
|
|
|
SlSetStructListLength(bst->speclist.size());
|
|
|
|
|
for (uint i = 0; i < bst->speclist.size(); i++) {
|
|
|
|
|
SlObject(&bst->speclist[i], this->GetDescription());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Load(BaseStation *bst) const override
|
|
|
|
|
{
|
|
|
|
|
if (!IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH)) {
|
|
|
|
|
bst->num_specs = (uint8)SlGetStructListLength(UINT8_MAX);
|
|
|
|
|
}
|
|
|
|
|
uint8 num_specs = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? last_num_specs : (uint8)SlGetStructListLength(UINT8_MAX);
|
|
|
|
|
|
|
|
|
|
if (bst->num_specs != 0) {
|
|
|
|
|
/* Allocate speclist memory when loading a game */
|
|
|
|
|
bst->speclist = CallocT<StationSpecList>(bst->num_specs);
|
|
|
|
|
for (uint i = 0; i < bst->num_specs; i++) {
|
|
|
|
|
SlObject(&bst->speclist[i], this->GetLoadDescription());
|
|
|
|
|
}
|
|
|
|
|
bst->speclist.resize(num_specs);
|
|
|
|
|
for (uint i = 0; i < num_specs; i++) {
|
|
|
|
|
SlObject(&bst->speclist[i], this->GetLoadDescription());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
uint8 SlStationSpecList::last_num_specs;
|
|
|
|
|
|
|
|
|
|
class SlStationCargo : public DefaultSaveLoadHandler<SlStationCargo, GoodsEntry> {
|
|
|
|
|
public:
|
|
|
|
|
inline static const SaveLoad description[] = {
|
|
|
|
@ -476,7 +475,7 @@ static const SaveLoad _old_station_desc[] = {
|
|
|
|
|
/* Used by newstations for graphic variations */
|
|
|
|
|
SLE_CONDVAR(Station, random_bits, SLE_UINT16, SLV_27, SL_MAX_VERSION),
|
|
|
|
|
SLE_CONDVAR(Station, waiting_triggers, SLE_UINT8, SLV_27, SL_MAX_VERSION),
|
|
|
|
|
SLE_CONDVAR(Station, num_specs, SLE_UINT8, SLV_27, SL_MAX_VERSION),
|
|
|
|
|
SLEG_CONDVAR("num_specs", SlStationSpecList::last_num_specs, SLE_UINT8, SLV_27, SL_MAX_VERSION),
|
|
|
|
|
|
|
|
|
|
SLE_CONDREFLIST(Station, loading_vehicles, REF_VEHICLE, SLV_57, SL_MAX_VERSION),
|
|
|
|
|
|
|
|
|
@ -536,7 +535,7 @@ public:
|
|
|
|
|
/* Used by newstations for graphic variations */
|
|
|
|
|
SLE_VAR(BaseStation, random_bits, SLE_UINT16),
|
|
|
|
|
SLE_VAR(BaseStation, waiting_triggers, SLE_UINT8),
|
|
|
|
|
SLE_CONDVAR(BaseStation, num_specs, SLE_UINT8, SL_MIN_VERSION, SLV_SAVELOAD_LIST_LENGTH),
|
|
|
|
|
SLEG_CONDVAR("num_specs", SlStationSpecList::last_num_specs, SLE_UINT8, SL_MIN_VERSION, SLV_SAVELOAD_LIST_LENGTH),
|
|
|
|
|
};
|
|
|
|
|
inline const static SaveLoadCompatTable compat_description = _station_base_sl_compat;
|
|
|
|
|
|
|
|
|
|