diff options
| author | Discover- <amort11@hotmail.com> | 2013-09-23 16:47:47 +0200 |
|---|---|---|
| committer | Discover- <amort11@hotmail.com> | 2013-09-23 16:47:47 +0200 |
| commit | a0db0728f2f48e7ca4156115b03e63d7ff2164c1 (patch) | |
| tree | c17b6d0bdc34f0a8297216f21dd7deb5df4eddcc /src/server/shared | |
| parent | 9653576cb4cc9449898d6af691c045d68e9361c5 (diff) | |
| parent | 4498ac0062d56aa0a0f2b9a21358f12f83c4b1f7 (diff) | |
Merge branch 'master' of https://github.com/TrinityCore/TrinityCore
Diffstat (limited to 'src/server/shared')
| -rw-r--r-- | src/server/shared/Common.h | 1 | ||||
| -rw-r--r-- | src/server/shared/CompilerDefs.h | 5 | ||||
| -rw-r--r-- | src/server/shared/Database/DatabaseWorkerPool.h | 5 | ||||
| -rw-r--r-- | src/server/shared/Database/Implementation/CharacterDatabase.cpp | 3 | ||||
| -rw-r--r-- | src/server/shared/Database/Implementation/CharacterDatabase.h | 3 | ||||
| -rw-r--r-- | src/server/shared/Logging/Appender.cpp | 5 | ||||
| -rw-r--r-- | src/server/shared/Logging/AppenderFile.cpp | 4 | ||||
| -rw-r--r-- | src/server/shared/Logging/AppenderFile.h | 3 | ||||
| -rw-r--r-- | src/server/shared/Logging/Log.cpp | 5 | ||||
| -rw-r--r-- | src/server/shared/Packets/ByteBuffer.h | 6 | ||||
| -rw-r--r-- | src/server/shared/Utilities/Timer.h | 2 | ||||
| -rw-r--r-- | src/server/shared/Utilities/Util.cpp | 5 | ||||
| -rw-r--r-- | src/server/shared/Utilities/Util.h | 33 |
13 files changed, 62 insertions, 18 deletions
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/CompilerDefs.h b/src/server/shared/CompilerDefs.h index 10cdaf4e179..909dcd1707b 100644 --- a/src/server/shared/CompilerDefs.h +++ b/src/server/shared/CompilerDefs.h @@ -55,11 +55,6 @@ # error "FATAL ERROR: Unknown compiler." #endif -#if COMPILER == COMPILER_MICROSOFT -# pragma warning( disable : 4267 ) // conversion from 'size_t' to 'int', possible loss of data -# pragma warning( disable : 4786 ) // identifier was truncated to '255' characters in the debug information -#endif - #if defined(__cplusplus) && __cplusplus == 201103L # define COMPILER_HAS_CPP11_SUPPORT 1 #else diff --git a/src/server/shared/Database/DatabaseWorkerPool.h b/src/server/shared/Database/DatabaseWorkerPool.h index 5ecadfe18a8..e209beef8b6 100644 --- a/src/server/shared/Database/DatabaseWorkerPool.h +++ b/src/server/shared/Database/DatabaseWorkerPool.h @@ -214,6 +214,9 @@ class DatabaseWorkerPool T* t = GetFreeConnection(); t->Execute(stmt); t->Unlock(); + + //! Delete proxy-class. Not needed anymore + delete stmt; } /** @@ -430,7 +433,7 @@ class DatabaseWorkerPool */ //! Automanaged (internally) pointer to a prepared statement object for usage in upper level code. - //! Pointer is deleted in this->Query(PreparedStatement*) or PreparedStatementTask::~PreparedStatementTask. + //! Pointer is deleted in this->DirectExecute(PreparedStatement*), this->Query(PreparedStatement*) or PreparedStatementTask::~PreparedStatementTask. //! This object is not tied to the prepared statement on the MySQL context yet until execution. PreparedStatement* GetPreparedStatement(uint32 index) { diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp index 7e237614f62..fdb71dd8d1a 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/shared/Database/Implementation/CharacterDatabase.cpp @@ -458,6 +458,9 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY, "SELECT gi.item_guid, gi.guildid, g.name FROM guild_bank_item gi INNER JOIN guild g ON g.guildid = gi.guildid INNER JOIN item_instance ii ON ii.guid = gi.item_guid WHERE ii.itemEntry = ? LIMIT ?", CONNECTION_SYNCH); PrepareStatement(CHAR_DEL_CHAR_ACHIEVEMENT, "DELETE FROM character_achievement WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS, "DELETE FROM character_achievement_progress WHERE guid = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_CHAR_ACHIEVEMENT, "INSERT INTO character_achievement (guid, achievement, date) VALUES (?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS_BY_CRITERIA, "DELETE FROM character_achievement_progress WHERE guid = ? AND criteria = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_CHAR_ACHIEVEMENT_PROGRESS, "INSERT INTO character_achievement_progress (guid, criteria, counter, date) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_REPUTATION_BY_FACTION, "DELETE FROM character_reputation WHERE guid = ? AND faction = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_CHAR_REPUTATION_BY_FACTION, "INSERT INTO character_reputation (guid, faction, standing, flags) VALUES (?, ?, ? , ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_CHAR_ARENA_POINTS, "UPDATE characters SET arenaPoints = (arenaPoints + ?) WHERE guid = ?", CONNECTION_ASYNC); diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.h b/src/server/shared/Database/Implementation/CharacterDatabase.h index f97dd63064d..4aeee0ac525 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.h +++ b/src/server/shared/Database/Implementation/CharacterDatabase.h @@ -394,6 +394,9 @@ enum CharacterDatabaseStatements CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY, CHAR_DEL_CHAR_ACHIEVEMENT, CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS, + CHAR_INS_CHAR_ACHIEVEMENT, + CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS_BY_CRITERIA, + CHAR_INS_CHAR_ACHIEVEMENT_PROGRESS, CHAR_DEL_CHAR_REPUTATION_BY_FACTION, CHAR_INS_CHAR_REPUTATION_BY_FACTION, CHAR_UPD_CHAR_ARENA_POINTS, 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/AppenderFile.cpp b/src/server/shared/Logging/AppenderFile.cpp index 93d53bcc30d..54458346bb9 100644 --- a/src/server/shared/Logging/AppenderFile.cpp +++ b/src/server/shared/Logging/AppenderFile.cpp @@ -40,7 +40,7 @@ AppenderFile::~AppenderFile() void AppenderFile::_write(LogMessage const& message) { - bool exceedMaxSize = maxFileSize > 0 && (fileSize + message.Size()) > maxFileSize; + bool exceedMaxSize = maxFileSize > 0 && (fileSize.value() + message.Size()) > maxFileSize; if (dynamicName) { @@ -56,7 +56,7 @@ void AppenderFile::_write(LogMessage const& message) fprintf(logfile, "%s%s", message.prefix.c_str(), message.text.c_str()); fflush(logfile); - fileSize += message.Size(); + fileSize += uint64(message.Size()); if (dynamicName) CloseFile(); diff --git a/src/server/shared/Logging/AppenderFile.h b/src/server/shared/Logging/AppenderFile.h index c15974799e1..de94a46d692 100644 --- a/src/server/shared/Logging/AppenderFile.h +++ b/src/server/shared/Logging/AppenderFile.h @@ -19,6 +19,7 @@ #define APPENDERFILE_H #include "Appender.h" +#include "ace/Atomic_Op.h" class AppenderFile: public Appender { @@ -37,7 +38,7 @@ class AppenderFile: public Appender bool dynamicName; bool backup; uint64 maxFileSize; - uint64 fileSize; + ACE_Atomic_Op<ACE_Thread_Mutex, uint64> fileSize; }; #endif 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..d2677538805 100644 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -23,6 +23,7 @@ #include "Errors.h" #include "ByteConverter.h" +#include <ace/OS_NS_time.h> #include <exception> #include <list> #include <map> @@ -457,8 +458,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, <); + 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); } diff --git a/src/server/shared/Utilities/Util.h b/src/server/shared/Utilities/Util.h index 6d0216225da..30a6b27f186 100644 --- a/src/server/shared/Utilities/Util.h +++ b/src/server/shared/Utilities/Util.h @@ -20,6 +20,7 @@ #define _UTIL_H #include "Define.h" +#include "Errors.h" #include <algorithm> #include <string> @@ -532,4 +533,36 @@ public: } }; +enum ComparisionType +{ + COMP_TYPE_EQ = 0, + COMP_TYPE_HIGH, + COMP_TYPE_LOW, + COMP_TYPE_HIGH_EQ, + COMP_TYPE_LOW_EQ, + COMP_TYPE_MAX +}; + +template <class T> +bool CompareValues(ComparisionType type, T val1, T val2) +{ + switch (type) + { + case COMP_TYPE_EQ: + return val1 == val2; + case COMP_TYPE_HIGH: + return val1 > val2; + case COMP_TYPE_LOW: + return val1 < val2; + case COMP_TYPE_HIGH_EQ: + return val1 >= val2; + case COMP_TYPE_LOW_EQ: + return val1 <= val2; + default: + // incorrect parameter + ASSERT(false); + return false; + } +} + #endif |
