Go to the documentation of this file.
1 /* $Id: order_backup.h 24444 2012-07-29 16:45:34Z frosch $ */
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 <>.
8  */
12 #ifndef ORDER_BACKUP_H
13 #define ORDER_BACKUP_H
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"
22 typedef uint8 OrderBackupID;
23 struct OrderBackup;
31 static const uint32 MAKE_ORDER_BACKUP_FLAG = 1U << 31;
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;
45  const Vehicle *clone;
50  OrderBackup(const Vehicle *v, uint32 user);
52  void DoRestore(Vehicle *v);
54 public:
55  ~OrderBackup();
57  static void Backup(const Vehicle *v, uint32 user);
58  static void Restore(Vehicle *v, uint32 user);
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);
64  static void ClearGroup(GroupID group);
65  static void ClearVehicle(const Vehicle *v);
66  static void RemoveOrder(OrderType type, DestinationID destination);
67 };
74 #define FOR_ALL_ORDER_BACKUPS_FROM(var, start) FOR_ALL_ITEMS_FROM(OrderBackup, order_backup_index, var, start)
82 #endif /* ORDER_BACKUP_H */
Order * orders
The actual orders if the vehicle was not a clone.
Definition: order_backup.h:46
static void ResetUser(uint32 user)
Reset an user&#39;s OrderBackup if needed.
uint32 user
The user that requested the backup.
Definition: order_backup.h:41
Free everything that is allocated.
TileIndex tile
Tile of the depot where the order was changed.
Definition: order_backup.h:42
Vehicle data structure.
Definition: vehicle_base.h:212
friend const struct SaveLoad * GetOrderBackupDescription()
Saving and loading of order backups.
Definition: order_sl.cpp:250
uint8 OrderBackupID
Unique identifier for an order backup.
Definition: order_backup.h:22
Defintion of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle...
static void ResetOfUser(TileIndex tile, uint32 user)
Reset an OrderBackup given a tile and user.
const Vehicle * clone
Vehicle this vehicle was a clone of.
Definition: order_backup.h:45
OrderBackupPool _order_backup_pool
The pool with order backups.
static const uint32 MAKE_ORDER_BACKUP_FLAG
Flag to pass to the vehicle construction command when an order should be preserved.
Definition: order_backup.h:31
Various front vehicle properties that are preserved when autoreplacing, using order-backup or switchi...
Definition: base_consist.h:19
uint16 GroupID
Type for all group identifiers.
Definition: group_type.h:15
Properties for front vehicles/consists.
Pool< OrderBackup, OrderBackupID, 1, 256 > OrderBackupPool
The pool type for order backups.
Definition: order_backup.h:23
Base class for all PoolItems.
Definition: pool_type.hpp:146
Order types.
Definition: order_type.h:37
Base class for all pools.
Definition: pool_type.hpp:83
static void Reset(TileIndex tile=INVALID_TILE, bool from_gui=true)
Reset the OrderBackups from GUI/game logic.
static void RemoveOrder(OrderType type, DestinationID destination)
Removes an order from all vehicles.
void DoRestore(Vehicle *v)
Restore the data of this order to the given vehicle.
static void ClearVehicle(const Vehicle *v)
Clear/update the (clone) vehicle from an order backup.
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
Types related to vehicles.
static void ClearGroup(GroupID group)
Clear the group of all backups having this group ID.
Creation for savegame restoration.
Definition: order_backup.h:49
SaveLoad type struct.
Definition: saveload.h:208
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:85
GroupID group
The group the vehicle was part of.
Definition: order_backup.h:43
static void Restore(Vehicle *v, uint32 user)
Restore the data of this order to the given vehicle.
static void Backup(const Vehicle *v, uint32 user)
Create an order backup for the given vehicle.
Types related to tiles.
Data for backing up an order of a vehicle so it can be restored after a vehicle is rebuilt in the sam...
Definition: order_backup.h:37
Types of a group.
friend void Load_BKOR()
Creating empty orders upon savegame loading.
Definition: order_sl.cpp:289