Codechange: Where the ship comes from is already known
This simplifies the handling of variables. `ChooseShipTrack` is called upon entering `tile`, and looking further back to the caller, it can be deduced that `v->tile` matches `src_tile`. With that said, `enterdir` can also be removed, as it's not used anywhere else. `CreateRandomPath` and `GetRandomFollowUpTrackdir` is being fed `src_tile` as it's 2nd parameter. This could be eliminated, as `v` is also being passed to it. Just use `v->tile` in those functions.
This commit is contained in:
@@ -501,14 +501,11 @@ static void ShipArrivesAt(const Vehicle *v, Station *st)
|
||||
*
|
||||
* @param v Ship to navigate
|
||||
* @param tile Tile, the ship is about to enter
|
||||
* @param enterdir Direction of entering
|
||||
* @param tracks Available track choices on \a tile
|
||||
* @return Track to choose, or INVALID_TRACK when to reverse.
|
||||
*/
|
||||
static Track ChooseShipTrack(Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
|
||||
static Track ChooseShipTrack(Ship *v, TileIndex tile, TrackBits tracks)
|
||||
{
|
||||
assert(IsValidDiagDirection(enterdir));
|
||||
|
||||
bool path_found = true;
|
||||
Track track;
|
||||
|
||||
@@ -535,7 +532,7 @@ static Track ChooseShipTrack(Ship *v, TileIndex tile, DiagDirection enterdir, Tr
|
||||
|
||||
switch (_settings_game.pf.pathfinder_for_ships) {
|
||||
case VPF_NPF: track = NPFShipChooseTrack(v, path_found); break;
|
||||
case VPF_YAPF: track = YapfShipChooseTrack(v, tile, enterdir, path_found, v->path); break;
|
||||
case VPF_YAPF: track = YapfShipChooseTrack(v, tile, path_found, v->path); break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
}
|
||||
@@ -821,7 +818,7 @@ static void ShipController(Ship *v)
|
||||
}
|
||||
|
||||
/* Choose a direction, and continue if we find one */
|
||||
const Track track = ChooseShipTrack(v, gp.new_tile, diagdir, tracks);
|
||||
const Track track = ChooseShipTrack(v, gp.new_tile, tracks);
|
||||
if (track == INVALID_TRACK) return ReverseShip(v);
|
||||
|
||||
const ShipSubcoordData &b = _ship_subcoord[diagdir][track];
|
||||
|
Reference in New Issue
Block a user