From 783e20a263a5e72bfed81ef7a9535a2caefebf79 Mon Sep 17 00:00:00 2001 From: bjarni Date: Sun, 27 Apr 2008 20:09:29 +0000 Subject: (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 --- src/vehicle_base.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/vehicle_base.h') 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 */ -- cgit v1.2.3-54-g00ecf