Codechange: Add base() method to StrongType to allow access to the base type without casting. (#11445)
This removes the ability to explicitly cast to the base type, but the requirement to use .base() means the conversion is still explicit.
This commit is contained in:
@@ -52,7 +52,7 @@ void FlowMapper::Run(LinkGraphJob &job) const
|
||||
* LinkGraph::Monthly(). */
|
||||
auto runtime = job.JoinDate() - job.Settings().recalc_time / CalendarTime::SECONDS_PER_DAY - job.LastCompression() + 1;
|
||||
for (auto &it : flows) {
|
||||
it.second.ScaleToMonthly(static_cast<int32_t>(runtime));
|
||||
it.second.ScaleToMonthly(runtime.base());
|
||||
}
|
||||
}
|
||||
/* Clear paths. */
|
||||
|
@@ -65,7 +65,7 @@ void LinkGraph::ShiftDates(TimerGameCalendar::Date interval)
|
||||
|
||||
void LinkGraph::Compress()
|
||||
{
|
||||
this->last_compression = static_cast<int32_t>(TimerGameCalendar::date + this->last_compression) / 2;
|
||||
this->last_compression = (TimerGameCalendar::date + this->last_compression).base() / 2;
|
||||
for (NodeID node1 = 0; node1 < this->Size(); ++node1) {
|
||||
this->nodes[node1].supply /= 2;
|
||||
for (BaseEdge &edge : this->nodes[node1].edges) {
|
||||
|
@@ -185,7 +185,7 @@ public:
|
||||
*/
|
||||
inline static uint Scale(uint val, TimerGameCalendar::Date target_age, TimerGameCalendar::Date orig_age)
|
||||
{
|
||||
return val > 0 ? std::max(1U, val * static_cast<int32_t>(target_age) / static_cast<int32_t>(orig_age)) : 0;
|
||||
return val > 0 ? std::max(1U, val * target_age.base() / orig_age.base()) : 0;
|
||||
}
|
||||
|
||||
/** Bare constructor, only for save/load. */
|
||||
@@ -248,7 +248,7 @@ public:
|
||||
*/
|
||||
inline uint Monthly(uint base) const
|
||||
{
|
||||
return base * 30 / static_cast<int32_t>(TimerGameCalendar::date - this->last_compression + 1);
|
||||
return base * 30 / (TimerGameCalendar::date - this->last_compression + 1).base();
|
||||
}
|
||||
|
||||
NodeID AddNode(const Station *st);
|
||||
|
@@ -178,7 +178,7 @@ void StateGameLoop_LinkGraphPauseControl()
|
||||
}
|
||||
} else if (_pause_mode == PM_UNPAUSED &&
|
||||
TimerGameCalendar::date_fract == LinkGraphSchedule::SPAWN_JOIN_TICK - 2 &&
|
||||
static_cast<int32_t>(TimerGameCalendar::date) % (_settings_game.linkgraph.recalc_interval / CalendarTime::SECONDS_PER_DAY) == (_settings_game.linkgraph.recalc_interval / CalendarTime::SECONDS_PER_DAY) / 2 &&
|
||||
TimerGameCalendar::date.base() % (_settings_game.linkgraph.recalc_interval / CalendarTime::SECONDS_PER_DAY) == (_settings_game.linkgraph.recalc_interval / CalendarTime::SECONDS_PER_DAY) / 2 &&
|
||||
LinkGraphSchedule::instance.IsJoinWithUnfinishedJobDue()) {
|
||||
/* Perform check two TimerGameCalendar::date_fract ticks before we would join, to make
|
||||
* sure it also works in multiplayer. */
|
||||
@@ -205,7 +205,7 @@ void AfterLoad_LinkGraphPauseControl()
|
||||
void OnTick_LinkGraph()
|
||||
{
|
||||
if (TimerGameCalendar::date_fract != LinkGraphSchedule::SPAWN_JOIN_TICK) return;
|
||||
TimerGameCalendar::Date offset = static_cast<int32_t>(TimerGameCalendar::date) % (_settings_game.linkgraph.recalc_interval / CalendarTime::SECONDS_PER_DAY);
|
||||
TimerGameCalendar::Date offset = TimerGameCalendar::date.base() % (_settings_game.linkgraph.recalc_interval / CalendarTime::SECONDS_PER_DAY);
|
||||
if (offset == 0) {
|
||||
LinkGraphSchedule::instance.SpawnNext();
|
||||
} else if (offset == (_settings_game.linkgraph.recalc_interval / CalendarTime::SECONDS_PER_DAY) / 2) {
|
||||
|
Reference in New Issue
Block a user