|
@@ -208,111 +208,114 @@ static void Ptrs_ORDR()
|
|
|
|
|
|
const SaveLoad *GetOrderListDescription()
|
|
|
{
|
|
|
static const SaveLoad _orderlist_desc[] = {
|
|
|
SLE_REF(OrderList, first, REF_ORDER),
|
|
|
SLE_END()
|
|
|
};
|
|
|
|
|
|
return _orderlist_desc;
|
|
|
}
|
|
|
|
|
|
static void Save_ORDL()
|
|
|
{
|
|
|
OrderList *list;
|
|
|
|
|
|
FOR_ALL_ORDER_LISTS(list) {
|
|
|
SlSetArrayIndex(list->index);
|
|
|
SlObject(list, GetOrderListDescription());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static void Load_ORDL()
|
|
|
{
|
|
|
int index;
|
|
|
|
|
|
while ((index = SlIterateArray()) != -1) {
|
|
|
/* set num_orders to 0 so it's a valid OrderList */
|
|
|
OrderList *list = new (index) OrderList(0);
|
|
|
SlObject(list, GetOrderListDescription());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
static void Ptrs_ORDL()
|
|
|
{
|
|
|
OrderList *list;
|
|
|
|
|
|
FOR_ALL_ORDER_LISTS(list) {
|
|
|
SlObject(list, GetOrderListDescription());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const SaveLoad *GetOrderBackupDescription()
|
|
|
{
|
|
|
static const SaveLoad _order_backup_desc[] = {
|
|
|
SLE_VAR(OrderBackup, user, SLE_UINT32),
|
|
|
SLE_VAR(OrderBackup, tile, SLE_UINT32),
|
|
|
SLE_VAR(OrderBackup, group, SLE_UINT16),
|
|
|
SLE_VAR(OrderBackup, service_interval, SLE_UINT32),
|
|
|
SLE_CONDVAR(OrderBackup, service_interval, SLE_FILE_U32 | SLE_VAR_U16, 0, 191),
|
|
|
SLE_CONDVAR(OrderBackup, service_interval, SLE_UINT16, 192, SL_MAX_VERSION),
|
|
|
SLE_STR(OrderBackup, name, SLE_STR, 0),
|
|
|
SLE_VAR(OrderBackup, clone, SLE_UINT16),
|
|
|
SLE_CONDNULL(2, 0, 191), // clone (2 bytes of pointer, i.e. garbage)
|
|
|
SLE_CONDREF(OrderBackup, clone, REF_VEHICLE, 192, SL_MAX_VERSION),
|
|
|
SLE_VAR(OrderBackup, cur_real_order_index, SLE_UINT8),
|
|
|
SLE_CONDVAR(OrderBackup, cur_implicit_order_index, SLE_UINT8, 176, SL_MAX_VERSION),
|
|
|
SLE_CONDVAR(OrderBackup, current_order_time, SLE_UINT32, 176, SL_MAX_VERSION),
|
|
|
SLE_CONDVAR(OrderBackup, lateness_counter, SLE_INT32, 176, SL_MAX_VERSION),
|
|
|
SLE_CONDVAR(OrderBackup, timetable_start, SLE_INT32, 176, SL_MAX_VERSION),
|
|
|
SLE_CONDVAR(OrderBackup, vehicle_flags, SLE_FILE_U8 | SLE_VAR_U16, 176, 179),
|
|
|
SLE_CONDVAR(OrderBackup, vehicle_flags, SLE_UINT16, 180, SL_MAX_VERSION),
|
|
|
SLE_REF(OrderBackup, orders, REF_ORDER),
|
|
|
SLE_END()
|
|
|
};
|
|
|
|
|
|
return _order_backup_desc;
|
|
|
}
|
|
|
|
|
|
static void Save_BKOR()
|
|
|
{
|
|
|
/* We only save this when we're a network server
|
|
|
* as we want this information on our clients. For
|
|
|
* normal games this information isn't needed. */
|
|
|
if (!_networking || !_network_server) return;
|
|
|
|
|
|
OrderBackup *ob;
|
|
|
FOR_ALL_ORDER_BACKUPS(ob) {
|
|
|
SlSetArrayIndex(ob->index);
|
|
|
SlObject(ob, GetOrderBackupDescription());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void Load_BKOR()
|
|
|
{
|
|
|
int index;
|
|
|
|
|
|
while ((index = SlIterateArray()) != -1) {
|
|
|
/* set num_orders to 0 so it's a valid OrderList */
|
|
|
OrderBackup *ob = new (index) OrderBackup();
|
|
|
SlObject(ob, GetOrderBackupDescription());
|
|
|
}
|
|
|
|
|
|
/* Only load order-backups for network clients.
|
|
|
* If we are a network server or not networking, then we just loaded
|
|
|
* a previously saved-by-server savegame. There are
|
|
|
* no clients with a backup anymore, so clear it. */
|
|
|
if (!_networking || _network_server) {
|
|
|
* If we are a network server or not networking, then we just loaded a previously
|
|
|
* saved-by-server savegame. There are no clients with a backup, so clear it.
|
|
|
* Furthermore before savegame version 192 the actual content was always corrupt.
|
|
|
*/
|
|
|
if (!_networking || _network_server || IsSavegameVersionBefore(192)) {
|
|
|
_order_backup_pool.CleanPool();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static void Ptrs_BKOR()
|
|
|
{
|
|
|
OrderBackup *ob;
|
|
|
FOR_ALL_ORDER_BACKUPS(ob) {
|
|
|
SlObject(ob, GetOrderBackupDescription());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
extern const ChunkHandler _order_chunk_handlers[] = {
|
|
|
{ 'BKOR', Save_BKOR, Load_BKOR, Ptrs_BKOR, NULL, CH_ARRAY},
|
|
|
{ 'ORDR', Save_ORDR, Load_ORDR, Ptrs_ORDR, NULL, CH_ARRAY},
|
|
|
{ 'ORDL', Save_ORDL, Load_ORDL, Ptrs_ORDL, NULL, CH_ARRAY | CH_LAST},
|
|
|
};
|