Fix extended order info not being saved for vehicle current order.
This fixes desync and related issues when loading savegames where extended order info is used.
This commit is contained in:
@@ -45,6 +45,8 @@ private:
|
||||
friend const struct SaveLoad *GetOrderDescription(); ///< Saving and loading of orders.
|
||||
friend void Load_ORDX(); ///< Saving and loading of orders.
|
||||
friend void Save_ORDX(); ///< Saving and loading of orders.
|
||||
friend void Load_VEOX(); ///< Saving and loading of orders.
|
||||
friend void Save_VEOX(); ///< Saving and loading of orders.
|
||||
|
||||
uint8 type; ///< The type of order + non-stop flags
|
||||
uint8 flags; ///< Load/unload types, depot order/action types.
|
||||
|
@@ -45,7 +45,7 @@ std::vector<uint32> _sl_xv_discardable_chunk_ids; ///< list of chunks
|
||||
static const uint32 _sl_xv_slxi_chunk_version = 0; ///< current version os SLXI chunk
|
||||
|
||||
const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
||||
{ XSLFI_CARGO_TYPE_ORDERS, XSCF_NULL, 1, 1, "cargo_type_orders", NULL, NULL, "ORDX" },
|
||||
{ XSLFI_CARGO_TYPE_ORDERS, XSCF_NULL, 2, 2, "cargo_type_orders", NULL, NULL, "ORDX,VEOX" },
|
||||
|
||||
{ XSLFI_NULL, XSCF_NULL, 0, 0, NULL, NULL, NULL, NULL },// This is the end marker
|
||||
};
|
||||
|
@@ -934,6 +934,33 @@ static void Ptrs_VEHS()
|
||||
}
|
||||
}
|
||||
|
||||
const SaveLoad *GetOrderExtraInfoDescription();
|
||||
|
||||
void Save_VEOX()
|
||||
{
|
||||
/* save extended order info for vehicle current order */
|
||||
Vehicle *v;
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
if (v->current_order.extra) {
|
||||
SlSetArrayIndex(v->index);
|
||||
SlObject(v->current_order.extra.get(), GetOrderExtraInfoDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Load_VEOX()
|
||||
{
|
||||
/* load extended order info for vehicle current order */
|
||||
int index;
|
||||
while ((index = SlIterateArray()) != -1) {
|
||||
Vehicle *v = Vehicle::GetIfValid(index);
|
||||
assert(v != NULL);
|
||||
v->current_order.AllocExtraInfo();
|
||||
SlObject(v->current_order.extra.get(), GetOrderExtraInfoDescription());
|
||||
}
|
||||
}
|
||||
|
||||
extern const ChunkHandler _veh_chunk_handlers[] = {
|
||||
{ 'VEHS', Save_VEHS, Load_VEHS, Ptrs_VEHS, NULL, CH_SPARSE_ARRAY | CH_LAST},
|
||||
{ 'VEHS', Save_VEHS, Load_VEHS, Ptrs_VEHS, NULL, CH_SPARSE_ARRAY},
|
||||
{ 'VEOX', Save_VEOX, Load_VEOX, NULL, NULL, CH_SPARSE_ARRAY | CH_LAST},
|
||||
};
|
||||
|
Reference in New Issue
Block a user