Rename DateTicksScaled to StateTicks

Rename various other related/derived types and variables
This commit is contained in:
Jonathan G Rennison
2024-02-07 18:36:47 +00:00
parent 39b4772a34
commit 0ea57528c9
39 changed files with 270 additions and 270 deletions

View File

@@ -53,7 +53,7 @@ void FlowMapper::Run(LinkGraphJob &job) const
/* Scale by time the graph has been running without being compressed. Add 1 to avoid
* division by 0 if spawn date == last compression date. This matches
* LinkGraph::Monthly(). */
uint runtime = (uint)Clamp<DateTicksScaledDelta>(DateTicksToScaledDateTicks(job.StartDateTicks()) - job.LastCompression() + 1, 1, UINT32_MAX).base();
uint runtime = (uint)Clamp<StateTicksDelta>(DateTicksToStateTicks(job.StartDateTicks()) - job.LastCompression() + 1, 1, UINT32_MAX).base();
for (auto &it : flows) {
it.ScaleToMonthly(runtime);
}

View File

@@ -54,7 +54,7 @@ void LinkGraph::ShiftDates(DateDelta interval)
void LinkGraph::Compress()
{
this->last_compression = (_scaled_date_ticks.base() + this->last_compression.base()) / 2;
this->last_compression = (_state_ticks.base() + this->last_compression.base()) / 2;
for (NodeID node1 = 0; node1 < this->Size(); ++node1) {
this->nodes[node1].supply /= 2;
}
@@ -79,8 +79,8 @@ void LinkGraph::Compress()
*/
void LinkGraph::Merge(LinkGraph *other)
{
uint32_t age = ClampTo<uint32_t>(CeilDivT<int64_t>(_scaled_date_ticks.base() - this->last_compression.base() + 1, DAY_TICKS));
uint32_t other_age = ClampTo<uint32_t>(CeilDivT<int64_t>(_scaled_date_ticks.base() - other->last_compression.base() + 1, DAY_TICKS));
uint32_t age = ClampTo<uint32_t>(CeilDivT<int64_t>(_state_ticks.base() - this->last_compression.base() + 1, DAY_TICKS));
uint32_t other_age = ClampTo<uint32_t>(CeilDivT<int64_t>(_state_ticks.base() - other->last_compression.base() + 1, DAY_TICKS));
NodeID first = this->Size();
this->nodes.reserve(first + other->Size());
for (NodeID node1 = 0; node1 < other->Size(); ++node1) {
@@ -266,7 +266,7 @@ void LinkGraph::Init(uint size)
this->nodes.resize(size);
}
void AdjustLinkGraphScaledTickBase(DateTicksScaledDelta delta)
void AdjustLinkGraphStateTicksBase(StateTicksDelta delta)
{
for (LinkGraph *lg : LinkGraph::Iterate()) lg->last_compression += delta;
@@ -278,11 +278,11 @@ void AdjustLinkGraphScaledTickBase(DateTicksScaledDelta delta)
void LinkGraphFixupLastCompressionAfterLoad()
{
/* last_compression was previously a Date, change it to a DateTicksScaled */
for (LinkGraph *lg : LinkGraph::Iterate()) lg->last_compression = DateToScaledDateTicks((Date)lg->last_compression.base());
/* last_compression was previously a Date, change it to a StateTicks */
for (LinkGraph *lg : LinkGraph::Iterate()) lg->last_compression = DateToStateTicks((Date)lg->last_compression.base());
for (LinkGraphJob *lgj : LinkGraphJob::Iterate()) {
LinkGraph *lg = &(const_cast<LinkGraph &>(lgj->Graph()));
lg->last_compression = DateToScaledDateTicks((Date)lg->last_compression.base());
lg->last_compression = DateToStateTicks((Date)lg->last_compression.base());
}
}

View File

@@ -290,7 +290,7 @@ public:
static constexpr DateDelta STALE_LINK_DEPOT_TIMEOUT = 1024;
/** Minimum number of ticks between subsequent compressions of a LG. */
static constexpr DateTicksScaledDelta COMPRESSION_INTERVAL = 256 * DAY_TICKS;
static constexpr StateTicksDelta COMPRESSION_INTERVAL = 256 * DAY_TICKS;
/**
* Scale a value from a link graph of age orig_age for usage in one of age
@@ -311,7 +311,7 @@ public:
* Real constructor.
* @param cargo Cargo the link graph is about.
*/
LinkGraph(CargoID cargo) : cargo(cargo), last_compression(_scaled_date_ticks) {}
LinkGraph(CargoID cargo) : cargo(cargo), last_compression(_state_ticks) {}
void Init(uint size);
void ShiftDates(DateDelta interval);
@@ -350,7 +350,7 @@ public:
* Get date of last compression.
* @return Date of last compression.
*/
inline DateTicksScaled LastCompression() const { return this->last_compression; }
inline StateTicks LastCompression() const { return this->last_compression; }
/**
* Get the cargo ID this component's link graph refers to.
@@ -365,7 +365,7 @@ public:
*/
inline uint Monthly(uint base) const
{
return (uint)((static_cast<uint64_t>(base) * 30 * DAY_TICKS * _settings_game.economy.day_length_factor) / std::max<uint64_t>((_scaled_date_ticks - this->last_compression).base(), DAY_TICKS));
return (uint)((static_cast<uint64_t>(base) * 30 * DAY_TICKS * _settings_game.economy.day_length_factor) / std::max<uint64_t>((_state_ticks - this->last_compression).base(), DAY_TICKS));
}
NodeID AddNode(const Station *st);
@@ -392,11 +392,11 @@ protected:
friend upstream_sl::SlLinkgraphNode;
friend upstream_sl::SlLinkgraphEdge;
friend void AdjustLinkGraphScaledTickBase(DateTicksScaledDelta delta);
friend void AdjustLinkGraphStateTicksBase(StateTicksDelta delta);
friend void LinkGraphFixupLastCompressionAfterLoad();
CargoID cargo; ///< Cargo of this component's link graph.
DateTicksScaled last_compression; ///< Last time the capacities and supplies were compressed.
StateTicks last_compression; ///< Last time the capacities and supplies were compressed.
NodeVector nodes; ///< Nodes in the component.
EdgeMatrix edges; ///< Edges in the component.

View File

@@ -348,10 +348,10 @@ public:
inline CargoID Cargo() const { return this->link_graph.Cargo(); }
/**
* Get the date when the underlying link graph was last compressed.
* Get the state tick when the underlying link graph was last compressed.
* @return Compression date.
*/
inline DateTicksScaled LastCompression() const { return this->link_graph.LastCompression(); }
inline StateTicks LastCompression() const { return this->link_graph.LastCompression(); }
/**
* Get the ID of the underlying link graph.