(svn r24444) -Codechange: Base OrderBackup on BaseConsist.
This commit is contained in:
		@@ -25,8 +25,6 @@ INSTANTIATE_POOL_METHODS(OrderBackup)
 | 
				
			|||||||
/** Free everything that is allocated. */
 | 
					/** Free everything that is allocated. */
 | 
				
			||||||
OrderBackup::~OrderBackup()
 | 
					OrderBackup::~OrderBackup()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	free(this->name);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (CleaningPool()) return;
 | 
						if (CleaningPool()) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Order *o = this->orders;
 | 
						Order *o = this->orders;
 | 
				
			||||||
@@ -46,11 +44,9 @@ OrderBackup::OrderBackup(const Vehicle *v, uint32 user)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	this->user             = user;
 | 
						this->user             = user;
 | 
				
			||||||
	this->tile             = v->tile;
 | 
						this->tile             = v->tile;
 | 
				
			||||||
	this->orderindex       = v->cur_implicit_order_index;
 | 
					 | 
				
			||||||
	this->group            = v->group_id;
 | 
						this->group            = v->group_id;
 | 
				
			||||||
	this->service_interval = v->service_interval;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (v->name != NULL) this->name = strdup(v->name);
 | 
						this->CopyConsistPropertiesFrom(v);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* If we have shared orders, store the vehicle we share the order with. */
 | 
						/* If we have shared orders, store the vehicle we share the order with. */
 | 
				
			||||||
	if (v->IsOrderListShared()) {
 | 
						if (v->IsOrderListShared()) {
 | 
				
			||||||
@@ -76,10 +72,6 @@ OrderBackup::OrderBackup(const Vehicle *v, uint32 user)
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
void OrderBackup::DoRestore(Vehicle *v)
 | 
					void OrderBackup::DoRestore(Vehicle *v)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/* If we have a custom name, process that */
 | 
					 | 
				
			||||||
	v->name = this->name;
 | 
					 | 
				
			||||||
	this->name = NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* If we had shared orders, recover that */
 | 
						/* If we had shared orders, recover that */
 | 
				
			||||||
	if (this->clone != NULL) {
 | 
						if (this->clone != NULL) {
 | 
				
			||||||
		DoCommand(0, v->index | CO_SHARE << 30, this->clone->index, DC_EXEC, CMD_CLONE_ORDER);
 | 
							DoCommand(0, v->index | CO_SHARE << 30, this->clone->index, DC_EXEC, CMD_CLONE_ORDER);
 | 
				
			||||||
@@ -90,12 +82,11 @@ void OrderBackup::DoRestore(Vehicle *v)
 | 
				
			|||||||
		InvalidateWindowClassesData(WC_STATION_LIST, 0);
 | 
							InvalidateWindowClassesData(WC_STATION_LIST, 0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint num_orders = v->GetNumOrders();
 | 
						v->CopyConsistPropertiesFrom(this);
 | 
				
			||||||
	if (num_orders != 0) {
 | 
					
 | 
				
			||||||
		v->cur_real_order_index = v->cur_implicit_order_index = this->orderindex % num_orders;
 | 
						/* Make sure orders are in range */
 | 
				
			||||||
	v->UpdateRealOrderIndex();
 | 
						v->UpdateRealOrderIndex();
 | 
				
			||||||
	}
 | 
						v->cur_implicit_order_index = v->cur_real_order_index;
 | 
				
			||||||
	v->service_interval = this->service_interval;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Restore vehicle group */
 | 
						/* Restore vehicle group */
 | 
				
			||||||
	DoCommand(0, this->group, v->index, DC_EXEC, CMD_ADD_VEHICLE_GROUP);
 | 
						DoCommand(0, this->group, v->index, DC_EXEC, CMD_ADD_VEHICLE_GROUP);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,11 +13,10 @@
 | 
				
			|||||||
#define ORDER_BACKUP_H
 | 
					#define ORDER_BACKUP_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "core/pool_type.hpp"
 | 
					#include "core/pool_type.hpp"
 | 
				
			||||||
#include "date_type.h"
 | 
					 | 
				
			||||||
#include "group_type.h"
 | 
					#include "group_type.h"
 | 
				
			||||||
#include "order_type.h"
 | 
					 | 
				
			||||||
#include "tile_type.h"
 | 
					#include "tile_type.h"
 | 
				
			||||||
#include "vehicle_type.h"
 | 
					#include "vehicle_type.h"
 | 
				
			||||||
 | 
					#include "base_consist.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** Unique identifier for an order backup. */
 | 
					/** Unique identifier for an order backup. */
 | 
				
			||||||
typedef uint8 OrderBackupID;
 | 
					typedef uint8 OrderBackupID;
 | 
				
			||||||
@@ -35,18 +34,15 @@ static const uint32 MAKE_ORDER_BACKUP_FLAG = 1U << 31;
 | 
				
			|||||||
 * Data for backing up an order of a vehicle so it can be
 | 
					 * Data for backing up an order of a vehicle so it can be
 | 
				
			||||||
 * restored after a vehicle is rebuilt in the same depot.
 | 
					 * restored after a vehicle is rebuilt in the same depot.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct OrderBackup : OrderBackupPool::PoolItem<&_order_backup_pool> {
 | 
					struct OrderBackup : OrderBackupPool::PoolItem<&_order_backup_pool>, BaseConsist {
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	friend const struct SaveLoad *GetOrderBackupDescription(); ///< Saving and loading of order backups.
 | 
						friend const struct SaveLoad *GetOrderBackupDescription(); ///< Saving and loading of order backups.
 | 
				
			||||||
	friend void Load_BKOR();   ///< Creating empty orders upon savegame loading.
 | 
						friend void Load_BKOR();   ///< Creating empty orders upon savegame loading.
 | 
				
			||||||
	uint32 user;               ///< The user that requested the backup.
 | 
						uint32 user;               ///< The user that requested the backup.
 | 
				
			||||||
	TileIndex tile;            ///< Tile of the depot where the order was changed.
 | 
						TileIndex tile;            ///< Tile of the depot where the order was changed.
 | 
				
			||||||
	GroupID group;             ///< The group the vehicle was part of.
 | 
						GroupID group;             ///< The group the vehicle was part of.
 | 
				
			||||||
	Date service_interval;     ///< The service interval of the vehicle.
 | 
					 | 
				
			||||||
	char *name;                ///< The custom name of the vehicle.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const Vehicle *clone;      ///< Vehicle this vehicle was a clone of.
 | 
						const Vehicle *clone;      ///< Vehicle this vehicle was a clone of.
 | 
				
			||||||
	VehicleOrderID orderindex; ///< The order-index the vehicle had.
 | 
					 | 
				
			||||||
	Order *orders;             ///< The actual orders if the vehicle was not a clone.
 | 
						Order *orders;             ///< The actual orders if the vehicle was not a clone.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Creation for savegame restoration. */
 | 
						/** Creation for savegame restoration. */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -250,7 +250,7 @@ const SaveLoad *GetOrderBackupDescription()
 | 
				
			|||||||
		SLE_VAR(OrderBackup, service_interval,      SLE_INT32),
 | 
							SLE_VAR(OrderBackup, service_interval,      SLE_INT32),
 | 
				
			||||||
		SLE_STR(OrderBackup, name,                  SLE_STR, 0),
 | 
							SLE_STR(OrderBackup, name,                  SLE_STR, 0),
 | 
				
			||||||
		SLE_VAR(OrderBackup, clone,                 SLE_UINT16),
 | 
							SLE_VAR(OrderBackup, clone,                 SLE_UINT16),
 | 
				
			||||||
		SLE_VAR(OrderBackup, orderindex,            SLE_UINT8),
 | 
							SLE_VAR(OrderBackup, cur_real_order_index,  SLE_UINT8),
 | 
				
			||||||
		SLE_REF(OrderBackup, orders,                REF_ORDER),
 | 
							SLE_REF(OrderBackup, orders,                REF_ORDER),
 | 
				
			||||||
		SLE_END()
 | 
							SLE_END()
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user