diff options
author | bjarni <bjarni@openttd.org> | 2008-04-27 20:09:29 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2008-04-27 20:09:29 +0000 |
commit | 757de2bdf567f5c8eb40578b949875eefe1c9335 (patch) | |
tree | efbff2346a07d27ade486566153b76347444eb3f /src/vehicle_base.h | |
parent | 9f5f4e59cdc9a9a8225131c7a007acb009016dfb (diff) | |
download | openttd-757de2bdf567f5c8eb40578b949875eefe1c9335.tar.xz |
(svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
Autoreplace uses this with the following benefits:
-Mass autoreplace (the button in the depot window) will now estimate costs correctly
-Autoreplace now either replaces correctly or manages to keep the original vehicle (no more broken trains)
Thanks to Ammler for testing this
Diffstat (limited to 'src/vehicle_base.h')
-rw-r--r-- | src/vehicle_base.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/vehicle_base.h b/src/vehicle_base.h index f89fd9458..d9dabdf58 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -14,6 +14,7 @@ #include "gfx_type.h" #include "command_type.h" #include "date_type.h" +#include "player_base.h" #include "player_type.h" #include "oldpool.h" #include "order_base.h" @@ -21,6 +22,7 @@ #include "texteff.hpp" #include "group_type.h" #include "engine_type.h" +#include "order_func.h" /** Road vehicle states */ enum RoadVehicleStates { @@ -520,6 +522,9 @@ public: * @return the cost of the depot action. */ CommandCost SendToDepot(uint32 flags, DepotCommand command); + + Vehicle* BackupVehicle() const; + Vehicle* RestoreBackupVehicle(); }; /** @@ -649,4 +654,21 @@ Trackdir GetVehicleTrackdir(const Vehicle* v); void CheckVehicle32Day(Vehicle *v); +struct BackuppedVehicle { +private: + Vehicle *vehicles; + BackuppedOrders *orders; + PlayerMoneyBackup *economy; + +public: + BackuppedVehicle(bool include_orders) : vehicles(NULL), economy(NULL) { + orders = include_orders ? new BackuppedOrders() : NULL; + } + ~BackuppedVehicle() { free(vehicles); delete orders; delete economy; } + + void Backup(const Vehicle *v, Player *p = NULL); + Vehicle *Restore(Vehicle *v); + bool ContainsBackup() { return vehicles != NULL; } +}; + #endif /* VEHICLE_BASE_H */ |