Add game setting to limit train lookahead to signal aspect
In realistic braking mode when multi-aspect signalling enabled by GRF
This commit is contained in:
21
src/pbs.h
21
src/pbs.h
@@ -58,11 +58,16 @@ enum TrainReservationLookAheadItemType : byte {
|
||||
TRLIT_CURVE_SPEED = 5, ///< Curve speed limit
|
||||
};
|
||||
|
||||
enum TrainReservationSignalLookAheadItemFlags {
|
||||
TRSLAI_NO_ASPECT_INC = 0, ///< This signal does not increase the signal aspect (e.g. banner repeater)
|
||||
};
|
||||
|
||||
struct TrainReservationLookAheadItem {
|
||||
int32 start;
|
||||
int32 end;
|
||||
int16 z_pos;
|
||||
uint16 data_id;
|
||||
uint16 data_aux;
|
||||
TrainReservationLookAheadItemType type;
|
||||
};
|
||||
|
||||
@@ -83,6 +88,7 @@ struct TrainReservationLookAhead {
|
||||
Trackdir reservation_end_trackdir; ///< The reserved trackdir on the end tile.
|
||||
int32 current_position; ///< Current position of the train on the reservation
|
||||
int32 reservation_end_position; ///< Position of the end of the reservation
|
||||
int32 lookahead_end_position; ///< Position of the end of the reservation within the lookahead distance
|
||||
int32 next_extend_position; ///< Next position to try extending the reservation at the sighting distance of the next mid-reservation signal
|
||||
int16 reservation_end_z; ///< The z coordinate of the reservation end
|
||||
int16 tunnel_bridge_reserved_tiles; ///< How many tiles a reservation into the tunnel/bridge currently extends into the wormhole
|
||||
@@ -101,38 +107,38 @@ struct TrainReservationLookAhead {
|
||||
void AddStation(int tiles, StationID id, int16 z_pos)
|
||||
{
|
||||
int end = this->RealEndPosition();
|
||||
this->items.push_back({ end, end + (((int)TILE_SIZE) * tiles), z_pos, id, TRLIT_STATION });
|
||||
this->items.push_back({ end, end + (((int)TILE_SIZE) * tiles), z_pos, id, 0, TRLIT_STATION });
|
||||
}
|
||||
|
||||
void AddReverse(int16 z_pos)
|
||||
{
|
||||
int end = this->RealEndPosition();
|
||||
this->items.push_back({ end, end, z_pos, 0, TRLIT_REVERSE });
|
||||
this->items.push_back({ end, end, z_pos, 0, 0, TRLIT_REVERSE });
|
||||
}
|
||||
|
||||
void AddTrackSpeedLimit(uint16 speed, int offset, int duration, int16 z_pos)
|
||||
{
|
||||
int end = this->RealEndPosition();
|
||||
this->items.push_back({ end + offset, end + offset + duration, z_pos, speed, TRLIT_TRACK_SPEED });
|
||||
this->items.push_back({ end + offset, end + offset + duration, z_pos, speed, 0, TRLIT_TRACK_SPEED });
|
||||
}
|
||||
|
||||
void AddSpeedRestriction(uint16 speed, int offset, int duration, int16 z_pos)
|
||||
{
|
||||
int end = this->RealEndPosition();
|
||||
this->items.push_back({ end + offset, end + offset + duration, z_pos, speed, TRLIT_SPEED_RESTRICTION });
|
||||
this->items.push_back({ end + offset, end + offset + duration, z_pos, speed, 0, TRLIT_SPEED_RESTRICTION });
|
||||
this->speed_restriction = speed;
|
||||
}
|
||||
|
||||
void AddSignal(uint16 target_speed, int offset, int16 z_pos)
|
||||
void AddSignal(uint16 target_speed, int offset, int16 z_pos, uint16 flags)
|
||||
{
|
||||
int end = this->RealEndPosition();
|
||||
this->items.push_back({ end + offset, end + offset, z_pos, target_speed, TRLIT_SIGNAL });
|
||||
this->items.push_back({ end + offset, end + offset, z_pos, target_speed, flags, TRLIT_SIGNAL });
|
||||
}
|
||||
|
||||
void AddCurveSpeedLimit(uint16 target_speed, int offset, int16 z_pos)
|
||||
{
|
||||
int end = this->RealEndPosition();
|
||||
this->items.push_back({ end + offset, end + offset, z_pos, target_speed, TRLIT_CURVE_SPEED });
|
||||
this->items.push_back({ end + offset, end + offset, z_pos, target_speed, 0, TRLIT_CURVE_SPEED });
|
||||
}
|
||||
|
||||
void SetNextExtendPosition();
|
||||
@@ -155,6 +161,7 @@ bool ValidateLookAhead(const Train *v);
|
||||
PBSTileInfo FollowTrainReservation(const Train *v, Vehicle **train_on_res = nullptr, FollowTrainReservationFlags flags = FTRF_NONE);
|
||||
void ApplyAvailableFreeTunnelBridgeTiles(TrainReservationLookAhead *lookahead, int free_tiles, TileIndex tile, TileIndex end);
|
||||
void TryCreateLookAheadForTrainInTunnelBridge(Train *t);
|
||||
void SetTrainReservationLookaheadEnd(Train *v);
|
||||
void FillTrainReservationLookAhead(Train *v);
|
||||
void SetLookAheadNextExtendPosition(Train *v);
|
||||
void SetLookAheadNextExtendPositionIfUnset(Train *v);
|
||||
|
||||
Reference in New Issue
Block a user