|
|
@ -23,6 +23,8 @@
|
|
|
|
#include "../safeguards.h"
|
|
|
|
#include "../safeguards.h"
|
|
|
|
|
|
|
|
|
|
|
|
static byte _old_last_vehicle_type;
|
|
|
|
static byte _old_last_vehicle_type;
|
|
|
|
|
|
|
|
static uint8 _num_specs;
|
|
|
|
|
|
|
|
static uint8 _num_roadstop_specs;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Update the buoy orders to be waypoint orders.
|
|
|
|
* Update the buoy orders to be waypoint orders.
|
|
|
@ -111,12 +113,12 @@ void AfterLoadStations()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Update the speclists of all stations to point to the currently loaded custom stations. */
|
|
|
|
/* Update the speclists of all stations to point to the currently loaded custom stations. */
|
|
|
|
for (BaseStation *st : BaseStation::Iterate()) {
|
|
|
|
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;
|
|
|
|
if (st->speclist[i].grfid == 0) continue;
|
|
|
|
|
|
|
|
|
|
|
|
st->speclist[i].spec = StationClass::GetByGrf(st->speclist[i].grfid, st->speclist[i].localidx, nullptr);
|
|
|
|
st->speclist[i].spec = StationClass::GetByGrf(st->speclist[i].grfid, st->speclist[i].localidx, nullptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (uint i = 0; i < st->num_roadstop_specs; i++) {
|
|
|
|
for (uint i = 0; i < st->roadstop_speclist.size(); i++) {
|
|
|
|
if (st->roadstop_speclist[i].grfid == 0) continue;
|
|
|
|
if (st->roadstop_speclist[i].grfid == 0) continue;
|
|
|
|
|
|
|
|
|
|
|
|
st->roadstop_speclist[i].spec = RoadStopClass::GetByGrf(st->roadstop_speclist[i].grfid, st->roadstop_speclist[i].localidx, nullptr);
|
|
|
|
st->roadstop_speclist[i].spec = RoadStopClass::GetByGrf(st->roadstop_speclist[i].grfid, st->roadstop_speclist[i].localidx, nullptr);
|
|
|
@ -218,7 +220,7 @@ static const SaveLoad _old_station_desc[] = {
|
|
|
|
/* Used by newstations for graphic variations */
|
|
|
|
/* Used by newstations for graphic variations */
|
|
|
|
SLE_CONDVAR(Station, random_bits, SLE_UINT16, SLV_27, SL_MAX_VERSION),
|
|
|
|
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, 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, SLE_UINT8, SLV_27, SL_MAX_VERSION),
|
|
|
|
|
|
|
|
|
|
|
|
SLE_CONDVEC(Station, loading_vehicles, REF_VEHICLE, SLV_57, SL_MAX_VERSION),
|
|
|
|
SLE_CONDVEC(Station, loading_vehicles, REF_VEHICLE, SLV_57, SL_MAX_VERSION),
|
|
|
|
|
|
|
|
|
|
|
@ -329,6 +331,7 @@ static void Load_STNS()
|
|
|
|
_cargo_source_xy = 0;
|
|
|
|
_cargo_source_xy = 0;
|
|
|
|
_cargo_days = 0;
|
|
|
|
_cargo_days = 0;
|
|
|
|
_cargo_feeder_share = 0;
|
|
|
|
_cargo_feeder_share = 0;
|
|
|
|
|
|
|
|
_num_specs = 0;
|
|
|
|
|
|
|
|
|
|
|
|
uint num_cargo = IsSavegameVersionBefore(SLV_55) ? 12 : IsSavegameVersionBefore(SLV_EXTEND_CARGOTYPES) ? 32 : NUM_CARGO;
|
|
|
|
uint num_cargo = IsSavegameVersionBefore(SLV_55) ? 12 : IsSavegameVersionBefore(SLV_EXTEND_CARGOTYPES) ? 32 : NUM_CARGO;
|
|
|
|
int index;
|
|
|
|
int index;
|
|
|
@ -364,10 +367,10 @@ static void Load_STNS()
|
|
|
|
if (SlXvIsFeatureMissing(XSLFI_ST_LAST_VEH_TYPE)) ge->last_vehicle_type = _old_last_vehicle_type;
|
|
|
|
if (SlXvIsFeatureMissing(XSLFI_ST_LAST_VEH_TYPE)) ge->last_vehicle_type = _old_last_vehicle_type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (st->num_specs != 0) {
|
|
|
|
if (_num_specs != 0) {
|
|
|
|
/* Allocate speclist memory when loading a game */
|
|
|
|
/* Allocate speclist memory when loading a game */
|
|
|
|
st->speclist = CallocT<StationSpecList>(st->num_specs);
|
|
|
|
st->speclist.resize(_num_specs);
|
|
|
|
for (uint i = 0; i < st->num_specs; i++) {
|
|
|
|
for (uint i = 0; i < st->speclist.size(); i++) {
|
|
|
|
SlObject(&st->speclist[i], _station_speclist_desc);
|
|
|
|
SlObject(&st->speclist[i], _station_speclist_desc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -409,8 +412,8 @@ static const SaveLoad _base_station_desc[] = {
|
|
|
|
/* Used by newstations for graphic variations */
|
|
|
|
/* Used by newstations for graphic variations */
|
|
|
|
SLE_VAR(BaseStation, random_bits, SLE_UINT16),
|
|
|
|
SLE_VAR(BaseStation, random_bits, SLE_UINT16),
|
|
|
|
SLE_VAR(BaseStation, waiting_triggers, SLE_UINT8),
|
|
|
|
SLE_VAR(BaseStation, waiting_triggers, SLE_UINT8),
|
|
|
|
SLE_VAR(BaseStation, num_specs, SLE_UINT8),
|
|
|
|
SLEG_VAR(_num_specs, SLE_UINT8),
|
|
|
|
SLE_CONDVAR_X(BaseStation, num_roadstop_specs, SLE_UINT8, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_GRF_ROADSTOPS)),
|
|
|
|
SLEG_CONDVAR_X(_num_roadstop_specs, SLE_UINT8, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_GRF_ROADSTOPS)),
|
|
|
|
SLE_CONDVARVEC_X(BaseStation, custom_road_stop_tiles, SLE_UINT32, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_GRF_ROADSTOPS)),
|
|
|
|
SLE_CONDVARVEC_X(BaseStation, custom_road_stop_tiles, SLE_UINT32, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_GRF_ROADSTOPS)),
|
|
|
|
SLE_CONDVARVEC_X(BaseStation, custom_road_stop_data, SLE_UINT16, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_GRF_ROADSTOPS)),
|
|
|
|
SLE_CONDVARVEC_X(BaseStation, custom_road_stop_data, SLE_UINT16, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_GRF_ROADSTOPS)),
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -510,6 +513,9 @@ static void SetupDescs_ROADSTOP()
|
|
|
|
|
|
|
|
|
|
|
|
static void RealSave_STNN(BaseStation *bst)
|
|
|
|
static void RealSave_STNN(BaseStation *bst)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
_num_specs = (uint8)bst->speclist.size();
|
|
|
|
|
|
|
|
_num_roadstop_specs = (uint8)bst->roadstop_speclist.size();
|
|
|
|
|
|
|
|
|
|
|
|
bool waypoint = (bst->facilities & FACIL_WAYPOINT) != 0;
|
|
|
|
bool waypoint = (bst->facilities & FACIL_WAYPOINT) != 0;
|
|
|
|
SlObjectSaveFiltered(bst, waypoint ? SaveLoadTable(_filtered_waypoint_desc) : SaveLoadTable(_filtered_station_desc));
|
|
|
|
SlObjectSaveFiltered(bst, waypoint ? SaveLoadTable(_filtered_waypoint_desc) : SaveLoadTable(_filtered_station_desc));
|
|
|
|
|
|
|
|
|
|
|
@ -562,11 +568,11 @@ static void RealSave_STNN(BaseStation *bst)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (uint i = 0; i < bst->num_specs; i++) {
|
|
|
|
for (uint i = 0; i < bst->speclist.size(); i++) {
|
|
|
|
SlObjectSaveFiltered(&bst->speclist[i], _filtered_station_speclist_desc);
|
|
|
|
SlObjectSaveFiltered(&bst->speclist[i], _filtered_station_speclist_desc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (uint i = 0; i < bst->num_roadstop_specs; i++) {
|
|
|
|
for (uint i = 0; i < bst->roadstop_speclist.size(); i++) {
|
|
|
|
SlObjectSaveFiltered(&bst->roadstop_speclist[i], _filtered_station_speclist_desc);
|
|
|
|
SlObjectSaveFiltered(&bst->roadstop_speclist[i], _filtered_station_speclist_desc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -587,6 +593,8 @@ static void Load_STNN()
|
|
|
|
SetupDescs_STNN();
|
|
|
|
SetupDescs_STNN();
|
|
|
|
|
|
|
|
|
|
|
|
_num_flows = 0;
|
|
|
|
_num_flows = 0;
|
|
|
|
|
|
|
|
_num_specs = 0;
|
|
|
|
|
|
|
|
_num_roadstop_specs = 0;
|
|
|
|
|
|
|
|
|
|
|
|
const uint num_cargo = IsSavegameVersionBefore(SLV_EXTEND_CARGOTYPES) ? 32 : NUM_CARGO;
|
|
|
|
const uint num_cargo = IsSavegameVersionBefore(SLV_EXTEND_CARGOTYPES) ? 32 : NUM_CARGO;
|
|
|
|
ReadBuffer *buffer = ReadBuffer::GetCurrent();
|
|
|
|
ReadBuffer *buffer = ReadBuffer::GetCurrent();
|
|
|
@ -691,18 +699,18 @@ static void Load_STNN()
|
|
|
|
st->station_cargo_history_offset = 0;
|
|
|
|
st->station_cargo_history_offset = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (bst->num_specs != 0) {
|
|
|
|
if (_num_specs != 0) {
|
|
|
|
/* Allocate speclist memory when loading a game */
|
|
|
|
/* Allocate speclist memory when loading a game */
|
|
|
|
bst->speclist = CallocT<StationSpecList>(bst->num_specs);
|
|
|
|
bst->speclist.resize(_num_specs);
|
|
|
|
for (uint i = 0; i < bst->num_specs; i++) {
|
|
|
|
for (uint i = 0; i < bst->speclist.size(); i++) {
|
|
|
|
SlObjectLoadFiltered(&bst->speclist[i], _filtered_station_speclist_desc);
|
|
|
|
SlObjectLoadFiltered(&bst->speclist[i], _filtered_station_speclist_desc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (bst->num_roadstop_specs != 0) {
|
|
|
|
if (_num_roadstop_specs != 0) {
|
|
|
|
/* Allocate speclist memory when loading a game */
|
|
|
|
/* Allocate speclist memory when loading a game */
|
|
|
|
bst->roadstop_speclist = CallocT<RoadStopSpecList>(bst->num_roadstop_specs);
|
|
|
|
bst->roadstop_speclist.resize(_num_roadstop_specs);
|
|
|
|
for (uint i = 0; i < bst->num_roadstop_specs; i++) {
|
|
|
|
for (uint i = 0; i < bst->roadstop_speclist.size(); i++) {
|
|
|
|
SlObjectLoadFiltered(&bst->roadstop_speclist[i], _filtered_station_speclist_desc);
|
|
|
|
SlObjectLoadFiltered(&bst->roadstop_speclist[i], _filtered_station_speclist_desc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|