src/vehicle.cpp
changeset 6500 f12678890222
parent 6492 286a52449b54
child 6501 7df55f74f00c
equal deleted inserted replaced
6499:e46cf40d8743 6500:f12678890222
   568 	}
   568 	}
   569 }
   569 }
   570 
   570 
   571 void DestroyVehicle(Vehicle *v)
   571 void DestroyVehicle(Vehicle *v)
   572 {
   572 {
       
   573 	if (v->last_station_visited != INVALID_STATION) {
       
   574 		GetStation(v->last_station_visited)->loading_vehicles.remove(v);
       
   575 	}
       
   576 
   573 	if (IsEngineCountable(v)) {
   577 	if (IsEngineCountable(v)) {
   574 		GetPlayer(v->owner)->num_engines[v->engine_type]--;
   578 		GetPlayer(v->owner)->num_engines[v->engine_type]--;
   575 		if (v->owner == _local_player) InvalidateAutoreplaceWindow(v->engine_type);
   579 		if (v->owner == _local_player) InvalidateAutoreplaceWindow(v->engine_type);
   576 	}
   580 	}
   577 
   581 
  2901 
  2905 
  2902 void Vehicle::BeginLoading()
  2906 void Vehicle::BeginLoading()
  2903 {
  2907 {
  2904 	assert(IsTileType(tile, MP_STATION) || type == VEH_SHIP);
  2908 	assert(IsTileType(tile, MP_STATION) || type == VEH_SHIP);
  2905 	current_order.type = OT_LOADING;
  2909 	current_order.type = OT_LOADING;
       
  2910 	GetStation(this->last_station_visited)->loading_vehicles.push_back(this);
  2906 }
  2911 }
  2907 
  2912 
  2908 void Vehicle::LeaveStation()
  2913 void Vehicle::LeaveStation()
  2909 {
  2914 {
  2910 	assert(IsTileType(tile, MP_STATION) || type == VEH_SHIP);
  2915 	assert(IsTileType(tile, MP_STATION) || type == VEH_SHIP);
  2911 	assert(current_order.type == OT_LOADING);
  2916 	assert(current_order.type == OT_LOADING);
  2912 	current_order.type = OT_LEAVESTATION;
  2917 	current_order.type = OT_LEAVESTATION;
  2913 	current_order.flags = 0;
  2918 	current_order.flags = 0;
  2914 }
  2919 	GetStation(this->last_station_visited)->loading_vehicles.push_back(this);
       
  2920 }