Codechange: Split dates and timers into Economy and Calendar time (#10700)
This commit is contained in:
@@ -132,7 +132,7 @@ void LinkGraphSchedule::SpawnAll()
|
||||
* graph jobs by the number of days given.
|
||||
* @param interval Number of days to be added or subtracted.
|
||||
*/
|
||||
void LinkGraphSchedule::ShiftDates(TimerGameCalendar::Date interval)
|
||||
void LinkGraphSchedule::ShiftDates(TimerGameEconomy::Date interval)
|
||||
{
|
||||
for (LinkGraph *lg : LinkGraph::Iterate()) lg->ShiftDates(interval);
|
||||
for (LinkGraphJob *lgj : LinkGraphJob::Iterate()) lgj->ShiftJoinDate(interval);
|
||||
@@ -163,10 +163,10 @@ LinkGraphSchedule::~LinkGraphSchedule()
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause the game if in 2 TimerGameCalendar::date_fract ticks, we would do a join with the next
|
||||
* Pause the game if in 2 TimerGameEconomy::date_fract ticks, we would do a join with the next
|
||||
* link graph job, but it is still running.
|
||||
* The check is done 2 TimerGameCalendar::date_fract ticks early instead of 1, as in multiplayer
|
||||
* calls to DoCommandP are executed after a delay of 1 TimerGameCalendar::date_fract tick.
|
||||
* The check is done 2 TimerGameEconomy::date_fract ticks early instead of 1, as in multiplayer
|
||||
* calls to DoCommandP are executed after a delay of 1 TimerGameEconomy::date_fract tick.
|
||||
* If we previously paused, unpause if the job is now ready to be joined with.
|
||||
*/
|
||||
void StateGameLoop_LinkGraphPauseControl()
|
||||
@@ -177,10 +177,10 @@ void StateGameLoop_LinkGraphPauseControl()
|
||||
Command<CMD_PAUSE>::Post(PM_PAUSED_LINK_GRAPH, false);
|
||||
}
|
||||
} else if (_pause_mode == PM_UNPAUSED &&
|
||||
TimerGameCalendar::date_fract == LinkGraphSchedule::SPAWN_JOIN_TICK - 2 &&
|
||||
TimerGameCalendar::date.base() % (_settings_game.linkgraph.recalc_interval / CalendarTime::SECONDS_PER_DAY) == (_settings_game.linkgraph.recalc_interval / CalendarTime::SECONDS_PER_DAY) / 2 &&
|
||||
TimerGameEconomy::date_fract == LinkGraphSchedule::SPAWN_JOIN_TICK - 2 &&
|
||||
TimerGameEconomy::date.base() % (_settings_game.linkgraph.recalc_interval / EconomyTime::SECONDS_PER_DAY) == (_settings_game.linkgraph.recalc_interval / EconomyTime::SECONDS_PER_DAY) / 2 &&
|
||||
LinkGraphSchedule::instance.IsJoinWithUnfinishedJobDue()) {
|
||||
/* Perform check two TimerGameCalendar::date_fract ticks before we would join, to make
|
||||
/* Perform check two TimerGameEconomy::date_fract ticks before we would join, to make
|
||||
* sure it also works in multiplayer. */
|
||||
Command<CMD_PAUSE>::Post(PM_PAUSED_LINK_GRAPH, true);
|
||||
}
|
||||
@@ -204,11 +204,11 @@ void AfterLoad_LinkGraphPauseControl()
|
||||
*/
|
||||
void OnTick_LinkGraph()
|
||||
{
|
||||
if (TimerGameCalendar::date_fract != LinkGraphSchedule::SPAWN_JOIN_TICK) return;
|
||||
TimerGameCalendar::Date offset = TimerGameCalendar::date.base() % (_settings_game.linkgraph.recalc_interval / CalendarTime::SECONDS_PER_DAY);
|
||||
if (TimerGameEconomy::date_fract != LinkGraphSchedule::SPAWN_JOIN_TICK) return;
|
||||
TimerGameEconomy::Date offset = TimerGameEconomy::date.base() % (_settings_game.linkgraph.recalc_interval / EconomyTime::SECONDS_PER_DAY);
|
||||
if (offset == 0) {
|
||||
LinkGraphSchedule::instance.SpawnNext();
|
||||
} else if (offset == (_settings_game.linkgraph.recalc_interval / CalendarTime::SECONDS_PER_DAY) / 2) {
|
||||
} else if (offset == (_settings_game.linkgraph.recalc_interval / EconomyTime::SECONDS_PER_DAY) / 2) {
|
||||
if (!_networking || _network_server) {
|
||||
PerformanceMeasurer::SetInactive(PFE_GL_LINKGRAPH);
|
||||
LinkGraphSchedule::instance.JoinNext();
|
||||
|
Reference in New Issue
Block a user