Replaced all ACE_OS::localtime_r calls

This commit is contained in:
leak
2014-06-22 15:42:46 +02:00
parent ccf3374e49
commit 7dd6f0f1d8
10 changed files with 27 additions and 24 deletions

View File

@@ -425,7 +425,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;

View File

@@ -5347,7 +5347,7 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
time_t curTime = time(NULL);
tm lt;
ACE_OS::localtime_r(&curTime, &lt);
localtime_r(&curTime, &lt);
uint64 basetime(curTime);
TC_LOG_INFO("misc", "Returning mails current time: hour: %d, minute: %d, second: %d ", lt.tm_hour, lt.tm_min, lt.tm_sec);

View File

@@ -94,7 +94,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(&gtime, &ltime);
localtime_r(&gtime, &ltime);
uint32 season = ((ltime.tm_yday - 78 + 365)/91)%4;
static char const* seasonName[WEATHER_SEASONS] = { "spring", "summer", "fall", "winter" };

View File

@@ -1745,7 +1745,7 @@ void World::SetInitialWorldSettings()
//one second is 1000 -(tested on win system)
/// @todo Get rid of magic numbers
tm localTm;
ACE_OS::localtime_r(&m_gameTime, &localTm);
localtime_r(&m_gameTime, &localTm);
mail_timer = ((((localTm.tm_hour + 20) % 24)* HOUR * IN_MILLISECONDS) / m_timers[WUPDATE_AUCTIONS].GetInterval());
//1440
mail_timer_expires = ((DAY * IN_MILLISECONDS) / (m_timers[WUPDATE_AUCTIONS].GetInterval()));
@@ -2775,7 +2775,7 @@ void World::InitDailyQuestResetTime()
// FIX ME: client not show day start time
time_t curTime = time(NULL);
tm localTm;
ACE_OS::localtime_r(&curTime, &localTm);
localtime_r(&curTime, &localTm);
localTm.tm_hour = 6;
localTm.tm_min = 0;
localTm.tm_sec = 0;
@@ -2809,7 +2809,7 @@ void World::InitRandomBGResetTime()
// generate time by config
time_t curTime = time(NULL);
tm localTm;
ACE_OS::localtime_r(&curTime, &localTm);
localtime_r(&curTime, &localTm);
localTm.tm_hour = getIntConfig(CONFIG_RANDOM_BG_RESET_HOUR);
localTm.tm_min = 0;
localTm.tm_sec = 0;
@@ -2837,7 +2837,7 @@ void World::InitGuildResetTime()
// generate time by config
time_t curTime = time(NULL);
tm localTm;
ACE_OS::localtime_r(&curTime, &localTm);
localtime_r(&curTime, &localTm);
localTm.tm_hour = getIntConfig(CONFIG_GUILD_RESET_HOUR);
localTm.tm_min = 0;
localTm.tm_sec = 0;
@@ -2922,7 +2922,7 @@ void World::ResetMonthlyQuests()
// generate time
time_t curTime = time(NULL);
tm localTm;
ACE_OS::localtime_r(&curTime, &localTm);
localtime_r(&curTime, &localTm);
int month = localTm.tm_mon;
int year = localTm.tm_year;

View File

@@ -457,7 +457,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())
{
@@ -469,7 +469,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,
@@ -546,7 +546,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())
{
@@ -558,7 +558,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,
@@ -627,7 +627,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|",
@@ -638,7 +638,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,

View File

@@ -21,7 +21,8 @@
std::string LogMessage::getTimeStr(time_t time)
{
tm aTm = localtime_r(time);
tm aTm;
localtime_r(&time, &aTm);
char buf[20];
snprintf(buf, 20, "%04d-%02d-%02d_%02d:%02d:%02d", aTm.tm_year+1900, aTm.tm_mon+1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec);
return std::string(buf);

View File

@@ -285,7 +285,8 @@ std::string Log::GetTimestampStr()
{
time_t tt = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::tm aTm = localtime_r(tt);
std::tm aTm;
localtime_r(&tt, &aTm);
// YYYY year
// MM month (2 digits 01-12)

View File

@@ -460,7 +460,8 @@ class ByteBuffer
void AppendPackedTime(time_t time)
{
tm lt = localtime_r(time);
tm lt;
localtime_r(&time, &lt);
append<uint32>((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);
}

View File

@@ -139,15 +139,14 @@ void stripLineInvisibleChars(std::string &str)
}
std::tm localtime_r(const time_t& time)
struct tm* localtime_r(const time_t* time, struct tm *result)
{
std::tm tm_snapshot;
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__))
localtime_s(&tm_snapshot, &time);
localtime_s(result, time);
return result;
#else
localtime_r(&time, &tm_snapshot); // POSIX
return localtime_r(&time, &result); // POSIX
#endif
return tm_snapshot;
}
@@ -239,7 +238,8 @@ uint32 TimeStringToSecs(const std::string& timestring)
std::string TimeToTimestampStr(time_t t)
{
tm aTm = localtime_r(t);
tm aTm;
localtime_r(&t, &aTm);
// YYYY year
// MM month (2 digits 01-12)
// DD day (2 digits 01-31)

View File

@@ -70,7 +70,7 @@ void stripLineInvisibleChars(std::string &src);
int32 MoneyStringToMoney(const std::string& moneyString);
std::tm localtime_r(const time_t& time);
struct tm* localtime_r(const time_t* time, struct tm *result);
std::string secsToTimeString(uint64 timeInSecs, bool shortText = false, bool hoursOnly = false);
uint32 TimeStringToSecs(const std::string& timestring);