Merge branch 'master' into jgrpp
This commit is contained in:
@@ -320,6 +320,14 @@ void Ship::UpdateDeltaXY()
|
||||
this->z_extent = 6;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test-procedure for HasVehicleOnPos to check for a ship.
|
||||
*/
|
||||
static Vehicle *EnsureNoVisibleShipProc(Vehicle *v, void *data)
|
||||
{
|
||||
return v->type == VEH_SHIP && (v->vehstatus & VS_HIDDEN) == 0 ? v : NULL;
|
||||
}
|
||||
|
||||
static bool CheckShipLeaveDepot(Ship *v)
|
||||
{
|
||||
if (!v->IsChainInDepot()) return false;
|
||||
@@ -338,6 +346,13 @@ static bool CheckShipLeaveDepot(Ship *v)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Don't leave depot if no destination set */
|
||||
if (v->dest_tile == 0) return true;
|
||||
|
||||
/* Don't leave depot if another vehicle is already entering/leaving */
|
||||
/* This helps avoid CPU load if many ships are set to start at the same time */
|
||||
if (HasVehicleOnPos(v->tile, NULL, &EnsureNoVisibleShipProc)) return true;
|
||||
|
||||
TileIndex tile = v->tile;
|
||||
Axis axis = GetShipDepotAxis(tile);
|
||||
|
||||
@@ -463,11 +478,27 @@ static Track ChooseShipTrack(Ship *v, TileIndex tile, DiagDirection enterdir, Tr
|
||||
|
||||
bool path_found = true;
|
||||
Track track;
|
||||
switch (_settings_game.pf.pathfinder_for_ships) {
|
||||
case VPF_OPF: track = OPFShipChooseTrack(v, tile, enterdir, tracks, path_found); break;
|
||||
case VPF_NPF: track = NPFShipChooseTrack(v, tile, enterdir, tracks, path_found); break;
|
||||
case VPF_YAPF: track = YapfShipChooseTrack(v, tile, enterdir, tracks, path_found); break;
|
||||
default: NOT_REACHED();
|
||||
|
||||
if (v->dest_tile == 0 || DistanceManhattan(tile, v->dest_tile) > SHIP_MAX_ORDER_DISTANCE + 5) {
|
||||
/* No destination or destination too far, don't invoke pathfinder. */
|
||||
track = TrackBitsToTrack(v->state);
|
||||
if (track != TRACK_X && track != TRACK_Y) track = TrackToOppositeTrack(track);
|
||||
if (!HasBit(tracks, track)) {
|
||||
/* Can't continue in same direction so pick first available track. */
|
||||
if (_settings_game.pf.forbid_90_deg) {
|
||||
tracks &= ~TrackCrossesTracks(TrackdirToTrack(v->GetVehicleTrackdir()));
|
||||
if (tracks == TRACK_BIT_NONE) return INVALID_TRACK;
|
||||
}
|
||||
track = FindFirstTrack(tracks);
|
||||
}
|
||||
path_found = false;
|
||||
} else {
|
||||
switch (_settings_game.pf.pathfinder_for_ships) {
|
||||
case VPF_OPF: track = OPFShipChooseTrack(v, tile, enterdir, tracks, path_found); break;
|
||||
case VPF_NPF: track = NPFShipChooseTrack(v, tile, enterdir, tracks, path_found); break;
|
||||
case VPF_YAPF: track = YapfShipChooseTrack(v, tile, enterdir, tracks, path_found); break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
v->HandlePathfindingResult(path_found);
|
||||
|
Reference in New Issue
Block a user