Changeset - r8551:25fc15391278
[Not reviewed]
master
0 11 0
smatz - 17 years ago 2008-02-13 14:21:36
smatz@openttd.org
(svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
11 files changed with 81 insertions and 40 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -1046,13 +1046,12 @@ STR_CONFIG_PATCHES_NEW_NONSTOP          
 
STR_CONFIG_PATCHES_ROADVEH_QUEUE                                :{LTBLUE}Road vehicle queueing (with quantum effects): {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_AUTOSCROLL                                   :{LTBLUE}Pan window when mouse is at the edge: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_BRIBE                                        :{LTBLUE}Allow bribing of the local authority: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE                              :{LTBLUE}Allow buying exclusive transport rights: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY                             :{LTBLUE}Allow sending money to other companies: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_NONUNIFORM_STATIONS                          :{LTBLUE}Nonuniform stations: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL                          :{LTBLUE}New global pathfinding (NPF, overrides NTP): {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_FREIGHT_TRAINS                               :{LTBLUE}Weight multiplier for freight to simulate heavy trains: {ORANGE}{STRING}
 
STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD                            :{LTBLUE}Allow drive-through road stops on town owned roads: {ORANGE}{STRING}
 
STR_CONFIG_PATCHES_ADJACENT_STATIONS                            :{LTBLUE}Allow building adjacent stations: {ORANGE}{STRING}
 

	
 
STR_CONFIG_PATCHES_SMALL_AIRPORTS                               :{LTBLUE}Always allow small airports: {ORANGE}{STRING1}
 

	
 
@@ -1201,15 +1200,25 @@ STR_CONFIG_PATCHES_AI                   
 
STR_CONFIG_PATCHES_DISABLED                                     :disabled
 
STR_CONFIG_PATCHES_INT32                                        :{NUM}
 
STR_CONFIG_PATCHES_CURRENCY                                     :{CURRENCY}
 

	
 
STR_CONFIG_PATCHES_QUERY_CAPT                                   :{WHITE}Change setting value
 
STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE                :{WHITE}Some or all of the default service interval(s) below are incompatible with the chosen setting! 5-90% and 30-800 days are valid
 
STR_CONFIG_PATCHES_YAPF_SHIPS                                   :{LTBLUE}Use YAPF for ships: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_YAPF_ROAD                                    :{LTBLUE}Use YAPF for roadvehs: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_YAPF_RAIL                                    :{LTBLUE}Use YAPF for trains: {ORANGE}{STRING1}
 

	
 
STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS                        :{LTBLUE}Pathfinder for trains: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS_NTP                    :NTP {RED}(Not recommended)
 
STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS_NPF                    :NPF
 
STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS_YAPF                   :YAPF {BLUE}(Recommended)
 
STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH                       :{LTBLUE}Pathfinder for road vehicles: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH_OPF                   :Original {RED}(Not recommended)
 
STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH_NPF                   :NPF
 
STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH_YAPF                  :YAPF {BLUE}(Recommended)
 
STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS                         :{LTBLUE}Pathfinder for ships: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS_OPF                     :Original {BLUE}(Recommended)
 
STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS_NPF                     :NPF
 
STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS_YAPF                    :YAPF {RED}(Not recommended)
 

	
 
STR_TEMPERATE_LANDSCAPE                                         :Temperate landscape
 
STR_SUB_ARCTIC_LANDSCAPE                                        :Sub-arctic landscape
 
STR_SUB_TROPICAL_LANDSCAPE                                      :Sub-tropical landscape
 
STR_TOYLAND_LANDSCAPE                                           :Toyland landscape
 

	
src/openttd.cpp
Show inline comments
 
@@ -2395,12 +2395,31 @@ bool AfterLoadGame()
 
						_current_player = o;
 
						DoCommand(t, 0, AxisToTrack(OtherAxis(GetCrossingRoadAxis(t))), DC_EXEC | DC_BANKRUPT, CMD_REMOVE_SINGLE_RAIL);
 
					}
 
				}
 
			}
 
		}
 

	
 
		/* Convert old PF settings to new */
 
		if (_patches.yapf.rail_use_yapf) {
 
			_patches.pathfinder_for_trains = VPF_YAPF;
 
		} else {
 
			_patches.pathfinder_for_trains = (_patches.new_pathfinding_all ? VPF_NPF : VPF_NTP);
 
		}
 

	
 
		if (_patches.yapf.road_use_yapf) {
 
			_patches.pathfinder_for_roadvehs = VPF_YAPF;
 
		} else {
 
			_patches.pathfinder_for_roadvehs = (_patches.new_pathfinding_all ? VPF_NPF : VPF_OPF);
 
		}
 

	
 
		if (_patches.yapf.ship_use_yapf) {
 
			_patches.pathfinder_for_ships = VPF_YAPF;
 
		} else {
 
			_patches.pathfinder_for_ships = (_patches.new_pathfinding_all ? VPF_NPF : VPF_OPF);
 
		}
 
	}
 

	
 
	return InitializeWindowsAndCaches();
 
}
 

	
 
/** Reload all NewGRF files during a running game. This is a cut-down
src/order_cmd.cpp
Show inline comments
 
@@ -325,16 +325,14 @@ CommandCost CmdInsertOrder(TileIndex til
 
	}
 

	
 
	if (sel_ord > v->num_orders) return CMD_ERROR;
 

	
 
	if (!HasOrderPoolFree(1)) return_cmd_error(STR_8831_NO_MORE_SPACE_FOR_ORDERS);
 

	
 
	if (v->type == VEH_SHIP &&
 
			IsHumanPlayer(v->owner) &&
 
			!_patches.new_pathfinding_all) {
 
		// Make sure the new destination is not too far away from the previous
 
	if (v->type == VEH_SHIP && IsHumanPlayer(v->owner) && _patches.pathfinder_for_ships != VPF_NPF) {
 
		/* Make sure the new destination is not too far away from the previous */
 
		const Order *prev = NULL;
 
		uint n = 0;
 

	
 
		/* Find the last goto station or depot order before the insert location.
 
		 * If the order is to be inserted at the beginning of the order list this
 
		 * finds the last order in the list. */
src/roadveh_cmd.cpp
Show inline comments
 
@@ -413,28 +413,28 @@ static bool EnumRoadSignalFindDepot(Tile
 
}
 

	
 
static const Depot* FindClosestRoadDepot(const Vehicle* v)
 
{
 
	TileIndex tile = v->tile;
 

	
 
	if (_patches.yapf.road_use_yapf) {
 
	if (_patches.pathfinder_for_roadvehs == VPF_YAPF) { /* YAPF is being used */
 
		Depot* ret = YapfFindNearestRoadDepot(v);
 
		return ret;
 
	} else if (_patches.new_pathfinding_all) {
 
	} else if (_patches.pathfinder_for_roadvehs == VPF_NPF) { /* NPF is being used */
 
		NPFFoundTargetData ftd;
 
		/* See where we are now */
 
		Trackdir trackdir = GetVehicleTrackdir(v);
 

	
 
		ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, false, v->tile, ReverseTrackdir(trackdir), false, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPES, 0);
 
		if (ftd.best_bird_dist == 0) {
 
			return GetDepotByTile(ftd.node.tile); /* Target found */
 
		} else {
 
			return NULL; /* Target not found */
 
		}
 
		/* We do not search in two directions here, why should we? We can't reverse right now can we? */
 
	} else {
 
	} else { /* OPF is being used */
 
		RoadFindDepotData rfdd;
 

	
 
		rfdd.owner = v->owner;
 
		rfdd.best_length = (uint)-1;
 

	
 
		/* search in all directions */
 
@@ -1214,17 +1214,17 @@ static Trackdir RoadFindPathToDest(Vehic
 

	
 
	/* Only one track to choose between? */
 
	if (KillFirstBit(trackdirs) == TRACKDIR_BIT_NONE) {
 
		return_track(FindFirstBit2x64(trackdirs));
 
	}
 

	
 
	if (_patches.yapf.road_use_yapf) {
 
	if (_patches.pathfinder_for_roadvehs == VPF_YAPF) { /* YAPF */
 
		Trackdir trackdir = YapfChooseRoadTrack(v, tile, enterdir);
 
		if (trackdir != INVALID_TRACKDIR) return_track(trackdir);
 
		return_track(PickRandomBit(trackdirs));
 
	} else if (_patches.new_pathfinding_all) {
 
	} else if (_patches.pathfinder_for_roadvehs == VPF_NPF) { /* NPF */
 
		NPFFindStationOrTileData fstd;
 
		NPFFoundTargetData ftd;
 
		Trackdir trackdir;
 

	
 
		NPFFillWithOrderData(&fstd, v);
 
		trackdir = DiagdirToDiagTrackdir(enterdir);
 
@@ -1240,13 +1240,13 @@ static Trackdir RoadFindPathToDest(Vehic
 
			/* 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. */
 
			return_track(ftd.best_trackdir);
 
		}
 
	} else {
 
	} else { /* OPF */
 
		DiagDirection dir;
 

	
 
		if (IsTileType(desttile, MP_ROAD)) {
 
			if (GetRoadTileType(desttile) == ROAD_TILE_DEPOT) {
 
				dir = GetRoadDepotDirection(desttile);
 
				goto do_it;
 
@@ -1297,13 +1297,13 @@ found_best_track:;
 
	return best_track;
 
}
 

	
 
static uint RoadFindPathToStop(const Vehicle *v, TileIndex tile)
 
{
 
	uint dist;
 
	if (_patches.yapf.road_use_yapf) {
 
	if (_patches.pathfinder_for_roadvehs == VPF_YAPF) {
 
		/* use YAPF */
 
		dist = YapfRoadVehDistanceToTile(v, tile);
 
	} else {
 
		/* use NPF */
 
		NPFFindStationOrTileData fstd;
 
		Trackdir trackdir = GetVehicleTrackdir(v);
src/saveload.cpp
Show inline comments
 
@@ -31,13 +31,13 @@
 
#include "vehicle_base.h"
 
#include "autoreplace_base.h"
 
#include <list>
 

	
 
#include "table/strings.h"
 

	
 
extern const uint16 SAVEGAME_VERSION = 86;
 
extern const uint16 SAVEGAME_VERSION = 87;
 
uint16 _sl_version;       ///< the major savegame version identifier
 
byte   _sl_minor_version; ///< the minor savegame version, DO NOT USE!
 

	
 
typedef void WriterProc(uint len);
 
typedef uint ReaderProc();
 

	
src/settings.cpp
Show inline comments
 
@@ -1397,17 +1397,21 @@ const SettingDesc _patch_settings[] = {
 
	/* Vehicle section of the GUI-configure patches window */
 
	SDT_BOOL(Patches, realistic_acceleration,        0, 0, false,                    STR_CONFIG_PATCHES_REALISTICACCEL,       NULL),
 
	SDT_BOOL(Patches, forbid_90_deg,                 0, 0, false,                    STR_CONFIG_PATCHES_FORBID_90_DEG,        NULL),
 
	SDT_BOOL(Patches, mammoth_trains,                0,NN,  true,                    STR_CONFIG_PATCHES_MAMMOTHTRAINS,        NULL),
 
	SDT_BOOL(Patches, gotodepot,                     0, 0,  true,                    STR_CONFIG_PATCHES_GOTODEPOT,            NULL),
 
	SDT_BOOL(Patches, roadveh_queue,                 0, 0,  true,                    STR_CONFIG_PATCHES_ROADVEH_QUEUE,        NULL),
 
	SDT_BOOL(Patches, new_pathfinding_all,           0, 0, false,                    STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL,  NULL),
 

	
 
	SDT_CONDBOOL(Patches, yapf.ship_use_yapf,      28, SL_MAX_VERSION, 0, 0, false,  STR_CONFIG_PATCHES_YAPF_SHIPS,      NULL),
 
	SDT_CONDBOOL(Patches, yapf.road_use_yapf,      28, SL_MAX_VERSION, 0, 0,  true,  STR_CONFIG_PATCHES_YAPF_ROAD,       NULL),
 
	SDT_CONDBOOL(Patches, yapf.rail_use_yapf,      28, SL_MAX_VERSION, 0, 0,  true,  STR_CONFIG_PATCHES_YAPF_RAIL,       NULL),
 
	SDT_CONDBOOL(Patches, new_pathfinding_all, 0,86, 0, 0, false,                    STR_NULL,                                NULL),
 
	SDT_CONDBOOL(Patches, yapf.ship_use_yapf, 28,86, 0, 0, false,                    STR_NULL,                                NULL),
 
	SDT_CONDBOOL(Patches, yapf.road_use_yapf, 28,86, 0, 0,  true,                    STR_NULL,                                NULL),
 
	SDT_CONDBOOL(Patches, yapf.rail_use_yapf, 28,86, 0, 0,  true,                    STR_NULL,                                NULL),
 

	
 
	SDT_CONDVAR(Patches, pathfinder_for_trains,   SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 2, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS,  NULL),
 
	SDT_CONDVAR(Patches, pathfinder_for_roadvehs, SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 2, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH, NULL),
 
	SDT_CONDVAR(Patches, pathfinder_for_ships,    SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 0, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS,   NULL),
 

	
 
	SDT_BOOL(Patches, train_income_warn,             S, 0,  true,                    STR_CONFIG_PATCHES_WARN_INCOME_LESS,     NULL),
 
	 SDT_VAR(Patches, order_review_system,SLE_UINT8, S,MS,     2,     0,       2, 0, STR_CONFIG_PATCHES_ORDER_REVIEW,         NULL),
 
	SDT_BOOL(Patches, never_expire_vehicles,         0,NN, false,                    STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES,NULL),
 
	SDT_BOOL(Patches, lost_train_warn,               S, 0,  true,                    STR_CONFIG_PATCHES_WARN_LOST_TRAIN,      NULL),
 
	SDT_BOOL(Patches, autorenew,                     S, 0, false,                    STR_CONFIG_PATCHES_AUTORENEW_VEHICLE,    EngineRenewUpdate),
src/settings_gui.cpp
Show inline comments
 
@@ -792,16 +792,15 @@ static const char *_patches_ai[] = {
 
static const char *_patches_vehicles[] = {
 
	"realistic_acceleration",
 
	"forbid_90_deg",
 
	"mammoth_trains",
 
	"gotodepot",
 
	"roadveh_queue",
 
	"new_pathfinding_all",
 
	"yapf.ship_use_yapf",
 
	"yapf.road_use_yapf",
 
	"yapf.rail_use_yapf",
 
	"pathfinder_for_trains",
 
	"pathfinder_for_roadvehs",
 
	"pathfinder_for_ships",
 
	"train_income_warn",
 
	"order_review_system",
 
	"never_expire_vehicles",
 
	"lost_train_warn",
 
	"autorenew",
 
	"autorenew_months",
src/settings_type.h
Show inline comments
 
@@ -123,12 +123,16 @@ struct Patches {
 
	bool servint_ispercent;             ///< service intervals are in percents
 
	uint16 servint_trains;              ///< service interval for trains
 
	uint16 servint_roadveh;             ///< service interval for road vehicles
 
	uint16 servint_aircraft;            ///< service interval for aircraft
 
	uint16 servint_ships;               ///< service interval for ships
 

	
 
	uint8 pathfinder_for_trains;        ///< the pathfinder to use for trains
 
	uint8 pathfinder_for_roadvehs;      ///< the pathfinder to use for roadvehicles
 
	uint8 pathfinder_for_ships;         ///< the pathfinder to use for ships
 

	
 
	bool autorenew;
 
	int16 autorenew_months;
 
	int32 autorenew_money;
 

	
 
	byte pf_maxdepth;                      ///< maximum recursion depth when searching for a train route for new pathfinder
 
	uint16 pf_maxlength;                   ///< maximum length when searching for a train route for new pathfinder
src/ship_cmd.cpp
Show inline comments
 
@@ -117,22 +117,22 @@ static const Depot* FindClosestShipDepot
 
	const Depot* best_depot = NULL;
 
	uint dist;
 
	uint best_dist = (uint)-1;
 
	TileIndex tile;
 
	TileIndex tile2 = v->tile;
 

	
 
	if (_patches.new_pathfinding_all) {
 
	if (_patches.pathfinder_for_ships == VPF_NPF) { /* NPF is used */
 
		NPFFoundTargetData ftd;
 
		Trackdir trackdir = GetVehicleTrackdir(v);
 
		ftd = NPFRouteToDepotTrialError(v->tile, trackdir, false, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPES);
 
		if (ftd.best_bird_dist == 0) {
 
			best_depot = GetDepotByTile(ftd.node.tile); /* Found target */
 
		} else {
 
			best_depot = NULL; /* Did not find target */
 
		}
 
	} else {
 
	} else { /* OPF or YAPF */
 
		FOR_ALL_DEPOTS(depot) {
 
			tile = depot->xy;
 
			if (IsTileDepotType(tile, TRANSPORT_WATER) && IsTileOwner(tile, v->owner)) {
 
				dist = DistanceManhattan(tile, tile2);
 
				if (dist < best_dist) {
 
					best_dist = dist;
 
@@ -524,16 +524,16 @@ static inline NPFFoundTargetData PerfNPF
 
 * 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(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
 
{
 
	assert(enterdir >= 0 && enterdir <= 3);
 

	
 
	if (_patches.yapf.ship_use_yapf) {
 
	if (_patches.pathfinder_for_ships == VPF_YAPF) { /* YAPF */
 
		Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks);
 
		return (trackdir != INVALID_TRACKDIR) ? TrackdirToTrack(trackdir) : INVALID_TRACK;
 
	} else if (_patches.new_pathfinding_all) {
 
	} else if (_patches.pathfinder_for_ships == VPF_NPF) { /* NPF */
 
		NPFFindStationOrTileData fstd;
 
		NPFFoundTargetData ftd;
 
		Trackdir trackdir = GetVehicleTrackdir(v);
 
		assert(trackdir != INVALID_TRACKDIR); // Check that we are not in a depot
 

	
 
		NPFFillWithOrderData(&fstd, v);
 
@@ -546,13 +546,13 @@ static Track ChooseShipTrack(Vehicle *v,
 
			we did not find our target, but ftd.best_trackdir contains the direction leading
 
			to the tile closest to our target. */
 
			return TrackdirToTrack(ftd.best_trackdir); /* TODO: Wrapper function? */
 
		} else {
 
			return INVALID_TRACK; /* Already at target, reverse? */
 
		}
 
	} else {
 
	} else { /* OPF */
 
		uint tot_dist, dist;
 
		Track track;
 
		TileIndex tile2;
 

	
 
		tile2 = TILE_ADD(tile, -TileOffsByDiagDir(enterdir));
 
		tot_dist = (uint)-1;
src/train_cmd.cpp
Show inline comments
 
@@ -2007,16 +2007,16 @@ static TrainFindDepotData FindClosestTra
 
	if (IsTileDepotType(tile, TRANSPORT_RAIL)) {
 
		tfdd.tile = tile;
 
		tfdd.best_length = 0;
 
		return tfdd;
 
	}
 

	
 
	if (_patches.yapf.rail_use_yapf) {
 
	if (_patches.pathfinder_for_trains == VPF_YAPF) { /* YAPF is selected */
 
		bool found = YapfFindNearestRailDepotTwoWay(v, max_distance, NPF_INFINITE_PENALTY, &tfdd.tile, &tfdd.reverse);
 
		tfdd.best_length = found ? max_distance / 2 : -1; // some fake distance or NOT_FOUND
 
	} else if (_patches.new_pathfinding_all) {
 
	} else if (_patches.pathfinder_for_trains == VPF_NPF) { /* NPF is selected */
 
		Vehicle* last = GetLastVehicleInChain(v);
 
		Trackdir trackdir = GetVehicleTrackdir(v);
 
		Trackdir trackdir_rev = ReverseTrackdir(GetVehicleTrackdir(last));
 

	
 
		assert(trackdir != INVALID_TRACKDIR);
 
		NPFFoundTargetData ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, false, last->tile, trackdir_rev, false, TRANSPORT_RAIL, 0, v->owner, v->u.rail.compatible_railtypes, NPF_INFINITE_PENALTY);
 
@@ -2027,13 +2027,13 @@ static TrainFindDepotData FindClosestTra
 
			 * number by this. It might not be completely what we want, but it will
 
			 * work for now :-) We can possibly change this when the old pathfinder
 
			 * is removed. */
 
			tfdd.best_length = ftd.best_path_dist / NPF_TILE_LENGTH;
 
			if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) tfdd.reverse = true;
 
		}
 
	} else {
 
	} else { /* NTP */
 
		/* search in the forward direction first. */
 
		DiagDirection i = TrainExitDir(v->direction, v->u.rail.track);
 
		NewTrainPathfind(tile, 0, v->u.rail.compatible_railtypes, i, (NTPEnumProc*)NtpCallbFindDepot, &tfdd);
 
		if (tfdd.best_length == (uint)-1){
 
			tfdd.reverse = true;
 
			/* search in backwards direction */
 
@@ -2355,20 +2355,20 @@ static Track ChooseTrainTrack(Vehicle* v
 

	
 
	assert((tracks & ~TRACK_BIT_MASK) == 0);
 

	
 
	/* quick return in case only one possible track is available */
 
	if (KillFirstBit(tracks) == TRACK_BIT_NONE) return FindFirstTrack(tracks);
 

	
 
	if (_patches.yapf.rail_use_yapf) {
 
	if (_patches.pathfinder_for_trains == VPF_YAPF) { /* YAPF is selected */
 
		Trackdir trackdir = YapfChooseRailTrack(v, tile, enterdir, tracks, &path_not_found);
 
		if (trackdir != INVALID_TRACKDIR) {
 
			best_track = TrackdirToTrack(trackdir);
 
		} else {
 
			best_track = FindFirstTrack(tracks);
 
		}
 
	} else if (_patches.new_pathfinding_all) { /* Use a new pathfinding for everything */
 
	} else if (_patches.pathfinder_for_trains == VPF_NPF) { /* NPF is selected */
 
		void* perf = NpfBeginInterval();
 

	
 
		NPFFindStationOrTileData fstd;
 
		NPFFillWithOrderData(&fstd, v);
 
		/* The enterdir for the new tile, is the exitdir for the old tile */
 
		Trackdir trackdir = GetVehicleTrackdir(v);
 
@@ -2390,13 +2390,13 @@ static Track ChooseTrainTrack(Vehicle* v
 
			/* Discard enterdir information, making it a normal track */
 
			best_track = TrackdirToTrack(ftd.best_trackdir);
 
		}
 

	
 
		int time = NpfEndInterval(perf);
 
		DEBUG(yapf, 4, "[NPFT] %d us - %d rounds - %d open - %d closed -- ", time, 0, _aystar_stats_open_size, _aystar_stats_closed_size);
 
	} else {
 
	} else { /* NTP is selected */
 
		void* perf = NpfBeginInterval();
 

	
 
		TrainTrackFollowerData fd;
 
		FillWithStationData(&fd, v);
 

	
 
		/* New train pathfinding */
 
@@ -2466,15 +2466,15 @@ static bool CheckReverseTrain(Vehicle *v
 
	uint reverse_best = 0;
 

	
 
	assert(v->u.rail.track);
 

	
 
	int i = _search_directions[FIND_FIRST_BIT(v->u.rail.track)][DirToDiagDir(v->direction)];
 

	
 
	if (_patches.yapf.rail_use_yapf) {
 
	if (_patches.pathfinder_for_trains == VPF_YAPF) { /* YAPF is selected */
 
		reverse_best = YapfCheckReverseTrain(v);
 
	} else if (_patches.new_pathfinding_all) { /* Use a new pathfinding for everything */
 
	} else if (_patches.pathfinder_for_trains == VPF_NPF) { /* NPF if selected for trains */
 
		NPFFindStationOrTileData fstd;
 
		NPFFoundTargetData ftd;
 
		Trackdir trackdir, trackdir_rev;
 
		Vehicle* last = GetLastVehicleInChain(v);
 

	
 
		NPFFillWithOrderData(&fstd, v);
 
@@ -2492,13 +2492,13 @@ static bool CheckReverseTrain(Vehicle *v
 
			if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) {
 
				reverse_best = true;
 
			} else {
 
				reverse_best = false;
 
			}
 
		}
 
	} else {
 
	} else { /* NTP is selected */
 
		int best_track = -1;
 
		uint reverse = 0;
 
		uint best_bird_dist  = 0;
 
		uint best_track_dist = 0;
 

	
 
		for (;;) {
 
@@ -3022,13 +3022,13 @@ static void TrainController(Vehicle *v, 
 

	
 
				/* Combine the from & to directions.
 
				 * Now, the lower byte contains the track status, and the byte at bit 16 contains
 
				 * the signal status. */
 
				uint32 tracks = ts | (ts >> 8);
 
				TrackBits bits = (TrackBits)(tracks & TRACK_BIT_MASK);
 
				if ((_patches.new_pathfinding_all || _patches.yapf.rail_use_yapf) && _patches.forbid_90_deg && prev == NULL) {
 
				if ((_patches.pathfinder_for_trains != VPF_NTP) && _patches.forbid_90_deg && prev == NULL) {
 
					/* We allow wagons to make 90 deg turns, because forbid_90_deg
 
					 * can be switched on halfway a turn */
 
					bits &= ~TrackCrossesTracks(FindFirstTrack(v->u.rail.track));
 
				}
 

	
 
				if (bits == TRACK_BIT_NONE) goto invalid_rail;
 
@@ -3456,13 +3456,13 @@ static bool TrainCheckIfLineEnds(Vehicle
 
	uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL, 0) & _reachable_tracks[dir];
 

	
 
	/* We are sure the train is not entering a depot, it is detected above */
 

	
 
	/* mask unreachable track bits if we are forbidden to do 90deg turns */
 
	TrackBits bits = (TrackBits)((ts | (ts >> 8)) & TRACK_BIT_MASK);
 
	if ((_patches.new_pathfinding_all || _patches.yapf.rail_use_yapf) && _patches.forbid_90_deg) {
 
	if ((_patches.pathfinder_for_trains != VPF_NTP) && _patches.forbid_90_deg) {
 
		bits &= ~TrackCrossesTracks(FindFirstTrack(v->u.rail.track));
 
	}
 

	
 
	/* no suitable trackbits at all || wrong railtype || not our track ||
 
	 *   tunnel/bridge from opposite side || depot from opposite side */
 
	if (bits == TRACK_BIT_NONE || !CheckCompatibleRail(v, tile) || GetTileOwner(tile) != v->owner ||
src/vehicle_type.h
Show inline comments
 
@@ -49,7 +49,15 @@ enum EffectVehicle {
 
	EV_BREAKDOWN_SMOKE = 6,
 
	EV_EXPLOSION_SMALL = 7,
 
	EV_BULLDOZER       = 8,
 
	EV_BUBBLE          = 9
 
};
 

	
 
/** Pathfinding option states */
 
enum {
 
	VPF_OPF  = 0, ///< The Original PathFinder
 
	VPF_NTP  = 0, ///< New Train Pathfinder, replacing OPF for trains
 
	VPF_NPF  = 1, ///< New PathFinder
 
	VPF_YAPF = 2, ///< Yet Another PathFinder
 
};
 

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