src/train_cmd.cpp
changeset 8734 b7fc8c6fd379
parent 8732 b18f578f7c16
child 8744 f926fa3978c8
equal deleted inserted replaced
8733:9e2d2a2619ff 8734:b7fc8c6fd379
    41 #include "functions.h"
    41 #include "functions.h"
    42 #include "window_func.h"
    42 #include "window_func.h"
    43 #include "date_func.h"
    43 #include "date_func.h"
    44 #include "vehicle_func.h"
    44 #include "vehicle_func.h"
    45 #include "sound_func.h"
    45 #include "sound_func.h"
       
    46 #include "signal_func.h"
    46 #include "variables.h"
    47 #include "variables.h"
    47 #include "autoreplace_gui.h"
    48 #include "autoreplace_gui.h"
    48 #include "gfx_func.h"
    49 #include "gfx_func.h"
    49 
    50 
    50 
    51 
  2154 			return true;
  2155 			return true;
  2155 		}
  2156 		}
  2156 
  2157 
  2157 		v->load_unload_time_rem = 0;
  2158 		v->load_unload_time_rem = 0;
  2158 
  2159 
  2159 		if (UpdateSignalsOnSegment(v->tile, DirToDiagDir(v->direction))) {
  2160 		if (UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR)) {
  2160 			InvalidateWindowClasses(WC_TRAINS_LIST);
  2161 			InvalidateWindowClasses(WC_TRAINS_LIST);
  2161 			return true;
  2162 			return true;
  2162 		}
  2163 		}
  2163 	}
  2164 	}
  2164 
  2165 
  2173 	v->cur_speed = 0;
  2174 	v->cur_speed = 0;
  2174 
  2175 
  2175 	v->UpdateDeltaXY(v->direction);
  2176 	v->UpdateDeltaXY(v->direction);
  2176 	v->cur_image = v->GetImage(v->direction);
  2177 	v->cur_image = v->GetImage(v->direction);
  2177 	VehiclePositionChanged(v);
  2178 	VehiclePositionChanged(v);
  2178 	UpdateSignalsOnSegment(v->tile, DirToDiagDir(v->direction));
  2179 	UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR);
  2179 	UpdateTrainAcceleration(v);
  2180 	UpdateTrainAcceleration(v);
  2180 	InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
  2181 	InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
  2181 
  2182 
  2182 	return false;
  2183 	return false;
  2183 }
  2184 }
  3112 	EndVehicleMove(v);
  3113 	EndVehicleMove(v);
  3113 
  3114 
  3114 	delete v;
  3115 	delete v;
  3115 
  3116 
  3116 	if (v->u.rail.track != TRACK_BIT_DEPOT && v->u.rail.track != TRACK_BIT_WORMHOLE)
  3117 	if (v->u.rail.track != TRACK_BIT_DEPOT && v->u.rail.track != TRACK_BIT_WORMHOLE)
  3117 		SetSignalsOnBothDir(v->tile, FIND_FIRST_BIT(v->u.rail.track));
  3118 		SetSignalsOnBothDir(v->tile, (Track)(FIND_FIRST_BIT(v->u.rail.track)));
  3118 
  3119 
  3119 	/* Check if the wagon was on a road/rail-crossing and disable it if no
  3120 	/* Check if the wagon was on a road/rail-crossing and disable it if no
  3120 	 * others are on it */
  3121 	 * others are on it */
  3121 	DisableTrainCrossing(v->tile);
  3122 	DisableTrainCrossing(v->tile);
  3122 
  3123 
  3123 	if (v->u.rail.track == TRACK_BIT_WORMHOLE) { // inside a tunnel / bridge
  3124 	if (v->u.rail.track == TRACK_BIT_WORMHOLE) { // inside a tunnel / bridge
  3124 		TileIndex endtile = GetOtherTunnelBridgeEnd(v->tile);
  3125 		TileIndex endtile = GetOtherTunnelBridgeEnd(v->tile);
  3125 
  3126 
  3126 		if (GetVehicleTunnelBridge(v->tile, endtile) != NULL) return; // tunnel / bridge is busy
  3127 		if (GetVehicleTunnelBridge(v->tile, endtile) != NULL) return; // tunnel / bridge is busy
  3127 
  3128 
  3128 		DiagDirection dir = GetTunnelBridgeDirection(v->tile);
       
  3129 
       
  3130 		/* v->direction is "random", so it cannot be used to determine the direction of the track */
  3129 		/* v->direction is "random", so it cannot be used to determine the direction of the track */
  3131 		UpdateSignalsOnSegment(v->tile, dir);
  3130 		UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR);
  3132 		UpdateSignalsOnSegment(endtile, ReverseDiagDir(dir));
       
  3133 	}
  3131 	}
  3134 }
  3132 }
  3135 
  3133 
  3136 static void ChangeTrainDirRandomly(Vehicle *v)
  3134 static void ChangeTrainDirRandomly(Vehicle *v)
  3137 {
  3135 {