summaryrefslogtreecommitdiff
path: root/src/yapf
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-05-24 20:29:04 +0000
committerrubidium <rubidium@openttd.org>2009-05-24 20:29:04 +0000
commit0d99b6c71cd096599b4805d230483f3e4e958af1 (patch)
tree463b69c3b2ea6f697506be055622229767dfebc4 /src/yapf
parent36e71c8df6fe1f4c303d98b609bb9cdd0c4b7e75 (diff)
downloadopenttd-0d99b6c71cd096599b4805d230483f3e4e958af1.tar.xz
(svn r16421) -Codechange: do not unnecessarily remove constness or unnecessarily add it.
Diffstat (limited to 'src/yapf')
-rw-r--r--src/yapf/follow_track.hpp8
-rw-r--r--src/yapf/yapf_costrail.hpp4
-rw-r--r--src/yapf/yapf_destrail.hpp8
-rw-r--r--src/yapf/yapf_rail.cpp12
-rw-r--r--src/yapf/yapf_road.cpp10
5 files changed, 21 insertions, 21 deletions
diff --git a/src/yapf/follow_track.hpp b/src/yapf/follow_track.hpp
index 0263150fe..f670ac82d 100644
--- a/src/yapf/follow_track.hpp
+++ b/src/yapf/follow_track.hpp
@@ -55,7 +55,7 @@ struct CFollowTrackT
{
assert(!IsRailTT() || (v != NULL && v->type == VEH_TRAIN));
m_veh = v;
- Init(v != NULL ? v->owner : INVALID_OWNER, railtype_override == INVALID_RAILTYPES ? ((Train *)v)->compatible_railtypes : railtype_override, pPerf);
+ Init(v != NULL ? v->owner : INVALID_OWNER, railtype_override == INVALID_RAILTYPES ? ((const Train *)v)->compatible_railtypes : railtype_override, pPerf);
}
FORCEINLINE void Init(Owner o, RailTypes railtype_override, CPerformanceTimer *pPerf)
@@ -76,7 +76,7 @@ struct CFollowTrackT
FORCEINLINE static TransportType TT() {return Ttr_type_;}
FORCEINLINE static bool IsWaterTT() {return TT() == TRANSPORT_WATER;}
FORCEINLINE static bool IsRailTT() {return TT() == TRANSPORT_RAIL;}
- FORCEINLINE bool IsTram() {return IsRoadTT() && HasBit(((RoadVehicle *)m_veh)->compatible_roadtypes, ROADTYPE_TRAM);}
+ FORCEINLINE bool IsTram() {return IsRoadTT() && HasBit(((const RoadVehicle *)m_veh)->compatible_roadtypes, ROADTYPE_TRAM);}
FORCEINLINE static bool IsRoadTT() {return TT() == TRANSPORT_ROAD;}
FORCEINLINE static bool Allow90degTurns() {return T90deg_turns_allowed_;}
FORCEINLINE static bool DoTrackMasking() {return IsRailTT() && Tmask_reserved_tracks;}
@@ -106,7 +106,7 @@ struct CFollowTrackT
m_old_tile = old_tile;
m_old_td = old_td;
m_err = EC_NONE;
- assert(((TrackStatusToTrackdirBits(GetTileTrackStatus(m_old_tile, TT(), m_veh ? ((RoadVehicle *)m_veh)->compatible_roadtypes : 0)) & TrackdirToTrackdirBits(m_old_td)) != 0) ||
+ assert(((TrackStatusToTrackdirBits(GetTileTrackStatus(m_old_tile, TT(), m_veh ? ((const RoadVehicle *)m_veh)->compatible_roadtypes : 0)) & TrackdirToTrackdirBits(m_old_td)) != 0) ||
(IsTram() && GetSingleTramBit(m_old_tile) != INVALID_DIAGDIR)); // Disable the assertion for single tram bits
m_exitdir = TrackdirToExitdir(m_old_td);
if (ForcedReverse()) return true;
@@ -207,7 +207,7 @@ protected:
if (IsRailTT() && IsPlainRailTile(m_new_tile)) {
m_new_td_bits = (TrackdirBits)(GetTrackBits(m_new_tile) * 0x101);
} else {
- m_new_td_bits = TrackStatusToTrackdirBits(GetTileTrackStatus(m_new_tile, TT(), m_veh != NULL ? ((RoadVehicle *)m_veh)->compatible_roadtypes : 0));
+ m_new_td_bits = TrackStatusToTrackdirBits(GetTileTrackStatus(m_new_tile, TT(), m_veh != NULL ? ((const RoadVehicle *)m_veh)->compatible_roadtypes : 0));
if (IsTram() && m_new_td_bits == 0) {
/* GetTileTrackStatus() returns 0 for single tram bits.
diff --git a/src/yapf/yapf_costrail.hpp b/src/yapf/yapf_costrail.hpp
index 2d6d78191..9504beced 100644
--- a/src/yapf/yapf_costrail.hpp
+++ b/src/yapf/yapf_costrail.hpp
@@ -247,8 +247,8 @@ public:
const Vehicle *v = Yapf().GetVehicle();
assert(v != NULL);
assert(v->type == VEH_TRAIN);
- assert(((Train *)v)->tcache.cached_total_length != 0);
- int missing_platform_length = (((Train *)v)->tcache.cached_total_length + TILE_SIZE - 1) / TILE_SIZE - platform_length;
+ assert(((const Train *)v)->tcache.cached_total_length != 0);
+ int missing_platform_length = (((const Train *)v)->tcache.cached_total_length + TILE_SIZE - 1) / TILE_SIZE - platform_length;
if (missing_platform_length < 0) {
/* apply penalty for longer platform than needed */
cost += Yapf().PfGetSettings().rail_longer_platform_penalty + Yapf().PfGetSettings().rail_longer_platform_per_tile_penalty * -missing_platform_length;
diff --git a/src/yapf/yapf_destrail.hpp b/src/yapf/yapf_destrail.hpp
index 99aa4ea48..498cc5975 100644
--- a/src/yapf/yapf_destrail.hpp
+++ b/src/yapf/yapf_destrail.hpp
@@ -13,8 +13,8 @@ protected:
public:
void SetDestination(const Vehicle *v, bool override_rail_type = false)
{
- m_compatible_railtypes = ((Train *)v)->compatible_railtypes;
- if (override_rail_type) m_compatible_railtypes |= GetRailTypeInfo(((Train *)v)->railtype)->compatible_railtypes;
+ m_compatible_railtypes = ((const Train *)v)->compatible_railtypes;
+ if (override_rail_type) m_compatible_railtypes |= GetRailTypeInfo(((const Train *)v)->railtype)->compatible_railtypes;
}
bool IsCompatibleRailType(RailType rt)
@@ -91,8 +91,8 @@ public:
FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
{
return
- IsSafeWaitingPosition((Train *)Yapf().GetVehicle(), tile, td, true, !TrackFollower::Allow90degTurns()) &&
- IsWaitingPositionFree((Train *)Yapf().GetVehicle(), tile, td, !TrackFollower::Allow90degTurns());
+ IsSafeWaitingPosition((const Train *)Yapf().GetVehicle(), tile, td, true, !TrackFollower::Allow90degTurns()) &&
+ IsWaitingPositionFree((const Train *)Yapf().GetVehicle(), tile, td, !TrackFollower::Allow90degTurns());
}
/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
diff --git a/src/yapf/yapf_rail.cpp b/src/yapf/yapf_rail.cpp
index 7b4e4e9bb..71e272038 100644
--- a/src/yapf/yapf_rail.cpp
+++ b/src/yapf/yapf_rail.cpp
@@ -54,7 +54,7 @@ private:
bool FindSafePositionProc(TileIndex tile, Trackdir td)
{
- if (IsSafeWaitingPosition((Train *)Yapf().GetVehicle(), tile, td, true, !TrackFollower::Allow90degTurns())) {
+ if (IsSafeWaitingPosition((const Train *)Yapf().GetVehicle(), tile, td, true, !TrackFollower::Allow90degTurns())) {
m_res_dest = tile;
m_res_dest_td = td;
return false; // Stop iterating segment
@@ -149,7 +149,7 @@ public:
}
/* Don't bother if the target is reserved. */
- if (!IsWaitingPositionFree((Train *)Yapf().GetVehicle(), m_res_dest, m_res_dest_td)) return false;
+ if (!IsWaitingPositionFree((const Train *)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);
@@ -411,7 +411,7 @@ public:
if (target != NULL) target->tile = INVALID_TILE;
/* set origin and destination nodes */
- PBSTileInfo origin = FollowTrainReservation((Train *)v);
+ PBSTileInfo origin = FollowTrainReservation((const Train *)v);
Yapf().SetOrigin(origin.tile, origin.trackdir, INVALID_TILE, INVALID_TRACKDIR, 1, true);
Yapf().SetDestination(v);
@@ -536,9 +536,9 @@ Trackdir YapfChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection ent
bool YapfCheckReverseTrain(const Vehicle *vt)
{
- Train *v = (Train *)vt;
+ const Train *v = (const Train *)vt;
/* last wagon */
- const Train *last_veh = (Train *)GetLastVehicleInChain(v);
+ const Train *last_veh = (const Train *)GetLastVehicleInChain(v);
/* get trackdirs of both ends */
Trackdir td = v->GetVehicleTrackdir();
@@ -602,7 +602,7 @@ bool YapfFindNearestRailDepotTwoWay(const Vehicle *v, int max_distance, int reve
const Vehicle *last_veh = GetLastVehicleInChain(v);
- PBSTileInfo origin = FollowTrainReservation((Train *)v);
+ PBSTileInfo origin = FollowTrainReservation((const Train *)v);
TileIndex last_tile = last_veh->tile;
Trackdir td_rev = ReverseTrackdir(last_veh->GetVehicleTrackdir());
diff --git a/src/yapf/yapf_road.cpp b/src/yapf/yapf_road.cpp
index 75dbc9e27..ce627b1f0 100644
--- a/src/yapf/yapf_road.cpp
+++ b/src/yapf/yapf_road.cpp
@@ -299,13 +299,13 @@ public:
/* our source tile will be the next vehicle tile (should be the given one) */
TileIndex src_tile = tile;
/* get available trackdirs on the start tile */
- TrackdirBits src_trackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, ((RoadVehicle *)v)->compatible_roadtypes));
+ TrackdirBits src_trackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, ((const RoadVehicle *)v)->compatible_roadtypes));
/* select reachable trackdirs only */
src_trackdirs &= DiagdirReachesTrackdirs(enterdir);
/* get available trackdirs on the destination tile */
TileIndex dest_tile = v->dest_tile;
- TrackdirBits dest_trackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(dest_tile, TRANSPORT_ROAD, ((RoadVehicle *)v)->compatible_roadtypes));
+ TrackdirBits dest_trackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(dest_tile, TRANSPORT_ROAD, ((const RoadVehicle *)v)->compatible_roadtypes));
/* set origin and destination nodes */
Yapf().SetOrigin(src_tile, src_trackdirs);
@@ -349,7 +349,7 @@ public:
/* set destination tile, trackdir
* get available trackdirs on the destination tile */
- TrackdirBits dst_td_bits = TrackStatusToTrackdirBits(GetTileTrackStatus(dst_tile, TRANSPORT_ROAD, ((RoadVehicle *)v)->compatible_roadtypes));
+ TrackdirBits dst_td_bits = TrackStatusToTrackdirBits(GetTileTrackStatus(dst_tile, TRANSPORT_ROAD, ((const RoadVehicle *)v)->compatible_roadtypes));
Yapf().SetDestination(dst_tile, dst_td_bits);
/* if path not found - return distance = UINT_MAX */
@@ -374,7 +374,7 @@ public:
/* set origin (tile, trackdir) */
TileIndex src_tile = v->tile;
Trackdir src_td = v->GetVehicleTrackdir();
- if ((TrackStatusToTrackdirBits(GetTileTrackStatus(src_tile, TRANSPORT_ROAD, ((RoadVehicle *)v)->compatible_roadtypes)) & TrackdirToTrackdirBits(src_td)) == 0) {
+ if ((TrackStatusToTrackdirBits(GetTileTrackStatus(src_tile, TRANSPORT_ROAD, ((const RoadVehicle *)v)->compatible_roadtypes)) & TrackdirToTrackdirBits(src_td)) == 0) {
/* sometimes the roadveh is not on the road (it resides on non-existing track)
* how should we handle that situation? */
return false;
@@ -471,7 +471,7 @@ Depot *YapfFindNearestRoadDepot(const Vehicle *v)
{
TileIndex tile = v->tile;
Trackdir trackdir = v->GetVehicleTrackdir();
- if ((TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, ((RoadVehicle *)v)->compatible_roadtypes)) & TrackdirToTrackdirBits(trackdir)) == 0) {
+ if ((TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, ((const RoadVehicle *)v)->compatible_roadtypes)) & TrackdirToTrackdirBits(trackdir)) == 0) {
return NULL;
}