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;