From e15a4939275e14b4d8ee2df94049edb34d57954e Mon Sep 17 00:00:00 2001 From: Kargatum Date: Fri, 11 Sep 2020 19:03:26 +0700 Subject: [PATCH] feat(Core/Time): remove inherited ACE Time (#3455) Co-authored-by: Viste --- src/common/Common.h | 1 - src/common/Database/MySQLConnection.cpp | 30 +++++------ src/common/Logging/Log.cpp | 2 +- src/common/Packets/ByteBuffer.h | 6 +-- src/common/Utilities/Duration.h | 33 ++++++++++++ src/common/Utilities/Timer.h | 24 +++++++-- src/common/Utilities/Util.cpp | 50 ++++++++++++++++++- src/common/Utilities/Util.h | 6 +++ .../game/Achievements/AchievementMgr.cpp | 2 +- src/server/game/Entities/Player/Player.cpp | 2 +- src/server/game/Server/WorldSocket.cpp | 23 +++++---- src/server/game/Server/WorldSocket.h | 4 +- src/server/game/Weather/Weather.cpp | 2 +- src/server/game/World/World.cpp | 4 +- src/server/scripts/Commands/cs_ban.cpp | 12 ++--- src/server/scripts/Commands/cs_guild.cpp | 2 +- src/server/scripts/Commands/cs_misc.cpp | 2 +- src/server/scripts/Events/brewfest.cpp | 2 +- src/server/scripts/World/npcs_special.cpp | 4 +- .../worldserver/RemoteAccess/RASocket.cpp | 4 +- 20 files changed, 157 insertions(+), 58 deletions(-) create mode 100644 src/common/Utilities/Duration.h diff --git a/src/common/Common.h b/src/common/Common.h index 5e750d087..8927c6f5e 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -83,7 +83,6 @@ #include #include #include -#include #include #if AC_PLATFORM == AC_PLATFORM_WINDOWS diff --git a/src/common/Database/MySQLConnection.cpp b/src/common/Database/MySQLConnection.cpp index ea05f21e3..f1218ec66 100644 --- a/src/common/Database/MySQLConnection.cpp +++ b/src/common/Database/MySQLConnection.cpp @@ -4,18 +4,7 @@ * Copyright (C) 2005-2009 MaNGOS */ - #include "Common.h" - -#ifdef _WIN32 - #include -#endif -#include -#include -#include -#include -#include - #include "MySQLConnection.h" #include "MySQLThreading.h" #include "QueryResult.h" @@ -24,9 +13,15 @@ #include "DatabaseWorker.h" #include "Timer.h" #include "Log.h" +#include "Duration.h" +#include +#include +#include +#include -using namespace std::this_thread; -using namespace std::chrono; +#ifdef _WIN32 +#include +#endif MySQLConnection::MySQLConnection(MySQLConnectionInfo& connInfo) : m_reconnecting(false), @@ -113,7 +108,6 @@ bool MySQLConnection::Open() // Possible improvement for future: make ATTEMPTS and SECONDS configurable values uint32 const ATTEMPTS = 180; - uint32 const SECONDS = 10; uint32 count = 0; do { @@ -153,7 +147,7 @@ bool MySQLConnection::Open() count++; sLog->outError("Could not connect to MySQL database at %s: %s\n", m_connectionInfo.host.c_str(), mysql_error(mysqlInit)); sLog->outError("Retrying in 10 seconds...\n\n"); - sleep_for(seconds(SECONDS)); + std::this_thread::sleep_for(10s); } } while (!m_Mysql && count < ATTEMPTS); @@ -537,7 +531,7 @@ bool MySQLConnection::_HandleMySQLErrno(uint32 errNo) } uint32 lErrno = mysql_errno(GetHandle()); // It's possible this attempted reconnect throws 2006 at us. To prevent crazy recursive calls, sleep here. - ACE_OS::sleep(3); // Sleep 3 seconds + std::this_thread::sleep_for(3s); // Sleep 3 seconds return _HandleMySQLErrno(lErrno); // Call self (recursive) } @@ -552,12 +546,12 @@ bool MySQLConnection::_HandleMySQLErrno(uint32 errNo) case ER_BAD_FIELD_ERROR: case ER_NO_SUCH_TABLE: sLog->outError("Your database structure is not up to date. Please make sure you've executed all queries in the sql/updates folders."); - ACE_OS::sleep(10); + std::this_thread::sleep_for(10s); std::abort(); return false; case ER_PARSE_ERROR: sLog->outError("Error while parsing SQL. Core fix required."); - ACE_OS::sleep(10); + std::this_thread::sleep_for(10s); std::abort(); return false; default: diff --git a/src/common/Logging/Log.cpp b/src/common/Logging/Log.cpp index 669adc4dc..05f1f83e8 100644 --- a/src/common/Logging/Log.cpp +++ b/src/common/Logging/Log.cpp @@ -340,7 +340,7 @@ std::string Log::GetTimestampStr() { time_t t = time(NULL); tm aTm; - ACE_OS::localtime_r(&t, &aTm); + localtime_r(&t, &aTm); // YYYY year // MM month (2 digits 01-12) // DD day (2 digits 01-31) diff --git a/src/common/Packets/ByteBuffer.h b/src/common/Packets/ByteBuffer.h index 09ba09005..f14d50cfe 100644 --- a/src/common/Packets/ByteBuffer.h +++ b/src/common/Packets/ByteBuffer.h @@ -9,16 +9,14 @@ #include "Common.h" #include "Errors.h" +#include "Util.h" #include "ByteConverter.h" - -#include #include #include #include #include #include #include -#include // Root of ByteBuffer exception hierarchy class ByteBufferException : public std::exception @@ -489,7 +487,7 @@ class ByteBuffer void AppendPackedTime(time_t time) { tm lt; - ACE_OS::localtime_r(&time, <); + localtime_r(&time, <); append((lt.tm_year - 100) << 24 | lt.tm_mon << 20 | (lt.tm_mday - 1) << 14 | lt.tm_wday << 11 | lt.tm_hour << 6 | lt.tm_min); } diff --git a/src/common/Utilities/Duration.h b/src/common/Utilities/Duration.h new file mode 100644 index 000000000..1f133c225 --- /dev/null +++ b/src/common/Utilities/Duration.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2 + * Copyright (C) 2008-2020 TrinityCore + */ + +#ifndef _DURATION_H_ +#define _DURATION_H_ + +#include + +/// Microseconds shorthand typedef. +typedef std::chrono::microseconds Microseconds; + +/// Milliseconds shorthand typedef. +typedef std::chrono::milliseconds Milliseconds; + +/// Seconds shorthand typedef. +typedef std::chrono::seconds Seconds; + +/// Minutes shorthand typedef. +typedef std::chrono::minutes Minutes; + +/// Hours shorthand typedef. +typedef std::chrono::hours Hours; + +/// time_point shorthand typedefs +typedef std::chrono::steady_clock::time_point TimePoint; +typedef std::chrono::system_clock::time_point SystemTimePoint; + +/// Makes std::chrono_literals globally available. +using namespace std::chrono_literals; + +#endif diff --git a/src/common/Utilities/Timer.h b/src/common/Utilities/Timer.h index 20fa6d13e..24396915d 100644 --- a/src/common/Utilities/Timer.h +++ b/src/common/Utilities/Timer.h @@ -7,13 +7,23 @@ #ifndef ACORE_TIMER_H #define ACORE_TIMER_H -#include "ace/OS_NS_sys_time.h" #include "Common.h" +#include "Duration.h" + +inline TimePoint GetApplicationStartTime() +{ + using namespace std::chrono; + + static const steady_clock::time_point ApplicationStartTime = steady_clock::now(); + + return ApplicationStartTime; +} inline uint32 getMSTime() { - static const ACE_Time_Value ApplicationStartTime = ACE_OS::gettimeofday(); - return (ACE_OS::gettimeofday() - ApplicationStartTime).msec(); + using namespace std::chrono; + + return uint32(duration_cast(steady_clock::now() - GetApplicationStartTime()).count()); } inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime) @@ -25,6 +35,14 @@ inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime) return newMSTime - oldMSTime; } +inline uint32 getMSTimeDiff(uint32 oldMSTime, TimePoint newTime) +{ + using namespace std::chrono; + + uint32 newMSTime = uint32(duration_cast(newTime - GetApplicationStartTime()).count()); + return getMSTimeDiff(oldMSTime, newMSTime); +} + inline uint32 GetMSTimeDiffToNow(uint32 oldMSTime) { return getMSTimeDiff(oldMSTime, getMSTime()); diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index 4cc28e37d..26a0cd396 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -102,6 +102,45 @@ Tokenizer::Tokenizer(const std::string &src, const char sep, uint32 vectorReserv } } +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) +struct tm* localtime_r(time_t const* time, struct tm* result) +{ + localtime_s(result, time); + return result; +} +#endif + +tm TimeBreakdown(time_t time) +{ + tm timeLocal; + localtime_r(&time, &timeLocal); + return timeLocal; +} + +time_t LocalTimeToUTCTime(time_t time) +{ +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) + return time + _timezone; +#else + return time + timezone; +#endif +} + +time_t GetLocalHourTimestamp(time_t time, uint8 hour, bool onlyAfterTime) +{ + tm timeLocal = TimeBreakdown(time); + timeLocal.tm_hour = 0; + timeLocal.tm_min = 0; + timeLocal.tm_sec = 0; + time_t midnightLocal = mktime(&timeLocal); + time_t hourLocal = midnightLocal + hour * HOUR; + + if (onlyAfterTime && hourLocal <= time) + hourLocal += DAY; + + return hourLocal; +} + void stripLineInvisibleChars(std::string &str) { static std::string const invChars = " \t\7\n"; @@ -227,7 +266,7 @@ uint32 TimeStringToSecs(const std::string& timestring) std::string TimeToTimestampStr(time_t t) { tm aTm; - ACE_OS::localtime_r(&t, &aTm); + localtime_r(&t, &aTm); // YYYY year // MM month (2 digits 01-12) // DD day (2 digits 01-31) @@ -245,6 +284,15 @@ std::string TimeToTimestampStr(time_t t) return std::string(buf); } +std::string TimeToHumanReadable(time_t t) +{ + tm time; + localtime_r(&t, &time); + char buf[30]; + strftime(buf, 30, "%c", &time); + return std::string(buf); +} + /// Check if the string is a valid ip address representation bool IsIPAddress(char const* ipaddress) { diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h index d14a339ac..3e0332b69 100644 --- a/src/common/Utilities/Util.h +++ b/src/common/Utilities/Util.h @@ -56,6 +56,11 @@ private: StorageType m_storage; }; +struct tm* localtime_r(time_t const* time, struct tm* result); +time_t LocalTimeToUTCTime(time_t time); +time_t GetLocalHourTimestamp(time_t time, uint8 hour, bool onlyAfterTime = true); +tm TimeBreakdown(time_t t); + void stripLineInvisibleChars(std::string &src); int32 MoneyStringToMoney(const std::string& moneyString); @@ -63,6 +68,7 @@ int32 MoneyStringToMoney(const std::string& moneyString); std::string secsToTimeString(uint64 timeInSecs, bool shortText = false); uint32 TimeStringToSecs(const std::string& timestring); std::string TimeToTimestampStr(time_t t); +std::string TimeToHumanReadable(time_t t); /* Return a random number in the range min..max. */ int32 irand(int32 min, int32 max); diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index ffdf94bd0..17d93697b 100644 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -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; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 7395e9e2c..6e6ad24f4 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -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; diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index 05564465e..bd9eb2296 100644 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -32,6 +32,8 @@ #include "PacketLog.h" #include "ScriptMgr.h" #include "AccountMgr.h" +#include + #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 (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(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) { diff --git a/src/server/game/Server/WorldSocket.h b/src/server/game/Server/WorldSocket.h index 9dd8bb65d..5dfc0c099 100644 --- a/src/server/game/Server/WorldSocket.h +++ b/src/server/game/Server/WorldSocket.h @@ -13,7 +13,6 @@ #ifndef _WORLDSOCKET_H #define _WORLDSOCKET_H -#include #include #include #include @@ -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; diff --git a/src/server/game/Weather/Weather.cpp b/src/server/game/Weather/Weather.cpp index 21074247a..a6acbc1c8 100644 --- a/src/server/game/Weather/Weather.cpp +++ b/src/server/game/Weather/Weather.cpp @@ -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) diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 1ed8956f3..38349d213 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -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; diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp index 65161050d..507d67aff 100644 --- a/src/server/scripts/Commands/cs_ban.cpp +++ b/src/server/scripts/Commands/cs_ban.cpp @@ -460,7 +460,7 @@ public: { time_t timeBan = time_t(fields2[0].GetUInt32()); tm tmBan; - ACE_OS::localtime_r(&timeBan, &tmBan); + localtime_r(&timeBan, &tmBan); if (fields2[0].GetUInt32() == fields2[1].GetUInt32()) { @@ -472,7 +472,7 @@ public: { time_t timeUnban = time_t(fields2[1].GetUInt32()); tm tmUnban; - ACE_OS::localtime_r(&timeUnban, &tmUnban); + localtime_r(&timeUnban, &tmUnban); handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", accountName.c_str(), tmBan.tm_year%100, tmBan.tm_mon+1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, tmUnban.tm_year%100, tmUnban.tm_mon+1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min, @@ -549,7 +549,7 @@ public: { time_t timeBan = time_t(banFields[0].GetUInt32()); tm tmBan; - ACE_OS::localtime_r(&timeBan, &tmBan); + localtime_r(&timeBan, &tmBan); if (banFields[0].GetUInt32() == banFields[1].GetUInt32()) { @@ -561,7 +561,7 @@ public: { time_t timeUnban = time_t(banFields[1].GetUInt32()); tm tmUnban; - ACE_OS::localtime_r(&timeUnban, &tmUnban); + localtime_r(&timeUnban, &tmUnban); handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", char_name.c_str(), tmBan.tm_year%100, tmBan.tm_mon+1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, tmUnban.tm_year%100, tmUnban.tm_mon+1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min, @@ -630,7 +630,7 @@ public: Field* fields = result->Fetch(); time_t timeBan = time_t(fields[1].GetUInt32()); tm tmBan; - ACE_OS::localtime_r(&timeBan, &tmBan); + localtime_r(&timeBan, &tmBan); if (fields[1].GetUInt32() == fields[2].GetUInt32()) { handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", @@ -641,7 +641,7 @@ public: { time_t timeUnban = time_t(fields[2].GetUInt32()); tm tmUnban; - ACE_OS::localtime_r(&timeUnban, &tmUnban); + localtime_r(&timeUnban, &tmUnban); handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", fields[0].GetCString(), tmBan.tm_year%100, tmBan.tm_mon+1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, tmUnban.tm_year%100, tmUnban.tm_mon+1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min, diff --git a/src/server/scripts/Commands/cs_guild.cpp b/src/server/scripts/Commands/cs_guild.cpp index 6ed6c7e23..1692cf1ac 100644 --- a/src/server/scripts/Commands/cs_guild.cpp +++ b/src/server/scripts/Commands/cs_guild.cpp @@ -224,7 +224,7 @@ public: char createdDateStr[20]; time_t createdDate = guild->GetCreatedDate(); tm localTm; - ACE_OS::localtime_r(&createdDate, &localTm); + localtime_r(&createdDate, &localTm); strftime(createdDateStr, 20, "%Y-%m-%d %H:%M:%S", &localTm); handler->PSendSysMessage(LANG_GUILD_INFO_CREATION_DATE, createdDateStr); // Creation Date diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 71b858ac9..17480baf3 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -2370,7 +2370,7 @@ public: char buffer[80]; // set it to string - ACE_OS::localtime_r(&sqlTime, &timeInfo); + localtime_r(&sqlTime, &timeInfo); strftime(buffer, sizeof(buffer), "%Y-%m-%d %I:%M%p", &timeInfo); handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY_OUTPUT, buffer, fields[1].GetUInt32(), fields[2].GetCString(), fields[3].GetCString()); diff --git a/src/server/scripts/Events/brewfest.cpp b/src/server/scripts/Events/brewfest.cpp index 5b4c0a876..77f2298e5 100644 --- a/src/server/scripts/Events/brewfest.cpp +++ b/src/server/scripts/Events/brewfest.cpp @@ -846,7 +846,7 @@ public: { time_t curtime = time(nullptr); tm strDate; - ACE_OS::localtime_r(&curtime, &strDate); + localtime_r(&curtime, &strDate); if (strDate.tm_min == 0 || strDate.tm_min == 30) return true; diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index f7e88a61f..e9d3dab3c 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -110,7 +110,7 @@ public: { time_t curtime = time(nullptr); tm strdate; - ACE_OS::localtime_r(&curtime, &strdate); + localtime_r(&curtime, &strdate); if (!preWarning && strdate.tm_hour == 13 && strdate.tm_min == 55) { @@ -255,7 +255,7 @@ public: { time_t curtime = time(nullptr); tm strdate; - ACE_OS::localtime_r(&curtime, &strdate); + localtime_r(&curtime, &strdate); if (!startWarning && strdate.tm_hour == 14 && strdate.tm_min == 0) { sCreatureTextMgr->SendChat(me, RIGGLE_SAY_START, 0, CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, TEXT_RANGE_ZONE); diff --git a/src/server/worldserver/RemoteAccess/RASocket.cpp b/src/server/worldserver/RemoteAccess/RASocket.cpp index 6da54150f..502c7f2b8 100644 --- a/src/server/worldserver/RemoteAccess/RASocket.cpp +++ b/src/server/worldserver/RemoteAccess/RASocket.cpp @@ -15,9 +15,11 @@ #include "Log.h" #include "RASocket.h" #include "Util.h" +#include "Duration.h" #include "World.h" #include "SHA1.h" #include "ServerMotd.h" +#include RASocket::RASocket() { @@ -49,7 +51,7 @@ int RASocket::handle_close(ACE_HANDLE /*handle*/, ACE_Reactor_Mask /*mask*/) // RASocket::commandfinished to be completed. Calling destroy() before the latter function ends // will lead to using a freed pointer -> crash. while (_commandExecuting) - ACE_OS::sleep(1); + std::this_thread::sleep_for(1s); destroy(); return 0;