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

@@ -211,7 +211,7 @@ class NIHVehicle : public NIHelper {
if (t->lookahead != nullptr) {
output.print(" Look ahead:");
const TrainReservationLookAhead &l = *t->lookahead;
TrainDecelerationStats stats(t);
TrainDecelerationStats stats(t, l.cached_zpos);
auto print_braking_speed = [&](int position, int end_speed, int end_z) {
if (!t->UsingRealisticBraking()) return;
@@ -229,6 +229,11 @@ class NIHVehicle : public NIHelper {
}
output.print(buffer);
const int overall_zpos = t->CalculateOverallZPos();
seprintf(buffer, lastof(buffer), " Cached zpos: %u (actual: %u, delta: %d), positions to refresh: %u",
l.cached_zpos, overall_zpos, (l.cached_zpos - overall_zpos), l.zpos_refresh_remaining);
output.print(buffer);
b = buffer + seprintf(buffer, lastof(buffer), " Reservation ends at %X (%u x %u), trackdir: %02X, z: %d",
l.reservation_end_tile, TileX(l.reservation_end_tile), TileY(l.reservation_end_tile), l.reservation_end_trackdir, l.reservation_end_z);
if (HasBit(l.flags, TRLF_DEPOT_END)) {