aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Battlegrounds/ArenaTeam.cpp10
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp5
-rw-r--r--src/server/game/Weather/Weather.cpp5
-rw-r--r--src/server/game/World/World.cpp16
-rw-r--r--src/server/scripts/Commands/cs_ban.cpp36
-rw-r--r--src/server/scripts/Commands/cs_pet.cpp2
-rw-r--r--src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp1
-rw-r--r--src/server/shared/Common.h1
-rw-r--r--src/server/shared/Logging/Appender.cpp5
-rw-r--r--src/server/shared/Logging/Log.cpp5
-rw-r--r--src/server/shared/Packets/ByteBuffer.h5
-rw-r--r--src/server/shared/Utilities/Timer.h2
-rw-r--r--src/server/shared/Utilities/Util.cpp5
13 files changed, 58 insertions, 40 deletions
diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp
index a84e7ec30db..08557b939eb 100644
--- a/src/server/game/Battlegrounds/ArenaTeam.cpp
+++ b/src/server/game/Battlegrounds/ArenaTeam.cpp
@@ -82,7 +82,7 @@ bool ArenaTeam::Create(uint64 captainGuid, uint8 type, std::string const& teamNa
// Add captain as member
AddMember(CaptainGuid);
- TC_LOG_INFO(LOG_FILTER_ARENAS, "New ArenaTeam created [Id: %u] [Type: %u] [Captain low GUID: %u]", GetId(), GetType(), captainLowGuid);
+ TC_LOG_INFO(LOG_FILTER_ARENAS, "New ArenaTeam created [Id: %u, Name: %s] [Type: %u] [Captain low GUID: %u]", GetId(), GetName().c_str(), GetType(), captainLowGuid);
return true;
}
@@ -304,9 +304,9 @@ void ArenaTeam::SetCaptain(uint64 guid)
newCaptain->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 0);
if (oldCaptain)
{
- TC_LOG_DEBUG(LOG_FILTER_BATTLEGROUND, "Player: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team [Id: %u] [Type: %u].",
+ TC_LOG_DEBUG(LOG_FILTER_BATTLEGROUND, "Player: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team [Id: %u, Name: %s] [Type: %u].",
oldCaptain->GetName().c_str(), oldCaptain->GetGUIDLow(), newCaptain->GetName().c_str(),
- newCaptain->GetGUIDLow(), GetId(), GetType());
+ newCaptain->GetGUIDLow(), GetId(), GetName().c_str(), GetType());
}
}
}
@@ -328,7 +328,7 @@ void ArenaTeam::DelMember(uint64 guid, bool cleanDb)
// delete all info regarding this team
for (uint32 i = 0; i < ARENA_TEAM_END; ++i)
player->SetArenaTeamInfoField(GetSlot(), ArenaTeamInfoType(i), 0);
- TC_LOG_DEBUG(LOG_FILTER_ARENAS, "Player: %s [GUID: %u] left arena team type: %u [Id: %u].", player->GetName().c_str(), player->GetGUIDLow(), GetType(), GetId());
+ TC_LOG_DEBUG(LOG_FILTER_ARENAS, "Player: %s [GUID: %u] left arena team type: %u [Id: %u, Name: %s].", player->GetName().c_str(), player->GetGUIDLow(), GetType(), GetId(), GetName().c_str());
}
// Only used for single member deletion, for arena team disband we use a single query for more efficiency
@@ -353,7 +353,7 @@ void ArenaTeam::Disband(WorldSession* session)
BroadcastEvent(ERR_ARENA_TEAM_DISBANDED_S, 0, 2, session->GetPlayerName(), GetName(), "");
if (Player* player = session->GetPlayer())
- TC_LOG_DEBUG(LOG_FILTER_ARENAS, "Player: %s [GUID: %u] disbanded arena team type: %u [Id: %u].", player->GetName().c_str(), player->GetGUIDLow(), GetType(), GetId());
+ TC_LOG_DEBUG(LOG_FILTER_ARENAS, "Player: %s [GUID: %u] disbanded arena team type: %u [Id: %u, Name: %s].", player->GetName().c_str(), player->GetGUIDLow(), GetType(), GetId(), GetName().c_str());
}
// Update database
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 7f1d231ebd9..2f309c07cce 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -5236,9 +5236,10 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
uint32 oldMSTime = getMSTime();
time_t curTime = time(NULL);
- tm* lt = localtime(&curTime);
+ tm lt;
+ ACE_OS::localtime_r(&curTime, &lt);
uint64 basetime(curTime);
- TC_LOG_INFO(LOG_FILTER_GENERAL, "Returning mails current time: hour: %d, minute: %d, second: %d ", lt->tm_hour, lt->tm_min, lt->tm_sec);
+ TC_LOG_INFO(LOG_FILTER_GENERAL, "Returning mails current time: hour: %d, minute: %d, second: %d ", lt.tm_hour, lt.tm_min, lt.tm_sec);
// Delete all old mails without item and without body immediately, if starting server
if (!serverUp)
diff --git a/src/server/game/Weather/Weather.cpp b/src/server/game/Weather/Weather.cpp
index 38d64eedd5c..0457dc7e033 100644
--- a/src/server/game/Weather/Weather.cpp
+++ b/src/server/game/Weather/Weather.cpp
@@ -93,8 +93,9 @@ bool Weather::ReGenerate()
//78 days between January 1st and March 20nd; 365/4=91 days by season
// season source http://aa.usno.navy.mil/data/docs/EarthSeasons.html
time_t gtime = sWorld->GetGameTime();
- struct tm * ltime = localtime(&gtime);
- uint32 season = ((ltime->tm_yday - 78 + 365)/91)%4;
+ struct tm ltime;
+ ACE_OS::localtime_r(&gtime, &ltime);
+ uint32 season = ((ltime.tm_yday - 78 + 365)/91)%4;
static char const* seasonName[WEATHER_SEASONS] = { "spring", "summer", "fall", "winter" };
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index b1dc05e8d63..bfc512bc9a6 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -1738,7 +1738,9 @@ void World::SetInitialWorldSettings()
//mailtimer is increased when updating auctions
//one second is 1000 -(tested on win system)
/// @todo Get rid of magic numbers
- mail_timer = ((((localtime(&m_gameTime)->tm_hour + 20) % 24)* HOUR * IN_MILLISECONDS) / m_timers[WUPDATE_AUCTIONS].GetInterval());
+ tm localTm;
+ ACE_OS::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()));
TC_LOG_INFO(LOG_FILTER_SERVER_LOADING, "Mail timer set to: " UI64FMTD ", mail return is called every " UI64FMTD " minutes", uint64(mail_timer), uint64(mail_timer_expires));
@@ -2777,7 +2779,8 @@ void World::InitDailyQuestResetTime()
// client built-in time for reset is 6:00 AM
// FIX ME: client not show day start time
time_t curTime = time(NULL);
- tm localTm = *localtime(&curTime);
+ tm localTm;
+ ACE_OS::localtime_r(&curTime, &localTm);
localTm.tm_hour = 6;
localTm.tm_min = 0;
localTm.tm_sec = 0;
@@ -2810,7 +2813,8 @@ void World::InitRandomBGResetTime()
// generate time by config
time_t curTime = time(NULL);
- tm localTm = *localtime(&curTime);
+ tm localTm;
+ ACE_OS::localtime_r(&curTime, &localTm);
localTm.tm_hour = getIntConfig(CONFIG_RANDOM_BG_RESET_HOUR);
localTm.tm_min = 0;
localTm.tm_sec = 0;
@@ -2837,7 +2841,8 @@ void World::InitGuildResetTime()
// generate time by config
time_t curTime = time(NULL);
- tm localTm = *localtime(&curTime);
+ tm localTm;
+ ACE_OS::localtime_r(&curTime, &localTm);
localTm.tm_hour = getIntConfig(CONFIG_GUILD_RESET_HOUR);
localTm.tm_min = 0;
localTm.tm_sec = 0;
@@ -2921,7 +2926,8 @@ void World::ResetMonthlyQuests()
// generate time
time_t curTime = time(NULL);
- tm localTm = *localtime(&curTime);
+ tm localTm;
+ ACE_OS::localtime_r(&curTime, &localTm);
int month = localTm.tm_mon;
int year = localTm.tm_year;
diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp
index b12e058a78f..dd6e104f135 100644
--- a/src/server/scripts/Commands/cs_ban.cpp
+++ b/src/server/scripts/Commands/cs_ban.cpp
@@ -436,21 +436,23 @@ public:
do
{
time_t timeBan = time_t(fields2[0].GetUInt32());
- tm* tmBan = localtime(&timeBan);
+ tm tmBan;
+ ACE_OS::localtime_r(&timeBan, &tmBan);
if (fields2[0].GetUInt32() == fields2[1].GetUInt32())
{
handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|",
- accountName.c_str(), tmBan->tm_year%100, tmBan->tm_mon+1, tmBan->tm_mday, tmBan->tm_hour, tmBan->tm_min,
+ accountName.c_str(), tmBan.tm_year%100, tmBan.tm_mon+1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
fields2[2].GetCString(), fields2[3].GetCString());
}
else
{
time_t timeUnban = time_t(fields2[1].GetUInt32());
- tm* tmUnban = localtime(&timeUnban);
+ tm tmUnban;
+ ACE_OS::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,
+ 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,
fields2[2].GetCString(), fields2[3].GetCString());
}
}
@@ -523,21 +525,23 @@ public:
do
{
time_t timeBan = time_t(banFields[0].GetUInt32());
- tm* tmBan = localtime(&timeBan);
+ tm tmBan;
+ ACE_OS::localtime_r(&timeBan, &tmBan);
if (banFields[0].GetUInt32() == banFields[1].GetUInt32())
{
handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-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,
+ char_name.c_str(), tmBan.tm_year%100, tmBan.tm_mon+1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
banFields[2].GetCString(), banFields[3].GetCString());
}
else
{
time_t timeUnban = time_t(banFields[1].GetUInt32());
- tm* tmUnban = localtime(&timeUnban);
+ tm tmUnban;
+ ACE_OS::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,
+ 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,
banFields[2].GetCString(), banFields[3].GetCString());
}
}
@@ -602,20 +606,22 @@ public:
handler->SendSysMessage("-------------------------------------------------------------------------------");
Field* fields = result->Fetch();
time_t timeBan = time_t(fields[1].GetUInt32());
- tm* tmBan = localtime(&timeBan);
+ tm tmBan;
+ ACE_OS::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|",
- fields[0].GetCString(), tmBan->tm_year%100, tmBan->tm_mon+1, tmBan->tm_mday, tmBan->tm_hour, tmBan->tm_min,
+ fields[0].GetCString(), tmBan.tm_year%100, tmBan.tm_mon+1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
fields[3].GetCString(), fields[4].GetCString());
}
else
{
time_t timeUnban = time_t(fields[2].GetUInt32());
- tm* tmUnban = localtime(&timeUnban);
+ tm tmUnban;
+ ACE_OS::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,
+ 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,
fields[3].GetCString(), fields[4].GetCString());
}
}
diff --git a/src/server/scripts/Commands/cs_pet.cpp b/src/server/scripts/Commands/cs_pet.cpp
index 237b25634c1..315cf06e995 100644
--- a/src/server/scripts/Commands/cs_pet.cpp
+++ b/src/server/scripts/Commands/cs_pet.cpp
@@ -56,7 +56,7 @@ public:
return false;
}
- CreatureTemplate const* creatrueTemplate = sObjectMgr->GetCreatureTemplate(creatureTarget->GetEntry());
+ CreatureTemplate const* creatrueTemplate = creatureTarget->GetCreatureTemplate();
// Creatures with family 0 crashes the server
if (!creatrueTemplate->family)
{
diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp
index 5e2e26b578a..38c14292289 100644
--- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp
+++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp
@@ -248,7 +248,6 @@ class ThunderingStormCheck
private:
WorldObject const* _source;
- float _dist;
};
// 39365 - Thundering Storm
diff --git a/src/server/shared/Common.h b/src/server/shared/Common.h
index 70ee32d2868..e3074ef45b9 100644
--- a/src/server/shared/Common.h
+++ b/src/server/shared/Common.h
@@ -92,6 +92,7 @@
#include <ace/Guard_T.h>
#include <ace/RW_Thread_Mutex.h>
#include <ace/Thread_Mutex.h>
+#include <ace/OS_NS_time.h>
#if PLATFORM == PLATFORM_WINDOWS
# include <ace/config-all.h>
diff --git a/src/server/shared/Logging/Appender.cpp b/src/server/shared/Logging/Appender.cpp
index cde94fe3a7c..f47cbc3b095 100644
--- a/src/server/shared/Logging/Appender.cpp
+++ b/src/server/shared/Logging/Appender.cpp
@@ -20,9 +20,10 @@
std::string LogMessage::getTimeStr(time_t time)
{
- tm* aTm = localtime(&time);
+ tm aTm;
+ ACE_OS::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);
+ 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);
}
diff --git a/src/server/shared/Logging/Log.cpp b/src/server/shared/Logging/Log.cpp
index be7aab9cf5e..e6400176155 100644
--- a/src/server/shared/Logging/Log.cpp
+++ b/src/server/shared/Logging/Log.cpp
@@ -295,7 +295,8 @@ void Log::write(LogMessage* msg)
std::string Log::GetTimestampStr()
{
time_t t = time(NULL);
- tm* aTm = localtime(&t);
+ tm aTm;
+ ACE_OS::localtime_r(&t, &aTm);
// YYYY year
// MM month (2 digits 01-12)
// DD day (2 digits 01-31)
@@ -303,7 +304,7 @@ std::string Log::GetTimestampStr()
// MM minutes (2 digits 00-59)
// SS seconds (2 digits 00-59)
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);
+ 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);
}
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h
index 7777842af17..b015e8daa35 100644
--- a/src/server/shared/Packets/ByteBuffer.h
+++ b/src/server/shared/Packets/ByteBuffer.h
@@ -457,8 +457,9 @@ class ByteBuffer
void AppendPackedTime(time_t time)
{
- tm* lt = localtime(&time);
- 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);
+ tm lt;
+ ACE_OS::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);
}
void put(size_t pos, const uint8 *src, size_t cnt)
diff --git a/src/server/shared/Utilities/Timer.h b/src/server/shared/Utilities/Timer.h
index 5bc19a2b779..b0b395865b4 100644
--- a/src/server/shared/Utilities/Timer.h
+++ b/src/server/shared/Utilities/Timer.h
@@ -66,7 +66,7 @@ struct IntervalTimer
void Reset()
{
if (_current >= _interval)
- _current -= _interval;
+ _current %= _interval;
}
void SetCurrent(time_t current)
diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp
index 1bba3c2db09..48012b6eea8 100644
--- a/src/server/shared/Utilities/Util.cpp
+++ b/src/server/shared/Utilities/Util.cpp
@@ -215,7 +215,8 @@ uint32 TimeStringToSecs(const std::string& timestring)
std::string TimeToTimestampStr(time_t t)
{
- tm* aTm = localtime(&t);
+ tm aTm;
+ ACE_OS::localtime_r(&t, &aTm);
// YYYY year
// MM month (2 digits 01-12)
// DD day (2 digits 01-31)
@@ -223,7 +224,7 @@ std::string TimeToTimestampStr(time_t t)
// MM minutes (2 digits 00-59)
// SS seconds (2 digits 00-59)
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);
+ 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);
}