diff options
author | rubidium <rubidium@openttd.org> | 2010-12-26 13:25:34 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-12-26 13:25:34 +0000 |
commit | 28f16a732fbcc759c9cceef7c9a160486b37f896 (patch) | |
tree | 59bdebd2d20b864446cb218e1bdac6742cfbf332 /src | |
parent | b06b05c360830efe5a689a9340b1d327f5d45189 (diff) | |
download | openttd-28f16a732fbcc759c9cceef7c9a160486b37f896.tar.xz |
(svn r21644) -Change: keep showing "No orders" when the order list is filled with only automatic orders
Diffstat (limited to 'src')
-rw-r--r-- | src/order_base.h | 19 | ||||
-rw-r--r-- | src/order_cmd.cpp | 13 | ||||
-rw-r--r-- | src/vehicle_base.h | 6 | ||||
-rw-r--r-- | src/vehicle_gui.cpp | 2 |
4 files changed, 31 insertions, 9 deletions
diff --git a/src/order_base.h b/src/order_base.h index 6503c2999..b04ca2b05 100644 --- a/src/order_base.h +++ b/src/order_base.h @@ -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. diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 57df98a8b..6b9a69dbe 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -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); } /** diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 2d59c3795..3d956b12b 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -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. diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 2d1e15694..35143e8fc 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -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 { |