Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
#include "timetable.h"
|
||||
#include "news_func.h"
|
||||
#include "company_func.h"
|
||||
#include "pathfinder/npf/npf_func.h"
|
||||
#include "depot_base.h"
|
||||
#include "station_base.h"
|
||||
#include "newgrf_engine.h"
|
||||
@@ -210,12 +209,7 @@ static void CheckIfShipNeedsService(Vehicle *v)
|
||||
return;
|
||||
}
|
||||
|
||||
uint max_distance;
|
||||
switch (_settings_game.pf.pathfinder_for_ships) {
|
||||
case VPF_NPF: max_distance = _settings_game.pf.npf.maximum_go_to_depot_penalty / NPF_TILE_LENGTH; break;
|
||||
case VPF_YAPF: max_distance = _settings_game.pf.yapf.maximum_go_to_depot_penalty / YAPF_TILE_LENGTH; break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
uint max_distance = _settings_game.pf.yapf.maximum_go_to_depot_penalty / YAPF_TILE_LENGTH;
|
||||
|
||||
const Depot *depot = FindClosestShipDepot(v, max_distance);
|
||||
|
||||
@@ -366,23 +360,17 @@ void Ship::UpdateDeltaXY()
|
||||
}
|
||||
|
||||
/**
|
||||
* Test-procedure for HasVehicleOnPos to check for any ships which are visible and not stopped by the player.
|
||||
* Test-procedure for HasVehicleOnPos to check for any ships which are moving.
|
||||
*/
|
||||
static Vehicle *EnsureNoMovingShipProc(Vehicle *v, void *)
|
||||
{
|
||||
return v->type == VEH_SHIP && (v->vehstatus & (VS_HIDDEN | VS_STOPPED)) == 0 ? v : nullptr;
|
||||
return v->type == VEH_SHIP && v->cur_speed != 0 ? v : nullptr;
|
||||
}
|
||||
|
||||
static bool CheckReverseShip(const Ship *v, Trackdir *trackdir = nullptr)
|
||||
{
|
||||
/* Ask pathfinder for best direction */
|
||||
bool reverse = false;
|
||||
switch (_settings_game.pf.pathfinder_for_ships) {
|
||||
case VPF_NPF: reverse = NPFShipCheckReverse(v, trackdir); break;
|
||||
case VPF_YAPF: reverse = YapfShipCheckReverse(v, trackdir); break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
return reverse;
|
||||
return YapfShipCheckReverse(v, trackdir);
|
||||
}
|
||||
|
||||
static bool CheckShipLeaveDepot(Ship *v)
|
||||
@@ -410,9 +398,9 @@ static bool CheckShipLeaveDepot(Ship *v)
|
||||
Axis axis = GetShipDepotAxis(tile);
|
||||
|
||||
DiagDirection north_dir = ReverseDiagDir(AxisToDiagDir(axis));
|
||||
TileIndex north_neighbour = TILE_ADD(tile, TileOffsByDiagDir(north_dir));
|
||||
TileIndex north_neighbour = TileAdd(tile, TileOffsByDiagDir(north_dir));
|
||||
DiagDirection south_dir = AxisToDiagDir(axis);
|
||||
TileIndex south_neighbour = TILE_ADD(tile, 2 * TileOffsByDiagDir(south_dir));
|
||||
TileIndex south_neighbour = TileAdd(tile, 2 * TileOffsByDiagDir(south_dir));
|
||||
|
||||
TrackBits north_tracks = DiagdirReachesTracks(north_dir) & GetTileShipTrackStatus(north_neighbour);
|
||||
TrackBits south_tracks = DiagdirReachesTracks(south_dir) & GetTileShipTrackStatus(south_neighbour);
|
||||
@@ -467,8 +455,8 @@ static uint ShipAccelerate(Vehicle *v)
|
||||
const uint advance_speed = v->GetAdvanceSpeed(speed);
|
||||
const uint number_of_steps = (advance_speed + v->progress) / v->GetAdvanceDistance();
|
||||
const uint remainder = (advance_speed + v->progress) % v->GetAdvanceDistance();
|
||||
assert(remainder <= std::numeric_limits<byte>::max());
|
||||
v->progress = static_cast<byte>(remainder);
|
||||
assert(remainder <= std::numeric_limits<uint8_t>::max());
|
||||
v->progress = static_cast<uint8_t>(remainder);
|
||||
return number_of_steps;
|
||||
}
|
||||
|
||||
@@ -518,10 +506,10 @@ static Track ChooseShipTrack(Ship *v, TileIndex tile, TrackBits tracks)
|
||||
} else {
|
||||
/* Attempt to follow cached path. */
|
||||
if (!v->path.empty()) {
|
||||
track = TrackdirToTrack(v->path.front());
|
||||
track = TrackdirToTrack(v->path.back().trackdir);
|
||||
|
||||
if (HasBit(tracks, track)) {
|
||||
v->path.pop_front();
|
||||
v->path.pop_back();
|
||||
/* HandlePathfindResult() is not called here because this is not a new pathfinder result. */
|
||||
return track;
|
||||
}
|
||||
@@ -530,11 +518,7 @@ static Track ChooseShipTrack(Ship *v, TileIndex tile, TrackBits tracks)
|
||||
v->path.clear();
|
||||
}
|
||||
|
||||
switch (_settings_game.pf.pathfinder_for_ships) {
|
||||
case VPF_NPF: track = NPFShipChooseTrack(v, path_found); break;
|
||||
case VPF_YAPF: track = YapfShipChooseTrack(v, tile, path_found, v->path); break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
track = YapfShipChooseTrack(v, tile, path_found, v->path);
|
||||
}
|
||||
|
||||
v->HandlePathfindingResult(path_found);
|
||||
@@ -556,8 +540,8 @@ static inline TrackBits GetAvailShipTracks(TileIndex tile, DiagDirection dir)
|
||||
|
||||
/** Structure for ship sub-coordinate data for moving into a new tile via a Diagdir onto a Track. */
|
||||
struct ShipSubcoordData {
|
||||
byte x_subcoord; ///< New X sub-coordinate on the new tile
|
||||
byte y_subcoord; ///< New Y sub-coordinate on the new tile
|
||||
uint8_t x_subcoord; ///< New X sub-coordinate on the new tile
|
||||
uint8_t y_subcoord; ///< New Y sub-coordinate on the new tile
|
||||
Direction dir; ///< New Direction to move in on the new track
|
||||
};
|
||||
/** Ship sub-coordinate data for moving into a new tile via a Diagdir onto a Track.
|
||||
@@ -865,12 +849,12 @@ static void ShipController(Ship *v)
|
||||
v->y_pos = gp.y;
|
||||
v->UpdatePosition();
|
||||
if ((v->vehstatus & VS_HIDDEN) == 0) v->Vehicle::UpdateViewport(true);
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Ship is back on the bridge head, we need to consume its path
|
||||
* cache entry here as we didn't have to choose a ship track. */
|
||||
if (!v->path.empty()) v->path.pop_front();
|
||||
if (!v->path.empty()) v->path.pop_back();
|
||||
}
|
||||
|
||||
/* update image of ship, as well as delta XY */
|
||||
|
||||
Reference in New Issue
Block a user