Remove second template parameter from class GUIList
[openttd/fttd.git] / src / order_backup.h
blobb847ba136f083ebb85946d9e78dd759cc70c0168
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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 */
10 /** @file order_backup.h Functions related to order backups. */
12 #ifndef ORDER_BACKUP_H
13 #define ORDER_BACKUP_H
15 #include "core/pool_type.hpp"
16 #include "map/coord.h"
17 #include "group_type.h"
18 #include "vehicle_type.h"
19 #include "base_consist.h"
20 #include "saveload/saveload_buffer.h"
22 /** Unique identifier for an order backup. */
23 typedef uint8 OrderBackupID;
24 struct OrderBackup;
26 /** Flag to pass to the vehicle construction command when an order should be preserved. */
27 static const uint32 MAKE_ORDER_BACKUP_FLAG = 1U << 31;
29 /**
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 : PooledItem <OrderBackup, OrderBackupID, 1, 256>, BaseConsist {
34 private:
35 friend const struct SaveLoad *GetOrderBackupDescription(); ///< Saving and loading of order backups.
36 friend void Load_BKOR(LoadBuffer *); ///< Creating empty orders upon savegame loading.
37 uint32 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. */
45 OrderBackup() {}
46 OrderBackup(const Vehicle *v, uint32 user);
48 void DoRestore(Vehicle *v);
50 public:
51 ~OrderBackup();
53 static void Backup(const Vehicle *v, uint32 user);
54 static void Restore(Vehicle *v, uint32 user);
56 static void ResetOfUser(TileIndex tile, uint32 user);
57 static void ResetUser(uint32 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);
65 /**
66 * Iterator over all order backups from a given ID.
67 * @param var The variable to iterate with.
68 * @param start The start of the iteration.
70 #define FOR_ALL_ORDER_BACKUPS_FROM(var, start) FOR_ALL_ITEMS_FROM(OrderBackup, order_backup_index, var, start)
72 /**
73 * Iterator over all order backups.
74 * @param var The variable to iterate with.
76 #define FOR_ALL_ORDER_BACKUPS(var) FOR_ALL_ORDER_BACKUPS_FROM(var, 0)
78 #endif /* ORDER_BACKUP_H */