Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends

# OrderBackup Struct Reference

Data for backing up an order of a vehicle so it can be restored after a vehicle is rebuilt in the same depot. More...

`#include <order_backup.h>`

Inheritance diagram for OrderBackup:

## Public Member Functions
| ~OrderBackup ()
| Free everything that is allocated.
## Static Public Member Functions
static void | Backup (const Vehicle *v, uint32 user)
| Create an order backup for the given vehicle.
static void | Restore (Vehicle *v, uint32 user)
| Restore the data of this order to the given vehicle.
static void | ResetOfUser (TileIndex tile, uint32 user)
| Reset an OrderBackup given a tile and user.
static void | ResetUser (uint32 user)
| Reset an user's OrderBackup if needed.
static void | Reset (TileIndex tile=INVALID_TILE, bool from_gui=true)
| Reset the OrderBackups from GUI/game logic.
static void | ClearGroup (GroupID group)
| Clear the group of all backups having this group ID.
static void | ClearVehicle (const Vehicle *v)
| Clear/update the (clone) vehicle from an order backup.
static void | RemoveOrder (OrderType type, DestinationID destination)
| Removes an order from all vehicles.
## Private Member Functions
| OrderBackup ()
| Creation for savegame restoration.
| OrderBackup (const Vehicle *v, uint32 user)
| Create an order backup for the given vehicle.
void | DoRestore (Vehicle *v)
| Restore the data of this order to the given vehicle.
## Private Attributes
uint32 | user
| The user that requested the backup.
TileIndex | tile
| Tile of the depot where the order was changed.
GroupID | group
| The group the vehicle was part of.
const Vehicle * | clone
| Vehicle this vehicle was a clone of.
Order * | orders
| The actual orders if the vehicle was not a clone.
## Friends
struct SaveLoad * | GetOrderBackupDescription ()
| Saving and loading of order backups.
void | Load_BKOR ()
| Creating empty orders upon savegame loading.

## Detailed Description

Data for backing up an order of a vehicle so it can be restored after a vehicle is rebuilt in the same depot.

Definition at line 37 of file order_backup.h.

## Constructor & Destructor Documentation

OrderBackup::OrderBackup | ( |  | ) | `[inline, private]`

Creation for savegame restoration.

Definition at line 49 of file order_backup.h.

Referenced by Backup().

OrderBackup::OrderBackup | ( | const Vehicle * | v,
|  | uint32 | user |
| ) |  |  | `[private]`

Create an order backup for the given vehicle.

Parameters:

  | v | The vehicle to make a backup of.
  | user | The user that is requesting the backup.

Definition at line 43 of file order_backup.cpp.

References Order::AssignOrder(), clone, BaseConsist::CopyConsistPropertiesFrom(), Vehicle::FirstShared(), group, Vehicle::group_id, Vehicle::IsOrderListShared(), Order::next, Vehicle::NextShared(), orders, Vehicle::tile, and tile.

OrderBackup::~OrderBackup | ( |  | ) |

Free everything that is allocated.

Definition at line 26 of file order_backup.cpp.

References Order::next.

## Member Function Documentation

void OrderBackup::Backup | ( | const Vehicle * | v,
|  | uint32 | user |
| ) |  |  | `[static]`

Create an order backup for the given vehicle.

Parameters:

  | v | The vehicle to make a backup of.
  | user | The user that is requesting the backup.

Note:
  Will automatically remove any previous backups of this user.

Definition at line 101 of file order_backup.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_order_backup_pool >::CanAllocateItem(), FOR_ALL_ORDER_BACKUPS, OrderBackup(), and user.

Referenced by CmdSellRailWagon(), and CmdSellVehicle().

void OrderBackup::ClearGroup | ( | GroupID | group | ) | `[static]`

Clear the group of all backups having this group ID.

Parameters:

  | group | The group to clear.

Definition at line 224 of file order_backup.cpp.

References DEFAULT_GROUP, FOR_ALL_ORDER_BACKUPS, and group.

Referenced by CmdDeleteGroup().

void OrderBackup::ClearVehicle | ( | const Vehicle * | v | ) | `[static]`

Clear/update the (clone) vehicle from an order backup.

Parameters:

  | v | The vehicle to clear.

Precondition:
  v != NULL

Note:
  If it is not possible to set another vehicle as clone "example", then this backed up order will be removed.

Definition at line 239 of file order_backup.cpp.

References clone, Vehicle::FirstShared(), FOR_ALL_ORDER_BACKUPS, and Vehicle::NextShared().

Referenced by Vehicle::PreDestructor().

void OrderBackup::DoRestore | ( | Vehicle * | v | ) | `[private]`

Restore the data of this order to the given vehicle.

Parameters:

  | v | The vehicle to restore to.

Definition at line 73 of file order_backup.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_orderlist_pool >::CanAllocateItem(), clone, CMD_ADD_VEHICLE_GROUP, CMD_CLONE_ORDER, BaseConsist::CopyConsistPropertiesFrom(), BaseConsist::cur_implicit_order_index, BaseConsist::cur_real_order_index, DC_EXEC, DoCommand(), Vehicle::GetNumOrders(), group, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWindowClassesData(), Vehicle::list, Vehicle::orders, orders, Vehicle::UpdateRealOrderIndex(), and WC_STATION_LIST.

Referenced by Restore().

void OrderBackup::RemoveOrder | ( | OrderType | type,
|  | DestinationID | destination |
| ) |  |  | `[static]`

Removes an order from all vehicles.

Triggers when, say, a station is removed.

Parameters:

  | type | The type of the order (OT_GOTO_[STATION|DEPOT|WAYPOINT]).
  | destination | The destination. Can be a StationID, DepotID or WaypointID.

Definition at line 258 of file order_backup.cpp.

References FOR_ALL_ORDER_BACKUPS, IsHangarTile(), Order::next, orders, and tile.

Referenced by RemoveOrderFromAllVehicles().

void OrderBackup::Reset | ( | TileIndex | t = `INVALID_TILE`,
|  | bool | from_gui = `true` |
| ) |  |  | `[static]`

Reset the OrderBackups from GUI/game logic.

Parameters:

  | t | The tile of the order backup.
  | from_gui | Whether the call came from the GUI, i.e. whether it must be synced over the network.

Definition at line 188 of file order_backup.cpp.

References _network_own_client_id, _network_server, _networking, CMD_CLEAR_ORDER_BACKUP, DoCommandPInternal(), FOR_ALL_ORDER_BACKUPS, INVALID_TILE, tile, and user.

Referenced by RemoveAirport(), and Depot::~Depot().

void OrderBackup::ResetOfUser | ( | TileIndex | tile,
|  | uint32 | user |
| ) |  |  | `[static]`

Reset an OrderBackup given a tile and user.

Parameters:

  | tile | The tile associated with the OrderBackup.
  | user | The user associated with the OrderBackup.

Note:
  Must not be used from the GUI!

Definition at line 137 of file order_backup.cpp.

References FOR_ALL_ORDER_BACKUPS, INVALID_TILE, tile, and user.

Referenced by CmdClearOrderBackup().

void OrderBackup::ResetUser | ( | uint32 | user | ) | `[static]`

Reset an user's OrderBackup if needed.

Parameters:

  | user | The user associated with the OrderBackup.

Precondition:
  _network_server.

Note:
  Must not be used from a command.

Definition at line 168 of file order_backup.cpp.

References _network_server, CMD_CLEAR_ORDER_BACKUP, DoCommandP(), FOR_ALL_ORDER_BACKUPS, and user.

Referenced by ServerNetworkGameSocketHandler::SendMap(), and ServerNetworkGameSocketHandler::~ServerNetworkGameSocketHandler().

void OrderBackup::Restore | ( | Vehicle * | v,
|  | uint32 | user |
| ) |  |  | `[static]`

Restore the data of this order to the given vehicle.

Parameters:

  | v | The vehicle to restore to.
  | user | The user that built the vehicle, thus wants to restore.

Note:
  After restoration the backup will automatically be removed.

Definition at line 120 of file order_backup.cpp.

References DoRestore(), FOR_ALL_ORDER_BACKUPS, tile, Vehicle::tile, and user.

Referenced by CmdBuildVehicle().

The documentation for this struct was generated from the following files:

- src/order_backup.h
- src/order_backup.cpp