2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /** @file order_backup.h Functions related to order backups. */
10 #ifndef ORDER_BACKUP_H
11 #define ORDER_BACKUP_H
13 #include "core/pool_type.hpp"
14 #include "group_type.h"
15 #include "tile_type.h"
16 #include "vehicle_type.h"
17 #include "base_consist.h"
18 #include "saveload/saveload.h"
20 /** Unique identifier for an order backup. */
21 typedef uint8_t OrderBackupID
;
24 /** The pool type for order backups. */
25 typedef Pool
<OrderBackup
, OrderBackupID
, 1, 256> OrderBackupPool
;
26 /** The pool with order backups. */
27 extern OrderBackupPool _order_backup_pool
;
30 * Data for backing up an order of a vehicle so it can be
31 * restored after a vehicle is rebuilt in the same depot.
33 struct OrderBackup
: OrderBackupPool::PoolItem
<&_order_backup_pool
>, BaseConsist
{
35 friend SaveLoadTable
GetOrderBackupDescription(); ///< Saving and loading of order backups.
36 friend struct BKORChunkHandler
; ///< Creating empty orders upon savegame loading.
37 uint32_t user
; ///< The user that requested the backup.
38 TileIndex tile
; ///< Tile of the depot where the order was changed.
39 GroupID group
; ///< The group the vehicle was part of.
41 const Vehicle
*clone
; ///< Vehicle this vehicle was a clone of.
42 Order
*orders
; ///< The actual orders if the vehicle was not a clone.
44 /** Creation for savegame restoration. */
46 OrderBackup(const Vehicle
*v
, uint32_t user
);
48 void DoRestore(Vehicle
*v
);
53 static void Backup(const Vehicle
*v
, uint32_t user
);
54 static void Restore(Vehicle
*v
, uint32_t user
);
56 static void ResetOfUser(TileIndex tile
, uint32_t user
);
57 static void ResetUser(uint32_t user
);
58 static void Reset(TileIndex tile
= INVALID_TILE
, bool from_gui
= true);
60 static void ClearGroup(GroupID group
);
61 static void ClearVehicle(const Vehicle
*v
);
62 static void RemoveOrder(OrderType type
, DestinationID destination
, bool hangar
);
65 #endif /* ORDER_BACKUP_H */