From 3b2bcbf0f0ecf649c7ccab8d83e8066dd6e38cf4 Mon Sep 17 00:00:00 2001 From: Darkvater Date: Sat, 24 Feb 2007 01:47:26 +0000 Subject: [PATCH] (svn r8874) [0.5] -Backport from trunk (r8744, r8685): - Call GetFirstVehicleInChain only for trains thus increasing performance in large games (r8744) - (Feature) Selecting "end of orders" and deleting will delete all the vehicle's orders (in unshared mode, shared is unchanged) (r8685) --- newgrf_engine.c | 2 +- order_gui.c | 2 +- vehicle.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/newgrf_engine.c b/newgrf_engine.c index 328ed3290e..067f902054 100644 --- a/newgrf_engine.c +++ b/newgrf_engine.c @@ -1031,7 +1031,7 @@ static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, byte base_rando * i.e.), so we give them all the NEW_CARGO triggered * vehicle's portion of random bits. */ assert(first); - DoTriggerVehicle(GetFirstVehicleInChain(v), VEHICLE_TRIGGER_ANY_NEW_CARGO, new_random_bits, false); + DoTriggerVehicle((v->type == VEH_Train) ? GetFirstVehicleInChain(v) : v, VEHICLE_TRIGGER_ANY_NEW_CARGO, new_random_bits, false); break; case VEHICLE_TRIGGER_DEPOT: diff --git a/order_gui.c b/order_gui.c index 44d8fd43d2..acdd625a2c 100644 --- a/order_gui.c +++ b/order_gui.c @@ -76,7 +76,7 @@ static void DrawOrdersWindow(Window *w) /* delete */ SetWindowWidgetDisabledState(w, 5, - (uint)v->num_orders + (shared_orders ? 1 : 0) <= (uint)WP(w, order_d).sel); + (uint)v->num_orders + ((shared_orders || v->num_orders != 0) ? 1 : 0) <= (uint)WP(w, order_d).sel); /* non-stop only for trains */ SetWindowWidgetDisabledState(w, 6, v->type != VEH_Train || order == NULL); diff --git a/vehicle.c b/vehicle.c index ae0690a3b4..e67f89df60 100644 --- a/vehicle.c +++ b/vehicle.c @@ -514,6 +514,7 @@ Vehicle *GetFirstVehicleInChain(const Vehicle *v) Vehicle* u; assert(v != NULL); + assert(v->type == VEH_Train); if (v->first != NULL) { if (IsFrontEngine(v->first) || IsFreeWagon(v->first)) return v->first;