(svn r6992) Make a const_cast<> obsolete by properly propagating the type
authortron
Sat, 28 Oct 2006 12:43:15 +0000
changeset 4989 cbcb63d9014b
parent 4988 cd54974faf2e
child 4990 776ba4323093
(svn r6992) Make a const_cast<> obsolete by properly propagating the type
yapf/yapf_road.cpp
--- a/yapf/yapf_road.cpp	Sat Oct 28 12:32:55 2006 +0000
+++ b/yapf/yapf_road.cpp	Sat Oct 28 12:43:15 2006 +0000
@@ -345,13 +345,13 @@
 		return true;
 	}
 
-	static Depot* stFindNearestDepot(Vehicle* v, TileIndex tile, Trackdir td)
+	static Depot* stFindNearestDepot(const Vehicle* v, TileIndex tile, Trackdir td)
 	{
 		Tpf pf;
 		return pf.FindNearestDepot(v, tile, td);
 	}
 
-	FORCEINLINE Depot* FindNearestDepot(Vehicle* v, TileIndex tile, Trackdir td)
+	FORCEINLINE Depot* FindNearestDepot(const Vehicle* v, TileIndex tile, Trackdir td)
 	{
 		// set origin and destination nodes
 		Yapf().SetOrigin(tile, TrackdirToTrackdirBits(td));
@@ -440,13 +440,13 @@
 	}
 
 	// default is YAPF type 2
-	typedef Depot* (*PfnFindNearestDepot)(Vehicle*, TileIndex, Trackdir);
+	typedef Depot* (*PfnFindNearestDepot)(const Vehicle*, TileIndex, Trackdir);
 	PfnFindNearestDepot pfnFindNearestDepot = &CYapfRoadAnyDepot2::stFindNearestDepot;
 
 	// check if non-default YAPF type should be used
 	if (_patches.yapf.disable_node_optimization)
 		pfnFindNearestDepot = &CYapfRoadAnyDepot1::stFindNearestDepot; // Trackdir, allow 90-deg
 
-	Depot* ret = pfnFindNearestDepot(const_cast<Vehicle*>(v), tile, trackdir);
+	Depot* ret = pfnFindNearestDepot(v, tile, trackdir);
 	return ret;
 }