(svn r18372) -Codechange: push some extra type safety into YAPF
This commit is contained in:
@@ -60,7 +60,7 @@ private:
|
||||
|
||||
bool FindSafePositionProc(TileIndex tile, Trackdir td)
|
||||
{
|
||||
if (IsSafeWaitingPosition(Train::From(Yapf().GetVehicle()), tile, td, true, !TrackFollower::Allow90degTurns())) {
|
||||
if (IsSafeWaitingPosition(Yapf().GetVehicle(), tile, td, true, !TrackFollower::Allow90degTurns())) {
|
||||
m_res_dest = tile;
|
||||
m_res_dest_td = td;
|
||||
return false; // Stop iterating segment
|
||||
@@ -155,7 +155,7 @@ public:
|
||||
}
|
||||
|
||||
/* Don't bother if the target is reserved. */
|
||||
if (!IsWaitingPositionFree(Train::From(Yapf().GetVehicle()), m_res_dest, m_res_dest_td)) return false;
|
||||
if (!IsWaitingPositionFree(Yapf().GetVehicle(), m_res_dest, m_res_dest_td)) return false;
|
||||
|
||||
for (Node *node = m_res_node; node->m_parent != NULL; node = node->m_parent) {
|
||||
node->IterateTiles(Yapf().GetVehicle(), Yapf(), *this, &CYapfReserveTrack<Types>::ReserveSingleTrack);
|
||||
@@ -216,7 +216,7 @@ public:
|
||||
return 't';
|
||||
}
|
||||
|
||||
static bool stFindNearestDepotTwoWay(const Vehicle *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_distance, int reverse_penalty, TileIndex *depot_tile, bool *reversed)
|
||||
static bool stFindNearestDepotTwoWay(const Train *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_distance, int reverse_penalty, TileIndex *depot_tile, bool *reversed)
|
||||
{
|
||||
Tpf pf1;
|
||||
/*
|
||||
@@ -246,7 +246,7 @@ public:
|
||||
return result1;
|
||||
}
|
||||
|
||||
FORCEINLINE bool FindNearestDepotTwoWay(const Vehicle *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_distance, int reverse_penalty, TileIndex *depot_tile, bool *reversed)
|
||||
FORCEINLINE bool FindNearestDepotTwoWay(const Train *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_distance, int reverse_penalty, TileIndex *depot_tile, bool *reversed)
|
||||
{
|
||||
/* set origin and destination nodes */
|
||||
Yapf().SetOrigin(t1, td1, t2, td2, reverse_penalty, true);
|
||||
@@ -310,7 +310,7 @@ public:
|
||||
return 't';
|
||||
}
|
||||
|
||||
static bool stFindNearestSafeTile(const Vehicle *v, TileIndex t1, Trackdir td, bool override_railtype)
|
||||
static bool stFindNearestSafeTile(const Train *v, TileIndex t1, Trackdir td, bool override_railtype)
|
||||
{
|
||||
/* Create pathfinder instance */
|
||||
Tpf pf1;
|
||||
@@ -331,7 +331,7 @@ public:
|
||||
return result1;
|
||||
}
|
||||
|
||||
bool FindNearestSafeTile(const Vehicle *v, TileIndex t1, Trackdir td, bool override_railtype, bool dont_reserve)
|
||||
bool FindNearestSafeTile(const Train *v, TileIndex t1, Trackdir td, bool override_railtype, bool dont_reserve)
|
||||
{
|
||||
/* Set origin and destination. */
|
||||
Yapf().SetOrigin(t1, td);
|
||||
@@ -391,7 +391,7 @@ public:
|
||||
return 't';
|
||||
}
|
||||
|
||||
static Trackdir stChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, PBSTileInfo *target)
|
||||
static Trackdir stChooseRailTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, PBSTileInfo *target)
|
||||
{
|
||||
/* create pathfinder instance */
|
||||
Tpf pf1;
|
||||
@@ -412,12 +412,12 @@ public:
|
||||
return result1;
|
||||
}
|
||||
|
||||
FORCEINLINE Trackdir ChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, PBSTileInfo *target)
|
||||
FORCEINLINE Trackdir ChooseRailTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, PBSTileInfo *target)
|
||||
{
|
||||
if (target != NULL) target->tile = INVALID_TILE;
|
||||
|
||||
/* set origin and destination nodes */
|
||||
PBSTileInfo origin = FollowTrainReservation(Train::From(v));
|
||||
PBSTileInfo origin = FollowTrainReservation(v);
|
||||
Yapf().SetOrigin(origin.tile, origin.trackdir, INVALID_TILE, INVALID_TRACKDIR, 1, true);
|
||||
Yapf().SetDestination(v);
|
||||
|
||||
@@ -454,7 +454,7 @@ public:
|
||||
return next_trackdir;
|
||||
}
|
||||
|
||||
static bool stCheckReverseTrain(const Vehicle *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int reverse_penalty)
|
||||
static bool stCheckReverseTrain(const Train *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int reverse_penalty)
|
||||
{
|
||||
Tpf pf1;
|
||||
bool result1 = pf1.CheckReverseTrain(v, t1, td1, t2, td2, reverse_penalty);
|
||||
@@ -472,7 +472,7 @@ public:
|
||||
return result1;
|
||||
}
|
||||
|
||||
FORCEINLINE bool CheckReverseTrain(const Vehicle *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int reverse_penalty)
|
||||
FORCEINLINE bool CheckReverseTrain(const Train *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int reverse_penalty)
|
||||
{
|
||||
/* create pathfinder instance
|
||||
* set origin and destination nodes */
|
||||
@@ -506,6 +506,7 @@ struct CYapfRail_TypesT
|
||||
typedef Tpf_ Tpf;
|
||||
typedef Ttrack_follower TrackFollower;
|
||||
typedef Tnode_list NodeList;
|
||||
typedef Train VehicleType;
|
||||
typedef CYapfBaseT<Types> PfBase;
|
||||
typedef TfollowT<Types> PfFollow;
|
||||
typedef CYapfOriginTileTwoWayT<Types> PfOrigin;
|
||||
@@ -527,7 +528,7 @@ struct CYapfAnySafeTileRail2 : CYapfT<CYapfRail_TypesT<CYapfAnySafeTileRail2, CF
|
||||
Track YapfTrainChooseTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, PBSTileInfo *target)
|
||||
{
|
||||
/* default is YAPF type 2 */
|
||||
typedef Trackdir (*PfnChooseRailTrack)(const Vehicle*, TileIndex, DiagDirection, TrackBits, bool*, bool, PBSTileInfo*);
|
||||
typedef Trackdir (*PfnChooseRailTrack)(const Train*, TileIndex, DiagDirection, TrackBits, bool*, bool, PBSTileInfo*);
|
||||
PfnChooseRailTrack pfnChooseRailTrack = &CYapfRail1::stChooseRailTrack;
|
||||
|
||||
/* check if non-default YAPF type needed */
|
||||
@@ -582,7 +583,7 @@ bool YapfTrainCheckReverse(const Train *v)
|
||||
reverse_penalty += DistanceManhattan(cur_tile, tile_rev) * YAPF_TILE_LENGTH;
|
||||
}
|
||||
|
||||
typedef bool (*PfnCheckReverseTrain)(const Vehicle*, TileIndex, Trackdir, TileIndex, Trackdir, int);
|
||||
typedef bool (*PfnCheckReverseTrain)(const Train*, TileIndex, Trackdir, TileIndex, Trackdir, int);
|
||||
PfnCheckReverseTrain pfnCheckReverseTrain = CYapfRail1::stCheckReverseTrain;
|
||||
|
||||
/* check if non-default YAPF type needed */
|
||||
@@ -604,11 +605,11 @@ FindDepotData YapfTrainFindNearestDepot(const Train *v, int max_distance)
|
||||
|
||||
const Train *last_veh = v->Last();
|
||||
|
||||
PBSTileInfo origin = FollowTrainReservation(Train::From(v));
|
||||
PBSTileInfo origin = FollowTrainReservation(v);
|
||||
TileIndex last_tile = last_veh->tile;
|
||||
Trackdir td_rev = ReverseTrackdir(last_veh->GetVehicleTrackdir());
|
||||
|
||||
typedef bool (*PfnFindNearestDepotTwoWay)(const Vehicle*, TileIndex, Trackdir, TileIndex, Trackdir, int, int, TileIndex*, bool*);
|
||||
typedef bool (*PfnFindNearestDepotTwoWay)(const Train*, TileIndex, Trackdir, TileIndex, Trackdir, int, int, TileIndex*, bool*);
|
||||
PfnFindNearestDepotTwoWay pfnFindNearestDepotTwoWay = &CYapfAnyDepotRail1::stFindNearestDepotTwoWay;
|
||||
|
||||
/* check if non-default YAPF type needed */
|
||||
@@ -623,7 +624,7 @@ FindDepotData YapfTrainFindNearestDepot(const Train *v, int max_distance)
|
||||
|
||||
bool YapfTrainFindNearestSafeTile(const Train *v, TileIndex tile, Trackdir td, bool override_railtype)
|
||||
{
|
||||
typedef bool (*PfnFindNearestSafeTile)(const Vehicle*, TileIndex, Trackdir, bool);
|
||||
typedef bool (*PfnFindNearestSafeTile)(const Train*, TileIndex, Trackdir, bool);
|
||||
PfnFindNearestSafeTile pfnFindNearestSafeTile = CYapfAnySafeTileRail1::stFindNearestSafeTile;
|
||||
|
||||
/* check if non-default YAPF type needed */
|
||||
|
Reference in New Issue
Block a user