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

@@ -212,6 +212,13 @@ public:
int GetCurrentMaxSpeed() const;
uint8 GetZPosCacheUpdateInterval() const
{
return Clamp<uint16>(std::min<uint16>(this->gcache.cached_total_length / 4, this->tcache.cached_centre_mass / 2), 2, 32);
}
uint32 CalculateOverallZPos() const;
bool UsingRealisticBraking() const { return this->tcache.cached_tflags & TCF_RL_BRAKING; }
/**
@@ -494,7 +501,7 @@ struct TrainDecelerationStats {
int z_pos;
const Train *t;
TrainDecelerationStats(const Train *t);
TrainDecelerationStats(const Train *t, int z_pos);
};
CommandCost CmdMoveRailVehicle(TileIndex, DoCommandFlag , uint32, uint32, const char *);