Codechange: Use cached town, station, industry names for list window sorting
[openttd-github.git] / src / order_backup.h
blob5d1dcef50e3783647d396385e7c5eff6c387fe55
1 /*
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/>.
6 */
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"
19 /** Unique identifier for an order backup. */
20 typedef uint8 OrderBackupID;
21 struct OrderBackup;
23 /** The pool type for order backups. */
24 typedef Pool<OrderBackup, OrderBackupID, 1, 256> OrderBackupPool;
25 /** The pool with order backups. */
26 extern OrderBackupPool _order_backup_pool;
28 /** Flag to pass to the vehicle construction command when an order should be preserved. */
29 static const uint32 MAKE_ORDER_BACKUP_FLAG = 1U << 31;
31 /**
32 * Data for backing up an order of a vehicle so it can be
33 * restored after a vehicle is rebuilt in the same depot.
35 struct OrderBackup : OrderBackupPool::PoolItem<&_order_backup_pool>, BaseConsist {
36 private:
37 friend const struct SaveLoad *GetOrderBackupDescription(); ///< Saving and loading of order backups.
38 friend void Load_BKOR(); ///< Creating empty orders upon savegame loading.
39 uint32 user; ///< The user that requested the backup.
40 TileIndex tile; ///< Tile of the depot where the order was changed.
41 GroupID group; ///< The group the vehicle was part of.
43 const Vehicle *clone; ///< Vehicle this vehicle was a clone of.
44 Order *orders; ///< The actual orders if the vehicle was not a clone.
46 /** Creation for savegame restoration. */
47 OrderBackup() {}
48 OrderBackup(const Vehicle *v, uint32 user);
50 void DoRestore(Vehicle *v);
52 public:
53 ~OrderBackup();
55 static void Backup(const Vehicle *v, uint32 user);
56 static void Restore(Vehicle *v, uint32 user);
58 static void ResetOfUser(TileIndex tile, uint32 user);
59 static void ResetUser(uint32 user);
60 static void Reset(TileIndex tile = INVALID_TILE, bool from_gui = true);
62 static void ClearGroup(GroupID group);
63 static void ClearVehicle(const Vehicle *v);
64 static void RemoveOrder(OrderType type, DestinationID destination, bool hangar);
67 #endif /* ORDER_BACKUP_H */