Codechange: move all date-related variables inside the timer (#10706)
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../strings_func.h"
|
||||
#include "../date_func.h"
|
||||
#include "core/game_info.h"
|
||||
#include "network_admin.h"
|
||||
#include "network_server.h"
|
||||
@@ -882,10 +881,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p)
|
||||
assert(NetworkClientInfo::CanAllocateItem());
|
||||
NetworkClientInfo *ci = new NetworkClientInfo(this->client_id);
|
||||
this->SetInfo(ci);
|
||||
ci->join_date = _date;
|
||||
ci->join_date = TimerGameCalendar::date;
|
||||
ci->client_name = client_name;
|
||||
ci->client_playas = playas;
|
||||
Debug(desync, 1, "client: {:08x}; {:02x}; {:02x}; {:02x}", _date, _date_fract, (int)ci->client_playas, (int)ci->index);
|
||||
Debug(desync, 1, "client: {:08x}; {:02x}; {:02x}; {:02x}", TimerGameCalendar::date, TimerGameCalendar::date_fract, (int)ci->client_playas, (int)ci->index);
|
||||
|
||||
/* Make sure companies to which people try to join are not autocleaned */
|
||||
if (Company::IsValidID(playas)) _network_company_states[playas].months_empty = 0;
|
||||
@@ -1479,7 +1478,7 @@ void NetworkUpdateClientInfo(ClientID client_id)
|
||||
|
||||
if (ci == nullptr) return;
|
||||
|
||||
Debug(desync, 1, "client: {:08x}; {:02x}; {:02x}; {:04x}", _date, _date_fract, (int)ci->client_playas, client_id);
|
||||
Debug(desync, 1, "client: {:08x}; {:02x}; {:02x}; {:04x}", TimerGameCalendar::date, TimerGameCalendar::date_fract, (int)ci->client_playas, client_id);
|
||||
|
||||
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
||||
if (cs->status >= ServerNetworkGameSocketHandler::STATUS_AUTHORIZED) {
|
||||
@@ -1493,8 +1492,8 @@ void NetworkUpdateClientInfo(ClientID client_id)
|
||||
/** Check if we want to restart the map */
|
||||
static void NetworkCheckRestartMap()
|
||||
{
|
||||
if (_settings_client.network.restart_game_year != 0 && _cur_year >= _settings_client.network.restart_game_year) {
|
||||
Debug(net, 3, "Auto-restarting map: year {} reached", _cur_year);
|
||||
if (_settings_client.network.restart_game_year != 0 && TimerGameCalendar::year >= _settings_client.network.restart_game_year) {
|
||||
Debug(net, 3, "Auto-restarting map: year {} reached", TimerGameCalendar::year);
|
||||
|
||||
_settings_newgame.game_creation.generation_seed = GENERATE_NEW_SEED;
|
||||
switch(_file_to_saveload.abstract_ftype) {
|
||||
@@ -1829,7 +1828,7 @@ static IntervalTimer<TimerGameCalendar> _network_monthly({TimerGameCalendar::MON
|
||||
|
||||
NetworkAutoCleanCompanies();
|
||||
NetworkAdminUpdate(ADMIN_FREQUENCY_MONTHLY);
|
||||
if ((_cur_month % 3) == 0) NetworkAdminUpdate(ADMIN_FREQUENCY_QUARTERLY);
|
||||
if ((TimerGameCalendar::month % 3) == 0) NetworkAdminUpdate(ADMIN_FREQUENCY_QUARTERLY);
|
||||
});
|
||||
|
||||
/** Daily "callback". Called whenever the date changes. */
|
||||
@@ -1838,7 +1837,7 @@ static IntervalTimer<TimerGameCalendar> _network_daily({TimerGameCalendar::DAY,
|
||||
if (!_network_server) return;
|
||||
|
||||
NetworkAdminUpdate(ADMIN_FREQUENCY_DAILY);
|
||||
if ((_date % 7) == 3) NetworkAdminUpdate(ADMIN_FREQUENCY_WEEKLY);
|
||||
if ((TimerGameCalendar::date % 7) == 3) NetworkAdminUpdate(ADMIN_FREQUENCY_WEEKLY);
|
||||
});
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user