Use head tile track pieces in Train::GetVehicleTrackdir for trains in wormhole
This commit is contained in:
		@@ -4092,8 +4092,15 @@ Trackdir Train::GetVehicleTrackdir() const
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (this->track == TRACK_BIT_WORMHOLE) {
 | 
						if (this->track == TRACK_BIT_WORMHOLE) {
 | 
				
			||||||
		/* train in tunnel or on bridge, so just use his direction and assume a diagonal track */
 | 
							/* Train in tunnel or on bridge, so just use his direction and make an educated guess
 | 
				
			||||||
		return DiagDirToDiagTrackdir(DirToDiagDir(this->direction));
 | 
							 * given the track bits on the tunnel/bridge head tile.
 | 
				
			||||||
 | 
							 * If a reachable track piece is reserved, use that, otherwise use the first reachable track piece.
 | 
				
			||||||
 | 
							 */
 | 
				
			||||||
 | 
							TrackBits tracks = GetAcrossTunnelBridgeReservationTrackBits(this->tile);
 | 
				
			||||||
 | 
							if (!tracks) tracks = GetAcrossTunnelBridgeTrackBits(this->tile);
 | 
				
			||||||
 | 
							Trackdir td = TrackExitdirToTrackdir(FindFirstTrack(tracks), GetTunnelBridgeDirection(this->tile));
 | 
				
			||||||
 | 
							if (GetTunnelBridgeDirection(this->tile) != DirToDiagDir(this->direction)) td = ReverseTrackdir(td);
 | 
				
			||||||
 | 
							return td;
 | 
				
			||||||
	} else if (this->track & TRACK_BIT_WORMHOLE) {
 | 
						} else if (this->track & TRACK_BIT_WORMHOLE) {
 | 
				
			||||||
		return TrackDirectionToTrackdir(FindFirstTrack(this->track & TRACK_BIT_MASK), this->direction);
 | 
							return TrackDirectionToTrackdir(FindFirstTrack(this->track & TRACK_BIT_MASK), this->direction);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user