# order_backup.h

Go to the documentation of this file.

    00001 /* $Id$ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * 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.
    00006  * 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.
    00007  * 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/>.
    00008  */
    00009
    00012 #ifndef ORDER_BACKUP_H
    00013 #define ORDER_BACKUP_H
    00014
    00015 #include "core/pool_type.hpp"
    00016 #include "group_type.h"
    00017 #include "tile_type.h"
    00018 #include "vehicle_type.h"
    00019 #include "base_consist.h"
    00020
    00022 typedef uint8 OrderBackupID;
    00023 struct OrderBackup;
    00024
    00026 typedef Pool<OrderBackup, OrderBackupID, 1, 256> OrderBackupPool;
    00028 extern OrderBackupPool _order_backup_pool;
    00029
    00031 static const uint32 MAKE_ORDER_BACKUP_FLAG = 1U << 31;
    00032
    00037 struct OrderBackup : OrderBackupPool::PoolItem<&_order_backup_pool>, BaseConsist {
    00038 private:
    00039   friend const struct SaveLoad *GetOrderBackupDescription();
    00040   friend void Load_BKOR();
    00041   uint32 user;
    00042   TileIndex tile;
    00043   GroupID group;
    00044
    00045   const Vehicle *clone;
    00046   Order *orders;
    00047
    00049   OrderBackup() {}
    00050   OrderBackup(const Vehicle *v, uint32 user);
    00051
    00052   void DoRestore(Vehicle *v);
    00053
    00054 public:
    00055   ~OrderBackup();
    00056
    00057   static void Backup(const Vehicle *v, uint32 user);
    00058   static void Restore(Vehicle *v, uint32 user);
    00059
    00060   static void ResetOfUser(TileIndex tile, uint32 user);
    00061   static void ResetUser(uint32 user);
    00062   static void Reset(TileIndex tile = INVALID_TILE, bool from_gui = true);
    00063
    00064   static void ClearGroup(GroupID group);
    00065   static void ClearVehicle(const Vehicle *v);
    00066   static void RemoveOrder(OrderType type, DestinationID destination);
    00067 };
    00068
    00074 #define FOR_ALL_ORDER_BACKUPS_FROM(var, start) FOR_ALL_ITEMS_FROM(OrderBackup, order_backup_index, var, start)
    00075
    00080 #define FOR_ALL_ORDER_BACKUPS(var) FOR_ALL_ORDER_BACKUPS_FROM(var, 0)
    00081
    00082 #endif /* ORDER_BACKUP_H */