Remove unused string code SCC_STRING_ID
[openttd/fttd.git] / src / order_backup.h
blobf05171987f6e45637e910eb3ff7ef18cd10f6553
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 /** The pool type for order backups. */
27 typedef Pool<OrderBackup, OrderBackupID, 1, 256> OrderBackupPool;
28 /** The pool with order backups. */
29 extern OrderBackupPool _order_backup_pool;
31 /** Flag to pass to the vehicle construction command when an order should be preserved. */
32 static const uint32 MAKE_ORDER_BACKUP_FLAG = 1U << 31;
34 /**
35 * Data for backing up an order of a vehicle so it can be
36 * restored after a vehicle is rebuilt in the same depot.
38 struct OrderBackup : OrderBackupPool::PoolItem<&_order_backup_pool>, BaseConsist {
39 private:
40 friend const struct SaveLoad *GetOrderBackupDescription(); ///< Saving and loading of order backups.
41 friend void Load_BKOR(LoadBuffer *); ///< Creating empty orders upon savegame loading.
42 uint32 user; ///< The user that requested the backup.
43 TileIndex tile; ///< Tile of the depot where the order was changed.
44 GroupID group; ///< The group the vehicle was part of.
46 const Vehicle *clone; ///< Vehicle this vehicle was a clone of.
47 Order *orders; ///< The actual orders if the vehicle was not a clone.
49 /** Creation for savegame restoration. */
50 OrderBackup() {}
51 OrderBackup(const Vehicle *v, uint32 user);
53 void DoRestore(Vehicle *v);
55 public:
56 ~OrderBackup();
58 static void Backup(const Vehicle *v, uint32 user);
59 static void Restore(Vehicle *v, uint32 user);
61 static void ResetOfUser(TileIndex tile, uint32 user);
62 static void ResetUser(uint32 user);
63 static void Reset(TileIndex tile = INVALID_TILE, bool from_gui = true);
65 static void ClearGroup(GroupID group);
66 static void ClearVehicle(const Vehicle *v);
67 static void RemoveOrder(OrderType type, DestinationID destination);
70 /**
71 * Iterator over all order backups from a given ID.
72 * @param var The variable to iterate with.
73 * @param start The start of the iteration.
75 #define FOR_ALL_ORDER_BACKUPS_FROM(var, start) FOR_ALL_ITEMS_FROM(OrderBackup, order_backup_index, var, start)
77 /**
78 * Iterator over all order backups.
79 * @param var The variable to iterate with.
81 #define FOR_ALL_ORDER_BACKUPS(var) FOR_ALL_ORDER_BACKUPS_FROM(var, 0)
83 #endif /* ORDER_BACKUP_H */