1
0
Fork 0

(svn r21644) -Change: keep showing "No orders" when the order list is filled with only automatic orders

release/1.1
rubidium 2010-12-26 13:25:34 +00:00
parent b06b05c360
commit 28f16a732f
4 changed files with 31 additions and 9 deletions

View File

@ -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) { }
/**
@ -327,6 +328,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.

View File

@ -212,11 +212,13 @@ void OrderList::Initialize(Order *chain, Vehicle *v)
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_orderlist)
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_order, int index)
}
}
++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() const
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);
}
/**

View File

@ -548,6 +548,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),

View File

@ -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 {