Changeset - r16899:d7758bff8ae6
[Not reviewed]
master
0 4 0
rubidium - 14 years ago 2010-12-26 13:25:34
rubidium@openttd.org
(svn r21644) -Change: keep showing "No orders" when the order list is filled with only automatic orders
4 files changed with 31 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/order_base.h
Show inline comments
 
@@ -272,17 +272,18 @@ private:
 
	friend void AfterLoadVehicles(bool part_of_load); ///< For instantiating the shared vehicle chain
 
	friend const struct SaveLoad *GetOrderListDescription(); ///< Saving and loading of order lists.
 

	
 
	Order *first;                   ///< First order of the order list
 
	VehicleOrderID num_orders;      ///< NOSAVE: How many orders there are in the list
 
	uint num_vehicles;              ///< NOSAVE: Number of vehicles that share this order list
 
	Vehicle *first_shared;          ///< NOSAVE: pointer to the first vehicle in the shared order chain
 
	Order *first;                     ///< First order of the order list.
 
	VehicleOrderID num_orders;        ///< NOSAVE: How many orders there are in the list.
 
	VehicleOrderID num_manual_orders; ///< NOSAVE: How many manually added orders are there in the list.
 
	uint num_vehicles;                ///< NOSAVE: Number of vehicles that share this order list.
 
	Vehicle *first_shared;            ///< NOSAVE: pointer to the first vehicle in the shared order chain.
 

	
 
	Ticks timetable_duration;       ///< NOSAVE: Total duration of the order list
 
	Ticks timetable_duration;         ///< NOSAVE: Total duration of the order list
 

	
 
public:
 
	/** Default constructor producing an invalid order list. */
 
	OrderList(VehicleOrderID num_orders = INVALID_VEH_ORDER_ID)
 
		: first(NULL), num_orders(num_orders), num_vehicles(0), first_shared(NULL),
 
		: first(NULL), num_orders(num_orders), num_manual_orders(0), num_vehicles(0), first_shared(NULL),
 
		  timetable_duration(0) { }
 

	
 
	/**
 
@@ -328,6 +329,12 @@ public:
 
	inline VehicleOrderID GetNumOrders() const { return this->num_orders; }
 

	
 
	/**
 
	 * Get number of manually added orders in the order list.
 
	 * @return number of manual orders in the chain.
 
	 */
 
	inline VehicleOrderID GetNumManualOrders() const { return this->num_manual_orders; }
 

	
 
	/**
 
	 * Insert a new order into the order chain.
 
	 * @param new_order is the order to insert into the chain.
 
	 * @param index is the position where the order is supposed to be inserted.
src/order_cmd.cpp
Show inline comments
 
@@ -212,11 +212,13 @@ void OrderList::Initialize(Order *chain,
 
	this->first_shared = v;
 

	
 
	this->num_orders = 0;
 
	this->num_manual_orders = 0;
 
	this->num_vehicles = 1;
 
	this->timetable_duration = 0;
 

	
 
	for (Order *o = this->first; o != NULL; o = o->next) {
 
		++this->num_orders;
 
		if (!o->IsType(OT_AUTOMATIC)) ++this->num_manual_orders;
 
		this->timetable_duration += o->wait_time + o->travel_time;
 
	}
 

	
 
@@ -239,6 +241,7 @@ void OrderList::FreeChain(bool keep_orde
 
	if (keep_orderlist) {
 
		this->first = NULL;
 
		this->num_orders = 0;
 
		this->num_manual_orders = 0;
 
		this->timetable_duration = 0;
 
	} else {
 
		delete this;
 
@@ -277,6 +280,7 @@ void OrderList::InsertOrderAt(Order *new
 
		}
 
	}
 
	++this->num_orders;
 
	if (!new_order->IsType(OT_AUTOMATIC)) ++this->num_manual_orders;
 
	this->timetable_duration += new_order->wait_time + new_order->travel_time;
 
}
 

	
 
@@ -296,6 +300,7 @@ void OrderList::DeleteOrderAt(int index)
 
		prev->next = to_remove->next;
 
	}
 
	--this->num_orders;
 
	if (!to_remove->IsType(OT_AUTOMATIC)) --this->num_manual_orders;
 
	this->timetable_duration -= (to_remove->wait_time + to_remove->travel_time);
 
	delete to_remove;
 
}
 
@@ -362,6 +367,7 @@ bool OrderList::IsCompleteTimetable() co
 
void OrderList::DebugCheckSanity() const
 
{
 
	VehicleOrderID check_num_orders = 0;
 
	VehicleOrderID check_num_manual_orders = 0;
 
	uint check_num_vehicles = 0;
 
	Ticks check_timetable_duration = 0;
 

	
 
@@ -369,9 +375,11 @@ void OrderList::DebugCheckSanity() const
 

	
 
	for (const Order *o = this->first; o != NULL; o = o->next) {
 
		++check_num_orders;
 
		if (!o->IsType(OT_AUTOMATIC)) ++check_num_manual_orders;
 
		check_timetable_duration += o->wait_time + o->travel_time;
 
	}
 
	assert(this->num_orders == check_num_orders);
 
	assert(this->num_manual_orders == check_num_manual_orders);
 
	assert(this->timetable_duration == check_timetable_duration);
 

	
 
	for (const Vehicle *v = this->first_shared; v != NULL; v = v->NextShared()) {
 
@@ -379,8 +387,9 @@ void OrderList::DebugCheckSanity() const
 
		assert(v->orders.list == this);
 
	}
 
	assert(this->num_vehicles == check_num_vehicles);
 
	DEBUG(misc, 6, "... detected %u orders, %u vehicles, %i ticks", (uint)this->num_orders,
 
	      this->num_vehicles, this->timetable_duration);
 
	DEBUG(misc, 6, "... detected %u orders (%u manual), %u vehicles, %i ticks",
 
			(uint)this->num_orders, (uint)this->num_manual_orders,
 
			this->num_vehicles, this->timetable_duration);
 
}
 

	
 
/**
src/vehicle_base.h
Show inline comments
 
@@ -549,6 +549,12 @@ public:
 
	inline VehicleOrderID GetNumOrders() const { return (this->orders.list == NULL) ? 0 : this->orders.list->GetNumOrders(); }
 

	
 
	/**
 
	 * Get the number of manually added orders this vehicle has.
 
	 * @return the number of manually added orders this vehicle has.
 
	 */
 
	inline VehicleOrderID GetNumManualOrders() const { return (this->orders.list == NULL) ? 0 : this->orders.list->GetNumManualOrders(); }
 

	
 
	/**
 
	 * Copy certain configurations and statistics of a vehicle after successful autoreplace/renew
 
	 * The function shall copy everything that cannot be copied by a command (like orders / group etc),
 
	 * and that shall not be resetted for the new vehicle.
src/vehicle_gui.cpp
Show inline comments
 
@@ -2447,7 +2447,7 @@ public:
 
					/* FALL THROUGH, if aircraft. Does this even happen? */
 

	
 
				default:
 
					if (v->GetNumOrders() == 0) {
 
					if (v->GetNumManualOrders() == 0) {
 
						str = STR_VEHICLE_STATUS_NO_ORDERS + _settings_client.gui.vehicle_speed;
 
						SetDParam(0, v->GetDisplaySpeed());
 
					} else {
0 comments (0 inline, 0 general)