src/yapf/yapf_destrail.hpp
branchnoai
changeset 9620 31e38d28a0af
parent 6447 3b71e57fd22b
child 9624 b71483f2330f
equal deleted inserted replaced
9619:6e81cec30a2b 9620:31e38d28a0af
    84 	}
    84 	}
    85 
    85 
    86 public:
    86 public:
    87 	void SetDestination(Vehicle* v)
    87 	void SetDestination(Vehicle* v)
    88 	{
    88 	{
    89 		if (v->current_order.type == OT_GOTO_STATION) {
    89 		switch (v->current_order.type) {
    90 			m_destTile = CalcStationCenterTile(v->current_order.dest);
    90 			case OT_GOTO_STATION:
    91 			m_dest_station_id = v->current_order.dest;
    91 				m_destTile = CalcStationCenterTile(v->current_order.dest);
    92 			m_destTrackdirs = INVALID_TRACKDIR_BIT;
    92 				m_dest_station_id = v->current_order.dest;
    93 		} else {
    93 				m_destTrackdirs = INVALID_TRACKDIR_BIT;
    94 			m_destTile = v->dest_tile;
    94 				break;
    95 			m_dest_station_id = INVALID_STATION;
    95 
    96 			m_destTrackdirs = (TrackdirBits)(GetTileTrackStatus(v->dest_tile, TRANSPORT_RAIL) & TRACKDIR_BIT_MASK);
    96 			case OT_GOTO_WAYPOINT: {
       
    97 				Waypoint *wp = GetWaypoint(v->current_order.dest);
       
    98 				if (wp == NULL) {
       
    99 					/* Invalid waypoint in orders! */
       
   100 					DEBUG(yapf, 0, "Invalid waypoint in orders == 0x%04X (train %d, player %d)", v->current_order.dest, v->unitnumber, (PlayerID)v->owner);
       
   101 					break;
       
   102 				}
       
   103 				m_destTile = wp->xy;
       
   104 				if (m_destTile != v->dest_tile) {
       
   105 					/* Something is wrong with orders! */
       
   106 					DEBUG(yapf, 0, "Invalid v->dest_tile == 0x%04X (train %d, player %d)", v->dest_tile, v->unitnumber, (PlayerID)v->owner);
       
   107 				}
       
   108 				m_dest_station_id = INVALID_STATION;
       
   109 				m_destTrackdirs = TrackToTrackdirBits(AxisToTrack(GetWaypointAxis(wp->xy)));
       
   110 				break;
       
   111 			}
       
   112 
       
   113 			default:
       
   114 				m_destTile = v->dest_tile;
       
   115 				m_dest_station_id = INVALID_STATION;
       
   116 				m_destTrackdirs = (TrackdirBits)(GetTileTrackStatus(v->dest_tile, TRANSPORT_RAIL) & TRACKDIR_BIT_MASK);
       
   117 				break;
    97 		}
   118 		}
    98 		CYapfDestinationRailBase::SetDestination(v);
   119 		CYapfDestinationRailBase::SetDestination(v);
    99 	}
   120 	}
   100 
   121 
   101 	/// Called by YAPF to detect if node ends in the desired destination
   122 	/// Called by YAPF to detect if node ends in the desired destination