Changeset - r13828:41995609971a
[Not reviewed]
master
0 12 1
rubidium - 15 years ago 2009-12-01 23:56:04
rubidium@openttd.org
(svn r18367) -Codechange: unify the ship pathfinder 'calls'
13 files changed with 273 insertions and 241 deletions:
0 comments (0 inline, 0 general)
projects/openttd_vs80.vcproj
Show inline comments
 
@@ -469,16 +469,12 @@
 
			</File>
 
			<File
 
				RelativePath=".\..\src\autoreplace.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\aystar.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\bmp.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\callback_table.cpp"
 
				>
 
@@ -637,36 +633,24 @@
 
			</File>
 
			<File
 
				RelativePath=".\..\src\network\network_udp.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\npf.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\openttd.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\os_timer.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfind.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pbs.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\queue.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\rail.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\rev.cpp"
 
				>
 
@@ -805,16 +789,12 @@
 
			</File>
 
			<File
 
				RelativePath=".\..\src\autoslope.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\aystar.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\base_media_base.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\base_media_func.h"
 
				>
 
@@ -1253,16 +1233,12 @@
 
			</File>
 
			<File
 
				RelativePath=".\..\src\news_type.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\npf.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\music\null_m.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\sound\null_s.h"
 
				>
 
@@ -1285,28 +1261,20 @@
 
			</File>
 
			<File
 
				RelativePath=".\..\src\order_type.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfind.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pbs.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\querystring_gui.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\queue.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\rail.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\rail_gui.h"
 
				>
 
@@ -3478,76 +3446,124 @@
 
			<File
 
				RelativePath=".\..\src\network\core\udp.h"
 
				>
 
			</File>
 
		</Filter>
 
		<Filter
 
			Name="Pathfinder"
 
			>
 
			<File
 
				RelativePath=".\..\src\pathfinder\opf\opf_ship.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\opf\opf_ship.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\pathfinder_func.h"
 
				>
 
			</File>
 
		</Filter>
 
		<Filter
 
			Name="NPF"
 
			>
 
			<File
 
				RelativePath=".\..\src\pathfinder\npf\aystar.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\npf\aystar.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\npf\queue.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\npf\queue.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\npf\npf.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\npf\npf.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\npf\npf_func.h"
 
				>
 
			</File>
 
		</Filter>
 
		<Filter
 
			Name="YAPF"
 
			>
 
			<File
 
				RelativePath=".\..\src\yapf\follow_track.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\nodelist.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_base.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_common.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_costbase.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_costcache.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_costrail.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_destrail.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_node.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_node_rail.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_node_road.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_rail.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_road.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_ship.cpp"
 
				RelativePath=".\..\src\pathfinder\yapf\follow_track.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\nodelist.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_base.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_common.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_costbase.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_costcache.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_costrail.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_destrail.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_node.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_node_rail.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_node_road.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_rail.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_road.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_ship.cpp"
 
				>
 
			</File>
 
		</Filter>
 
		<Filter
 
			Name="Video"
 
			>
projects/openttd_vs90.vcproj
Show inline comments
 
@@ -466,16 +466,12 @@
 
			</File>
 
			<File
 
				RelativePath=".\..\src\autoreplace.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\aystar.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\bmp.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\callback_table.cpp"
 
				>
 
@@ -634,36 +630,24 @@
 
			</File>
 
			<File
 
				RelativePath=".\..\src\network\network_udp.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\npf.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\openttd.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\os_timer.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfind.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pbs.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\queue.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\rail.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\rev.cpp"
 
				>
 
@@ -802,16 +786,12 @@
 
			</File>
 
			<File
 
				RelativePath=".\..\src\autoslope.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\aystar.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\base_media_base.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\base_media_func.h"
 
				>
 
@@ -1250,16 +1230,12 @@
 
			</File>
 
			<File
 
				RelativePath=".\..\src\news_type.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\npf.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\music\null_m.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\sound\null_s.h"
 
				>
 
@@ -1282,28 +1258,20 @@
 
			</File>
 
			<File
 
				RelativePath=".\..\src\order_type.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfind.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pbs.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\querystring_gui.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\queue.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\rail.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\rail_gui.h"
 
				>
 
@@ -3475,76 +3443,124 @@
 
			<File
 
				RelativePath=".\..\src\network\core\udp.h"
 
				>
 
			</File>
 
		</Filter>
 
		<Filter
 
			Name="Pathfinder"
 
			>
 
			<File
 
				RelativePath=".\..\src\pathfinder\opf\opf_ship.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\opf\opf_ship.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\pathfinder_func.h"
 
				>
 
			</File>
 
		</Filter>
 
		<Filter
 
			Name="NPF"
 
			>
 
			<File
 
				RelativePath=".\..\src\pathfinder\npf\aystar.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\npf\aystar.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\npf\queue.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\npf\queue.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\npf\npf.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\npf\npf.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\npf\npf_func.h"
 
				>
 
			</File>
 
		</Filter>
 
		<Filter
 
			Name="YAPF"
 
			>
 
			<File
 
				RelativePath=".\..\src\yapf\follow_track.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\nodelist.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_base.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_common.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_costbase.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_costcache.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_costrail.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_destrail.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_node.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_node_rail.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_node_road.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_rail.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_road.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\yapf\yapf_ship.cpp"
 
				RelativePath=".\..\src\pathfinder\yapf\follow_track.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\nodelist.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_base.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_common.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_costbase.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_costcache.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_costrail.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_destrail.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_node.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_node_rail.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_node_road.hpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_rail.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_road.cpp"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\pathfinder\yapf\yapf_ship.cpp"
 
				>
 
			</File>
 
		</Filter>
 
		<Filter
 
			Name="Video"
 
			>
source.list
Show inline comments
 
@@ -822,12 +822,13 @@ pathfinder/pathfinder_func.h
 
pathfinder/npf/aystar.cpp
 
pathfinder/npf/aystar.h
 
pathfinder/npf/queue.cpp
 
pathfinder/npf/queue.h
 
pathfinder/npf/npf.cpp
 
pathfinder/npf/npf.h
 
pathfinder/npf/npf_func.h
 

	
 
# YAPF
 
pathfinder/yapf/follow_track.hpp
 
pathfinder/yapf/nodelist.hpp
 
pathfinder/yapf/yapf.h
 
pathfinder/yapf/yapf.hpp
src/pathfinder/npf/npf.cpp
Show inline comments
 
@@ -16,12 +16,13 @@
 
#include "../../network/network.h"
 
#include "../../tunnelbridge_map.h"
 
#include "../../functions.h"
 
#include "../../tunnelbridge.h"
 
#include "../../pbs.h"
 
#include "../../train.h"
 
#include "../../ship.h"
 
#include "../pathfinder_func.h"
 
#include "npf.h"
 

	
 
static AyStar _npf_aystar;
 

	
 
/* The cost of each trackdir. A diagonal piece is the full NPF_TILE_LENGTH,
 
@@ -1115,6 +1116,26 @@ void NPFFillWithOrderData(NPFFindStation
 
		fstd->dest_coords = v->dest_tile;
 
		fstd->station_index = INVALID_STATION;
 
	}
 
	fstd->reserve_path = reserve_path;
 
	fstd->v = v;
 
}
 

	
 
/*** Ships ***/
 

	
 
Track NPFShipChooseTrack(Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
 
{
 
	NPFFindStationOrTileData fstd;
 
	Trackdir trackdir = v->GetVehicleTrackdir();
 
	assert(trackdir != INVALID_TRACKDIR); // Check that we are not in a depot
 

	
 
	NPFFillWithOrderData(&fstd, v);
 

	
 
	NPFFoundTargetData ftd = NPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, true, &fstd, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPES);
 

	
 
	/* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains
 
		* the direction we need to take to get there, if ftd.best_bird_dist is not 0,
 
		* we did not find our target, but ftd.best_trackdir contains the direction leading
 
		* to the tile closest to our target. */
 
	if (ftd.best_trackdir == 0xff) return INVALID_TRACK;
 
	return TrackdirToTrack(ftd.best_trackdir);
 
}
src/pathfinder/npf/npf_func.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/*
 
 * This file is part of OpenTTD.
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file npf_func.h Functions to access the new pathfinder. */
 

	
 
#ifndef NPF_FUNC_H
 
#define NPF_FUNC_H
 

	
 
Track NPFShipChooseTrack(class Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks);
 

	
 
#endif /* NPF_FUNC_H */
src/pathfinder/yapf/yapf.h
Show inline comments
 
@@ -9,26 +9,23 @@
 

	
 
/** @file yapf.h Entry point for OpenTTD to YAPF. */
 

	
 
#ifndef  YAPF_H
 
#define  YAPF_H
 

	
 
#include "../../debug.h"
 
#include "../../depot_type.h"
 
#include "../../direction_type.h"
 
#include "../../station_type.h"
 
#include "../../pbs.h"
 

	
 
/** Finds the best path for given ship.
 
 * @param v        the ship that needs to find a path
 
 * @param tile     the tile to find the path from (should be next tile the ship is about to enter)
 
 * @param enterdir diagonal direction which the ship will enter this new tile from
 
 * @param tracks   available tracks on the new tile (to choose from)
 
 * @return         the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
 
 * @return         the best trackdir for next turn or INVALID_TRACK if the path could not be found
 
 */
 
Trackdir YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks);
 
Track YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks);
 

	
 
/** Finds the best path for given road vehicle.
 
 * @param v        the RV that needs to find a path
 
 * @param tile     the tile to find the path from (should be next tile the RV is about to enter)
 
 * @param enterdir diagonal direction which the RV will enter this new tile from
 
 * @return         the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
 
@@ -42,13 +39,13 @@ Trackdir YapfChooseRoadTrack(const Vehic
 
 * @param tracks   available trackdirs on the new tile (to choose from)
 
 * @param path_not_found [out] true is returned if no path can be found (returned Trackdir is only a 'guess')
 
 * @param reserve_track indicates whether YAPF should try to reserve the found path
 
 * @param target   [out] the target tile of the reservation, free is set to true if path was reserved
 
 * @return         the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
 
 */
 
Trackdir YapfChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, PBSTileInfo *target);
 
Trackdir YapfChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, struct PBSTileInfo *target);
 

	
 
/** Used by RV multistop feature to find the nearest road stop that has a free slot.
 
 * @param v      RV (its current tile will be the origin)
 
 * @param tile   destination tile
 
 * @return       distance from origin tile to the destination (number of road tiles) or UINT_MAX if path not found
 
 */
src/pathfinder/yapf/yapf.hpp
Show inline comments
 
@@ -21,12 +21,13 @@
 
#include "../../bridge.h"
 
#include "../../station_map.h"
 
#include "../../tile_cmd.h"
 
#include "../../landscape.h"
 
#include "yapf.h"
 
#include "../pathfinder_func.h"
 
#include "../../pbs.h"
 
#include "../../waypoint_base.h"
 
#include "../../debug.h"
 
#include "../../settings_type.h"
 
#include "../../tunnelbridge.h"
 

	
 
extern uint64 ottd_rdtsc();
src/pathfinder/yapf/yapf_ship.cpp
Show inline comments
 
@@ -164,13 +164,13 @@ struct CYapfShip1 : CYapfT<CYapfShip_Typ
 
/* YAPF type 2 - uses TileIndex/DiagDirection as Node key, allows 90-deg turns */
 
struct CYapfShip2 : CYapfT<CYapfShip_TypesT<CYapfShip2, CFollowTrackWater    , CShipNodeListExitDir > > {};
 
/* YAPF type 3 - uses TileIndex/Trackdir as Node key, forbids 90-deg turns */
 
struct CYapfShip3 : CYapfT<CYapfShip_TypesT<CYapfShip3, CFollowTrackWaterNo90, CShipNodeListTrackDir> > {};
 

	
 
/** Ship controller helper - path finder invoker */
 
Trackdir YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
 
Track YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
 
{
 
	/* default is YAPF type 2 */
 
	typedef Trackdir (*PfnChooseShipTrack)(const Vehicle*, TileIndex, DiagDirection, TrackBits);
 
	PfnChooseShipTrack pfnChooseShipTrack = CYapfShip2::ChooseShipTrack; // default: ExitDir, allow 90-deg
 

	
 
	/* check if non-default YAPF type needed */
 
@@ -178,13 +178,13 @@ Trackdir YapfChooseShipTrack(const Vehic
 
		pfnChooseShipTrack = &CYapfShip3::ChooseShipTrack; // Trackdir, forbid 90-deg
 
	} else if (_settings_game.pf.yapf.disable_node_optimization) {
 
		pfnChooseShipTrack = &CYapfShip1::ChooseShipTrack; // Trackdir, allow 90-deg
 
	}
 

	
 
	Trackdir td_ret = pfnChooseShipTrack(v, tile, enterdir, tracks);
 
	return td_ret;
 
	return (td_ret != INVALID_TRACKDIR) ? TrackdirToTrack(td_ret) : INVALID_TRACK;
 
}
 

	
 
/** performance measurement helper */
 
void *NpfBeginInterval()
 
{
 
	CPerformanceTimer& perf = *new CPerformanceTimer;
src/rail_cmd.cpp
Show inline comments
 
@@ -30,12 +30,13 @@
 
#include "vehicle_func.h"
 
#include "sound_func.h"
 
#include "tunnelbridge.h"
 
#include "functions.h"
 
#include "elrail_func.h"
 
#include "town.h"
 
#include "pbs.h"
 

	
 
#include "table/strings.h"
 
#include "table/railtypes.h"
 
#include "table/track_land.h"
 

	
 
RailtypeInfo _railtypes[RAILTYPE_END];
src/roadveh_cmd.cpp
Show inline comments
 
@@ -34,12 +34,13 @@
 
#include "ai/ai.hpp"
 
#include "depot_map.h"
 
#include "effectvehicle_func.h"
 
#include "roadstop_base.h"
 
#include "cargotype.h"
 
#include "spritecache.h"
 
#include "debug.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 

	
 
static const uint16 _roadveh_images[63] = {
 
	0xCD4, 0xCDC, 0xCE4, 0xCEC, 0xCF4, 0xCFC, 0xD0C, 0xD14,
src/ship_cmd.cpp
Show inline comments
 
@@ -13,13 +13,13 @@
 
#include "ship.h"
 
#include "landscape.h"
 
#include "timetable.h"
 
#include "command_func.h"
 
#include "news_func.h"
 
#include "company_func.h"
 
#include "pathfinder/npf/npf.h"
 
#include "pathfinder/npf/npf_func.h"
 
#include "depot_base.h"
 
#include "station_base.h"
 
#include "vehicle_gui.h"
 
#include "newgrf_engine.h"
 
#include "pathfinder/yapf/yapf.h"
 
#include "newgrf_sound.h"
 
@@ -96,23 +96,13 @@ SpriteID Ship::GetImage(Direction direct
 

	
 
	return _ship_sprites[spritenum] + direction;
 
}
 

	
 
static const Depot *FindClosestShipDepot(const Vehicle *v)
 
{
 
	if (_settings_game.pf.pathfinder_for_ships == VPF_NPF) { // NPF is used
 
		Trackdir trackdir = v->GetVehicleTrackdir();
 
		NPFFoundTargetData ftd = NPFRouteToDepotTrialError(v->tile, trackdir, false, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPES);
 

	
 
		if (ftd.best_bird_dist == 0) return Depot::GetByTile(ftd.node.tile); // Found target
 

	
 
		return NULL; // Did not find target
 
	}
 

	
 
	/* OPF or YAPF - find the closest depot */
 

	
 
	/* Find the closest depot */
 
	const Depot *depot;
 
	const Depot *best_depot = NULL;
 
	uint best_dist = UINT_MAX;
 

	
 
	FOR_ALL_DEPOTS(depot) {
 
		TileIndex tile = depot->xy;
 
@@ -366,57 +356,25 @@ static void ShipArrivesAt(const Vehicle 
 
		);
 
		AI::NewEvent(v->owner, new AIEventStationFirstVehicle(st->index, v->index));
 
	}
 
}
 

	
 

	
 
static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, bool ignore_start_tile, NPFFindStationOrTileData *target, TransportType type, Owner owner, RailTypes railtypes)
 
{
 

	
 
	void *perf = NpfBeginInterval();
 
	NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, ignore_start_tile, target, type, 0, owner, railtypes);
 
	int t = NpfEndInterval(perf);
 
	DEBUG(yapf, 4, "[NPFW] %d us - %d rounds - %d open - %d closed -- ", t, 0, _aystar_stats_open_size, _aystar_stats_closed_size);
 
	return ret;
 
}
 

	
 
/** returns the track to choose on the next tile, or -1 when it's better to
 
 * reverse. The tile given is the tile we are about to enter, enterdir is the
 
 * direction in which we are entering the tile */
 
static Track ChooseShipTrack(Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
 
{
 
	assert(IsValidDiagDirection(enterdir));
 

	
 
	switch (_settings_game.pf.pathfinder_for_ships) {
 
		case VPF_YAPF: { // YAPF
 
			Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks);
 
			if (trackdir != INVALID_TRACKDIR) return TrackdirToTrack(trackdir);
 
		} break;
 

	
 
		case VPF_NPF: { // NPF
 
			NPFFindStationOrTileData fstd;
 
			Trackdir trackdir = v->GetVehicleTrackdir();
 
			assert(trackdir != INVALID_TRACKDIR); // Check that we are not in a depot
 

	
 
			NPFFillWithOrderData(&fstd, v);
 

	
 
			NPFFoundTargetData ftd = PerfNPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, true, &fstd, TRANSPORT_WATER, v->owner, INVALID_RAILTYPES);
 

	
 
			/* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains
 
			 * the direction we need to take to get there, if ftd.best_bird_dist is not 0,
 
			 * we did not find our target, but ftd.best_trackdir contains the direction leading
 
			 * to the tile closest to our target. */
 
			if (ftd.best_trackdir != 0xff) return TrackdirToTrack(ftd.best_trackdir); // TODO: Wrapper function?
 
		} break;
 

	
 
		case VPF_OPF: return OPFShipChooseTrack(v, tile, enterdir, tracks);
 
		case VPF_NPF: return NPFShipChooseTrack(v, tile, enterdir, tracks);
 
		case VPF_YAPF: return YapfChooseShipTrack(v, tile, enterdir, tracks);
 
		default: NOT_REACHED();
 

	
 
		case VPF_OPF: return OPFShipChooseTrack(v, tile, enterdir, tracks);
 
	}
 

	
 
	return INVALID_TRACK; // We could better reverse
 
}
 

	
 
static const Direction _new_vehicle_direction_table[] = {
 
	DIR_N , DIR_NW, DIR_W , INVALID_DIR,
 
	DIR_NE, DIR_N , DIR_SW, INVALID_DIR,
 
	DIR_E , DIR_SE, DIR_S
src/station_cmd.cpp
Show inline comments
 
@@ -40,12 +40,14 @@
 
#include "animated_tile_func.h"
 
#include "elrail_func.h"
 
#include "station_base.h"
 
#include "roadstop_base.h"
 
#include "waypoint_base.h"
 
#include "waypoint_func.h"
 
#include "pbs.h"
 
#include "debug.h"
 

	
 
#include "table/strings.h"
 

	
 
/**
 
 * Check whether the given tile is a hangar.
 
 * @param t the tile to of whether it is a hangar.
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -35,12 +35,13 @@
 
#include "vehicle_func.h"
 
#include "sound_func.h"
 
#include "tunnelbridge.h"
 
#include "cheat_type.h"
 
#include "elrail_func.h"
 
#include "landscape_type.h"
 
#include "pbs.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "table/bridge_land.h"
 

	
 
BridgeSpec _bridge[MAX_BRIDGES];
0 comments (0 inline, 0 general)