diff options
author | rubidium <rubidium@openttd.org> | 2009-12-02 09:31:38 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-12-02 09:31:38 +0000 |
commit | ef8cc49175ae8f97c6659c3acd13fdb4434cd535 (patch) | |
tree | 70b95a04f49f1755580f2d0a31bf7ec47df717ad /src | |
parent | 250c355508ea280d89ad0004e715831b59522419 (diff) | |
download | openttd-ef8cc49175ae8f97c6659c3acd13fdb4434cd535.tar.xz |
(svn r18370) -Codechange: push some constness/type strictness into the ship pathfinders
Diffstat (limited to 'src')
-rw-r--r-- | src/pathfinder/npf/npf.cpp | 4 | ||||
-rw-r--r-- | src/pathfinder/npf/npf.h | 2 | ||||
-rw-r--r-- | src/pathfinder/npf/npf_func.h | 2 | ||||
-rw-r--r-- | src/pathfinder/opf/opf_ship.cpp | 4 | ||||
-rw-r--r-- | src/pathfinder/opf/opf_ship.h | 2 | ||||
-rw-r--r-- | src/pathfinder/yapf/yapf.h | 2 | ||||
-rw-r--r-- | src/pathfinder/yapf/yapf_ship.cpp | 7 | ||||
-rw-r--r-- | src/ship_cmd.cpp | 2 |
8 files changed, 13 insertions, 12 deletions
diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp index 085a00053..13410a0f5 100644 --- a/src/pathfinder/npf/npf.cpp +++ b/src/pathfinder/npf/npf.cpp @@ -1100,7 +1100,7 @@ void InitializeNPF() _npf_aystar.max_search_nodes = _settings_game.pf.npf.npf_max_search_nodes; } -void NPFFillWithOrderData(NPFFindStationOrTileData *fstd, Vehicle *v, bool reserve_path) +void NPFFillWithOrderData(NPFFindStationOrTileData *fstd, const Vehicle *v, bool reserve_path) { /* Ships don't really reach their stations, but the tile in front. So don't * save the station id for ships. For roadvehs we don't store it either, @@ -1122,7 +1122,7 @@ void NPFFillWithOrderData(NPFFindStationOrTileData *fstd, Vehicle *v, bool reser /*** Ships ***/ -Track NPFShipChooseTrack(Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks) +Track NPFShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks) { NPFFindStationOrTileData fstd; Trackdir trackdir = v->GetVehicleTrackdir(); diff --git a/src/pathfinder/npf/npf.h b/src/pathfinder/npf/npf.h index 3beb09391..fcd75db4d 100644 --- a/src/pathfinder/npf/npf.h +++ b/src/pathfinder/npf/npf.h @@ -125,7 +125,7 @@ NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir, NPFFoundTargetData NPFRouteToSafeTile(const struct Train *v, TileIndex tile, Trackdir trackdir, bool override_railtype); -void NPFFillWithOrderData(NPFFindStationOrTileData *fstd, Vehicle *v, bool reserve_path = false); +void NPFFillWithOrderData(NPFFindStationOrTileData *fstd, const Vehicle *v, bool reserve_path = false); /* diff --git a/src/pathfinder/npf/npf_func.h b/src/pathfinder/npf/npf_func.h index 4d38d5807..ef3b1001c 100644 --- a/src/pathfinder/npf/npf_func.h +++ b/src/pathfinder/npf/npf_func.h @@ -20,6 +20,6 @@ * @param tracks available tracks on the new tile (to choose from) * @return the best trackdir for next turn or INVALID_TRACK if the path could not be found */ -Track NPFShipChooseTrack(class Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks); +Track NPFShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks); #endif /* NPF_FUNC_H */ diff --git a/src/pathfinder/opf/opf_ship.cpp b/src/pathfinder/opf/opf_ship.cpp index cbc4a99f4..0d967c67a 100644 --- a/src/pathfinder/opf/opf_ship.cpp +++ b/src/pathfinder/opf/opf_ship.cpp @@ -131,7 +131,7 @@ static const byte _ship_search_directions[6][4] = { static const byte _pick_shiptrack_table[6] = {1, 3, 2, 2, 0, 0}; -static uint FindShipTrack(Ship *v, TileIndex tile, DiagDirection dir, TrackBits bits, TileIndex skiptile, Track *track) +static uint FindShipTrack(const Ship *v, TileIndex tile, DiagDirection dir, TrackBits bits, TileIndex skiptile, Track *track) { TrackPathFinder pfs; uint best_bird_dist = 0; @@ -183,7 +183,7 @@ bad:; /** 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 */ -Track OPFShipChooseTrack(Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks) +Track OPFShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks) { assert(IsValidDiagDirection(enterdir)); diff --git a/src/pathfinder/opf/opf_ship.h b/src/pathfinder/opf/opf_ship.h index 829417b38..10055067b 100644 --- a/src/pathfinder/opf/opf_ship.h +++ b/src/pathfinder/opf/opf_ship.h @@ -20,6 +20,6 @@ * @param tracks available tracks on the new tile (to choose from) * @return the best trackdir for next turn or INVALID_TRACK if the path could not be found */ -Track OPFShipChooseTrack(Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks); +Track OPFShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks); #endif /* OPF_SHIP_H */ diff --git a/src/pathfinder/yapf/yapf.h b/src/pathfinder/yapf/yapf.h index 1a21b67ea..2f39cd6c5 100644 --- a/src/pathfinder/yapf/yapf.h +++ b/src/pathfinder/yapf/yapf.h @@ -23,7 +23,7 @@ * @param tracks available tracks on the new tile (to choose from) * @return the best trackdir for next turn or INVALID_TRACK if the path could not be found */ -Track YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks); +Track YapfChooseShipTrack(const Ship *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 diff --git a/src/pathfinder/yapf/yapf_ship.cpp b/src/pathfinder/yapf/yapf_ship.cpp index f0de614ac..44ec9fe55 100644 --- a/src/pathfinder/yapf/yapf_ship.cpp +++ b/src/pathfinder/yapf/yapf_ship.cpp @@ -10,6 +10,7 @@ /** @file yapf_ship.cpp Implementation of YAPF for ships. */ #include "../../stdafx.h" +#include "../../ship.h" #include "yapf.hpp" @@ -48,7 +49,7 @@ public: return 'w'; } - static Trackdir ChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks) + static Trackdir ChooseShipTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks) { /* handle special case - when next tile is destination tile */ if (tile == v->dest_tile) { @@ -167,10 +168,10 @@ struct CYapfShip2 : CYapfT<CYapfShip_TypesT<CYapfShip2, CFollowTrackWater , C struct CYapfShip3 : CYapfT<CYapfShip_TypesT<CYapfShip3, CFollowTrackWaterNo90, CShipNodeListTrackDir> > {}; /** Ship controller helper - path finder invoker */ -Track YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks) +Track YapfChooseShipTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks) { /* default is YAPF type 2 */ - typedef Trackdir (*PfnChooseShipTrack)(const Vehicle*, TileIndex, DiagDirection, TrackBits); + typedef Trackdir (*PfnChooseShipTrack)(const Ship*, TileIndex, DiagDirection, TrackBits); PfnChooseShipTrack pfnChooseShipTrack = CYapfShip2::ChooseShipTrack; // default: ExitDir, allow 90-deg /* check if non-default YAPF type needed */ diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 1d8943a15..4ce5798c6 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -362,7 +362,7 @@ static void ShipArrivesAt(const Vehicle *v, Station *st) /** 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) +static Track ChooseShipTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks) { assert(IsValidDiagDirection(enterdir)); |