src/yapf/yapf_costrail.hpp
branchgamebalance
changeset 9913 e79cd19772dd
parent 9912 1ac8aac92385
child 7533 f43efe7a2b23
equal deleted inserted replaced
9912:1ac8aac92385 9913:e79cd19772dd
   193 		TileType tile_type = GetTileType(tile);
   193 		TileType tile_type = GetTileType(tile);
   194 
   194 
   195 		RailType rail_type = GetTileRailType(tile);
   195 		RailType rail_type = GetTileRailType(tile);
   196 
   196 
   197 		bool target_seen = Yapf().PfDetectDestination(tile, trackdir);
   197 		bool target_seen = Yapf().PfDetectDestination(tile, trackdir);
       
   198 		bool end_by_target_seen = false;
   198 
   199 
   199 		if (tf.m_is_station) {
   200 		if (tf.m_is_station) {
   200 			// station tiles have an extra penalty
   201 			// station tiles have an extra penalty
   201 			segment_cost += Yapf().PfGetSettings().rail_station_penalty * (tf.m_tiles_skipped + 1);
   202 			segment_cost += Yapf().PfGetSettings().rail_station_penalty * (tf.m_tiles_skipped + 1);
   202 		}
   203 		}
   210 				break;
   211 				break;
   211 			}
   212 			}
   212 
   213 
   213 			// finish if we have reached the destination
   214 			// finish if we have reached the destination
   214 			if (target_seen) {
   215 			if (target_seen) {
       
   216 				end_by_target_seen = true;
   215 				break;
   217 				break;
   216 			}
   218 			}
   217 
   219 
   218 			// finish on first station tile - segment should end here to avoid target skipping
   220 			// finish on first station tile - segment should end here to avoid target skipping
   219 			// when cached segments are used
   221 			// when cached segments are used
   340 			// save end of segment back to the node
   342 			// save end of segment back to the node
   341 			n.SetLastTileTrackdir(tile, trackdir);
   343 			n.SetLastTileTrackdir(tile, trackdir);
   342 		}
   344 		}
   343 
   345 
   344 		// special costs for the case we have reached our target
   346 		// special costs for the case we have reached our target
   345 		if (target_seen) {
   347 		if (end_by_target_seen) {
   346 			n.flags_u.flags_s.m_targed_seen = true;
   348 			n.flags_u.flags_s.m_targed_seen = true;
   347 			if (n.flags_u.flags_s.m_last_signal_was_red) {
   349 			if (n.flags_u.flags_s.m_last_signal_was_red) {
   348 				if (n.m_last_red_signal_type == SIGTYPE_EXIT) {
   350 				if (n.m_last_red_signal_type == SIGTYPE_EXIT) {
   349 					// last signal was red pre-signal-exit
   351 					// last signal was red pre-signal-exit
   350 					extra_cost += Yapf().PfGetSettings().rail_lastred_exit_penalty;
   352 					extra_cost += Yapf().PfGetSettings().rail_lastred_exit_penalty;
   356 		}
   358 		}
   357 
   359 
   358 		// total node cost
   360 		// total node cost
   359 		n.m_cost = parent_cost + first_tile_cost + segment_cost + extra_cost;
   361 		n.m_cost = parent_cost + first_tile_cost + segment_cost + extra_cost;
   360 
   362 
   361 		return !n.m_segment->flags_u.flags_s.m_end_of_line;
   363 		return !n.m_segment->flags_u.flags_s.m_end_of_line || end_by_target_seen;
   362 	}
   364 	}
   363 
   365 
   364 	FORCEINLINE bool CanUseGlobalCache(Node& n) const
   366 	FORCEINLINE bool CanUseGlobalCache(Node& n) const
   365 	{
   367 	{
   366 		return (n.m_parent != NULL)
   368 		return (n.m_parent != NULL)