feat(Core/Time): Implement saparated manager for game time (#8630)

This commit is contained in:
Kargatum
2022-01-24 17:55:00 +07:00
committed by GitHub
parent 12da792a90
commit 8b7df23f06
129 changed files with 1147 additions and 817 deletions

View File

@@ -17,6 +17,7 @@
#include "PacketLog.h"
#include "Config.h"
#include "GameTime.h"
#include "IpAddress.h"
#include "Timer.h"
#include "WorldPacket.h"
@@ -99,7 +100,7 @@ void PacketLog::Initialize()
header.Build = 12340;
header.Locale[0] = 'e'; header.Locale[1] = 'n'; header.Locale[2] = 'U'; header.Locale[3] = 'S';
std::memset(header.SessionKey, 0, sizeof(header.SessionKey));
header.SniffStartUnixtime = time(nullptr);
header.SniffStartUnixtime = GameTime::GetGameTime().count();
header.SniffStartTicks = getMSTime();
header.OptionalDataSize = 0;

View File

@@ -25,6 +25,7 @@
#include "CharacterPackets.h"
#include "Common.h"
#include "DatabaseEnv.h"
#include "GameTime.h"
#include "Group.h"
#include "Guild.h"
#include "GuildMgr.h"
@@ -219,13 +220,13 @@ void WorldSession::SendPacket(WorldPacket const* packet)
static uint64 sendPacketCount = 0;
static uint64 sendPacketBytes = 0;
static time_t firstTime = time(nullptr);
static time_t firstTime = GameTime::GetGameTime().count();
static time_t lastTime = firstTime; // next 60 secs start time
static uint64 sendLastPacketCount = 0;
static uint64 sendLastPacketBytes = 0;
time_t cur_time = time(nullptr);
time_t cur_time = GameTime::GetGameTime().count();
if ((cur_time - lastTime) < 60)
{
@@ -306,7 +307,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
bool deletePacket = true;
std::vector<WorldPacket*> requeuePackets;
uint32 processedPackets = 0;
time_t currentTime = time(nullptr);
time_t currentTime = GameTime::GetGameTime().count();
while (m_Socket && _recvQueue.next(packet, updater))
{
@@ -510,7 +511,7 @@ void WorldSession::HandleTeleportTimeout(bool updateInSessions)
// pussywizard: handle teleport ack timeout
if (m_Socket && m_Socket->IsOpen() && GetPlayer() && GetPlayer()->IsBeingTeleported())
{
time_t currTime = time(nullptr);
time_t currTime = GameTime::GetGameTime().count();
if (updateInSessions) // session update from World::UpdateSessions
{
if (GetPlayer()->IsBeingTeleportedFar() && GetPlayer()->GetSemaphoreTeleportFar() + sWorld->getIntConfig(CONFIG_TELEPORT_TIMEOUT_FAR) < currTime)
@@ -897,7 +898,7 @@ void WorldSession::SetAccountData(AccountDataType type, time_t tm, std::string c
void WorldSession::SendAccountDataTimes(uint32 mask)
{
WorldPacket data(SMSG_ACCOUNT_DATA_TIMES, 4 + 1 + 4 + 8 * 4); // changed in WotLK
data << uint32(time(nullptr)); // unix time of something
data << uint32(GameTime::GetGameTime().count()); // unix time of something
data << uint8(1);
data << uint32(mask); // type mask
for (uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)

View File

@@ -21,6 +21,7 @@
#include "CryptoHash.h"
#include "CryptoRandom.h"
#include "DatabaseEnv.h"
#include "GameTime.h"
#include "IPLocation.h"
#include "Opcodes.h"
#include "PacketLog.h"
@@ -357,7 +358,7 @@ WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler()
_worldSession->ResetTimeOutTime(true);
return ReadDataHandlerResult::Ok;
case CMSG_TIME_SYNC_RESP:
packetToQueue = new WorldPacket(std::move(packet), std::chrono::steady_clock::now());
packetToQueue = new WorldPacket(std::move(packet), GameTime::Now());
break;
default:
packetToQueue = new WorldPacket(std::move(packet));
@@ -556,7 +557,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes
//! Negative mutetime indicates amount of minutes to be muted effective on next login - which is now.
if (account.MuteTime < 0)
{
account.MuteTime = time(nullptr) + llabs(account.MuteTime);
account.MuteTime = GameTime::GetGameTime().count() + llabs(account.MuteTime);
auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME_LOGIN);
stmt->setInt64(0, account.MuteTime);