OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

order_backup.h
Go to the documentation of this file.
1 /* $Id: order_backup.h 24444 2012-07-29 16:45:34Z frosch $ */
2
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 */
9
12 #ifndef ORDER_BACKUP_H
13 #define ORDER_BACKUP_H
14
15 #include "core/pool_type.hpp"
16 #include "group_type.h"
17 #include "tile_type.h"
18 #include "vehicle_type.h"
19 #include "base_consist.h"
20
22 typedef uint8 OrderBackupID;
23 struct OrderBackup;
24
26 typedef Pool<OrderBackup, OrderBackupID, 1, 256> OrderBackupPool;
28 extern OrderBackupPool _order_backup_pool;
29
31 static const uint32 MAKE_ORDER_BACKUP_FLAG = 1U << 31;
32
37 struct OrderBackup : OrderBackupPool::PoolItem<&_order_backup_pool>, BaseConsist {
38 private:
39 friend const struct SaveLoad *GetOrderBackupDescription();
40 friend void Load_BKOR();
41 uint32 user;
42 TileIndex tile;
43 GroupID group;
44
45 const Vehicle *clone;
46 Order *orders;
47
49 OrderBackup() {}
50 OrderBackup(const Vehicle *v, uint32 user);
51
52 void DoRestore(Vehicle *v);
53
54 public:
55 ~OrderBackup();
56
57 static void Backup(const Vehicle *v, uint32 user);
58 static void Restore(Vehicle *v, uint32 user);
59
60 static void ResetOfUser(TileIndex tile, uint32 user);
61 static void ResetUser(uint32 user);
62 static void Reset(TileIndex tile = INVALID_TILE, bool from_gui = true);
63
64 static void ClearGroup(GroupID group);
65 static void ClearVehicle(const Vehicle *v);
66 static void RemoveOrder(OrderType type, DestinationID destination);
67 };
68
74 #define FOR_ALL_ORDER_BACKUPS_FROM(var, start) FOR_ALL_ITEMS_FROM(OrderBackup, order_backup_index, var, start)
75
80 #define FOR_ALL_ORDER_BACKUPS(var) FOR_ALL_ORDER_BACKUPS_FROM(var, 0)
81
82 #endif /* ORDER_BACKUP_H */