src/train_cmd.cpp
changeset 5856 c82e61d62cd3
parent 5827 2d0ec2a21996
child 5858 a48c5b18747a
equal deleted inserted replaced
5855:6f273e99a57a 5856:c82e61d62cd3
  2603 	} while ((v = v->next) != NULL);
  2603 	} while ((v = v->next) != NULL);
  2604 }
  2604 }
  2605 
  2605 
  2606 static void HandleTrainLoading(Vehicle *v, bool mode)
  2606 static void HandleTrainLoading(Vehicle *v, bool mode)
  2607 {
  2607 {
  2608 	if (v->current_order.type == OT_NOTHING) return;
  2608 	switch (v->current_order.type) {
  2609 
  2609 		case OT_LOADING:
  2610 	if (v->current_order.type != OT_DUMMY) {
  2610 			if (mode) return;
  2611 		if (v->current_order.type != OT_LOADING) return;
  2611 
  2612 		if (mode) return;
  2612 			// don't mark the train as lost if we're loading on the final station.
  2613 
  2613 			if (v->current_order.flags & OF_NON_STOP) {
  2614 		// don't mark the train as lost if we're loading on the final station.
  2614 				v->u.rail.days_since_order_progr = 0;
  2615 		if (v->current_order.flags & OF_NON_STOP)
  2615 			}
  2616 			v->u.rail.days_since_order_progr = 0;
  2616 
  2617 
  2617 			if (--v->load_unload_time_rem) return;
  2618 		if (--v->load_unload_time_rem) return;
  2618 
  2619 
  2619 			if (CanFillVehicle(v) && (
  2620 		if (CanFillVehicle(v) && (v->current_order.flags & OF_FULL_LOAD ||
  2620 						v->current_order.flags & OF_FULL_LOAD ||
  2621 				(_patches.gradual_loading && !HASBIT(v->load_status, LS_LOADING_FINISHED)))) {
  2621 						(_patches.gradual_loading && !HASBIT(v->load_status, LS_LOADING_FINISHED))
  2622 			v->u.rail.days_since_order_progr = 0; /* Prevent a train lost message for full loading trains */
  2622 					)) {
  2623 			SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC);
  2623 				v->u.rail.days_since_order_progr = 0; /* Prevent a train lost message for full loading trains */
  2624 			if (LoadUnloadVehicle(v, false)) {
  2624 				SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC);
  2625 				InvalidateWindow(WC_TRAINS_LIST, v->owner);
  2625 				if (LoadUnloadVehicle(v, false)) {
  2626 				MarkTrainDirty(v);
  2626 					InvalidateWindow(WC_TRAINS_LIST, v->owner);
  2627 
  2627 					MarkTrainDirty(v);
  2628 				// need to update acceleration and cached values since the goods on the train changed.
  2628 
  2629 				TrainCargoChanged(v);
  2629 					// need to update acceleration and cached values since the goods on the train changed.
  2630 				UpdateTrainAcceleration(v);
  2630 					TrainCargoChanged(v);
  2631 			}
  2631 					UpdateTrainAcceleration(v);
  2632 			return;
  2632 				}
  2633 		}
  2633 				return;
  2634 
  2634 			}
  2635 		TrainPlayLeaveStationSound(v);
  2635 
  2636 
  2636 			TrainPlayLeaveStationSound(v);
  2637 		{
  2637 
  2638 			Order b = v->current_order;
  2638 			Order b = v->current_order;
  2639 			v->LeaveStation();
  2639 			v->LeaveStation();
  2640 
  2640 
  2641 			// If this was not the final order, don't remove it from the list.
  2641 			// If this was not the final order, don't remove it from the list.
  2642 			if (!(b.flags & OF_NON_STOP)) return;
  2642 			if (!(b.flags & OF_NON_STOP)) return;
  2643 		}
  2643 			break;
       
  2644 
       
  2645 		case OT_DUMMY: break;
       
  2646 
       
  2647 		default: return;
  2644 	}
  2648 	}
  2645 
  2649 
  2646 	v->u.rail.days_since_order_progr = 0;
  2650 	v->u.rail.days_since_order_progr = 0;
  2647 	v->cur_order_index++;
  2651 	v->cur_order_index++;
  2648 	InvalidateVehicleOrder(v);
  2652 	InvalidateVehicleOrder(v);