Changeset - r14560:a63b9e37c39e
[Not reviewed]
master
0 3 0
rubidium - 14 years ago 2010-02-15 23:55:04
rubidium@openttd.org
(svn r19141) -Fix [FS#3619] (r18421): look-ahead for multitile waypoints 'made up' data that shouldn't go into the cache, causing desyncs in MP
3 files changed with 22 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/pathfinder/yapf/yapf_costrail.hpp
Show inline comments
 
@@ -401,25 +401,27 @@ no_entry_cost: // jump here at the begin
 

	
 
			end_segment_reason = segment.m_end_segment_reason;
 

	
 
			/* Tests for 'potential target' reasons to close the segment. */
 
			if (cur.tile == prev.tile) {
 
				/* Penalty for reversing in a depot. */
 
				assert(IsRailDepot(cur.tile));
 
				segment_cost += Yapf().PfGetSettings().rail_depot_reverse_penalty;
 
				/* We will end in this pass (depot is possible target) */
 
				end_segment_reason |= ESRB_DEPOT;
 

	
 
			} else if (cur.tile_type == MP_STATION && IsRailWaypoint(cur.tile)) {
 
				if (v->current_order.IsType(OT_GOTO_WAYPOINT) && GetStationIndex(cur.tile) == v->current_order.GetDestination()) {
 
				if (v->current_order.IsType(OT_GOTO_WAYPOINT) &&
 
						GetStationIndex(cur.tile) == v->current_order.GetDestination() &&
 
						!Waypoint::Get(v->current_order.GetDestination())->IsSingleTile()) {
 
					/* This waypoint is our destination; maybe this isn't an unreserved
 
					 * one, so check that and if so see that as the last signal being
 
					 * red. This way waypoints near stations should work better. */
 
					CFollowTrackRail ft(v);
 
					TileIndex t = cur.tile;
 
					Trackdir td = cur.td;
 
					while (ft.Follow(t, td)) {
 
						assert(t != ft.m_new_tile);
 
						t = ft.m_new_tile;
 
						if (KillFirstBit(ft.m_new_td_bits) != TRACKDIR_BIT_NONE) {
 
							/* We encountered a junction; it's going to be too complex to
 
							 * handle this perfectly, so just bail out. There is no simple
src/pathfinder/yapf/yapf_destrail.hpp
Show inline comments
 
@@ -126,26 +126,35 @@ protected:
 
	StationID    m_dest_station_id;
 

	
 
	/** to access inherited path finder */
 
	Tpf& Yapf()
 
	{
 
		return *static_cast<Tpf*>(this);
 
	}
 

	
 
public:
 
	void SetDestination(const Train *v)
 
	{
 
		switch (v->current_order.GetType()) {
 
			case OT_GOTO_WAYPOINT:
 
				if (!Waypoint::Get(v->current_order.GetDestination())->IsSingleTile()) {
 
					/* In case of 'complex' waypoints we need to do a look
 
					 * ahead. This look ahead messes a bit about, which
 
					 * means that it 'corrupts' the cache. To prevent this
 
					 * we disable caching when we're looking for a complex
 
					 * waypoint. */
 
					Yapf().DisableCache(true);
 
				}
 
				/* FALL THROUGH */
 
			case OT_GOTO_STATION:
 
			case OT_GOTO_WAYPOINT:
 
				m_destTile = CalcClosestStationTile(v->current_order.GetDestination(), v->tile, v->current_order.IsType(OT_GOTO_STATION) ? STATION_RAIL : STATION_WAYPOINT);
 
				m_dest_station_id = v->current_order.GetDestination();
 
				m_destTrackdirs = INVALID_TRACKDIR_BIT;
 
				break;
 

	
 
			default:
 
				m_destTile = v->dest_tile;
 
				m_dest_station_id = INVALID_STATION;
 
				m_destTrackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(v->dest_tile, TRANSPORT_RAIL, 0));
 
				break;
 
		}
 
		CYapfDestinationRailBase::SetDestination(v);
src/waypoint_base.h
Show inline comments
 
@@ -31,17 +31,26 @@ struct Waypoint : SpecializedStation<Way
 

	
 
	/* virtual */ void GetTileArea(TileArea *ta, StationType type) const;
 

	
 
	/* virtual */ uint GetPlatformLength(TileIndex tile, DiagDirection dir) const
 
	{
 
		return 1;
 
	}
 

	
 
	/* virtual */ uint GetPlatformLength(TileIndex tile) const
 
	{
 
		return 1;
 
	}
 

	
 
	/**
 
	 * Is this a single tile waypoint?
 
	 * @return true if it is.
 
	 */
 
	FORCEINLINE bool IsSingleTile() const
 
	{
 
		return (this->facilities & FACIL_TRAIN) != 0 && this->train_station.w == 1 && this->train_station.h == 1;
 
	}
 
};
 

	
 
#define FOR_ALL_WAYPOINTS(var) FOR_ALL_BASE_STATIONS_OF_TYPE(Waypoint, var)
 

	
 
#endif /* WAYPOINT_H */
0 comments (0 inline, 0 general)