Realistic braking: Cache train overall z position

Refresh cache at a variable rate depending on train length and
weight distribution
This commit is contained in:
Jonathan G Rennison
2022-06-03 00:41:41 +01:00
parent c238bd5012
commit 99ee4b13ce
9 changed files with 57 additions and 16 deletions

View File

@@ -931,6 +931,8 @@ void TryCreateLookAheadForTrainInTunnelBridge(Train *t)
t->lookahead->reservation_end_position = GetTileMarginInFrontOfTrain(t);
t->lookahead->flags = 0;
t->lookahead->speed_restriction = t->speed_restriction;
t->lookahead->cached_zpos = t->CalculateOverallZPos();
t->lookahead->zpos_refresh_remaining = t->GetZPosCacheUpdateInterval();
if (IsTunnel(t->tile) && Tunnel::GetByTile(t->tile)->is_chunnel) SetBit(t->lookahead->flags, TRLF_CHUNNEL);
if (IsTunnelBridgeSignalSimulationEntrance(t->tile)) {
@@ -1002,6 +1004,8 @@ void FillTrainReservationLookAhead(Train *v)
v->lookahead->tunnel_bridge_reserved_tiles = 0;
v->lookahead->flags = 0;
v->lookahead->speed_restriction = v->speed_restriction;
v->lookahead->cached_zpos = v->CalculateOverallZPos();
v->lookahead->zpos_refresh_remaining = v->GetZPosCacheUpdateInterval();
FillLookAheadCurveDataFromTrainPosition(v);
tile = v->tile;
trackdir = v->GetVehicleTrackdir();