mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-28 16:16:27 +00:00
feat(Core/Time): remove inherited ACE Time (#3455)
Co-authored-by: Viste <viste02@gmail.com>
This commit is contained in:
@@ -428,7 +428,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un
|
||||
{
|
||||
time_t birthday_start = time_t(sWorld->getIntConfig(CONFIG_BIRTHDAY_TIME));
|
||||
tm birthday_tm;
|
||||
ACE_OS::localtime_r(&birthday_start, &birthday_tm);
|
||||
localtime_r(&birthday_start, &birthday_tm);
|
||||
|
||||
// exactly N birthday
|
||||
birthday_tm.tm_year += birthday_login.nth_birthday;
|
||||
|
||||
@@ -27411,7 +27411,7 @@ void Player::_LoadBrewOfTheMonth(PreparedQueryResult result)
|
||||
|
||||
time_t curtime = time(nullptr);
|
||||
tm localTime;
|
||||
ACE_OS::localtime_r(&curtime, &localTime);
|
||||
localtime_r(&curtime, &localTime);
|
||||
|
||||
uint16 month = uint16(localTime.tm_mon);
|
||||
uint16 eventId = month;
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
#include "PacketLog.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "AccountMgr.h"
|
||||
#include <thread>
|
||||
|
||||
#ifdef ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
@@ -90,7 +92,7 @@ struct ClientPktHeader
|
||||
#endif
|
||||
|
||||
WorldSocket::WorldSocket(void): WorldHandler(),
|
||||
m_LastPingTime(ACE_Time_Value::zero), m_OverSpeedPings(0), m_Session(0),
|
||||
m_LastPingTime(SystemTimePoint::min()), m_OverSpeedPings(0), m_Session(0),
|
||||
m_RecvWPct(0), m_RecvPct(), m_Header(sizeof (ClientPktHeader)),
|
||||
m_OutBuffer(0), m_OutBufferSize(65536), m_OutActive(false),
|
||||
m_Seed(static_cast<uint32> (rand32()))
|
||||
@@ -1021,9 +1023,9 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
|
||||
|
||||
// Sleep this Network thread for
|
||||
uint32 sleepTime = sWorld->getIntConfig(CONFIG_SESSION_ADD_DELAY);
|
||||
ACE_OS::sleep (ACE_Time_Value (0, sleepTime));
|
||||
std::this_thread::sleep_for(Microseconds(sleepTime));
|
||||
|
||||
sWorld->AddSession (m_Session);
|
||||
sWorld->AddSession(m_Session);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1037,20 +1039,19 @@ int WorldSocket::HandlePing(WorldPacket& recvPacket)
|
||||
recvPacket >> ping;
|
||||
recvPacket >> latency;
|
||||
|
||||
if (m_LastPingTime == ACE_Time_Value::zero)
|
||||
m_LastPingTime = ACE_OS::gettimeofday(); // for 1st ping
|
||||
if (m_LastPingTime == SystemTimePoint::min())
|
||||
m_LastPingTime = std::chrono::system_clock::now(); // for 1st ping
|
||||
else
|
||||
{
|
||||
ACE_Time_Value cur_time = ACE_OS::gettimeofday();
|
||||
ACE_Time_Value diff_time (cur_time);
|
||||
diff_time -= m_LastPingTime;
|
||||
m_LastPingTime = cur_time;
|
||||
auto now = std::chrono::system_clock::now();
|
||||
Seconds seconds = std::chrono::duration_cast<Seconds>(now - m_LastPingTime);
|
||||
m_LastPingTime = now;
|
||||
|
||||
if (diff_time < ACE_Time_Value (27))
|
||||
if (seconds.count() < 27)
|
||||
{
|
||||
++m_OverSpeedPings;
|
||||
|
||||
uint32 max_count = sWorld->getIntConfig (CONFIG_MAX_OVERSPEED_PINGS);
|
||||
uint32 max_count = sWorld->getIntConfig(CONFIG_MAX_OVERSPEED_PINGS);
|
||||
|
||||
if (max_count && m_OverSpeedPings > max_count)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#ifndef _WORLDSOCKET_H
|
||||
#define _WORLDSOCKET_H
|
||||
|
||||
#include <ace/Basic_Types.h>
|
||||
#include <ace/Synch_Traits.h>
|
||||
#include <ace/Svc_Handler.h>
|
||||
#include <ace/SOCK_Stream.h>
|
||||
@@ -28,6 +27,7 @@
|
||||
|
||||
#include "Common.h"
|
||||
#include "AuthCrypt.h"
|
||||
#include "Duration.h"
|
||||
|
||||
class ACE_Message_Block;
|
||||
class WorldPacket;
|
||||
@@ -151,7 +151,7 @@ class WorldSocket : public WorldHandler
|
||||
|
||||
private:
|
||||
/// Time in which the last ping was received
|
||||
ACE_Time_Value m_LastPingTime;
|
||||
SystemTimePoint m_LastPingTime;
|
||||
|
||||
/// Keep track of over-speed pings, to prevent ping flood.
|
||||
uint32 m_OverSpeedPings;
|
||||
|
||||
@@ -84,7 +84,7 @@ bool Weather::ReGenerate()
|
||||
// season source http://aa.usno.navy.mil/data/docs/EarthSeasons.html
|
||||
time_t gtime = sWorld->GetGameTime();
|
||||
struct tm ltime;
|
||||
ACE_OS::localtime_r(>ime, <ime);
|
||||
localtime_r(>ime, <ime);
|
||||
uint32 season = ((ltime.tm_yday - 78 + 365)/91)%4;
|
||||
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
|
||||
@@ -2838,7 +2838,7 @@ time_t World::GetNextTimeWithDayAndHour(int8 dayOfWeek, int8 hour)
|
||||
hour = 0;
|
||||
time_t curr = time(nullptr);
|
||||
tm localTm;
|
||||
ACE_OS::localtime_r(&curr, &localTm);
|
||||
localtime_r(&curr, &localTm);
|
||||
localTm.tm_hour = hour;
|
||||
localTm.tm_min = 0;
|
||||
localTm.tm_sec = 0;
|
||||
@@ -2859,7 +2859,7 @@ time_t World::GetNextTimeWithMonthAndHour(int8 month, int8 hour)
|
||||
hour = 0;
|
||||
time_t curr = time(nullptr);
|
||||
tm localTm;
|
||||
ACE_OS::localtime_r(&curr, &localTm);
|
||||
localtime_r(&curr, &localTm);
|
||||
localTm.tm_mday = 1;
|
||||
localTm.tm_hour = hour;
|
||||
localTm.tm_min = 0;
|
||||
|
||||
Reference in New Issue
Block a user