(svn r8874) [0.5] -Backport from trunk (r8744, r8685): 0.5
authorDarkvater
Sat, 24 Feb 2007 01:47:26 +0000
branch0.5
changeset 5446 68d042c57e9e
parent 5445 5af942067209
child 5447 fdd232ac18d0
(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
order_gui.c
vehicle.c
--- a/newgrf_engine.c	Sat Feb 24 01:39:59 2007 +0000
+++ b/newgrf_engine.c	Sat Feb 24 01:47:26 2007 +0000
@@ -1031,7 +1031,7 @@
 			 * 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:
--- a/order_gui.c	Sat Feb 24 01:39:59 2007 +0000
+++ b/order_gui.c	Sat Feb 24 01:47:26 2007 +0000
@@ -76,7 +76,7 @@
 
 		/* 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);
--- a/vehicle.c	Sat Feb 24 01:39:59 2007 +0000
+++ b/vehicle.c	Sat Feb 24 01:47:26 2007 +0000
@@ -514,6 +514,7 @@
 	Vehicle* u;
 
 	assert(v != NULL);
+	assert(v->type == VEH_Train);
 
 	if (v->first != NULL) {
 		if (IsFrontEngine(v->first) || IsFreeWagon(v->first)) return v->first;