File diff r19520:2f25138b0538 → r19521:9abf5bbcc05a
src/order_backup.cpp
Show inline comments
 
@@ -65,49 +65,49 @@ OrderBackup::OrderBackup(const Vehicle *
 
		}
 
	}
 
}
 

	
 
/**
 
 * Restore the data of this order to the given vehicle.
 
 * @param v The vehicle to restore to.
 
 */
 
void OrderBackup::DoRestore(Vehicle *v)
 
{
 
	/* If we had shared orders, recover that */
 
	if (this->clone != NULL) {
 
		DoCommand(0, v->index | CO_SHARE << 30, this->clone->index, DC_EXEC, CMD_CLONE_ORDER);
 
	} else if (this->orders != NULL && OrderList::CanAllocateItem()) {
 
		v->orders.list = new OrderList(this->orders, v);
 
		this->orders = NULL;
 
		/* Make sure buoys/oil rigs are updated in the station list. */
 
		InvalidateWindowClassesData(WC_STATION_LIST, 0);
 
	}
 

	
 
	v->CopyConsistPropertiesFrom(this);
 

	
 
	/* Make sure orders are in range */
 
	v->UpdateRealOrderIndex();
 
	v->cur_implicit_order_index = v->cur_real_order_index;
 
	if (v->cur_implicit_order_index >= v->GetNumOrders()) v->cur_implicit_order_index = v->cur_real_order_index;
 

	
 
	/* Restore vehicle group */
 
	DoCommand(0, this->group, v->index, DC_EXEC, CMD_ADD_VEHICLE_GROUP);
 
}
 

	
 
/**
 
 * Create an order backup for the given vehicle.
 
 * @param v    The vehicle to make a backup of.
 
 * @param user The user that is requesting the backup.
 
 * @note Will automatically remove any previous backups of this user.
 
 */
 
/* static */ void OrderBackup::Backup(const Vehicle *v, uint32 user)
 
{
 
	/* Don't use reset as that broadcasts over the network to reset the variable,
 
	 * which is what we are doing at the moment. */
 
	OrderBackup *ob;
 
	FOR_ALL_ORDER_BACKUPS(ob) {
 
		if (ob->user == user) delete ob;
 
	}
 
	if (OrderBackup::CanAllocateItem()) {
 
		new OrderBackup(v, user);
 
	}
 
}