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:
@@ -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)) {
|
||||
|
Reference in New Issue
Block a user