src/train_cmd.cpp
changeset 8072 7b188d7b8199
parent 8062 eb133d21f363
child 8073 5a254e1c34e7
equal deleted inserted replaced
8071:9232ad90ad93 8072:7b188d7b8199
  3024 	v->cur_speed = 0;
  3024 	v->cur_speed = 0;
  3025 	v->subspeed = 0;
  3025 	v->subspeed = 0;
  3026 	ReverseTrainDirection(v);
  3026 	ReverseTrainDirection(v);
  3027 }
  3027 }
  3028 
  3028 
  3029 extern TileIndex CheckTunnelBusy(TileIndex tile, uint *length);
       
  3030 
       
  3031 /**
  3029 /**
  3032  * Deletes/Clears the last wagon of a crashed train. It takes the engine of the
  3030  * Deletes/Clears the last wagon of a crashed train. It takes the engine of the
  3033  * train, then goes to the last wagon and deletes that. Each call to this function
  3031  * train, then goes to the last wagon and deletes that. Each call to this function
  3034  * will remove the last wagon of a crashed train. If this wagon was on a crossing,
  3032  * will remove the last wagon of a crashed train. If this wagon was on a crossing,
  3035  * or inside a tunnel, recalculate the signals as they might need updating
  3033  * or inside a tunnel, recalculate the signals as they might need updating
  3060 	/* Check if the wagon was on a road/rail-crossing and disable it if no
  3058 	/* Check if the wagon was on a road/rail-crossing and disable it if no
  3061 	 * others are on it */
  3059 	 * others are on it */
  3062 	DisableTrainCrossing(v->tile);
  3060 	DisableTrainCrossing(v->tile);
  3063 
  3061 
  3064 	if ((v->u.rail.track == TRACK_BIT_WORMHOLE && v->vehstatus & VS_HIDDEN)) { // inside a tunnel
  3062 	if ((v->u.rail.track == TRACK_BIT_WORMHOLE && v->vehstatus & VS_HIDDEN)) { // inside a tunnel
  3065 		TileIndex endtile = CheckTunnelBusy(v->tile, NULL);
  3063 		TileIndex endtile = GetOtherTunnelEnd(v->tile);
  3066 
  3064 
  3067 		if (endtile == INVALID_TILE) return; // tunnel is busy (error returned)
  3065 		if (GetVehicleTunnelBridge(v->tile, endtile) != NULL) return; // tunnel is busy (error returned)
  3068 
  3066 
  3069 		switch (v->direction) {
  3067 		switch (v->direction) {
  3070 			case 1:
  3068 			case 1:
  3071 			case 5:
  3069 			case 5:
  3072 				SetSignalsOnBothDir(v->tile, 0);
  3070 				SetSignalsOnBothDir(v->tile, 0);