diff options
Diffstat (limited to 'src')
220 files changed, 3826 insertions, 3595 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 2339399e022..7f20fe36ab6 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -83,6 +83,8 @@ add_library(common STATIC ${common_STAT_PCH_SRC} ) +add_dependencies(common revision_data.h) + # Generate precompiled header if (USE_COREPCH) add_cxx_pch(common ${common_STAT_PCH_HDR} ${common_STAT_PCH_SRC}) diff --git a/src/common/Collision/Management/VMapManager2.cpp b/src/common/Collision/Management/VMapManager2.cpp index 9594951196f..a63eac1b935 100644 --- a/src/common/Collision/Management/VMapManager2.cpp +++ b/src/common/Collision/Management/VMapManager2.cpp @@ -326,4 +326,9 @@ namespace VMAP return StaticMapTree::CanLoadMap(std::string(basePath), mapId, x, y); } + void VMapManager2::getInstanceMapTree(InstanceTreeMap &instanceMapTree) + { + instanceMapTree = iInstanceMapTrees; + } + } // namespace VMAP diff --git a/src/common/Collision/Management/VMapManager2.h b/src/common/Collision/Management/VMapManager2.h index a5891e9642b..c2e1aee1ff7 100644 --- a/src/common/Collision/Management/VMapManager2.h +++ b/src/common/Collision/Management/VMapManager2.h @@ -128,7 +128,7 @@ namespace VMAP return getMapFileName(mapId); } virtual bool existsMap(const char* basePath, unsigned int mapId, int x, int y) override; - public: + void getInstanceMapTree(InstanceTreeMap &instanceMapTree); typedef uint32(*GetLiquidFlagsFn)(uint32 liquidType); diff --git a/src/common/Collision/Maps/MapTree.cpp b/src/common/Collision/Maps/MapTree.cpp index b493ec18f5f..e374da4f1b9 100644 --- a/src/common/Collision/Maps/MapTree.cpp +++ b/src/common/Collision/Maps/MapTree.cpp @@ -474,4 +474,10 @@ namespace VMAP } iLoadedTiles.erase(tile); } + + void StaticMapTree::getModelInstances(ModelInstance* &models, uint32 &count) + { + models = iTreeValues; + count = iNTreeValues; + } } diff --git a/src/common/Collision/Models/ModelInstance.h b/src/common/Collision/Models/ModelInstance.h index dfdb001db0a..f8bbfa4fa73 100644 --- a/src/common/Collision/Models/ModelInstance.h +++ b/src/common/Collision/Models/ModelInstance.h @@ -70,12 +70,11 @@ namespace VMAP void intersectPoint(const G3D::Vector3& p, AreaInfo &info) const; bool GetLocationInfo(const G3D::Vector3& p, LocationInfo &info) const; bool GetLiquidLevel(const G3D::Vector3& p, LocationInfo &info, float &liqHeight) const; + WorldModel* getWorldModel() { return iModel; } protected: G3D::Matrix3 iInvRot; float iInvScale; WorldModel* iModel; - public: - WorldModel* getWorldModel(); }; } // namespace VMAP diff --git a/src/common/Collision/Models/WorldModel.cpp b/src/common/Collision/Models/WorldModel.cpp index 86ab9366c71..7f4d76b244a 100644 --- a/src/common/Collision/Models/WorldModel.cpp +++ b/src/common/Collision/Models/WorldModel.cpp @@ -249,6 +249,13 @@ namespace VMAP return result; } + void WmoLiquid::getPosInfo(uint32 &tilesX, uint32 &tilesY, G3D::Vector3 &corner) const + { + tilesX = iTilesX; + tilesY = iTilesY; + corner = iCorner; + } + // ===================== GroupModel ================================== GroupModel::GroupModel(const GroupModel &other): @@ -409,6 +416,13 @@ namespace VMAP return 0; } + void GroupModel::getMeshData(std::vector<G3D::Vector3>& outVertices, std::vector<MeshTriangle>& outTriangles, WmoLiquid*& liquid) + { + outVertices = vertices; + outTriangles = triangles; + liquid = iLiquid; + } + // ===================== WorldModel ================================== void WorldModel::setGroupModels(std::vector<GroupModel> &models) @@ -582,4 +596,9 @@ namespace VMAP fclose(rf); return result; } + + void WorldModel::getGroupModels(std::vector<GroupModel>& outGroupModels) + { + outGroupModels = groupModels; + } } diff --git a/src/common/Collision/Models/WorldModel.h b/src/common/Collision/Models/WorldModel.h index 6a901a59fdf..afa9d15b264 100644 --- a/src/common/Collision/Models/WorldModel.h +++ b/src/common/Collision/Models/WorldModel.h @@ -58,6 +58,7 @@ namespace VMAP uint32 GetFileSize(); bool writeToFile(FILE* wf); static bool readFromFile(FILE* rf, WmoLiquid* &liquid); + void getPosInfo(uint32 &tilesX, uint32 &tilesY, G3D::Vector3 &corner) const; private: WmoLiquid() : iTilesX(0), iTilesY(0), iCorner(), iType(0), iHeight(NULL), iFlags(NULL) { } uint32 iTilesX; //!< number of tiles in x direction, each @@ -66,8 +67,6 @@ namespace VMAP uint32 iType; //!< liquid type float *iHeight; //!< (tilesX + 1)*(tilesY + 1) height values uint8 *iFlags; //!< info if liquid tile is used - public: - void getPosInfo(uint32 &tilesX, uint32 &tilesY, G3D::Vector3 &corner) const; }; /*! holding additional info for WMO group files */ @@ -92,6 +91,7 @@ namespace VMAP const G3D::AABox& GetBound() const { return iBound; } uint32 GetMogpFlags() const { return iMogpFlags; } uint32 GetWmoID() const { return iGroupWMOID; } + void getMeshData(std::vector<G3D::Vector3>& outVertices, std::vector<MeshTriangle>& outTriangles, WmoLiquid*& liquid); protected: G3D::AABox iBound; uint32 iMogpFlags;// 0x8 outdor; 0x2000 indoor @@ -100,9 +100,8 @@ namespace VMAP std::vector<MeshTriangle> triangles; BIH meshTree; WmoLiquid* iLiquid; - public: - void getMeshData(std::vector<G3D::Vector3> &vertices, std::vector<MeshTriangle> &triangles, WmoLiquid* &liquid); }; + /*! Holds a model (converted M2 or WMO) in its original coordinate space */ class WorldModel { @@ -117,12 +116,11 @@ namespace VMAP bool GetLocationInfo(const G3D::Vector3 &p, const G3D::Vector3 &down, float &dist, LocationInfo &info) const; bool writeFile(const std::string &filename); bool readFile(const std::string &filename); + void getGroupModels(std::vector<GroupModel>& outGroupModels); protected: uint32 RootWMOID; std::vector<GroupModel> groupModels; BIH groupTree; - public: - void getGroupModels(std::vector<GroupModel> &groupModels); }; } // namespace VMAP diff --git a/src/common/Common.h b/src/common/Common.h index 4c209f89ec8..7a1ea247a94 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -21,7 +21,6 @@ #include "Define.h" -#include <unordered_map> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -32,14 +31,19 @@ #include <assert.h> #include <set> +#include <unordered_set> #include <list> #include <string> #include <map> +#include <unordered_map> #include <queue> #include <sstream> #include <algorithm> #include <memory> #include <vector> +#include <array> + +#include <boost/functional/hash.hpp> #include "Debugging/Errors.h" @@ -116,10 +120,11 @@ enum LocaleConstant LOCALE_zhTW = 5, LOCALE_esES = 6, LOCALE_esMX = 7, - LOCALE_ruRU = 8 + LOCALE_ruRU = 8, + + TOTAL_LOCALES }; -const uint8 TOTAL_LOCALES = 9; #define DEFAULT_LOCALE LOCALE_enUS #define MAX_LOCALES 8 @@ -156,4 +161,19 @@ namespace Trinity } } +//! Hash implementation for std::pair to allow using pairs in unordered_set or as key for unordered_map +//! Individual types used in pair must be hashable by boost::hash +namespace std +{ + template<class K, class V> + struct hash<std::pair<K, V>> + { + public: + size_t operator()(std::pair<K, V> const& key) const + { + return boost::hash_value(key); + } + }; +} + #endif diff --git a/src/common/Debugging/WheatyExceptionReport.cpp b/src/common/Debugging/WheatyExceptionReport.cpp index 7cf109b4070..5b9a1b1bd6c 100644 --- a/src/common/Debugging/WheatyExceptionReport.cpp +++ b/src/common/Debugging/WheatyExceptionReport.cpp @@ -63,6 +63,8 @@ std::stack<SymbolDetail> WheatyExceptionReport::symbolDetails; bool WheatyExceptionReport::stackOverflowException; bool WheatyExceptionReport::alreadyCrashed; std::mutex WheatyExceptionReport::alreadyCrashedLock; +WheatyExceptionReport::pRtlGetVersion WheatyExceptionReport::RtlGetVersion; + // Declare global instance of class WheatyExceptionReport g_WheatyExceptionReport; @@ -76,6 +78,7 @@ WheatyExceptionReport::WheatyExceptionReport() // Constructor m_hProcess = GetCurrentProcess(); stackOverflowException = false; alreadyCrashed = false; + RtlGetVersion = (pRtlGetVersion)GetProcAddress(GetModuleHandle(_T("ntdll.dll")), "RtlGetVersion"); if (!IsDebuggerPresent()) { _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); @@ -207,21 +210,36 @@ BOOL WheatyExceptionReport::_GetProcessorName(TCHAR* sProcessorName, DWORD maxco return TRUE; } +template<size_t size> +void ToTchar(wchar_t const* src, TCHAR (&dst)[size], std::true_type) +{ + wcstombs_s(nullptr, dst, src, size); +} + +template<size_t size> +void ToTchar(wchar_t const* src, TCHAR (&dst)[size], std::false_type) +{ + wcscpy_s(dst, src); +} + BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) { // Try calling GetVersionEx using the OSVERSIONINFOEX structure. // If that fails, try using the OSVERSIONINFO structure. - OSVERSIONINFOEX osvi = { 0 }; - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - BOOL bOsVersionInfoEx; - bOsVersionInfoEx = ::GetVersionEx((LPOSVERSIONINFO)(&osvi)); - if (!bOsVersionInfoEx) + RTL_OSVERSIONINFOEXW osvi = { 0 }; + osvi.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW); + NTSTATUS bVersionEx = RtlGetVersion((PRTL_OSVERSIONINFOW)&osvi); + if (bVersionEx < 0) { - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (!::GetVersionEx((OSVERSIONINFO*)&osvi)) + osvi.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOW); + if (!RtlGetVersion((PRTL_OSVERSIONINFOW)&osvi)) return FALSE; } *szVersion = _T('\0'); + + TCHAR szCSDVersion[256]; + ToTchar(osvi.szCSDVersion, szCSDVersion, std::is_same<TCHAR, char>::type()); + TCHAR wszTmp[128]; switch (osvi.dwPlatformId) { @@ -237,17 +255,28 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) #endif // WINVER < 0x0500 // Test for the specific product family. - if (osvi.dwMajorVersion == 6) + if (osvi.dwMajorVersion == 10) + { + if (productType == VER_NT_WORKSTATION) + _tcsncat(szVersion, _T("Windows 10 "), cntMax); + else + _tcsncat(szVersion, _T("Windows Server 2016 "), cntMax); + } + else if (osvi.dwMajorVersion == 6) { if (productType == VER_NT_WORKSTATION) { - if (osvi.dwMinorVersion == 2) + if (osvi.dwMinorVersion == 3) + _tcsncat(szVersion, _T("Windows 8.1 "), cntMax); + else if (osvi.dwMinorVersion == 2) _tcsncat(szVersion, _T("Windows 8 "), cntMax); else if (osvi.dwMinorVersion == 1) _tcsncat(szVersion, _T("Windows 7 "), cntMax); else _tcsncat(szVersion, _T("Windows Vista "), cntMax); } + else if (osvi.dwMinorVersion == 3) + _tcsncat(szVersion, _T("Windows Server 2012 R2 "), cntMax); else if (osvi.dwMinorVersion == 2) _tcsncat(szVersion, _T("Windows Server 2012 "), cntMax); else if (osvi.dwMinorVersion == 1) @@ -265,7 +294,7 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) _tcsncat(szVersion, _T("Microsoft Windows NT "), cntMax); // Test for specific product on Windows NT 4.0 SP6 and later. - if (bOsVersionInfoEx) + if (bVersionEx >= 0) { // Test for the workstation type. if (productType == VER_NT_WORKSTATION) @@ -282,7 +311,18 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) // Test for the server type. else if (productType == VER_NT_SERVER) { - if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) + if (osvi.dwMajorVersion == 6 || osvi.dwMajorVersion == 10) + { + if (suiteMask & VER_SUITE_SMALLBUSINESS_RESTRICTED) + _tcsncat(szVersion, _T("Essentials "), cntMax); + else if (suiteMask & VER_SUITE_DATACENTER) + _tcsncat(szVersion, _T("Datacenter "), cntMax); + else if (suiteMask & VER_SUITE_ENTERPRISE) + _tcsncat(szVersion, _T("Enterprise "), cntMax); + else + _tcsncat(szVersion, _T("Standard "), cntMax); + } + else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) { if (suiteMask & VER_SUITE_DATACENTER) _tcsncat(szVersion, _T("Datacenter Edition "), cntMax); @@ -313,7 +353,7 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) } // Display service pack (if any) and build number. - if (osvi.dwMajorVersion == 4 && _tcsicmp(osvi.szCSDVersion, _T("Service Pack 6")) == 0) + if (osvi.dwMajorVersion == 4 && _tcsicmp(szCSDVersion, _T("Service Pack 6")) == 0) { HKEY hKey; LONG lRet; @@ -329,26 +369,26 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) else // Windows NT 4.0 prior to SP6a { _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), - osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); + szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); _tcsncat(szVersion, wszTmp, cntMax); } ::RegCloseKey(hKey); } else // Windows NT 3.51 and earlier or Windows 2000 and later { - if (!_tcslen(osvi.szCSDVersion)) + if (!_tcslen(szCSDVersion)) _stprintf(wszTmp, _T("(Version %d.%d, Build %d)"), osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); else _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), - osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); + szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); _tcsncat(szVersion, wszTmp, cntMax); } break; } default: _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), - osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); + szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); _tcsncat(szVersion, wszTmp, cntMax); break; } diff --git a/src/common/Debugging/WheatyExceptionReport.h b/src/common/Debugging/WheatyExceptionReport.h index 8c2479d5232..eb62d8bceef 100644 --- a/src/common/Debugging/WheatyExceptionReport.h +++ b/src/common/Debugging/WheatyExceptionReport.h @@ -3,6 +3,8 @@ #if PLATFORM == PLATFORM_WINDOWS && !defined(__MINGW32__) +#include <winnt.h> +#include <winternl.h> #include <dbghelp.h> #include <set> #include <stdlib.h> @@ -197,6 +199,8 @@ class WheatyExceptionReport static bool stackOverflowException; static bool alreadyCrashed; static std::mutex alreadyCrashedLock; + typedef NTSTATUS(NTAPI* pRtlGetVersion)(PRTL_OSVERSIONINFOW lpVersionInformation); + static pRtlGetVersion RtlGetVersion; static char* PushSymbolDetail(char* pszCurrBuffer); static char* PopSymbolDetail(char* pszCurrBuffer); diff --git a/src/server/database/Database/Field.h b/src/server/database/Database/Field.h index 42a842e6283..72364f2c034 100644 --- a/src/server/database/Database/Field.h +++ b/src/server/database/Database/Field.h @@ -23,6 +23,36 @@ #include <mysql.h> +/** + @class Field + + @brief Class used to access individual fields of database query result + + Guideline on field type matching: + + | MySQL type | method to use | + |------------------------|----------------------------------------| + | TINYINT | GetBool, GetInt8, GetUInt8 | + | SMALLINT | GetInt16, GetUInt16 | + | MEDIUMINT, INT | GetInt32, GetUInt32 | + | BIGINT | GetInt64, GetUInt64 | + | FLOAT | GetFloat | + | DOUBLE, DECIMAL | GetDouble | + | CHAR, VARCHAR, | GetCString, GetString | + | TINYTEXT, MEDIUMTEXT, | GetCString, GetString | + | TEXT, LONGTEXT | GetCString, GetString | + | TINYBLOB, MEDIUMBLOB, | GetBinary, GetString | + | BLOB, LONGBLOB | GetBinary, GetString | + | BINARY, VARBINARY | GetBinary | + + Return types of aggregate functions: + + | Function | Type | + |----------|-------------------| + | MIN, MAX | Same as the field | + | SUM, AVG | DECIMAL | + | COUNT | BIGINT | +*/ class Field { friend class ResultSet; @@ -214,15 +244,15 @@ class Field return 0.0f; #ifdef TRINITY_DEBUG - if (!IsType(MYSQL_TYPE_DOUBLE)) + if (!IsType(MYSQL_TYPE_DOUBLE) && !IsType(MYSQL_TYPE_NEWDECIMAL)) { - TC_LOG_WARN("sql.sql", "Warning: GetDouble() on non-double field %s.%s (%s.%s) at index %u. Using type: %s.", + TC_LOG_WARN("sql.sql", "Warning: GetDouble() on non-double/non-decimal field %s.%s (%s.%s) at index %u. Using type: %s.", meta.TableAlias, meta.Alias, meta.TableName, meta.Name, meta.Index, meta.Type); return 0.0f; } #endif - if (data.raw) + if (data.raw && !IsType(MYSQL_TYPE_NEWDECIMAL)) return *reinterpret_cast<double*>(data.value); return static_cast<double>(atof((char*)data.value)); } diff --git a/src/server/database/Database/Implementation/CharacterDatabase.cpp b/src/server/database/Database/Implementation/CharacterDatabase.cpp index 14e7571dd42..3e0d684a1fd 100644 --- a/src/server/database/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/database/Database/Implementation/CharacterDatabase.cpp @@ -105,7 +105,7 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_SEL_MAIL_COUNT, "SELECT COUNT(*) FROM mail WHERE receiver = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_CHARACTER_SOCIALLIST, "SELECT friend, flags, note FROM character_social JOIN characters ON characters.guid = character_social.friend WHERE character_social.guid = ? AND deleteinfos_name IS NULL LIMIT 255", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHARACTER_HOMEBIND, "SELECT mapId, zoneId, posX, posY, posZ FROM character_homebind WHERE guid = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_SEL_CHARACTER_SPELLCOOLDOWNS, "SELECT spell, item, time FROM character_spell_cooldown WHERE guid = ? AND time > UNIX_TIMESTAMP()", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_CHARACTER_SPELLCOOLDOWNS, "SELECT spell, item, time, categoryId, categoryEnd FROM character_spell_cooldown WHERE guid = ? AND time > UNIX_TIMESTAMP()", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHARACTER_DECLINEDNAMES, "SELECT genitive, dative, accusative, instrumental, prepositional FROM character_declinedname WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_GUILD_MEMBER, "SELECT guildid, rank FROM guild_member WHERE guid = ?", CONNECTION_BOTH); PrepareStatement(CHAR_SEL_GUILD_MEMBER_EXTENDED, "SELECT g.guildid, g.name, gr.rname, gr.rid, gm.pnote, gm.offnote " @@ -157,7 +157,6 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_GIFT, "DELETE FROM character_gifts WHERE item_guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_CHARACTER_GIFT_BY_ITEM, "SELECT entry, flags FROM character_gifts WHERE item_guid = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_ACCOUNT_BY_NAME, "SELECT account FROM characters WHERE name = ?", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_ACCOUNT_BY_GUID, "SELECT account FROM characters WHERE guid = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_CHARACTER_DATA_BY_GUID, "SELECT account, name, level FROM characters WHERE guid = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_DEL_ACCOUNT_INSTANCE_LOCK_TIMES, "DELETE FROM account_instance_times WHERE accountId = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_ACCOUNT_INSTANCE_LOCK_TIMES, "INSERT INTO account_instance_times (accountId, instanceId, releaseTime) VALUES (?, ?, ?)", CONNECTION_ASYNC); @@ -251,7 +250,7 @@ void CharacterDatabaseConnection::DoPrepareStatements() "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); // Account data - PrepareStatement(CHAR_SEL_ACCOUNT_DATA, "SELECT type, time, data FROM account_data WHERE accountId = ?", CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_ACCOUNT_DATA, "SELECT type, time, data FROM account_data WHERE accountId = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_REP_ACCOUNT_DATA, "REPLACE INTO account_data (accountId, type, time, data) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_ACCOUNT_DATA, "DELETE FROM account_data WHERE accountId = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_PLAYER_ACCOUNT_DATA, "SELECT type, time, data FROM character_account_data WHERE guid = ?", CONNECTION_ASYNC); @@ -259,7 +258,7 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_DEL_PLAYER_ACCOUNT_DATA, "DELETE FROM character_account_data WHERE guid = ?", CONNECTION_ASYNC); // Tutorials - PrepareStatement(CHAR_SEL_TUTORIALS, "SELECT tut0, tut1, tut2, tut3, tut4, tut5, tut6, tut7 FROM account_tutorial WHERE accountId = ?", CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_TUTORIALS, "SELECT tut0, tut1, tut2, tut3, tut4, tut5, tut6, tut7 FROM account_tutorial WHERE accountId = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_HAS_TUTORIALS, "SELECT 1 FROM account_tutorial WHERE accountId = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_INS_TUTORIALS, "INSERT INTO account_tutorial(tut0, tut1, tut2, tut3, tut4, tut5, tut6, tut7, accountId) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_TUTORIALS, "UPDATE account_tutorial SET tut0 = ?, tut1 = ?, tut2 = ?, tut3 = ?, tut4 = ?, tut5 = ?, tut6 = ?, tut7 = ? WHERE accountId = ?", CONNECTION_ASYNC); @@ -498,7 +497,7 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_UPD_CHAR_TITLES_FACTION_CHANGE, "UPDATE characters SET knownTitles = ? WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_RES_CHAR_TITLES_FACTION_CHANGE, "UPDATE characters SET chosenTitle = 0 WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_SPELL_COOLDOWNS, "DELETE FROM character_spell_cooldown WHERE guid = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_INS_CHAR_SPELL_COOLDOWN, "INSERT INTO character_spell_cooldown (guid, spell, item, time) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_CHAR_SPELL_COOLDOWN, "INSERT INTO character_spell_cooldown (guid, spell, item, time, categoryId, categoryEnd) VALUES (?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHARACTER, "DELETE FROM characters WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_ACTION, "DELETE FROM character_action WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_CHAR_AURA, "DELETE FROM character_aura WHERE guid = ?", CONNECTION_ASYNC); @@ -578,12 +577,12 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_INS_CHAR_PET_DECLINEDNAME, "INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES (?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_PET_AURA, "SELECT casterGuid, spell, effectMask, recalculateMask, stackCount, amount0, amount1, amount2, base_amount0, base_amount1, base_amount2, maxDuration, remainTime, remainCharges FROM pet_aura WHERE guid = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_PET_SPELL, "SELECT spell, active FROM pet_spell WHERE guid = ?", CONNECTION_SYNCH); - PrepareStatement(CHAR_SEL_PET_SPELL_COOLDOWN, "SELECT spell, time FROM pet_spell_cooldown WHERE guid = ? AND time > UNIX_TIMESTAMP()", CONNECTION_SYNCH); + PrepareStatement(CHAR_SEL_PET_SPELL_COOLDOWN, "SELECT spell, time, categoryId, categoryEnd FROM pet_spell_cooldown WHERE guid = ? AND time > UNIX_TIMESTAMP()", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_PET_DECLINED_NAME, "SELECT genitive, dative, accusative, instrumental, prepositional FROM character_pet_declinedname WHERE owner = ? AND id = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_DEL_PET_AURAS, "DELETE FROM pet_aura WHERE guid = ?", CONNECTION_BOTH); PrepareStatement(CHAR_DEL_PET_SPELLS, "DELETE FROM pet_spell WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_PET_SPELL_COOLDOWNS, "DELETE FROM pet_spell_cooldown WHERE guid = ?", CONNECTION_BOTH); - PrepareStatement(CHAR_INS_PET_SPELL_COOLDOWN, "INSERT INTO pet_spell_cooldown (guid, spell, time) VALUES (?, ?, ?)", CONNECTION_BOTH); + PrepareStatement(CHAR_INS_PET_SPELL_COOLDOWN, "INSERT INTO pet_spell_cooldown (guid, spell, time, categoryId, categoryEnd) VALUES (?, ?, ?, ?, ?)", CONNECTION_BOTH); PrepareStatement(CHAR_DEL_PET_SPELL_BY_SPELL, "DELETE FROM pet_spell WHERE guid = ? and spell = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_PET_SPELL, "INSERT INTO pet_spell (guid, spell, active) VALUES (?, ?, ?)", CONNECTION_BOTH); PrepareStatement(CHAR_INS_PET_AURA, "INSERT INTO pet_aura (guid, casterGuid, spell, effectMask, recalculateMask, stackCount, amount0, amount1, amount2, " @@ -603,7 +602,7 @@ void CharacterDatabaseConnection::DoPrepareStatements() // PvPstats PrepareStatement(CHAR_SEL_PVPSTATS_MAXID, "SELECT MAX(id) FROM pvpstats_battlegrounds", CONNECTION_SYNCH); PrepareStatement(CHAR_INS_PVPSTATS_BATTLEGROUND, "INSERT INTO pvpstats_battlegrounds (id, winner_faction, bracket_id, type, date) VALUES (?, ?, ?, ?, NOW())", CONNECTION_ASYNC); - PrepareStatement(CHAR_INS_PVPSTATS_PLAYER, "INSERT INTO pvpstats_players (battleground_id, character_guid, score_killing_blows, score_deaths, score_honorable_kills, score_bonus_honor, score_damage_done, score_healing_done, attr_1, attr_2, attr_3, attr_4, attr_5) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_INS_PVPSTATS_PLAYER, "INSERT INTO pvpstats_players (battleground_id, character_guid, winner, score_killing_blows, score_deaths, score_honorable_kills, score_bonus_honor, score_damage_done, score_healing_done, attr_1, attr_2, attr_3, attr_4, attr_5) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_SEL_PVPSTATS_FACTIONS_OVERALL, "SELECT winner_faction, COUNT(*) AS count FROM pvpstats_battlegrounds WHERE DATEDIFF(NOW(), date) < 7 GROUP BY winner_faction ORDER BY winner_faction ASC", CONNECTION_SYNCH); // QuestTracker @@ -611,4 +610,7 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_UPD_QUEST_TRACK_GM_COMPLETE, "UPDATE quest_tracker SET completed_by_gm = 1 WHERE id = ? AND character_guid = ? ORDER BY quest_accept_time DESC LIMIT 1", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_QUEST_TRACK_COMPLETE_TIME, "UPDATE quest_tracker SET quest_complete_time = NOW() WHERE id = ? AND character_guid = ? ORDER BY quest_accept_time DESC LIMIT 1", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_QUEST_TRACK_ABANDON_TIME, "UPDATE quest_tracker SET quest_abandon_time = NOW() WHERE id = ? AND character_guid = ? ORDER BY quest_accept_time DESC LIMIT 1", CONNECTION_ASYNC); + + // DeserterTracker + PrepareStatement(CHAR_INS_DESERTER_TRACK, "INSERT INTO battleground_deserters (guid, type, datetime) VALUES (?, ?, NOW())", CONNECTION_ASYNC); } diff --git a/src/server/database/Database/Implementation/CharacterDatabase.h b/src/server/database/Database/Implementation/CharacterDatabase.h index c76c584a0a8..3382430d695 100644 --- a/src/server/database/Database/Implementation/CharacterDatabase.h +++ b/src/server/database/Database/Implementation/CharacterDatabase.h @@ -143,7 +143,6 @@ enum CharacterDatabaseStatements CHAR_DEL_GIFT, CHAR_SEL_CHARACTER_GIFT_BY_ITEM, CHAR_SEL_ACCOUNT_BY_NAME, - CHAR_SEL_ACCOUNT_BY_GUID, CHAR_DEL_ACCOUNT_INSTANCE_LOCK_TIMES, CHAR_INS_ACCOUNT_INSTANCE_LOCK_TIMES, CHAR_SEL_CHARACTER_NAME_CLASS, @@ -531,6 +530,8 @@ enum CharacterDatabaseStatements CHAR_UPD_QUEST_TRACK_COMPLETE_TIME, CHAR_UPD_QUEST_TRACK_ABANDON_TIME, + CHAR_INS_DESERTER_TRACK, + MAX_CHARACTERDATABASE_STATEMENTS }; diff --git a/src/server/database/Database/Implementation/LoginDatabase.cpp b/src/server/database/Database/Implementation/LoginDatabase.cpp index 8f0b5067957..9b7bf285efc 100644 --- a/src/server/database/Database/Implementation/LoginDatabase.cpp +++ b/src/server/database/Database/Implementation/LoginDatabase.cpp @@ -25,6 +25,9 @@ void LoginDatabaseConnection::DoPrepareStatements() PrepareStatement(LOGIN_SEL_REALMLIST, "SELECT id, name, address, localAddress, localSubnetMask, port, icon, flag, timezone, allowedSecurityLevel, population, gamebuild FROM realmlist WHERE flag <> 3 ORDER BY name", CONNECTION_SYNCH); PrepareStatement(LOGIN_DEL_EXPIRED_IP_BANS, "DELETE FROM ip_banned WHERE unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()", CONNECTION_ASYNC); PrepareStatement(LOGIN_UPD_EXPIRED_ACCOUNT_BANS, "UPDATE account_banned SET active = 0 WHERE active = 1 AND unbandate<>bandate AND unbandate<=UNIX_TIMESTAMP()", CONNECTION_SYNCH); + PrepareStatement(LOGIN_SEL_IP_INFO, "(SELECT unbandate > UNIX_TIMESTAMP() OR unbandate = bandate AS banned, NULL as country FROM ip_banned WHERE ip = ?) " + "UNION " + "(SELECT NULL AS banned, country FROM ip2nation WHERE INET_NTOA(ip) = ?)", CONNECTION_ASYNC); PrepareStatement(LOGIN_SEL_IP_BANNED, "SELECT * FROM ip_banned WHERE ip = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_INS_IP_AUTO_BANNED, "INSERT INTO ip_banned (ip, bandate, unbandate, bannedby, banreason) VALUES (?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+?, 'Trinity Auth', 'Failed login autoban')", CONNECTION_ASYNC); PrepareStatement(LOGIN_SEL_IP_BANNED_ALL, "SELECT ip, bandate, unbandate, bannedby, banreason FROM ip_banned WHERE (bandate = unbandate OR unbandate > UNIX_TIMESTAMP()) ORDER BY unbandate", CONNECTION_SYNCH); @@ -43,7 +46,9 @@ void LoginDatabaseConnection::DoPrepareStatements() PrepareStatement(LOGIN_SEL_FAILEDLOGINS, "SELECT id, failed_logins FROM account WHERE username = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_ACCOUNT_ID_BY_NAME, "SELECT id FROM account WHERE username = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_ACCOUNT_LIST_BY_NAME, "SELECT id, username FROM account WHERE username = ?", CONNECTION_SYNCH); - PrepareStatement(LOGIN_SEL_ACCOUNT_INFO_BY_NAME, "SELECT id, sessionkey, last_ip, locked, expansion, mutetime, locale, recruiter, os FROM account WHERE username = ?", CONNECTION_SYNCH); + PrepareStatement(LOGIN_SEL_ACCOUNT_INFO_BY_NAME, "SELECT a.id, a.sessionkey, a.last_ip, a.locked, a.lock_country, a.expansion, a.mutetime, a.locale, a.recruiter, a.os, aa.gmLevel, " + "(ab.unbandate > UNIX_TIMESTAMP() OR ab.unbandate = ab.bandate) AND ab.active, r.id FROM account a LEFT JOIN account_access aa ON a.id = aa.id AND aa.RealmID IN (-1, ?) " + "LEFT JOIN account_banned ab ON a.id = ab.id LEFT JOIN account r ON a.id = r.recruiter WHERE a.username = ? ORDER BY aa.RealmID DESC LIMIT 1", CONNECTION_ASYNC); PrepareStatement(LOGIN_SEL_ACCOUNT_LIST_BY_EMAIL, "SELECT id, username FROM account WHERE email = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_NUM_CHARS_ON_REALM, "SELECT numchars FROM realmcharacters WHERE realmid = ? AND acctid= ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_ACCOUNT_BY_IP, "SELECT id, username FROM account WHERE last_ip = ?", CONNECTION_SYNCH); @@ -88,8 +93,6 @@ void LoginDatabaseConnection::DoPrepareStatements() PrepareStatement(LOGIN_SEL_ACCOUNT_INFO, "SELECT a.username, a.last_ip, aa.gmlevel, a.expansion FROM account a LEFT JOIN account_access aa ON (a.id = aa.id) WHERE a.id = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_ACCOUNT_ACCESS_GMLEVEL_TEST, "SELECT 1 FROM account_access WHERE id = ? AND gmlevel > ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_ACCOUNT_ACCESS, "SELECT a.id, aa.gmlevel, aa.RealmID FROM account a LEFT JOIN account_access aa ON (a.id = aa.id) WHERE a.username = ?", CONNECTION_SYNCH); - PrepareStatement(LOGIN_SEL_ACCOUNT_RECRUITER, "SELECT 1 FROM account WHERE recruiter = ?", CONNECTION_SYNCH); - PrepareStatement(LOGIN_SEL_BANS, "SELECT 1 FROM account_banned WHERE id = ? AND active = 1 UNION SELECT 1 FROM ip_banned WHERE ip = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_ACCOUNT_WHOIS, "SELECT username, email, last_ip FROM account WHERE id = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_LAST_ATTEMPT_IP, "SELECT last_attempt_ip FROM account WHERE id = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_LAST_IP, "SELECT last_ip FROM account WHERE id = ?", CONNECTION_SYNCH); @@ -108,7 +111,7 @@ void LoginDatabaseConnection::DoPrepareStatements() PrepareStatement(LOGIN_INS_FALP_IP_LOGGING, "INSERT INTO logs_ip_actions (account_id,character_guid,type,ip,systemnote,unixtime,time) VALUES ((SELECT id FROM account WHERE username = ?), 0, 1, ?, ?, unix_timestamp(NOW()), NOW())", CONNECTION_ASYNC); PrepareStatement(LOGIN_SEL_ACCOUNT_ACCESS_BY_ID, "SELECT gmlevel, RealmID FROM account_access WHERE id = ? and (RealmID = ? OR RealmID = -1) ORDER BY gmlevel desc", CONNECTION_SYNCH); - PrepareStatement(LOGIN_SEL_RBAC_ACCOUNT_PERMISSIONS, "SELECT permissionId, granted FROM rbac_account_permissions WHERE accountId = ? AND (realmId = ? OR realmId = -1) ORDER BY permissionId, realmId", CONNECTION_SYNCH); + PrepareStatement(LOGIN_SEL_RBAC_ACCOUNT_PERMISSIONS, "SELECT permissionId, granted FROM rbac_account_permissions WHERE accountId = ? AND (realmId = ? OR realmId = -1) ORDER BY permissionId, realmId", CONNECTION_BOTH); PrepareStatement(LOGIN_INS_RBAC_ACCOUNT_PERMISSION, "INSERT INTO rbac_account_permissions (accountId, permissionId, granted, realmId) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE granted = VALUES(granted)", CONNECTION_ASYNC); PrepareStatement(LOGIN_DEL_RBAC_ACCOUNT_PERMISSION, "DELETE FROM rbac_account_permissions WHERE accountId = ? AND permissionId = ? AND (realmId = ? OR realmId = -1)", CONNECTION_ASYNC); PrepareStatement(LOGIN_INS_ACCOUNT_MUTE, "INSERT INTO account_muted VALUES (?, UNIX_TIMESTAMP(), ?, ?, ?)", CONNECTION_ASYNC); diff --git a/src/server/database/Database/Implementation/LoginDatabase.h b/src/server/database/Database/Implementation/LoginDatabase.h index 79b7a53cb6e..3b30105e670 100644 --- a/src/server/database/Database/Implementation/LoginDatabase.h +++ b/src/server/database/Database/Implementation/LoginDatabase.h @@ -32,6 +32,7 @@ enum LoginDatabaseStatements LOGIN_SEL_REALMLIST, LOGIN_DEL_EXPIRED_IP_BANS, LOGIN_UPD_EXPIRED_ACCOUNT_BANS, + LOGIN_SEL_IP_INFO, LOGIN_SEL_IP_BANNED, LOGIN_INS_IP_AUTO_BANNED, LOGIN_SEL_ACCOUNT_BANNED, @@ -95,8 +96,6 @@ enum LoginDatabaseStatements LOGIN_SEL_ACCOUNT_INFO, LOGIN_SEL_ACCOUNT_ACCESS_GMLEVEL_TEST, LOGIN_SEL_ACCOUNT_ACCESS, - LOGIN_SEL_ACCOUNT_RECRUITER, - LOGIN_SEL_BANS, LOGIN_SEL_ACCOUNT_WHOIS, LOGIN_SEL_REALMLIST_SECURITY_LEVEL, LOGIN_DEL_ACCOUNT, diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp index 7efed2976c4..9d76ee5573d 100644 --- a/src/server/game/AI/CoreAI/CombatAI.cpp +++ b/src/server/game/AI/CoreAI/CombatAI.cpp @@ -259,7 +259,7 @@ void TurretAI::UpdateAI(uint32 /*diff*/) // VehicleAI ////////////// -VehicleAI::VehicleAI(Creature* creature) : CreatureAI(creature), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME) +VehicleAI::VehicleAI(Creature* creature) : CreatureAI(creature), m_HasConditions(false), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME) { LoadConditions(); m_DoDismiss = false; @@ -285,7 +285,7 @@ void VehicleAI::UpdateAI(uint32 diff) void VehicleAI::OnCharmed(bool apply) { - if (!me->GetVehicleKit()->IsVehicleInUse() && !apply && !conditions.empty()) // was used and has conditions + if (!me->GetVehicleKit()->IsVehicleInUse() && !apply && m_HasConditions) // was used and has conditions { m_DoDismiss = true; // needs reset } @@ -297,16 +297,14 @@ void VehicleAI::OnCharmed(bool apply) void VehicleAI::LoadConditions() { - conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, me->GetEntry()); - if (!conditions.empty()) - TC_LOG_DEBUG("condition", "VehicleAI::LoadConditions: loaded %u conditions", uint32(conditions.size())); + m_HasConditions = sConditionMgr->HasConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, me->GetEntry()); } void VehicleAI::CheckConditions(uint32 diff) { if (m_ConditionsTimer < diff) { - if (!conditions.empty()) + if (m_HasConditions) { if (Vehicle* vehicleKit = me->GetVehicleKit()) for (SeatMap::iterator itr = vehicleKit->Seats.begin(); itr != vehicleKit->Seats.end(); ++itr) @@ -314,7 +312,7 @@ void VehicleAI::CheckConditions(uint32 diff) { if (Player* player = passenger->ToPlayer()) { - if (!sConditionMgr->IsObjectMeetToConditions(player, me, conditions)) + if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, me->GetEntry(), player, me)) { player->ExitVehicle(); return; // check other pessanger in next tick diff --git a/src/server/game/AI/CoreAI/CombatAI.h b/src/server/game/AI/CoreAI/CombatAI.h index 97308f22e5d..26b5db3e7c8 100644 --- a/src/server/game/AI/CoreAI/CombatAI.h +++ b/src/server/game/AI/CoreAI/CombatAI.h @@ -112,7 +112,7 @@ struct VehicleAI : public CreatureAI private: void LoadConditions(); void CheckConditions(uint32 diff); - ConditionList conditions; + bool m_HasConditions; uint32 m_ConditionsTimer; bool m_DoDismiss; uint32 m_DismissTimer; diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index 5aa6ea8ea7a..f0d9d34db69 100644 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -29,7 +29,15 @@ void UnitAI::AttackStart(Unit* victim) { if (victim && me->Attack(victim, true)) + { + // Clear distracted state on attacking + if (me->HasUnitState(UNIT_STATE_DISTRACTED)) + { + me->ClearUnitState(UNIT_STATE_DISTRACTED); + me->GetMotionMaster()->Clear(); + } me->GetMotionMaster()->MoveChase(victim); + } } void UnitAI::AttackStartCaster(Unit* victim, float dist) diff --git a/src/server/game/AI/CreatureAIFactory.h b/src/server/game/AI/CreatureAIFactory.h index 4473d3e9cd5..4e11630259b 100644 --- a/src/server/game/AI/CreatureAIFactory.h +++ b/src/server/game/AI/CreatureAIFactory.h @@ -50,6 +50,8 @@ CreatureAIFactory<REAL_AI>::Create(void* data) const typedef FactoryHolder<CreatureAI> CreatureAICreator; typedef FactoryHolder<CreatureAI>::FactoryHolderRegistry CreatureAIRegistry; +#define sCreatureAIRegistry CreatureAIRegistry::instance() + //GO struct SelectableGameObjectAI : public FactoryHolder<GameObjectAI>, public Permissible<GameObject> { @@ -76,4 +78,7 @@ GameObjectAIFactory<REAL_GO_AI>::Create(void* data) const typedef FactoryHolder<GameObjectAI> GameObjectAICreator; typedef FactoryHolder<GameObjectAI>::FactoryHolderRegistry GameObjectAIRegistry; + +#define sGameObjectAIRegistry GameObjectAIRegistry::instance() + #endif diff --git a/src/server/game/AI/CreatureAIImpl.h b/src/server/game/AI/CreatureAIImpl.h index a2c5c5db057..529f7420021 100644 --- a/src/server/game/AI/CreatureAIImpl.h +++ b/src/server/game/AI/CreatureAIImpl.h @@ -23,292 +23,14 @@ #include "CreatureAI.h" #include "SpellMgr.h" -template<class T> -inline -const T& RAND(const T& v1, const T& v2) -{ - return (urand(0, 1)) ? v1 : v2; -} - -template<class T> -inline -const T& RAND(const T& v1, const T& v2, const T& v3) -{ - switch (urand(0, 2)) - { - default: - case 0: return v1; - case 1: return v2; - case 2: return v3; - } -} - -template<class T> -inline -const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4) -{ - switch (urand(0, 3)) - { - default: - case 0: return v1; - case 1: return v2; - case 2: return v3; - case 3: return v4; - } -} - -template<class T> -inline -const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) -{ - switch (urand(0, 4)) - { - default: - case 0: return v1; - case 1: return v2; - case 2: return v3; - case 3: return v4; - case 4: return v5; - } -} - -template<class T> -inline -const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6) -{ - switch (urand(0, 5)) - { - default: - case 0: return v1; - case 1: return v2; - case 2: return v3; - case 3: return v4; - case 4: return v5; - case 5: return v6; - } -} - -template<class T> -inline -const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7) -{ - switch (urand(0, 6)) - { - default: - case 0: return v1; - case 1: return v2; - case 2: return v3; - case 3: return v4; - case 4: return v5; - case 5: return v6; - case 6: return v7; - } -} - -template<class T> -inline -const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8) -{ - switch (urand(0, 7)) - { - default: - case 0: return v1; - case 1: return v2; - case 2: return v3; - case 3: return v4; - case 4: return v5; - case 5: return v6; - case 6: return v7; - case 7: return v8; - } -} - -template<class T> -inline -const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, - const T& v9) -{ - switch (urand(0, 8)) - { - default: - case 0: return v1; - case 1: return v2; - case 2: return v3; - case 3: return v4; - case 4: return v5; - case 5: return v6; - case 6: return v7; - case 7: return v8; - case 8: return v9; - } -} - -template<class T> -inline -const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, - const T& v9, const T& v10) -{ - switch (urand(0, 9)) - { - default: - case 0: return v1; - case 1: return v2; - case 2: return v3; - case 3: return v4; - case 4: return v5; - case 5: return v6; - case 6: return v7; - case 7: return v8; - case 8: return v9; - case 9: return v10; - } -} - -template<class T> -inline -const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, - const T& v9, const T& v10, const T& v11) -{ - switch (urand(0, 10)) - { - default: - case 0: return v1; - case 1: return v2; - case 2: return v3; - case 3: return v4; - case 4: return v5; - case 5: return v6; - case 6: return v7; - case 7: return v8; - case 8: return v9; - case 9: return v10; - case 10: return v11; - } -} - -template<class T> -inline -const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, - const T& v9, const T& v10, const T& v11, const T& v12) -{ - switch (urand(0, 11)) - { - default: - case 0: return v1; - case 1: return v2; - case 2: return v3; - case 3: return v4; - case 4: return v5; - case 5: return v6; - case 6: return v7; - case 7: return v8; - case 8: return v9; - case 9: return v10; - case 10: return v11; - case 11: return v12; - } -} - -template<class T> -inline -const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, - const T& v9, const T& v10, const T& v11, const T& v12, const T& v13) -{ - switch (urand(0, 12)) - { - default: - case 0: return v1; - case 1: return v2; - case 2: return v3; - case 3: return v4; - case 4: return v5; - case 5: return v6; - case 6: return v7; - case 7: return v8; - case 8: return v9; - case 9: return v10; - case 10: return v11; - case 11: return v12; - case 12: return v13; - } -} - -template<class T> -inline -const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, - const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14) -{ - switch (urand(0, 13)) - { - default: - case 0: return v1; - case 1: return v2; - case 2: return v3; - case 3: return v4; - case 4: return v5; - case 5: return v6; - case 6: return v7; - case 7: return v8; - case 8: return v9; - case 9: return v10; - case 10: return v11; - case 11: return v12; - case 12: return v13; - case 13: return v14; - } -} - -template<class T> -inline -const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, - const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14, const T& v15) -{ - switch (urand(0, 14)) - { - default: - case 0: return v1; - case 1: return v2; - case 2: return v3; - case 3: return v4; - case 4: return v5; - case 5: return v6; - case 6: return v7; - case 7: return v8; - case 8: return v9; - case 9: return v10; - case 10: return v11; - case 11: return v12; - case 12: return v13; - case 13: return v14; - case 14: return v15; - } -} +#include <functional> +#include <type_traits> -template<class T> -inline -const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, - const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14, const T& v15, const T& v16) +template<typename First, typename Second, typename... Rest> +static inline First const& RAND(First const& first, Second const& second, Rest const&... rest) { - switch (urand(0, 15)) - { - default: - case 0: return v1; - case 1: return v2; - case 2: return v3; - case 3: return v4; - case 4: return v5; - case 5: return v6; - case 6: return v7; - case 7: return v8; - case 8: return v9; - case 9: return v10; - case 10: return v11; - case 11: return v12; - case 12: return v13; - case 13: return v14; - case 14: return v15; - case 15: return v16; - } + std::reference_wrapper<typename std::add_const<First>::type> const pack[] = { first, second, rest... }; + return pack[urand(0, sizeof...(rest) + 1)].get(); } enum AITarget diff --git a/src/server/game/AI/CreatureAISelector.cpp b/src/server/game/AI/CreatureAISelector.cpp index d3e11733997..4cab7d5c099 100644 --- a/src/server/game/AI/CreatureAISelector.cpp +++ b/src/server/game/AI/CreatureAISelector.cpp @@ -30,10 +30,9 @@ namespace FactorySelector CreatureAI* selectAI(Creature* creature) { const CreatureAICreator* ai_factory = NULL; - CreatureAIRegistry& ai_registry(*CreatureAIRegistry::instance()); if (creature->IsPet()) - ai_factory = ai_registry.GetRegistryItem("PetAI"); + ai_factory = sCreatureAIRegistry->GetRegistryItem("PetAI"); //scriptname in db if (!ai_factory) @@ -43,32 +42,32 @@ namespace FactorySelector // AIname in db std::string ainame=creature->GetAIName(); if (!ai_factory && !ainame.empty()) - ai_factory = ai_registry.GetRegistryItem(ainame); + ai_factory = sCreatureAIRegistry->GetRegistryItem(ainame); // select by NPC flags if (!ai_factory) { if (creature->IsVehicle()) - ai_factory = ai_registry.GetRegistryItem("VehicleAI"); + ai_factory = sCreatureAIRegistry->GetRegistryItem("VehicleAI"); else if (creature->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN) && ((Guardian*)creature)->GetOwner()->GetTypeId() == TYPEID_PLAYER) - ai_factory = ai_registry.GetRegistryItem("PetAI"); + ai_factory = sCreatureAIRegistry->GetRegistryItem("PetAI"); else if (creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK)) - ai_factory = ai_registry.GetRegistryItem("NullCreatureAI"); + ai_factory = sCreatureAIRegistry->GetRegistryItem("NullCreatureAI"); else if (creature->IsGuard()) - ai_factory = ai_registry.GetRegistryItem("GuardAI"); + ai_factory = sCreatureAIRegistry->GetRegistryItem("GuardAI"); else if (creature->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN)) - ai_factory = ai_registry.GetRegistryItem("PetAI"); + ai_factory = sCreatureAIRegistry->GetRegistryItem("PetAI"); else if (creature->IsTotem()) - ai_factory = ai_registry.GetRegistryItem("TotemAI"); + ai_factory = sCreatureAIRegistry->GetRegistryItem("TotemAI"); else if (creature->IsTrigger()) { if (creature->m_spells[0]) - ai_factory = ai_registry.GetRegistryItem("TriggerAI"); + ai_factory = sCreatureAIRegistry->GetRegistryItem("TriggerAI"); else - ai_factory = ai_registry.GetRegistryItem("NullCreatureAI"); + ai_factory = sCreatureAIRegistry->GetRegistryItem("NullCreatureAI"); } else if (creature->IsCritter() && !creature->HasUnitTypeMask(UNIT_MASK_GUARDIAN)) - ai_factory = ai_registry.GetRegistryItem("CritterAI"); + ai_factory = sCreatureAIRegistry->GetRegistryItem("CritterAI"); } // select by permit check @@ -76,7 +75,7 @@ namespace FactorySelector { int best_val = -1; typedef CreatureAIRegistry::RegistryMapType RMT; - RMT const& l = ai_registry.GetRegisteredItems(); + RMT const& l = sCreatureAIRegistry->GetRegisteredItems(); for (RMT::const_iterator iter = l.begin(); iter != l.end(); ++iter) { const CreatureAICreator* factory = iter->second; @@ -128,14 +127,13 @@ namespace FactorySelector GameObjectAI* SelectGameObjectAI(GameObject* go) { - const GameObjectAICreator* ai_factory = NULL; - GameObjectAIRegistry& ai_registry(*GameObjectAIRegistry::instance()); + GameObjectAICreator const* ai_factory = NULL; // scriptname in db if (GameObjectAI* scriptedAI = sScriptMgr->GetGameObjectAI(go)) return scriptedAI; - ai_factory = ai_registry.GetRegistryItem(go->GetAIName()); + ai_factory = sGameObjectAIRegistry->GetRegistryItem(go->GetAIName()); //future goAI types go here diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index 8e2a82dbfd3..7b145268d22 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -470,6 +470,7 @@ void BossAI::_Reset() if (!me->IsAlive()) return; + me->SetCombatPulseDelay(0); me->ResetLootMode(); events.Reset(); summons.DespawnAll(); @@ -500,6 +501,7 @@ void BossAI::_EnterCombat() instance->SetBossState(_bossId, IN_PROGRESS); } + me->SetCombatPulseDelay(5); me->setActive(true); DoZoneInCombat(); ScheduleTasks(); diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 46122697094..46cf934356d 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -453,45 +453,15 @@ void SmartAI::MoveInLineOfSight(Unit* who) GetScript()->OnMoveInLineOfSight(who); - if (me->HasReactState(REACT_PASSIVE) || AssistPlayerInCombat(who)) + if (AssistPlayerInCombat(who)) return; - if (!CanAIAttack(who)) - return; - - if (!me->CanStartAttack(who, false)) - return; - - if (me->IsHostileTo(who)) - { - float fAttackRadius = me->GetAttackDistance(who); - if (me->IsWithinDistInMap(who, fAttackRadius) && me->IsWithinLOSInMap(who)) - { - if (!me->GetVictim()) - { - // Clear distracted state on combat - if (me->HasUnitState(UNIT_STATE_DISTRACTED)) - { - me->ClearUnitState(UNIT_STATE_DISTRACTED); - me->GetMotionMaster()->Clear(); - } - - AttackStart(who); - } - else/* if (me->GetMap()->IsDungeon())*/ - { - who->SetInCombatWith(me); - me->AddThreat(who, 0.0f); - } - } - } + CreatureAI::MoveInLineOfSight(who); } bool SmartAI::CanAIAttack(const Unit* /*who*/) const { - if (me->GetReactState() == REACT_PASSIVE) - return false; - return true; + return !(me->HasReactState(REACT_PASSIVE)); } bool SmartAI::AssistPlayerInCombat(Unit* who) diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index efee565e151..6a3e978e504 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -89,13 +89,8 @@ void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint3 continue; if (eventType == e /*&& (!i->event.event_phase_mask || IsInPhase(i->event.event_phase_mask)) && !(i->event.event_flags & SMART_EVENT_FLAG_NOT_REPEATABLE && i->runOnce)*/) - { - ConditionList conds = sConditionMgr->GetConditionsForSmartEvent(i->entryOrGuid, i->event_id, i->source_type); - ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject()); - - if (sConditionMgr->IsObjectMeetToConditions(info, conds)) + if (sConditionMgr->IsObjectMeetingSmartEventConditions(i->entryOrGuid, i->event_id, i->source_type, unit, GetBaseObject())) ProcessEvent(*i, unit, var0, var1, bvar, spell, gob); - } } } @@ -2322,10 +2317,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u void SmartScript::ProcessTimedAction(SmartScriptHolder& e, uint32 const& min, uint32 const& max, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob) { - ConditionList const conds = sConditionMgr->GetConditionsForSmartEvent(e.entryOrGuid, e.event_id, e.source_type); - ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject()); - - if (sConditionMgr->IsObjectMeetToConditions(info, conds)) + if (sConditionMgr->IsObjectMeetingSmartEventConditions(e.entryOrGuid, e.event_id, e.source_type, unit, GetBaseObject())) ProcessAction(e, unit, var0, var1, bvar, spell, gob); RecalcTimer(e, min, max); diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h index cb338cd3584..96aa1f735fc 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.h +++ b/src/server/game/AI/SmartScripts/SmartScript.h @@ -175,7 +175,7 @@ class SmartScript return 0; } - GameObject* FindGameObjectNear(WorldObject* searchObject, uint32 guid) const + GameObject* FindGameObjectNear(WorldObject* searchObject, ObjectGuid::LowType guid) const { auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid); if (bounds.first == bounds.second) @@ -184,7 +184,7 @@ class SmartScript return bounds.first->second; } - Creature* FindCreatureNear(WorldObject* searchObject, uint32 guid) const + Creature* FindCreatureNear(WorldObject* searchObject, ObjectGuid::LowType guid) const { auto bounds = searchObject->GetMap()->GetCreatureBySpawnIdStore().equal_range(guid); if (bounds.first == bounds.second) diff --git a/src/server/game/Accounts/RBAC.cpp b/src/server/game/Accounts/RBAC.cpp index 74ff060636e..c520564f0fa 100644 --- a/src/server/game/Accounts/RBAC.cpp +++ b/src/server/game/Accounts/RBAC.cpp @@ -17,7 +17,6 @@ #include "RBAC.h" #include "AccountMgr.h" -#include "DatabaseEnv.h" #include "Log.h" namespace rbac @@ -180,7 +179,24 @@ void RBACData::LoadFromDB() stmt->setUInt32(0, GetId()); stmt->setInt32(1, GetRealmId()); - PreparedQueryResult result = LoginDatabase.Query(stmt); + LoadFromDBCallback(LoginDatabase.Query(stmt)); +} + +PreparedQueryResultFuture RBACData::LoadFromDBAsync() +{ + ClearData(); + + TC_LOG_DEBUG("rbac", "RBACData::LoadFromDB [Id: %u Name: %s]: Loading permissions", GetId(), GetName().c_str()); + // Load account permissions (granted and denied) that affect current realm + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_RBAC_ACCOUNT_PERMISSIONS); + stmt->setUInt32(0, GetId()); + stmt->setInt32(1, GetRealmId()); + + return LoginDatabase.AsyncQuery(stmt); +} + +void RBACData::LoadFromDBCallback(PreparedQueryResult result) +{ if (result) { do @@ -190,8 +206,7 @@ void RBACData::LoadFromDB() GrantPermission(fields[0].GetUInt32()); else DenyPermission(fields[0].GetUInt32()); - } - while (result->NextRow()); + } while (result->NextRow()); } // Add default permissions diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h index 805f613155d..4acadd7f2b4 100644 --- a/src/server/game/Accounts/RBAC.h +++ b/src/server/game/Accounts/RBAC.h @@ -40,7 +40,7 @@ #ifndef _RBAC_H #define _RBAC_H -#include "Define.h" +#include "DatabaseEnv.h" #include <string> #include <set> #include <map> @@ -864,6 +864,8 @@ class RBACData /// Loads all permissions assigned to current account void LoadFromDB(); + PreparedQueryResultFuture LoadFromDBAsync(); + void LoadFromDBCallback(PreparedQueryResult result); /// Sets security level void SetSecurityLevel(uint8 id) diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 1809e306a45..768def2ff4d 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -300,7 +300,7 @@ void AuctionHouseMgr::LoadAuctionItems() { Field* fields = result->Fetch(); - uint32 item_guid = fields[11].GetUInt32(); + ObjectGuid::LowType item_guid = fields[11].GetUInt32(); uint32 itemEntry = fields[12].GetUInt32(); ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemEntry); @@ -372,7 +372,7 @@ void AuctionHouseMgr::AddAItem(Item* it) mAitems[it->GetGUID().GetCounter()] = it; } -bool AuctionHouseMgr::RemoveAItem(uint32 id, bool deleteItem) +bool AuctionHouseMgr::RemoveAItem(ObjectGuid::LowType id, bool deleteItem) { ItemMap::iterator i = mAitems.find(id); if (i == mAitems.end()) @@ -738,7 +738,7 @@ std::string AuctionEntry::BuildAuctionMailSubject(MailAuctionAnswers response) c return strm.str(); } -std::string AuctionEntry::BuildAuctionMailBody(uint32 lowGuid, uint32 bid, uint32 buyout, uint32 deposit, uint32 cut) +std::string AuctionEntry::BuildAuctionMailBody(ObjectGuid::LowType lowGuid, uint32 bid, uint32 buyout, uint32 deposit, uint32 cut) { std::ostringstream strm; strm.width(16); diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.h b/src/server/game/AuctionHouse/AuctionHouseMgr.h index f05d8583329..45cdba361f3 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.h +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.h @@ -72,15 +72,15 @@ struct AuctionEntry { uint32 Id; uint8 houseId; - uint32 itemGUIDLow; + ObjectGuid::LowType itemGUIDLow; uint32 itemEntry; uint32 itemCount; - uint32 owner; + ObjectGuid::LowType owner; uint32 startbid; //maybe useless uint32 bid; uint32 buyout; time_t expire_time; - uint32 bidder; + ObjectGuid::LowType bidder; uint32 deposit; //deposit can be calculated only when creating auction AuctionHouseEntry const* auctionHouseEntry; // in AuctionHouse.dbc @@ -93,7 +93,7 @@ struct AuctionEntry void SaveToDB(SQLTransaction& trans) const; bool LoadFromDB(Field* fields); std::string BuildAuctionMailSubject(MailAuctionAnswers response) const; - static std::string BuildAuctionMailBody(uint32 lowGuid, uint32 bid, uint32 buyout, uint32 deposit, uint32 cut); + static std::string BuildAuctionMailBody(ObjectGuid::LowType lowGuid, uint32 bid, uint32 buyout, uint32 deposit, uint32 cut); }; @@ -150,13 +150,13 @@ class AuctionHouseMgr return &instance; } - typedef std::unordered_map<uint32, Item*> ItemMap; + typedef std::unordered_map<ObjectGuid::LowType, Item*> ItemMap; AuctionHouseObject* GetAuctionsMap(uint32 factionTemplateId); AuctionHouseObject* GetAuctionsMapByHouseId(uint8 auctionHouseId); AuctionHouseObject* GetBidsMap(uint32 factionTemplateId); - Item* GetAItem(uint32 id) + Item* GetAItem(ObjectGuid::LowType id) { ItemMap::const_iterator itr = mAitems.find(id); if (itr != mAitems.end()) @@ -183,7 +183,7 @@ class AuctionHouseMgr void LoadAuctions(); void AddAItem(Item* it); - bool RemoveAItem(uint32 id, bool deleteItem = false); + bool RemoveAItem(ObjectGuid::LowType id, bool deleteItem = false); void Update(); diff --git a/src/server/game/Battlefield/Battlefield.h b/src/server/game/Battlefield/Battlefield.h index c860d36e712..bb3ecb60838 100644 --- a/src/server/game/Battlefield/Battlefield.h +++ b/src/server/game/Battlefield/Battlefield.h @@ -193,7 +193,7 @@ class Battlefield : public ZoneScript virtual ~Battlefield(); /// typedef of map witch store capturepoint and the associate gameobject entry - typedef std::map<uint32 /*lowguid */, BfCapturePoint*> BfCapturePointMap; + typedef std::map<ObjectGuid::LowType /*lowguid */, BfCapturePoint*> BfCapturePointMap; /// Call this to init the Battlefield virtual bool SetupBattlefield() { return true; } @@ -400,7 +400,7 @@ class Battlefield : public ZoneScript // CapturePoint system void AddCapturePoint(BfCapturePoint* cp) { m_capturePoints[cp->GetCapturePointEntry()] = cp; } - BfCapturePoint* GetCapturePoint(uint32 lowguid) const + BfCapturePoint* GetCapturePoint(ObjectGuid::LowType lowguid) const { Battlefield::BfCapturePointMap::const_iterator itr = m_capturePoints.find(lowguid); if (itr != m_capturePoints.end()) diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp index e75c07d8946..7806e0b343b 100644 --- a/src/server/game/Battlegrounds/ArenaTeam.cpp +++ b/src/server/game/Battlegrounds/ArenaTeam.cpp @@ -63,7 +63,7 @@ bool ArenaTeam::Create(ObjectGuid captainGuid, uint8 type, std::string const& te EmblemColor = emblemColor; BorderStyle = borderStyle; BorderColor = borderColor; - uint32 captainLowGuid = captainGuid.GetCounter(); + ObjectGuid::LowType captainLowGuid = captainGuid.GetCounter(); // Save arena team to db PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM); diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index ad8a7b9e729..d368b347a0f 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -306,6 +306,15 @@ inline void Battleground::_ProcessOfflineQueue() { if (itr->second.OfflineRemoveTime <= sWorld->GetGameTime()) { + if (isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS) && + (GetStatus() == STATUS_IN_PROGRESS || GetStatus() == STATUS_WAIT_JOIN)) + { + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK); + stmt->setUInt32(0, itr->first.GetCounter()); + stmt->setUInt8(1, BG_DESERTION_TYPE_OFFLINE); + CharacterDatabase.Execute(stmt); + } + RemovePlayerAtLeave(itr->first, true, true);// remove player from BG m_OfflineQueue.pop_front(); // remove from offline queue //do not use itr for anything, because it is erased in RemovePlayerAtLeave() @@ -784,19 +793,20 @@ void Battleground::EndBattleground(uint32 winner) stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PVPSTATS_PLAYER); BattlegroundScoreMap::const_iterator score = PlayerScores.find(player->GetGUID().GetCounter()); - stmt->setUInt32(0, battlegroundId); - stmt->setUInt32(1, player->GetGUID().GetCounter()); - stmt->setUInt32(2, score->second->GetKillingBlows()); - stmt->setUInt32(3, score->second->GetDeaths()); - stmt->setUInt32(4, score->second->GetHonorableKills()); - stmt->setUInt32(5, score->second->GetBonusHonor()); - stmt->setUInt32(6, score->second->GetDamageDone()); - stmt->setUInt32(7, score->second->GetHealingDone()); - stmt->setUInt32(8, score->second->GetAttr1()); - stmt->setUInt32(9, score->second->GetAttr2()); - stmt->setUInt32(10, score->second->GetAttr3()); - stmt->setUInt32(11, score->second->GetAttr4()); - stmt->setUInt32(12, score->second->GetAttr5()); + stmt->setUInt32(0, battlegroundId); + stmt->setUInt32(1, player->GetGUID().GetCounter()); + stmt->setBool (2, team == winner); + stmt->setUInt32(3, score->second->GetKillingBlows()); + stmt->setUInt32(4, score->second->GetDeaths()); + stmt->setUInt32(5, score->second->GetHonorableKills()); + stmt->setUInt32(6, score->second->GetBonusHonor()); + stmt->setUInt32(7, score->second->GetDamageDone()); + stmt->setUInt32(8, score->second->GetHealingDone()); + stmt->setUInt32(9, score->second->GetAttr1()); + stmt->setUInt32(10, score->second->GetAttr2()); + stmt->setUInt32(11, score->second->GetAttr3()); + stmt->setUInt32(12, score->second->GetAttr4()); + stmt->setUInt32(13, score->second->GetAttr5()); CharacterDatabase.Execute(stmt); } @@ -1165,48 +1175,58 @@ void Battleground::RemoveFromBGFreeSlotQueue() // returns the number how many players can join battleground to MaxPlayersPerTeam uint32 Battleground::GetFreeSlotsForTeam(uint32 Team) const { - // if BG is starting ... invite anyone - if (GetStatus() == STATUS_WAIT_JOIN) + // if BG is starting and CONFIG_BATTLEGROUND_INVITATION_TYPE == BG_QUEUE_INVITATION_TYPE_NO_BALANCE, invite anyone + if (GetStatus() == STATUS_WAIT_JOIN && sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) == BG_QUEUE_INVITATION_TYPE_NO_BALANCE) return (GetInvitedCount(Team) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(Team) : 0; - // if BG is already started .. do not allow to join too much players of one faction - uint32 otherTeam; - uint32 otherIn; + + // if BG is already started or CONFIG_BATTLEGROUND_INVITATION_TYPE != BG_QUEUE_INVITATION_TYPE_NO_BALANCE, do not allow to join too much players of one faction + uint32 otherTeamInvitedCount; + uint32 thisTeamInvitedCount; + uint32 otherTeamPlayersCount; + uint32 thisTeamPlayersCount; + if (Team == ALLIANCE) { - otherTeam = GetInvitedCount(HORDE); - otherIn = GetPlayersCountByTeam(HORDE); + thisTeamInvitedCount = GetInvitedCount(ALLIANCE); + otherTeamInvitedCount = GetInvitedCount(HORDE); + thisTeamPlayersCount = GetPlayersCountByTeam(ALLIANCE); + otherTeamPlayersCount = GetPlayersCountByTeam(HORDE); } else { - otherTeam = GetInvitedCount(ALLIANCE); - otherIn = GetPlayersCountByTeam(ALLIANCE); + thisTeamInvitedCount = GetInvitedCount(HORDE); + otherTeamInvitedCount = GetInvitedCount(ALLIANCE); + thisTeamPlayersCount = GetPlayersCountByTeam(HORDE); + otherTeamPlayersCount = GetPlayersCountByTeam(ALLIANCE); } - if (GetStatus() == STATUS_IN_PROGRESS) + if (GetStatus() == STATUS_IN_PROGRESS || GetStatus() == STATUS_WAIT_JOIN) { // difference based on ppl invited (not necessarily entered battle) // default: allow 0 uint32 diff = 0; - // allow join one person if the sides are equal (to fill up bg to minplayersperteam) - if (otherTeam == GetInvitedCount(Team)) + + // allow join one person if the sides are equal (to fill up bg to minPlayerPerTeam) + if (otherTeamInvitedCount == thisTeamInvitedCount) diff = 1; // allow join more ppl if the other side has more players - else if (otherTeam > GetInvitedCount(Team)) - diff = otherTeam - GetInvitedCount(Team); + else if (otherTeamInvitedCount > thisTeamInvitedCount) + diff = otherTeamInvitedCount - thisTeamInvitedCount; // difference based on max players per team (don't allow inviting more) - uint32 diff2 = (GetInvitedCount(Team) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(Team) : 0; + uint32 diff2 = (thisTeamInvitedCount < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - thisTeamInvitedCount : 0; + // difference based on players who already entered // default: allow 0 uint32 diff3 = 0; - // allow join one person if the sides are equal (to fill up bg minplayersperteam) - if (otherIn == GetPlayersCountByTeam(Team)) + // allow join one person if the sides are equal (to fill up bg minPlayerPerTeam) + if (otherTeamPlayersCount == thisTeamPlayersCount) diff3 = 1; // allow join more ppl if the other side has more players - else if (otherIn > GetPlayersCountByTeam(Team)) - diff3 = otherIn - GetPlayersCountByTeam(Team); + else if (otherTeamPlayersCount > thisTeamPlayersCount) + diff3 = otherTeamPlayersCount - thisTeamPlayersCount; // or other side has less than minPlayersPerTeam - else if (GetInvitedCount(Team) <= GetMinPlayersPerTeam()) - diff3 = GetMinPlayersPerTeam() - GetInvitedCount(Team) + 1; + else if (thisTeamInvitedCount <= GetMinPlayersPerTeam()) + diff3 = GetMinPlayersPerTeam() - thisTeamInvitedCount + 1; // return the minimum of the 3 differences diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index 08134298569..471da9846b2 100644 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -40,6 +40,15 @@ class BattlegroundMap; struct PvPDifficultyEntry; struct WorldSafeLocsEntry; +enum BattlegroundDesertionType +{ + BG_DESERTION_TYPE_LEAVE_BG = 0, // player leaves the BG + BG_DESERTION_TYPE_OFFLINE = 1, // player is kicked from BG because offline + BG_DESERTION_TYPE_LEAVE_QUEUE = 2, // player is invited to join and refuses to do it + BG_DESERTION_TYPE_NO_ENTER_BUTTON = 3, // player is invited to join and do nothing (time expires) + BG_DESERTION_TYPE_INVITE_LOGOUT = 4, // player is invited to join and logs out +}; + enum BattlegroundCriteriaId { BG_CRITERIA_CHECK_RESILIENT_VICTORY, diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 73c0f1c22a5..87e07e15191 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -497,24 +497,51 @@ void BattlegroundQueue::FillPlayersToBG(Battleground* bg, BattlegroundBracketId { int32 hordeFree = bg->GetFreeSlotsForTeam(HORDE); int32 aliFree = bg->GetFreeSlotsForTeam(ALLIANCE); + uint32 aliCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].size(); + uint32 hordeCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].size(); + + // try to get even teams + if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) == BG_QUEUE_INVITATION_TYPE_EVEN) + { + // check if the teams are even + if (hordeFree == 1 && aliFree == 1) + { + // if we are here, the teams have the same amount of players + // then we have to allow to join the same amount of players + int32 hordeExtra = hordeCount - aliCount; + int32 aliExtra = aliCount - hordeCount; + + hordeExtra = std::max(hordeExtra, 0); + aliExtra = std::max(aliExtra, 0); + + if (aliCount != hordeCount) + { + aliFree -= aliExtra; + hordeFree -= hordeExtra; + + aliFree = std::max(aliFree, 0); + hordeFree = std::max(hordeFree, 0); + } + } + } //iterator for iterating through bg queue GroupsQueueType::const_iterator Ali_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].begin(); //count of groups in queue - used to stop cycles - uint32 aliCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].size(); + //index to queue which group is current uint32 aliIndex = 0; for (; aliIndex < aliCount && m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), aliFree); aliIndex++) ++Ali_itr; //the same thing for horde GroupsQueueType::const_iterator Horde_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].begin(); - uint32 hordeCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].size(); + uint32 hordeIndex = 0; for (; hordeIndex < hordeCount && m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), hordeFree); hordeIndex++) ++Horde_itr; //if ofc like BG queue invitation is set in config, then we are happy - if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) == 0) + if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) == BG_QUEUE_INVITATION_TYPE_NO_BALANCE) return; /* @@ -649,7 +676,7 @@ bool BattlegroundQueue::CheckNormalMatch(Battleground* bg_template, Battleground uint32 j = TEAM_ALLIANCE; if (m_SelectionPools[TEAM_HORDE].GetPlayerCount() < m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount()) j = TEAM_HORDE; - if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) != 0 + if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) != BG_QUEUE_INVITATION_TYPE_NO_BALANCE && m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= minPlayers) { //we will try to invite more groups to team with less players indexed by j @@ -1041,6 +1068,16 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) BattlegroundQueue &bgQueue = sBattlegroundMgr->GetBattlegroundQueue(m_BgQueueTypeId); if (bgQueue.IsPlayerInvited(m_PlayerGuid, m_BgInstanceGUID, m_RemoveTime)) { + // track if player leaves the BG by not clicking enter button + if (bg->isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS) && + (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN)) + { + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK); + stmt->setUInt32(0, player->GetGUID().GetCounter()); + stmt->setUInt8(1, BG_DESERTION_TYPE_NO_ENTER_BUTTON); + CharacterDatabase.Execute(stmt); + } + TC_LOG_DEBUG("bg.battleground", "Battleground: removing player %u from bg queue for instance %u because of not pressing enter battle in time.", player->GetGUID().GetCounter(), m_BgInstanceGUID); player->RemoveBattlegroundQueueId(m_BgQueueTypeId); diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h index 7e8debfd24d..1509a60e15d 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.h +++ b/src/server/game/Battlegrounds/BattlegroundQueue.h @@ -64,6 +64,13 @@ enum BattlegroundQueueGroupTypes }; #define BG_QUEUE_GROUP_TYPES_COUNT 4 +enum BattlegroundQueueInvitationType +{ + BG_QUEUE_INVITATION_TYPE_NO_BALANCE = 0, // no balance: N+M vs N players + BG_QUEUE_INVITATION_TYPE_BALANCED = 1, // teams balanced: N+1 vs N players + BG_QUEUE_INVITATION_TYPE_EVEN = 2 // teams even: N vs N players +}; + class Battleground; class BattlegroundQueue { diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp index fd63dd04bf6..368ebecba84 100644 --- a/src/server/game/Calendar/CalendarMgr.cpp +++ b/src/server/game/Calendar/CalendarMgr.cpp @@ -66,7 +66,7 @@ void CalendarMgr::LoadFromDB() uint32 eventTime = fields[6].GetUInt32(); uint32 flags = fields[7].GetUInt32(); uint32 timezoneTime = fields[8].GetUInt32(); - uint32 guildId = 0; + ObjectGuid::LowType guildId = 0; if (flags & CALENDAR_FLAG_GUILD_EVENT || flags & CALENDAR_FLAG_WITHOUT_INVITES) guildId = Player::GetGuildIdFromDB(creatorGUID); @@ -270,7 +270,7 @@ void CalendarMgr::RemoveAllPlayerEventsAndInvites(ObjectGuid guid) RemoveInvite((*itr)->GetInviteId(), (*itr)->GetEventId(), guid); } -void CalendarMgr::RemovePlayerGuildEventsAndSignups(ObjectGuid guid, uint32 guildId) +void CalendarMgr::RemovePlayerGuildEventsAndSignups(ObjectGuid guid, ObjectGuid::LowType guildId) { for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) if ((*itr)->GetCreatorGUID() == guid && ((*itr)->IsGuildEvent() || (*itr)->IsGuildAnnouncement())) @@ -573,7 +573,7 @@ void CalendarMgr::SendCalendarEvent(ObjectGuid guid, CalendarEvent const& calend Player* invitee = ObjectAccessor::FindPlayer(inviteeGuid); uint8 inviteeLevel = invitee ? invitee->getLevel() : Player::GetLevelFromDB(inviteeGuid); - uint32 inviteeGuildId = invitee ? invitee->GetGuildId() : Player::GetGuildIdFromDB(inviteeGuid); + ObjectGuid::LowType inviteeGuildId = invitee ? invitee->GetGuildId() : Player::GetGuildIdFromDB(inviteeGuid); data << inviteeGuid.WriteAsPacked(); data << uint8(inviteeLevel); diff --git a/src/server/game/Calendar/CalendarMgr.h b/src/server/game/Calendar/CalendarMgr.h index 1027bd817f0..9969c00e3af 100644 --- a/src/server/game/Calendar/CalendarMgr.h +++ b/src/server/game/Calendar/CalendarMgr.h @@ -203,7 +203,7 @@ struct CalendarEvent _description = calendarEvent.GetDescription(); } - CalendarEvent(uint64 eventId, ObjectGuid creatorGUID, uint32 guildId, CalendarEventType type, int32 dungeonId, + CalendarEvent(uint64 eventId, ObjectGuid creatorGUID, ObjectGuid::LowType guildId, CalendarEventType type, int32 dungeonId, time_t eventTime, uint32 flags, time_t timezoneTime, std::string title, std::string description) : _eventId(eventId), _creatorGUID(creatorGUID), _guildId(guildId), _type(type), _dungeonId(dungeonId), _eventTime(eventTime), _flags(flags), _timezoneTime(timezoneTime), _title(title), @@ -220,8 +220,8 @@ struct CalendarEvent void SetCreatorGUID(ObjectGuid guid) { _creatorGUID = guid; } ObjectGuid GetCreatorGUID() const { return _creatorGUID; } - void SetGuildId(uint32 guildId) { _guildId = guildId; } - uint32 GetGuildId() const { return _guildId; } + void SetGuildId(ObjectGuid::LowType guildId) { _guildId = guildId; } + ObjectGuid::LowType GetGuildId() const { return _guildId; } void SetTitle(const std::string& title) { _title = title; } std::string GetTitle() const { return _title; } @@ -253,7 +253,7 @@ struct CalendarEvent private: uint64 _eventId; ObjectGuid _creatorGUID; - uint32 _guildId; + ObjectGuid::LowType _guildId; CalendarEventType _type; int32 _dungeonId; time_t _eventTime; @@ -316,7 +316,7 @@ class CalendarMgr void UpdateInvite(CalendarInvite* invite, SQLTransaction& trans); void RemoveAllPlayerEventsAndInvites(ObjectGuid guid); - void RemovePlayerGuildEventsAndSignups(ObjectGuid guid, uint32 guildId); + void RemovePlayerGuildEventsAndSignups(ObjectGuid guid, ObjectGuid::LowType guildId); void SendCalendarEvent(ObjectGuid guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType); void SendCalendarEventInvite(CalendarInvite const& invite); diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index 2f003a58a69..161aefdfc67 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -34,54 +34,16 @@ bool ChatHandler::load_command_table = true; -// get number of commands in table -static size_t getCommandTableSize(const ChatCommand* commands) +std::vector<ChatCommand> const& ChatHandler::getCommandTable() { - if (!commands) - return 0; - size_t count = 0; - while (commands[count].Name != NULL) - count++; - return count; -} - -// append source command table to target, return number of appended commands -static size_t appendCommandTable(ChatCommand* target, const ChatCommand* source) -{ - const size_t count = getCommandTableSize(source); - if (count) - memcpy(target, source, count * sizeof(ChatCommand)); - return count; -} - -ChatCommand* ChatHandler::getCommandTable() -{ - // cache for commands, needed because some commands are loaded dynamically through ScriptMgr - // cache is never freed and will show as a memory leak in diagnostic tools - // can't use vector as vector storage is implementation-dependent, eg, there can be alignment gaps between elements - static ChatCommand* commandTableCache = NULL; + static std::vector<ChatCommand> commandTableCache; if (LoadCommandTable()) { SetLoadCommandTable(false); - { - // count total number of top-level commands - size_t total = 0; - std::vector<ChatCommand*> const& dynamic = sScriptMgr->GetChatCommands(); - for (std::vector<ChatCommand*>::const_iterator it = dynamic.begin(); it != dynamic.end(); ++it) - total += getCommandTableSize(*it); - total += 1; // ending zero - - // cache top-level commands - size_t added = 0; - free(commandTableCache); - commandTableCache = (ChatCommand*)malloc(sizeof(ChatCommand) * total); - ASSERT(commandTableCache); - memset(commandTableCache, 0, sizeof(ChatCommand) * total); - for (std::vector<ChatCommand*>::const_iterator it = dynamic.begin(); it != dynamic.end(); ++it) - added += appendCommandTable(commandTableCache + added, *it); - } + std::vector<ChatCommand> cmds = sScriptMgr->GetChatCommands(); + commandTableCache.swap(cmds); PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_COMMANDS); PreparedQueryResult result = WorldDatabase.Query(stmt); @@ -264,7 +226,7 @@ void ChatHandler::SendSysMessage(uint32 entry) SendSysMessage(GetTrinityString(entry)); } -bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, std::string const& fullcmd) +bool ChatHandler::ExecuteCommandInTable(std::vector<ChatCommand> const& table, const char* text, std::string const& fullcmd) { char const* oldtext = text; std::string cmd = ""; @@ -277,7 +239,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st while (*text == ' ') ++text; - for (uint32 i = 0; table[i].Name != NULL; ++i) + for (uint32 i = 0; i < table.size(); ++i) { if (!hasStringAbbr(table[i].Name, cmd.c_str())) continue; @@ -285,7 +247,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st bool match = false; if (strlen(table[i].Name) > cmd.length()) { - for (uint32 j = 0; table[j].Name != NULL; ++j) + for (uint32 j = 0; j < table.size(); ++j) { if (!hasStringAbbr(table[j].Name, cmd.c_str())) continue; @@ -301,7 +263,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st continue; // select subcommand from child commands list - if (table[i].ChildCommands != NULL) + if (!table[i].ChildCommands.empty()) { if (!ExecuteCommandInTable(table[i].ChildCommands, text, fullcmd)) { @@ -346,7 +308,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st fullcmd.c_str(), player->GetName().c_str(), player->GetGUID().ToString().c_str(), m_session->GetAccountId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), - player->GetMap() ? player->GetMap()->GetMapName() : "Unknown", + player->FindMap() ? player->FindMap()->GetMapName() : "Unknown", areaId, areaName.c_str(), zoneName.c_str(), (player->GetSelectedUnit()) ? player->GetSelectedUnit()->GetName().c_str() : "", guid.ToString().c_str()); @@ -367,7 +329,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, st return false; } -bool ChatHandler::SetDataForCommandInTable(ChatCommand* table, char const* text, uint32 permission, std::string const& help, std::string const& fullcommand) +bool ChatHandler::SetDataForCommandInTable(std::vector<ChatCommand>& table, char const* text, uint32 permission, std::string const& help, std::string const& fullcommand) { std::string cmd = ""; @@ -379,14 +341,14 @@ bool ChatHandler::SetDataForCommandInTable(ChatCommand* table, char const* text, while (*text == ' ') ++text; - for (uint32 i = 0; table[i].Name != NULL; i++) + for (uint32 i = 0; i < table.size(); i++) { // for data fill use full explicit command names if (table[i].Name != cmd) continue; // select subcommand from child commands list (including "") - if (table[i].ChildCommands != NULL) + if (!table[i].ChildCommands.empty()) { if (SetDataForCommandInTable(table[i].ChildCommands, text, permission, help, fullcommand)) return true; @@ -413,7 +375,7 @@ bool ChatHandler::SetDataForCommandInTable(ChatCommand* table, char const* text, // in case "" command let process by caller if (!cmd.empty()) { - if (table == getCommandTable()) + if (&table == &getCommandTable()) TC_LOG_ERROR("sql.sql", "Table `command` have not existed command '%s', skip.", cmd.c_str()); else TC_LOG_ERROR("sql.sql", "Table `command` have not existed subcommand '%s' in command '%s', skip.", cmd.c_str(), fullcommand.c_str()); @@ -519,10 +481,10 @@ Valid examples: return LinkExtractor(message).IsValidMessage(); } -bool ChatHandler::ShowHelpForSubCommands(ChatCommand* table, char const* cmd, char const* subcmd) +bool ChatHandler::ShowHelpForSubCommands(std::vector<ChatCommand> const& table, char const* cmd, char const* subcmd) { std::string list; - for (uint32 i = 0; table[i].Name != NULL; ++i) + for (uint32 i = 0; i < table.size(); ++i) { // must be available (ignore handler existence for show command with possible available subcommands) if (!isAvailable(table[i])) @@ -539,14 +501,14 @@ bool ChatHandler::ShowHelpForSubCommands(ChatCommand* table, char const* cmd, ch list += table[i].Name; - if (table[i].ChildCommands) + if (!table[i].ChildCommands.empty()) list += " ..."; } if (list.empty()) return false; - if (table == getCommandTable()) + if (&table == &getCommandTable()) { SendSysMessage(LANG_AVIABLE_CMD); PSendSysMessage("%s", list.c_str()); @@ -557,11 +519,11 @@ bool ChatHandler::ShowHelpForSubCommands(ChatCommand* table, char const* cmd, ch return true; } -bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd) +bool ChatHandler::ShowHelpForCommand(std::vector<ChatCommand> const& table, const char* cmd) { if (*cmd) { - for (uint32 i = 0; table[i].Name != NULL; ++i) + for (uint32 i = 0; i < table.size(); ++i) { // must be available (ignore handler existence for show command with possible available subcommands) if (!isAvailable(table[i])) @@ -573,7 +535,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd) // have subcommand char const* subcmd = (*cmd) ? strtok(NULL, " ") : ""; - if (table[i].ChildCommands && subcmd && *subcmd) + if (!table[i].ChildCommands.empty() && subcmd && *subcmd) { if (ShowHelpForCommand(table[i].ChildCommands, subcmd)) return true; @@ -582,7 +544,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd) if (!table[i].Help.empty()) SendSysMessage(table[i].Help.c_str()); - if (table[i].ChildCommands) + if (!table[i].ChildCommands.empty()) if (ShowHelpForSubCommands(table[i].ChildCommands, table[i].Name, subcmd ? subcmd : "")) return true; @@ -591,7 +553,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd) } else { - for (uint32 i = 0; table[i].Name != NULL; ++i) + for (uint32 i = 0; i < table.size(); ++i) { // must be available (ignore handler existence for show command with possible available subcommands) if (!isAvailable(table[i])) @@ -603,7 +565,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd) if (!table[i].Help.empty()) SendSysMessage(table[i].Help.c_str()); - if (table[i].ChildCommands) + if (!table[i].ChildCommands.empty()) if (ShowHelpForSubCommands(table[i].ChildCommands, "", "")) return true; @@ -910,7 +872,7 @@ GameObject* ChatHandler::GetNearbyGameObject() return obj; } -GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid, uint32 entry) +GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(ObjectGuid::LowType lowguid, uint32 entry) { if (!m_session) return NULL; @@ -1060,7 +1022,7 @@ ObjectGuid ChatHandler::extractGuidFromLink(char* text) } case SPELL_LINK_CREATURE: { - uint32 lowguid = atoul(idS); + ObjectGuid::LowType lowguid = atoul(idS); if (CreatureData const* data = sObjectMgr->GetCreatureData(lowguid)) return ObjectGuid(HighGuid::Unit, data->id, lowguid); @@ -1069,7 +1031,7 @@ ObjectGuid ChatHandler::extractGuidFromLink(char* text) } case SPELL_LINK_GAMEOBJECT: { - uint32 lowguid = atoul(idS); + ObjectGuid::LowType lowguid = atoul(idS); if (GameObjectData const* data = sObjectMgr->GetGOData(lowguid)) return ObjectGuid(HighGuid::GameObject, data->id, lowguid); diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h index 72d80aba7e6..ff8757a891d 100644 --- a/src/server/game/Chat/Chat.h +++ b/src/server/game/Chat/Chat.h @@ -38,13 +38,18 @@ struct GameTele; class ChatCommand { + typedef bool(*pHandler)(ChatHandler*, char const*); + public: - const char * Name; - uint32 Permission; // function pointer required correct align (use uint32) - bool AllowConsole; - bool (*Handler)(ChatHandler*, const char* args); - std::string Help; - ChatCommand* ChildCommands; + ChatCommand(char const* name, uint32 permission, bool allowConsole, pHandler handler, std::string help, std::vector<ChatCommand> childCommands = std::vector<ChatCommand>()) + : Name(name), Permission(permission), AllowConsole(allowConsole), Handler(handler), Help(std::move(help)), ChildCommands(std::move(childCommands)) { } + + char const* Name; + uint32 Permission; // function pointer required correct align (use uint32) + bool AllowConsole; + pHandler Handler; + std::string Help; + std::vector<ChatCommand> ChildCommands; }; class ChatHandler @@ -90,7 +95,7 @@ class ChatHandler bool ParseCommands(const char* text); - static ChatCommand* getCommandTable(); + static std::vector<ChatCommand> const& getCommandTable(); bool isValidChatMessage(const char* msg); void SendGlobalSysMessage(const char *str); @@ -135,18 +140,18 @@ class ChatHandler std::string GetNameLink(Player* chr) const; GameObject* GetNearbyGameObject(); - GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid, uint32 entry); + GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(ObjectGuid::LowType lowguid, uint32 entry); bool HasSentErrorMessage() const { return sentErrorMessage; } void SetSentErrorMessage(bool val){ sentErrorMessage = val; } static bool LoadCommandTable() { return load_command_table; } static void SetLoadCommandTable(bool val) { load_command_table = val; } - bool ShowHelpForCommand(ChatCommand* table, const char* cmd); + bool ShowHelpForCommand(std::vector<ChatCommand> const& table, const char* cmd); protected: explicit ChatHandler() : m_session(NULL), sentErrorMessage(false) { } // for CLI subclass - static bool SetDataForCommandInTable(ChatCommand* table, const char* text, uint32 permission, std::string const& help, std::string const& fullcommand); - bool ExecuteCommandInTable(ChatCommand* table, const char* text, std::string const& fullcmd); - bool ShowHelpForSubCommands(ChatCommand* table, char const* cmd, char const* subcmd); + static bool SetDataForCommandInTable(std::vector<ChatCommand>& table, const char* text, uint32 permission, std::string const& help, std::string const& fullcommand); + bool ExecuteCommandInTable(std::vector<ChatCommand> const& table, const char* text, std::string const& fullcmd); + bool ShowHelpForSubCommands(std::vector<ChatCommand> const& table, char const* cmd, char const* subcmd); private: WorldSession* m_session; // != NULL for chat command call and NULL for CLI command diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index f7260326857..3675d43a3b4 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -28,7 +28,7 @@ #include "SpellAuras.h" #include "SpellMgr.h" -char const* ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX] = +char const* const ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX] = { "None", "Creature Loot", @@ -105,7 +105,7 @@ ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[COND // Checks if object meets the condition // Can have CONDITION_SOURCE_TYPE_NONE && !mReferenceId if called from a special event (ie: eventAI) -bool Condition::Meets(ConditionSourceInfo& sourceInfo) +bool Condition::Meets(ConditionSourceInfo& sourceInfo) const { ASSERT(ConditionTarget < MAX_CONDITION_TARGETS); WorldObject* object = sourceInfo.mConditionTargets[ConditionTarget]; @@ -231,7 +231,7 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) case CONDITION_INSTANCE_INFO: { Map* map = object->GetMap(); - if (map && map->IsDungeon()) + if (map->IsDungeon()) { if (InstanceScript const* instance = ((InstanceMap*)map)->GetInstanceScript()) { @@ -445,7 +445,7 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) return condMeets && script; } -uint32 Condition::GetSearcherTypeMaskForCondition() +uint32 Condition::GetSearcherTypeMaskForCondition() const { // build mask of types for which condition can return true // this is used for speeding up gridsearches @@ -607,7 +607,7 @@ uint32 Condition::GetSearcherTypeMaskForCondition() return mask; } -uint32 Condition::GetMaxAvailableConditionTargets() +uint32 Condition::GetMaxAvailableConditionTargets() const { // returns number of targets which are available for given source type switch (SourceType) @@ -663,114 +663,105 @@ ConditionMgr::~ConditionMgr() Clean(); } -ConditionList ConditionMgr::GetConditionReferences(uint32 refId) -{ - ConditionList conditions; - ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find(refId); - if (ref != ConditionReferenceStore.end()) - conditions = (*ref).second; - return conditions; -} - -uint32 ConditionMgr::GetSearcherTypeMaskForConditionList(ConditionList const& conditions) +uint32 ConditionMgr::GetSearcherTypeMaskForConditionList(ConditionContainer const& conditions) const { if (conditions.empty()) return GRID_MAP_TYPE_MASK_ALL; // groupId, typeMask - std::map<uint32, uint32> ElseGroupStore; - for (ConditionList::const_iterator i = conditions.begin(); i != conditions.end(); ++i) + std::map<uint32, uint32> elseGroupSearcherTypeMasks; + for (ConditionContainer::const_iterator i = conditions.begin(); i != conditions.end(); ++i) { // no point of having not loaded conditions in list ASSERT((*i)->isLoaded() && "ConditionMgr::GetSearcherTypeMaskForConditionList - not yet loaded condition found in list"); - std::map<uint32, uint32>::const_iterator itr = ElseGroupStore.find((*i)->ElseGroup); + std::map<uint32, uint32>::const_iterator itr = elseGroupSearcherTypeMasks.find((*i)->ElseGroup); // group not filled yet, fill with widest mask possible - if (itr == ElseGroupStore.end()) - ElseGroupStore[(*i)->ElseGroup] = GRID_MAP_TYPE_MASK_ALL; + if (itr == elseGroupSearcherTypeMasks.end()) + elseGroupSearcherTypeMasks[(*i)->ElseGroup] = GRID_MAP_TYPE_MASK_ALL; // no point of checking anymore, empty mask - else if (!(*itr).second) + else if (!itr->second) continue; if ((*i)->ReferenceId) // handle reference { ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find((*i)->ReferenceId); ASSERT(ref != ConditionReferenceStore.end() && "ConditionMgr::GetSearcherTypeMaskForConditionList - incorrect reference"); - ElseGroupStore[(*i)->ElseGroup] &= GetSearcherTypeMaskForConditionList((*ref).second); + elseGroupSearcherTypeMasks[(*i)->ElseGroup] &= GetSearcherTypeMaskForConditionList((*ref).second); } else // handle normal condition { // object will match conditions in one ElseGroupStore only when it matches all of them // so, let's find a smallest possible mask which satisfies all conditions - ElseGroupStore[(*i)->ElseGroup] &= (*i)->GetSearcherTypeMaskForCondition(); + elseGroupSearcherTypeMasks[(*i)->ElseGroup] &= (*i)->GetSearcherTypeMaskForCondition(); } } // object will match condition when one of the checks in ElseGroupStore is matching // so, let's include all possible masks uint32 mask = 0; - for (std::map<uint32, uint32>::const_iterator i = ElseGroupStore.begin(); i != ElseGroupStore.end(); ++i) + for (std::map<uint32, uint32>::const_iterator i = elseGroupSearcherTypeMasks.begin(); i != elseGroupSearcherTypeMasks.end(); ++i) mask |= i->second; return mask; } -bool ConditionMgr::IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo, ConditionList const& conditions) +bool ConditionMgr::IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo, ConditionContainer const& conditions) const { // groupId, groupCheckPassed - std::map<uint32, bool> ElseGroupStore; - for (ConditionList::const_iterator i = conditions.begin(); i != conditions.end(); ++i) + std::map<uint32, bool> elseGroupStore; + for (Condition const* condition : conditions) { - TC_LOG_DEBUG("condition", "ConditionMgr::IsPlayerMeetToConditionList %s val1: %u", (*i)->ToString().c_str(), (*i)->ConditionValue1); - if ((*i)->isLoaded()) + TC_LOG_DEBUG("condition", "ConditionMgr::IsPlayerMeetToConditionList %s val1: %u", condition->ToString().c_str(), condition->ConditionValue1); + if (condition->isLoaded()) { //! Find ElseGroup in ElseGroupStore - std::map<uint32, bool>::const_iterator itr = ElseGroupStore.find((*i)->ElseGroup); + std::map<uint32, bool>::const_iterator itr = elseGroupStore.find(condition->ElseGroup); //! If not found, add an entry in the store and set to true (placeholder) - if (itr == ElseGroupStore.end()) - ElseGroupStore[(*i)->ElseGroup] = true; + if (itr == elseGroupStore.end()) + elseGroupStore[condition->ElseGroup] = true; else if (!(*itr).second) continue; - if ((*i)->ReferenceId)//handle reference + if (condition->ReferenceId)//handle reference { - ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find((*i)->ReferenceId); + ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find(condition->ReferenceId); if (ref != ConditionReferenceStore.end()) { - if (!IsObjectMeetToConditionList(sourceInfo, (*ref).second)) - ElseGroupStore[(*i)->ElseGroup] = false; + if (!IsObjectMeetToConditionList(sourceInfo, ref->second)) + elseGroupStore[condition->ElseGroup] = false; } else { TC_LOG_DEBUG("condition", "ConditionMgr::IsPlayerMeetToConditionList %s Reference template -%u not found", - (*i)->ToString().c_str(), (*i)->ReferenceId); // checked at loading, should never happen + condition->ToString().c_str(), condition->ReferenceId); // checked at loading, should never happen } } else //handle normal condition { - if (!(*i)->Meets(sourceInfo)) - ElseGroupStore[(*i)->ElseGroup] = false; + if (!condition->Meets(sourceInfo)) + elseGroupStore[condition->ElseGroup] = false; } } } - for (std::map<uint32, bool>::const_iterator i = ElseGroupStore.begin(); i != ElseGroupStore.end(); ++i) + for (std::map<uint32, bool>::const_iterator i = elseGroupStore.begin(); i != elseGroupStore.end(); ++i) if (i->second) return true; return false; } -bool ConditionMgr::IsObjectMeetToConditions(WorldObject* object, ConditionList const& conditions) +bool ConditionMgr::IsObjectMeetToConditions(WorldObject* object, ConditionContainer const& conditions) const { ConditionSourceInfo srcInfo = ConditionSourceInfo(object); return IsObjectMeetToConditions(srcInfo, conditions); } -bool ConditionMgr::IsObjectMeetToConditions(WorldObject* object1, WorldObject* object2, ConditionList const& conditions) +bool ConditionMgr::IsObjectMeetToConditions(WorldObject* object1, WorldObject* object2, ConditionContainer const& conditions) const { ConditionSourceInfo srcInfo = ConditionSourceInfo(object1, object2); return IsObjectMeetToConditions(srcInfo, conditions); } -bool ConditionMgr::IsObjectMeetToConditions(ConditionSourceInfo& sourceInfo, ConditionList const& conditions) +bool ConditionMgr::IsObjectMeetToConditions(ConditionSourceInfo& sourceInfo, ConditionContainer const& conditions) const { if (conditions.empty()) return true; @@ -807,87 +798,113 @@ bool ConditionMgr::CanHaveSourceIdSet(ConditionSourceType sourceType) return (sourceType == CONDITION_SOURCE_TYPE_SMART_EVENT); } -ConditionList ConditionMgr::GetConditionsForNotGroupedEntry(ConditionSourceType sourceType, uint32 entry) +bool ConditionMgr::IsObjectMeetingNotGroupedConditions(ConditionSourceType sourceType, uint32 entry, ConditionSourceInfo& sourceInfo) const { - ConditionList spellCond; if (sourceType > CONDITION_SOURCE_TYPE_NONE && sourceType < CONDITION_SOURCE_TYPE_MAX) { - ConditionContainer::const_iterator itr = ConditionStore.find(sourceType); - if (itr != ConditionStore.end()) + ConditionsByEntryMap::const_iterator i = ConditionStore[sourceType].find(entry); + if (i != ConditionStore[sourceType].end()) { - ConditionTypeContainer::const_iterator i = (*itr).second.find(entry); - if (i != (*itr).second.end()) - { - spellCond = (*i).second; - TC_LOG_DEBUG("condition", "GetConditionsForNotGroupedEntry: found conditions for type %u and entry %u", uint32(sourceType), entry); - } + TC_LOG_DEBUG("condition", "GetConditionsForNotGroupedEntry: found conditions for type %u and entry %u", uint32(sourceType), entry); + return IsObjectMeetToConditions(sourceInfo, i->second); + } + } + + return true; +} + +bool ConditionMgr::IsObjectMeetingNotGroupedConditions(ConditionSourceType sourceType, uint32 entry, WorldObject* target0, WorldObject* target1 /*= nullptr*/, WorldObject* target2 /*= nullptr*/) const +{ + ConditionSourceInfo conditionSource(target0, target1, target2); + return IsObjectMeetingNotGroupedConditions(sourceType, entry, conditionSource); +} + +bool ConditionMgr::HasConditionsForNotGroupedEntry(ConditionSourceType sourceType, uint32 entry) const +{ + if (sourceType > CONDITION_SOURCE_TYPE_NONE && sourceType < CONDITION_SOURCE_TYPE_MAX) + if (ConditionStore[sourceType].find(entry) != ConditionStore[sourceType].end()) + return true; + + return false; +} + +bool ConditionMgr::IsObjectMeetingSpellClickConditions(uint32 creatureId, uint32 spellId, WorldObject* clicker, WorldObject* target) const +{ + ConditionEntriesByCreatureIdMap::const_iterator itr = SpellClickEventConditionStore.find(creatureId); + if (itr != SpellClickEventConditionStore.end()) + { + ConditionsByEntryMap::const_iterator i = itr->second.find(spellId); + if (i != itr->second.end()) + { + TC_LOG_DEBUG("condition", "GetConditionsForSpellClickEvent: found conditions for SpellClickEvent entry %u spell %u", creatureId, spellId); + ConditionSourceInfo sourceInfo(clicker, target); + return IsObjectMeetToConditions(sourceInfo, i->second); } } - return spellCond; + return true; } -ConditionList ConditionMgr::GetConditionsForSpellClickEvent(uint32 creatureId, uint32 spellId) +ConditionContainer const* ConditionMgr::GetConditionsForSpellClickEvent(uint32 creatureId, uint32 spellId) const { - ConditionList cond; - CreatureSpellConditionContainer::const_iterator itr = SpellClickEventConditionStore.find(creatureId); + ConditionEntriesByCreatureIdMap::const_iterator itr = SpellClickEventConditionStore.find(creatureId); if (itr != SpellClickEventConditionStore.end()) { - ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId); - if (i != (*itr).second.end()) + ConditionsByEntryMap::const_iterator i = itr->second.find(spellId); + if (i != itr->second.end()) { - cond = (*i).second; TC_LOG_DEBUG("condition", "GetConditionsForSpellClickEvent: found conditions for SpellClickEvent entry %u spell %u", creatureId, spellId); + return &i->second; } } - return cond; + return nullptr; } -ConditionList ConditionMgr::GetConditionsForVehicleSpell(uint32 creatureId, uint32 spellId) +bool ConditionMgr::IsObjectMeetingVehicleSpellConditions(uint32 creatureId, uint32 spellId, Player* player, Unit* vehicle) const { - ConditionList cond; - CreatureSpellConditionContainer::const_iterator itr = VehicleSpellConditionStore.find(creatureId); + ConditionEntriesByCreatureIdMap::const_iterator itr = VehicleSpellConditionStore.find(creatureId); if (itr != VehicleSpellConditionStore.end()) { - ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId); - if (i != (*itr).second.end()) + ConditionsByEntryMap::const_iterator i = itr->second.find(spellId); + if (i != itr->second.end()) { - cond = (*i).second; TC_LOG_DEBUG("condition", "GetConditionsForVehicleSpell: found conditions for Vehicle entry %u spell %u", creatureId, spellId); + ConditionSourceInfo sourceInfo(player, vehicle); + return IsObjectMeetToConditions(sourceInfo, i->second); } } - return cond; + return true; } -ConditionList ConditionMgr::GetConditionsForSmartEvent(int32 entryOrGuid, uint32 eventId, uint32 sourceType) +bool ConditionMgr::IsObjectMeetingSmartEventConditions(int32 entryOrGuid, uint32 eventId, uint32 sourceType, Unit* unit, WorldObject* baseObject) const { - ConditionList cond; SmartEventConditionContainer::const_iterator itr = SmartEventConditionStore.find(std::make_pair(entryOrGuid, sourceType)); if (itr != SmartEventConditionStore.end()) { - ConditionTypeContainer::const_iterator i = (*itr).second.find(eventId + 1); - if (i != (*itr).second.end()) + ConditionsByEntryMap::const_iterator i = itr->second.find(eventId + 1); + if (i != itr->second.end()) { - cond = (*i).second; TC_LOG_DEBUG("condition", "GetConditionsForSmartEvent: found conditions for Smart Event entry or guid %d eventId %u", entryOrGuid, eventId); + ConditionSourceInfo sourceInfo(unit, baseObject); + return IsObjectMeetToConditions(sourceInfo, i->second); } } - return cond; + return true; } -ConditionList ConditionMgr::GetConditionsForNpcVendorEvent(uint32 creatureId, uint32 itemId) +bool ConditionMgr::IsObjectMeetingVendorItemConditions(uint32 creatureId, uint32 itemId, Player* player, Creature* vendor) const { - ConditionList cond; - NpcVendorConditionContainer::const_iterator itr = NpcVendorConditionContainerStore.find(creatureId); + ConditionEntriesByCreatureIdMap::const_iterator itr = NpcVendorConditionContainerStore.find(creatureId); if (itr != NpcVendorConditionContainerStore.end()) { - ConditionTypeContainer::const_iterator i = (*itr).second.find(itemId); + ConditionsByEntryMap::const_iterator i = (*itr).second.find(itemId); if (i != (*itr).second.end()) { - cond = (*i).second; TC_LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry %u item %u", creatureId, itemId); + ConditionSourceInfo sourceInfo(player, vendor); + return IsObjectMeetToConditions(sourceInfo, i->second); } } - return cond; + return true; } void ConditionMgr::LoadConditions(bool isReload) @@ -995,14 +1012,8 @@ void ConditionMgr::LoadConditions(bool isReload) if (iSourceTypeOrReferenceId < 0)//it is a reference template { - uint32 uRefId = abs(iSourceTypeOrReferenceId); - if (ConditionReferenceStore.find(uRefId) == ConditionReferenceStore.end())//make sure we have a list for our conditions, based on reference id - { - ConditionList mCondList; - ConditionReferenceStore[uRefId] = mCondList; - } - ConditionReferenceStore[uRefId].push_back(cond);//add to reference storage - count++; + ConditionReferenceStore[std::abs(iSourceTypeOrReferenceId)].push_back(cond);//add to reference storage + ++count; continue; }//end of reference templates @@ -1138,20 +1149,6 @@ void ConditionMgr::LoadConditions(bool isReload) } //handle not grouped conditions - //make sure we have a storage list for our SourceType - if (ConditionStore.find(cond->SourceType) == ConditionStore.end()) - { - ConditionTypeContainer mTypeMap; - ConditionStore[cond->SourceType] = mTypeMap;//add new empty list for SourceType - } - - //make sure we have a condition list for our SourceType's entry - if (ConditionStore[cond->SourceType].find(cond->SourceEntry) == ConditionStore[cond->SourceType].end()) - { - ConditionList mCondList; - ConditionStore[cond->SourceType][cond->SourceEntry] = mCondList; - } - //add new Condition to storage based on Type/Entry ConditionStore[cond->SourceType][cond->SourceEntry].push_back(cond); ++count; @@ -1161,7 +1158,7 @@ void ConditionMgr::LoadConditions(bool isReload) TC_LOG_INFO("server.loading", ">> Loaded %u conditions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } -bool ConditionMgr::addToLootTemplate(Condition* cond, LootTemplate* loot) +bool ConditionMgr::addToLootTemplate(Condition* cond, LootTemplate* loot) const { if (!loot) { @@ -1176,7 +1173,7 @@ bool ConditionMgr::addToLootTemplate(Condition* cond, LootTemplate* loot) return false; } -bool ConditionMgr::addToGossipMenus(Condition* cond) +bool ConditionMgr::addToGossipMenus(Condition* cond) const { GossipMenusMapBoundsNonConst pMenuBounds = sObjectMgr->GetGossipMenusMapBoundsNonConst(cond->SourceGroup); @@ -1196,7 +1193,7 @@ bool ConditionMgr::addToGossipMenus(Condition* cond) return false; } -bool ConditionMgr::addToGossipMenuItems(Condition* cond) +bool ConditionMgr::addToGossipMenuItems(Condition* cond) const { GossipMenuItemsMapBoundsNonConst pMenuItemBounds = sObjectMgr->GetGossipMenuItemsMapBoundsNonConst(cond->SourceGroup); if (pMenuItemBounds.first != pMenuItemBounds.second) @@ -1215,7 +1212,7 @@ bool ConditionMgr::addToGossipMenuItems(Condition* cond) return false; } -bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond) +bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond) const { uint32 conditionEffMask = cond->SourceGroup; SpellInfo* spellInfo = const_cast<SpellInfo*>(sSpellMgr->EnsureSpellInfo(cond->SourceEntry)); @@ -1236,9 +1233,9 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond) continue; // build new shared mask with found effect - uint32 sharedMask = (1 << i); - ConditionList* cmp = spellInfo->Effects[i].ImplicitTargetConditions; - for (uint8 effIndex = i+1; effIndex < MAX_SPELL_EFFECTS; ++effIndex) + uint32 sharedMask = 1 << i; + ConditionContainer* cmp = spellInfo->Effects[i].ImplicitTargetConditions; + for (uint8 effIndex = i + 1; effIndex < MAX_SPELL_EFFECTS; ++effIndex) { if (spellInfo->Effects[effIndex].ImplicitTargetConditions == cmp) sharedMask |= 1 << effIndex; @@ -1260,7 +1257,7 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond) return false; // get shared data - ConditionList* sharedList = spellInfo->Effects[firstEffIndex].ImplicitTargetConditions; + ConditionContainer* sharedList = spellInfo->Effects[firstEffIndex].ImplicitTargetConditions; // there's already data entry for that sharedMask if (sharedList) @@ -1277,7 +1274,7 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond) else { // add new list, create new shared mask - sharedList = new ConditionList(); + sharedList = new ConditionContainer(); bool assigned = false; for (uint8 i = firstEffIndex; i < MAX_SPELL_EFFECTS; ++i) { @@ -1298,7 +1295,7 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond) return true; } -bool ConditionMgr::isSourceTypeValid(Condition* cond) +bool ConditionMgr::isSourceTypeValid(Condition* cond) const { if (cond->SourceType == CONDITION_SOURCE_TYPE_NONE || cond->SourceType >= CONDITION_SOURCE_TYPE_MAX) { @@ -1650,7 +1647,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) return true; } -bool ConditionMgr::isConditionTypeValid(Condition* cond) +bool ConditionMgr::isConditionTypeValid(Condition* cond) const { if (cond->ConditionType == CONDITION_NONE || cond->ConditionType >= CONDITION_MAX) { @@ -2113,81 +2110,50 @@ void ConditionMgr::LogUselessConditionValue(Condition* cond, uint8 index, uint32 void ConditionMgr::Clean() { for (ConditionReferenceContainer::iterator itr = ConditionReferenceStore.begin(); itr != ConditionReferenceStore.end(); ++itr) - { - for (ConditionList::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it) + for (ConditionContainer::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it) delete *it; - itr->second.clear(); - } ConditionReferenceStore.clear(); - for (ConditionContainer::iterator itr = ConditionStore.begin(); itr != ConditionStore.end(); ++itr) + for (uint32 i = 0; i < CONDITION_SOURCE_TYPE_MAX; ++i) { - for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it) - { - for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) - delete *i; - it->second.clear(); - } - itr->second.clear(); - } + for (ConditionsByEntryMap::iterator it = ConditionStore[i].begin(); it != ConditionStore[i].end(); ++it) + for (ConditionContainer::const_iterator itr = it->second.begin(); itr != it->second.end(); ++itr) + delete *itr; - ConditionStore.clear(); + ConditionStore[i].clear(); + } - for (CreatureSpellConditionContainer::iterator itr = VehicleSpellConditionStore.begin(); itr != VehicleSpellConditionStore.end(); ++itr) - { - for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it) - { - for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) + for (ConditionEntriesByCreatureIdMap::iterator itr = VehicleSpellConditionStore.begin(); itr != VehicleSpellConditionStore.end(); ++itr) + for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it) + for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i; - it->second.clear(); - } - itr->second.clear(); - } VehicleSpellConditionStore.clear(); for (SmartEventConditionContainer::iterator itr = SmartEventConditionStore.begin(); itr != SmartEventConditionStore.end(); ++itr) - { - for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it) - { - for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) + for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it) + for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i; - it->second.clear(); - } - itr->second.clear(); - } SmartEventConditionStore.clear(); - for (CreatureSpellConditionContainer::iterator itr = SpellClickEventConditionStore.begin(); itr != SpellClickEventConditionStore.end(); ++itr) - { - for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it) - { - for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) + for (ConditionEntriesByCreatureIdMap::iterator itr = SpellClickEventConditionStore.begin(); itr != SpellClickEventConditionStore.end(); ++itr) + for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it) + for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i; - it->second.clear(); - } - itr->second.clear(); - } SpellClickEventConditionStore.clear(); - for (NpcVendorConditionContainer::iterator itr = NpcVendorConditionContainerStore.begin(); itr != NpcVendorConditionContainerStore.end(); ++itr) - { - for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it) - { - for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) + for (ConditionEntriesByCreatureIdMap::iterator itr = NpcVendorConditionContainerStore.begin(); itr != NpcVendorConditionContainerStore.end(); ++itr) + for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it) + for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i; - it->second.clear(); - } - itr->second.clear(); - } NpcVendorConditionContainerStore.clear(); // this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;) - for (std::list<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr) + for (std::vector<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr) delete *itr; AllocatedMemoryStore.clear(); diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index 27983782bdc..81fe379f0db 100644 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -19,12 +19,9 @@ #ifndef TRINITY_CONDITIONMGR_H #define TRINITY_CONDITIONMGR_H -#include "Define.h" -#include "Errors.h" -#include <list> -#include <map> -#include <string> +#include "Common.h" +class Creature; class Player; class Unit; class WorldObject; @@ -162,13 +159,13 @@ enum MaxConditionTargets struct ConditionSourceInfo { WorldObject* mConditionTargets[MAX_CONDITION_TARGETS]; // an array of targets available for conditions - Condition* mLastFailedCondition; - ConditionSourceInfo(WorldObject* target0, WorldObject* target1 = NULL, WorldObject* target2 = NULL) + Condition const* mLastFailedCondition; + ConditionSourceInfo(WorldObject* target0, WorldObject* target1 = nullptr, WorldObject* target2 = nullptr) { mConditionTargets[0] = target0; mConditionTargets[1] = target1; mConditionTargets[2] = target2; - mLastFailedCondition = NULL; + mLastFailedCondition = nullptr; } }; @@ -209,22 +206,20 @@ struct Condition NegativeCondition = false; } - bool Meets(ConditionSourceInfo& sourceInfo); - uint32 GetSearcherTypeMaskForCondition(); + bool Meets(ConditionSourceInfo& sourceInfo) const; + uint32 GetSearcherTypeMaskForCondition() const; bool isLoaded() const { return ConditionType > CONDITION_NONE || ReferenceId; } - uint32 GetMaxAvailableConditionTargets(); + uint32 GetMaxAvailableConditionTargets() const; std::string ToString(bool ext = false) const; /// For logging purpose }; -typedef std::list<Condition*> ConditionList; -typedef std::map<uint32, ConditionList> ConditionTypeContainer; -typedef std::map<ConditionSourceType, ConditionTypeContainer> ConditionContainer; -typedef std::map<uint32, ConditionTypeContainer> CreatureSpellConditionContainer; -typedef std::map<uint32, ConditionTypeContainer> NpcVendorConditionContainer; -typedef std::map<std::pair<int32, uint32 /*SAI source_type*/>, ConditionTypeContainer> SmartEventConditionContainer; - -typedef std::map<uint32, ConditionList> ConditionReferenceContainer;//only used for references +typedef std::vector<Condition*> ConditionContainer; +typedef std::unordered_map<uint32 /*SourceEntry*/, ConditionContainer> ConditionsByEntryMap; +typedef std::array<ConditionsByEntryMap, CONDITION_SOURCE_TYPE_MAX> ConditionEntriesByTypeArray; +typedef std::unordered_map<uint32, ConditionsByEntryMap> ConditionEntriesByCreatureIdMap; +typedef std::unordered_map<std::pair<int32, uint32 /*SAI source_type*/>, ConditionsByEntryMap> SmartEventConditionContainer; +typedef std::unordered_map<uint32, ConditionContainer> ConditionReferenceContainer;//only used for references class ConditionMgr { @@ -240,20 +235,22 @@ class ConditionMgr } void LoadConditions(bool isReload = false); - bool isConditionTypeValid(Condition* cond); - ConditionList GetConditionReferences(uint32 refId); + bool isConditionTypeValid(Condition* cond) const; - uint32 GetSearcherTypeMaskForConditionList(ConditionList const& conditions); - bool IsObjectMeetToConditions(WorldObject* object, ConditionList const& conditions); - bool IsObjectMeetToConditions(WorldObject* object1, WorldObject* object2, ConditionList const& conditions); - bool IsObjectMeetToConditions(ConditionSourceInfo& sourceInfo, ConditionList const& conditions); + uint32 GetSearcherTypeMaskForConditionList(ConditionContainer const& conditions) const; + bool IsObjectMeetToConditions(WorldObject* object, ConditionContainer const& conditions) const; + bool IsObjectMeetToConditions(WorldObject* object1, WorldObject* object2, ConditionContainer const& conditions) const; + bool IsObjectMeetToConditions(ConditionSourceInfo& sourceInfo, ConditionContainer const& conditions) const; static bool CanHaveSourceGroupSet(ConditionSourceType sourceType); static bool CanHaveSourceIdSet(ConditionSourceType sourceType); - ConditionList GetConditionsForNotGroupedEntry(ConditionSourceType sourceType, uint32 entry); - ConditionList GetConditionsForSpellClickEvent(uint32 creatureId, uint32 spellId); - ConditionList GetConditionsForSmartEvent(int32 entryOrGuid, uint32 eventId, uint32 sourceType); - ConditionList GetConditionsForVehicleSpell(uint32 creatureId, uint32 spellId); - ConditionList GetConditionsForNpcVendorEvent(uint32 creatureId, uint32 itemId); + bool IsObjectMeetingNotGroupedConditions(ConditionSourceType sourceType, uint32 entry, ConditionSourceInfo& sourceInfo) const; + bool IsObjectMeetingNotGroupedConditions(ConditionSourceType sourceType, uint32 entry, WorldObject* target0, WorldObject* target1 = nullptr, WorldObject* target2 = nullptr) const; + bool HasConditionsForNotGroupedEntry(ConditionSourceType sourceType, uint32 entry) const; + bool IsObjectMeetingSpellClickConditions(uint32 creatureId, uint32 spellId, WorldObject* clicker, WorldObject* target) const; + ConditionContainer const* GetConditionsForSpellClickEvent(uint32 creatureId, uint32 spellId) const; + bool IsObjectMeetingVehicleSpellConditions(uint32 creatureId, uint32 spellId, Player* player, Unit* vehicle) const; + bool IsObjectMeetingSmartEventConditions(int32 entryOrGuid, uint32 eventId, uint32 sourceType, Unit* unit, WorldObject* baseObject) const; + bool IsObjectMeetingVendorItemConditions(uint32 creatureId, uint32 itemId, Player* player, Creature* vendor) const; struct ConditionTypeInfo { @@ -262,28 +259,28 @@ class ConditionMgr bool HasConditionValue2; bool HasConditionValue3; }; - static char const* StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX]; + static char const* const StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX]; static ConditionTypeInfo const StaticConditionTypeData[CONDITION_MAX]; private: - bool isSourceTypeValid(Condition* cond); - bool addToLootTemplate(Condition* cond, LootTemplate* loot); - bool addToGossipMenus(Condition* cond); - bool addToGossipMenuItems(Condition* cond); - bool addToSpellImplicitTargetConditions(Condition* cond); - bool IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo, ConditionList const& conditions); + bool isSourceTypeValid(Condition* cond) const; + bool addToLootTemplate(Condition* cond, LootTemplate* loot) const; + bool addToGossipMenus(Condition* cond) const; + bool addToGossipMenuItems(Condition* cond) const; + bool addToSpellImplicitTargetConditions(Condition* cond) const; + bool IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo, ConditionContainer const& conditions) const; static void LogUselessConditionValue(Condition* cond, uint8 index, uint32 value); void Clean(); // free up resources - std::list<Condition*> AllocatedMemoryStore; // some garbage collection :) - - ConditionContainer ConditionStore; - ConditionReferenceContainer ConditionReferenceStore; - CreatureSpellConditionContainer VehicleSpellConditionStore; - CreatureSpellConditionContainer SpellClickEventConditionStore; - NpcVendorConditionContainer NpcVendorConditionContainerStore; - SmartEventConditionContainer SmartEventConditionStore; + std::vector<Condition*> AllocatedMemoryStore; // some garbage collection :) + + ConditionEntriesByTypeArray ConditionStore; + ConditionReferenceContainer ConditionReferenceStore; + ConditionEntriesByCreatureIdMap VehicleSpellConditionStore; + ConditionEntriesByCreatureIdMap SpellClickEventConditionStore; + ConditionEntriesByCreatureIdMap NpcVendorConditionContainerStore; + SmartEventConditionContainer SmartEventConditionStore; }; #define sConditionMgr ConditionMgr::instance() diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp index e268b376b34..806d9d46763 100644 --- a/src/server/game/DataStores/DBCStores.cpp +++ b/src/server/game/DataStores/DBCStores.cpp @@ -25,6 +25,7 @@ #include "Timer.h" #include "ObjectDefines.h" +#include <boost/regex.hpp> #include <map> typedef std::map<uint16, uint32> AreaFlagByAreaID; @@ -140,6 +141,12 @@ MapDifficultyMap sMapDifficultyMap; DBCStorage <MovieEntry> sMovieStore(MovieEntryfmt); +DBCStorage<NamesProfanityEntry> sNamesProfanityStore(NamesProfanityEntryfmt); +DBCStorage<NamesReservedEntry> sNamesReservedStore(NamesReservedEntryfmt); +typedef std::array<std::vector<boost::regex>, TOTAL_LOCALES> NameValidationRegexContainer; +NameValidationRegexContainer NamesProfaneValidators; +NameValidationRegexContainer NamesReservedValidators; + DBCStorage <OverrideSpellDataEntry> sOverrideSpellDataStore(OverrideSpellDatafmt); DBCStorage <PowerDisplayEntry> sPowerDisplayStore(PowerDisplayfmt); @@ -163,7 +170,6 @@ DBCStorage <SoundEntriesEntry> sSoundEntriesStore(SoundEntriesfmt); DBCStorage <SpellItemEnchantmentEntry> sSpellItemEnchantmentStore(SpellItemEnchantmentfmt); DBCStorage <SpellItemEnchantmentConditionEntry> sSpellItemEnchantmentConditionStore(SpellItemEnchantmentConditionfmt); DBCStorage <SpellEntry> sSpellStore(SpellEntryfmt); -SpellCategoryStore sSpellsByCategoryStore; PetFamilySpellsStore sPetFamilySpellsStore; DBCStorage <SpellCastTimesEntry> sSpellCastTimesStore(SpellCastTimefmt); @@ -402,6 +408,37 @@ void LoadDBCStores(const std::string& dataPath) LoadDBC(availableDbcLocales, bad_dbc_files, sMovieStore, dbcPath, "Movie.dbc"); + LoadDBC(availableDbcLocales, bad_dbc_files, sNamesProfanityStore, dbcPath, "NamesProfanity.dbc"); + LoadDBC(availableDbcLocales, bad_dbc_files, sNamesReservedStore, dbcPath, "NamesReserved.dbc"); + for (uint32 i = 0; i < sNamesProfanityStore.GetNumRows(); ++i) + { + NamesProfanityEntry const* namesProfanity = sNamesProfanityStore.LookupEntry(i); + if (!namesProfanity) + continue; + + ASSERT(namesProfanity->Language < TOTAL_LOCALES || namesProfanity->Language == -1); + if (namesProfanity->Language != -1) + NamesProfaneValidators[namesProfanity->Language].emplace_back(namesProfanity->Name, boost::regex::perl | boost::regex::icase | boost::regex::optimize); + else + for (uint32 i = 0; i < TOTAL_LOCALES; ++i) + NamesProfaneValidators[i].emplace_back(namesProfanity->Name, boost::regex::perl | boost::regex::icase | boost::regex::optimize); + } + + for (uint32 i = 0; i < sNamesReservedStore.GetNumRows(); ++i) + { + NamesReservedEntry const* namesReserved = sNamesReservedStore.LookupEntry(i); + if (!namesReserved) + continue; + + ASSERT(namesReserved->Language < TOTAL_LOCALES || namesReserved->Language == -1); + if (namesReserved->Language != -1) + NamesReservedValidators[namesReserved->Language].emplace_back(namesReserved->Name, boost::regex::perl | boost::regex::icase | boost::regex::optimize); + else + for (uint32 i = 0; i < TOTAL_LOCALES; ++i) + NamesReservedValidators[i].emplace_back(namesReserved->Name, boost::regex::perl | boost::regex::icase | boost::regex::optimize); + } + + LoadDBC(availableDbcLocales, bad_dbc_files, sOverrideSpellDataStore, dbcPath, "OverrideSpellData.dbc"); LoadDBC(availableDbcLocales, bad_dbc_files, sPowerDisplayStore, dbcPath, "PowerDisplay.dbc"); @@ -430,12 +467,6 @@ void LoadDBCStores(const std::string& dataPath) LoadDBC(availableDbcLocales, bad_dbc_files, sSkillTiersStore, dbcPath, "SkillTiers.dbc"); LoadDBC(availableDbcLocales, bad_dbc_files, sSoundEntriesStore, dbcPath, "SoundEntries.dbc"); LoadDBC(availableDbcLocales, bad_dbc_files, sSpellStore, dbcPath, "Spell.dbc", &CustomSpellEntryfmt, &CustomSpellEntryIndex); - for (uint32 i = 1; i < sSpellStore.GetNumRows(); ++i) - { - SpellEntry const* spell = sSpellStore.LookupEntry(i); - if (spell && spell->Category) - sSpellsByCategoryStore[spell->Category].insert(i); - } for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) { @@ -1012,3 +1043,20 @@ SkillRaceClassInfoEntry const* GetSkillRaceClassInfo(uint32 skill, uint8 race, u return NULL; } + +ResponseCodes ValidateName(std::string const& name, LocaleConstant locale) +{ + if (locale >= TOTAL_LOCALES) + return RESPONSE_FAILURE; + + for (boost::regex const& regex : NamesProfaneValidators[locale]) + if (boost::regex_search(name, regex)) + return CHAR_NAME_PROFANE; + + // regexes at TOTAL_LOCALES are loaded from NamesReserved which is not locale specific + for (boost::regex const& regex : NamesReservedValidators[locale]) + if (boost::regex_search(name, regex)) + return CHAR_NAME_RESERVED; + + return CHAR_NAME_SUCCESS; +} diff --git a/src/server/game/DataStores/DBCStores.h b/src/server/game/DataStores/DBCStores.h index d955e9581ab..2def7901244 100644 --- a/src/server/game/DataStores/DBCStores.h +++ b/src/server/game/DataStores/DBCStores.h @@ -22,6 +22,7 @@ #include "Common.h" #include "DBCStore.h" #include "DBCStructure.h" +#include "SharedDefines.h" #include <list> @@ -79,6 +80,8 @@ typedef std::unordered_multimap<uint32, SkillRaceClassInfoEntry const*> SkillRac typedef std::pair<SkillRaceClassInfoMap::iterator, SkillRaceClassInfoMap::iterator> SkillRaceClassInfoBounds; SkillRaceClassInfoEntry const* GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_); +ResponseCodes ValidateName(std::string const& name, LocaleConstant locale); + extern DBCStorage <AchievementEntry> sAchievementStore; extern DBCStorage <AchievementCriteriaEntry> sAchievementCriteriaStore; extern DBCStorage <AreaTableEntry> sAreaStore;// recommend access using functions @@ -165,7 +168,6 @@ extern DBCStorage <SpellDurationEntry> sSpellDurationStore; extern DBCStorage <SpellFocusObjectEntry> sSpellFocusObjectStore; extern DBCStorage <SpellItemEnchantmentEntry> sSpellItemEnchantmentStore; extern DBCStorage <SpellItemEnchantmentConditionEntry> sSpellItemEnchantmentConditionStore; -extern SpellCategoryStore sSpellsByCategoryStore; extern PetFamilySpellsStore sPetFamilySpellsStore; extern DBCStorage <SpellRadiusEntry> sSpellRadiusStore; extern DBCStorage <SpellRangeEntry> sSpellRangeStore; diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h index 092ef714145..dc4ad55d9c2 100644 --- a/src/server/game/DataStores/DBCStructure.h +++ b/src/server/game/DataStores/DBCStructure.h @@ -21,7 +21,6 @@ #include "Common.h" #include "DBCEnums.h" -#include "Define.h" #include "Util.h" // Structures using to access raw DBC data and required packing to portability @@ -1405,6 +1404,20 @@ struct MovieEntry //uint32 unk2; // 2 always 100 }; +struct NamesProfanityEntry +{ + //uint32 ID; // 0 + char const* Name; // 1 + int32 Language; // 2 +}; + +struct NamesReservedEntry +{ + //uint32 ID; // 0 + char const* Name; // 1 + int32 Language; // 2 +}; + #define MAX_OVERRIDE_SPELL 10 struct OverrideSpellDataEntry @@ -1638,10 +1651,8 @@ struct SpellEntry uint32 AttributesEx5; // 9 m_attributesExE uint32 AttributesEx6; // 10 m_attributesExF uint32 AttributesEx7; // 11 m_attributesExG - uint32 Stances; // 12 m_shapeshiftMask - // uint32 unk_320_2; // 13 3.2.0 - uint32 StancesNot; // 14 m_shapeshiftExclude - // uint32 unk_320_3; // 15 3.2.0 + uint32 Stances[2]; // 12 m_shapeshiftMask + uint32 StancesNot[2]; // 14 m_shapeshiftExclude uint32 Targets; // 16 m_targets uint32 TargetCreatureType; // 17 m_targetCreatureType uint32 RequiresSpellFocus; // 18 m_requiresSpellFocus @@ -1737,8 +1748,6 @@ struct SpellEntry //uint32 SpellDifficultyId; // 233 3.3.0 }; -typedef std::set<uint32> SpellCategorySet; -typedef std::map<uint32, SpellCategorySet > SpellCategoryStore; typedef std::set<uint32> PetFamilySpellsSet; typedef std::map<uint32, PetFamilySpellsSet > PetFamilySpellsStore; diff --git a/src/server/game/DataStores/DBCfmt.h b/src/server/game/DataStores/DBCfmt.h index 5c24e6f938a..c75c0fff625 100644 --- a/src/server/game/DataStores/DBCfmt.h +++ b/src/server/game/DataStores/DBCfmt.h @@ -88,6 +88,8 @@ char const MailTemplateEntryfmt[] = "nxxxxxxxxxxxxxxxxxssssssssssssssssx"; char const MapEntryfmt[] = "nxiixssssssssssssssssxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixiffxiii"; char const MapDifficultyEntryfmt[] = "diisxxxxxxxxxxxxxxxxiix"; char const MovieEntryfmt[] = "nxx"; +char const NamesProfanityEntryfmt[] = "dsi"; +char const NamesReservedEntryfmt[] = "dsi"; char const OverrideSpellDatafmt[] = "niiiiiiiiiix"; char const QuestFactionRewardfmt[] = "niiiiiiiiii"; char const QuestSortEntryfmt[] = "nxxxxxxxxxxxxxxxxx"; @@ -108,7 +110,7 @@ char const SpellDifficultyfmt[] = "niiii"; const std::string CustomSpellDifficultyfmt = "ppppp"; const std::string CustomSpellDifficultyIndex = "id"; char const SpellDurationfmt[] = "niii"; -char const SpellEntryfmt[] = "niiiiiiiiiiiixixiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiiiiiiiiiiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiixfffxxxiiiiixxfffxx"; +char const SpellEntryfmt[] = "niiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiiiiiiiiiiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiixfffxxxiiiiixxfffxx"; const std::string CustomSpellEntryfmt = "papppppppppppapapaaaaaaaaaaapaaapapppppppaaaaapaapaaaaaaaaaaaaaaaaaappppppppppppppppppppppppppppppppppppaaappppppppppppaaapppppppppaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaappppppppapppaaaaappaaaaaaa"; const std::string CustomSpellEntryIndex = "Id"; char const SpellFocusObjectfmt[] = "nxxxxxxxxxxxxxxxxx"; diff --git a/src/server/game/Entities/Corpse/Corpse.cpp b/src/server/game/Entities/Corpse/Corpse.cpp index 360cfdf1ae3..ce4e94b8ea6 100644 --- a/src/server/game/Entities/Corpse/Corpse.cpp +++ b/src/server/game/Entities/Corpse/Corpse.cpp @@ -59,14 +59,13 @@ void Corpse::RemoveFromWorld() WorldObject::RemoveFromWorld(); } -bool Corpse::Create(uint32 guidlow, Map* map) +bool Corpse::Create(ObjectGuid::LowType guidlow) { - SetMap(map); Object::_Create(guidlow, 0, HighGuid::Corpse); return true; } -bool Corpse::Create(uint32 guidlow, Player* owner) +bool Corpse::Create(ObjectGuid::LowType guidlow, Player* owner) { ASSERT(owner); @@ -79,16 +78,12 @@ bool Corpse::Create(uint32 guidlow, Player* owner) return false; } - //we need to assign owner's map for corpse - //in other way we will get a crash in Corpse::SaveToDB() - SetMap(owner->GetMap()); - WorldObject::_Create(guidlow, HighGuid::Corpse, owner->GetPhaseMask()); SetObjectScale(1.0f); SetGuidValue(CORPSE_FIELD_OWNER, owner->GetGUID()); - _gridCoord = Trinity::ComputeGridCoord(GetPositionX(), GetPositionY()); + _cellCoord = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()); return true; } @@ -123,20 +118,6 @@ void Corpse::SaveToDB() CharacterDatabase.CommitTransaction(trans); } -void Corpse::DeleteBonesFromWorld() -{ - ASSERT(GetType() == CORPSE_BONES); - Corpse* corpse = ObjectAccessor::GetCorpse(*this, GetGUID()); - - if (!corpse) - { - TC_LOG_ERROR("entities.player", "Bones %u not found in world.", GetGUID().GetCounter()); - return; - } - - AddObjectToRemoveList(); -} - void Corpse::DeleteFromDB(SQLTransaction& trans) { DeleteFromDB(GetOwnerGUID(), trans); @@ -149,13 +130,13 @@ void Corpse::DeleteFromDB(ObjectGuid const& ownerGuid, SQLTransaction& trans) CharacterDatabase.ExecuteOrAppend(trans, stmt); } -bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields) +bool Corpse::LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields) { // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 // SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, guid FROM corpse WHERE mapId = ? AND instanceId = ? - uint32 ownerGuid = fields[16].GetUInt32(); + ObjectGuid::LowType ownerGuid = fields[16].GetUInt32(); float posX = fields[0].GetFloat(); float posY = fields[1].GetFloat(); float posZ = fields[2].GetFloat(); @@ -192,14 +173,14 @@ bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields) return false; } - _gridCoord = Trinity::ComputeGridCoord(GetPositionX(), GetPositionY()); + _cellCoord = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()); return true; } bool Corpse::IsExpired(time_t t) const { // Deleted character - if (!sWorld->GetCharacterNameData(GetOwnerGUID())) + if (!sWorld->GetCharacterInfo(GetOwnerGUID())) return true; if (m_type == CORPSE_BONES) diff --git a/src/server/game/Entities/Corpse/Corpse.h b/src/server/game/Entities/Corpse/Corpse.h index eeb22a064ba..7f2608e4bf3 100644 --- a/src/server/game/Entities/Corpse/Corpse.h +++ b/src/server/game/Entities/Corpse/Corpse.h @@ -55,13 +55,12 @@ class Corpse : public WorldObject, public GridObject<Corpse> void AddToWorld() override; void RemoveFromWorld() override; - bool Create(uint32 guidlow, Map* map); - bool Create(uint32 guidlow, Player* owner); + bool Create(ObjectGuid::LowType guidlow); + bool Create(ObjectGuid::LowType guidlow, Player* owner); void SaveToDB(); - bool LoadCorpseFromDB(uint32 guid, Field* fields); + bool LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields); - void DeleteBonesFromWorld(); void DeleteFromDB(SQLTransaction& trans); static void DeleteFromDB(ObjectGuid const& ownerGuid, SQLTransaction& trans); @@ -71,8 +70,8 @@ class Corpse : public WorldObject, public GridObject<Corpse> void ResetGhostTime() { m_time = time(NULL); } CorpseType GetType() const { return m_type; } - GridCoord const& GetGridCoord() const { return _gridCoord; } - void SetGridCoord(GridCoord const& gridCoord) { _gridCoord = gridCoord; } + CellCoord const& GetCellCoord() const { return _cellCoord; } + void SetCellCoord(CellCoord const& cellCoord) { _cellCoord = cellCoord; } Loot loot; // remove insignia ONLY at BG Player* lootRecipient; @@ -83,6 +82,6 @@ class Corpse : public WorldObject, public GridObject<Corpse> private: CorpseType m_type; time_t m_time; - GridCoord _gridCoord; // gride for corpse position for fast search + CellCoord _cellCoord; }; #endif diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 7fe3628f893..6a994d61852 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -138,7 +138,7 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) Creature::Creature(bool isWorldObject): Unit(isWorldObject), MapObject(), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), m_lootRecipient(), m_lootRecipientGroup(0), _skinner(), _pickpocketLootRestore(0), m_corpseRemoveTime(0), m_respawnTime(0), -m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_reactState(REACT_AGGRESSIVE), +m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_combatPulseTime(0), m_combatPulseDelay(0), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE), m_spawnId(0), m_equipmentId(0), m_originalEquipmentId(0), m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_homePosition(), m_transportHomePosition(), m_creatureInfo(NULL), m_creatureData(NULL), m_waypointID(0), m_path_id(0), m_formation(NULL) @@ -226,7 +226,7 @@ void Creature::SearchFormation() if (IsSummon()) return; - uint32 lowguid = GetSpawnId(); + ObjectGuid::LowType lowguid = GetSpawnId(); if (!lowguid) return; @@ -539,10 +539,44 @@ void Creature::Update(uint32 diff) LastCharmerGUID.Clear(); } + // if periodic combat pulse is enabled and we are both in combat and in a dungeon, do this now + if (m_combatPulseDelay > 0 && IsInCombat() && GetMap()->IsDungeon()) + { + if (diff > m_combatPulseTime) + m_combatPulseTime = 0; + else + m_combatPulseTime -= diff; + + if (m_combatPulseTime == 0) + { + Map::PlayerList const &players = GetMap()->GetPlayers(); + if (!players.isEmpty()) + for (Map::PlayerList::const_iterator it = players.begin(); it != players.end(); ++it) + { + if (Player* player = it->GetSource()) + { + if (player->IsGameMaster()) + continue; + + if (player->IsAlive() && this->IsHostileTo(player)) + { + if (CanHaveThreatList()) + AddThreat(player, 0.0f); + this->SetInCombatWith(player); + player->SetInCombatWith(this); + } + } + } + + m_combatPulseTime = m_combatPulseDelay * IN_MILLISECONDS; + } + } + if (!IsInEvadeMode() && IsAIEnabled) { // do not allow the AI to be changed during update m_AI_locked = true; + i_AI->UpdateAI(diff); m_AI_locked = false; } @@ -741,7 +775,7 @@ void Creature::Motion_Initialize() GetMotionMaster()->Initialize(); } -bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const* data /*= nullptr*/, uint32 vehId /*= 0*/) +bool Creature::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const* data /*= nullptr*/, uint32 vehId /*= 0*/) { ASSERT(map); SetMap(map); @@ -1164,7 +1198,7 @@ float Creature::GetSpellDamageMod(int32 Rank) const } } -bool Creature::CreateFromProto(uint32 guidlow, uint32 entry, CreatureData const* data /*= nullptr*/, uint32 vehId /*= 0*/) +bool Creature::CreateFromProto(ObjectGuid::LowType guidlow, uint32 entry, CreatureData const* data /*= nullptr*/, uint32 vehId /*= 0*/) { SetZoneScript(); if (GetZoneScript() && data) @@ -1205,7 +1239,7 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 entry, CreatureData const* return true; } -bool Creature::LoadCreatureFromDB(uint32 spawnId, Map* map, bool addToMap) +bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap) { CreatureData const* data = sObjectMgr->GetCreatureData(spawnId); diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 3e381063772..df83a2f9c0f 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -83,7 +83,7 @@ struct CreatureTemplate uint32 Modelid3; uint32 Modelid4; std::string Name; - std::string SubName; + std::string Title; std::string IconName; uint32 GossipMenuId; uint8 minlevel; @@ -218,7 +218,7 @@ typedef std::unordered_map<uint16, CreatureBaseStats> CreatureBaseStatsContainer struct CreatureLocale { StringVector Name; - StringVector SubName; + StringVector Title; }; struct GossipMenuItemsLocale @@ -317,7 +317,8 @@ struct CreatureAddon std::vector<uint32> auras; }; -typedef std::unordered_map<uint32, CreatureAddon> CreatureAddonContainer; +typedef std::unordered_map<ObjectGuid::LowType, CreatureAddon> CreatureAddonContainer; +typedef std::unordered_map<uint32, CreatureAddon> CreatureAddonTemplateContainer; // Vendors struct VendorItem @@ -430,12 +431,12 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject void DisappearAndDie(); - bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const* data = nullptr, uint32 vehId = 0); + bool Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const* data = nullptr, uint32 vehId = 0); bool LoadCreaturesAddon(bool reload = false); void SelectLevel(); void LoadEquipment(int8 id = 1, bool force = false); - uint32 GetSpawnId() const { return m_spawnId; } + ObjectGuid::LowType GetSpawnId() const { return m_spawnId; } void Update(uint32 time) override; // overwrited Unit::Update void GetRespawnPosition(float &x, float &y, float &z, float* ori = nullptr, float* dist =nullptr) const; @@ -529,8 +530,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject void setDeathState(DeathState s) override; // override virtual Unit::setDeathState - bool LoadFromDB(uint32 spawnId, Map* map) { return LoadCreatureFromDB(spawnId, map, false); } - bool LoadCreatureFromDB(uint32 spawnId, Map* map, bool addToMap = true); + bool LoadFromDB(ObjectGuid::LowType spawnId, Map* map) { return LoadCreatureFromDB(spawnId, map, false); } + bool LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap = true); void SaveToDB(); // overriden in Pet virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); @@ -601,8 +602,16 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject float GetRespawnRadius() const { return m_respawnradius; } void SetRespawnRadius(float dist) { m_respawnradius = dist; } + uint32 GetCombatPulseDelay() const { return m_combatPulseDelay; } + void SetCombatPulseDelay(uint32 delay) // (secs) interval at which the creature pulses the entire zone into combat (only works in dungeons) + { + m_combatPulseDelay = delay; + if (m_combatPulseTime == 0 || m_combatPulseTime > delay) + m_combatPulseTime = delay; + } + uint32 m_groupLootTimer; // (msecs)timer used for group loot - uint32 lootingGroupLowGUID; // used to find group which is looting corpse + ObjectGuid::LowType lootingGroupLowGUID; // used to find group which is looting corpse void SendZoneUnderAttackMessage(Player* attacker); @@ -667,7 +676,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject void ClearTextRepeatGroup(uint8 textGroup); protected: - bool CreateFromProto(uint32 guidlow, uint32 entry, CreatureData const* data = nullptr, uint32 vehId = 0); + bool CreateFromProto(ObjectGuid::LowType guidlow, uint32 entry, CreatureData const* data = nullptr, uint32 vehId = 0); bool InitEntry(uint32 entry, CreatureData const* data = nullptr); // vendor items @@ -686,13 +695,15 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance float m_respawnradius; + uint32 m_combatPulseTime; // (msecs) remaining time for next zone-in-combat pulse + uint32 m_combatPulseDelay; // (secs) how often the creature puts the entire zone in combat (only works in dungeons) ReactStates m_reactState; // for AI, not charmInfo void RegenerateMana(); void RegenerateHealth(); void Regenerate(Powers power); MovementGeneratorType m_defaultMovementType; - uint32 m_spawnId; ///< For new or temporary creatures is 0 for saved it is lowguid + ObjectGuid::LowType m_spawnId; ///< For new or temporary creatures is 0 for saved it is lowguid uint8 m_equipmentId; int8 m_originalEquipmentId; // can be -1 diff --git a/src/server/game/Entities/Creature/CreatureGroups.cpp b/src/server/game/Entities/Creature/CreatureGroups.cpp index f29e896f050..2d353fa154e 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.cpp +++ b/src/server/game/Entities/Creature/CreatureGroups.cpp @@ -30,27 +30,27 @@ FormationMgr::~FormationMgr() delete itr->second; } -void FormationMgr::AddCreatureToGroup(uint32 groupId, Creature* member) +void FormationMgr::AddCreatureToGroup(uint32 leaderGuid, Creature* creature) { - Map* map = member->FindMap(); + Map* map = creature->FindMap(); if (!map) return; - CreatureGroupHolderType::iterator itr = map->CreatureGroupHolder.find(groupId); + CreatureGroupHolderType::iterator itr = map->CreatureGroupHolder.find(leaderGuid); //Add member to an existing group if (itr != map->CreatureGroupHolder.end()) { - TC_LOG_DEBUG("entities.unit", "Group found: %u, inserting creature GUID: %u, Group InstanceID %u", groupId, member->GetGUID().GetCounter(), member->GetInstanceId()); - itr->second->AddMember(member); + TC_LOG_DEBUG("entities.unit", "Group found: %u, inserting creature GUID: %u, Group InstanceID %u", leaderGuid, creature->GetGUID().GetCounter(), creature->GetInstanceId()); + itr->second->AddMember(creature); } //Create new group else { - TC_LOG_DEBUG("entities.unit", "Group not found: %u. Creating new group.", groupId); - CreatureGroup* group = new CreatureGroup(groupId); - map->CreatureGroupHolder[groupId] = group; - group->AddMember(member); + TC_LOG_DEBUG("entities.unit", "Group not found: %u. Creating new group.", leaderGuid); + CreatureGroup* group = new CreatureGroup(leaderGuid); + map->CreatureGroupHolder[leaderGuid] = group; + group->AddMember(creature); } } diff --git a/src/server/game/Entities/Creature/CreatureGroups.h b/src/server/game/Entities/Creature/CreatureGroups.h index e4b2f63c1a3..3de1370379b 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.h +++ b/src/server/game/Entities/Creature/CreatureGroups.h @@ -32,8 +32,8 @@ struct FormationInfo float follow_dist; float follow_angle; uint8 groupAI; - uint16 point_1; - uint16 point_2; + uint32 point_1; + uint32 point_2; }; typedef std::unordered_map<uint32/*memberDBGUID*/, FormationInfo*> CreatureGroupInfoType; diff --git a/src/server/game/Entities/DynamicObject/DynamicObject.cpp b/src/server/game/Entities/DynamicObject/DynamicObject.cpp index 714a0a35caf..3d92f9e18cf 100644 --- a/src/server/game/Entities/DynamicObject/DynamicObject.cpp +++ b/src/server/game/Entities/DynamicObject/DynamicObject.cpp @@ -79,7 +79,7 @@ void DynamicObject::RemoveFromWorld() } } -bool DynamicObject::CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type) +bool DynamicObject::CreateDynamicObject(ObjectGuid::LowType guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type) { SetMap(caster->GetMap()); Relocate(pos); diff --git a/src/server/game/Entities/DynamicObject/DynamicObject.h b/src/server/game/Entities/DynamicObject/DynamicObject.h index f850573ec5a..44c771c77c4 100644 --- a/src/server/game/Entities/DynamicObject/DynamicObject.h +++ b/src/server/game/Entities/DynamicObject/DynamicObject.h @@ -41,7 +41,7 @@ class DynamicObject : public WorldObject, public GridObject<DynamicObject>, publ void AddToWorld() override; void RemoveFromWorld() override; - bool CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type); + bool CreateDynamicObject(ObjectGuid::LowType guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type); void Update(uint32 p_time) override; void Remove(); void SetDuration(int32 newDuration); diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 42ed4674a53..c1ec2294c3d 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -167,7 +167,7 @@ void GameObject::RemoveFromWorld() } } -bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit) +bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit) { ASSERT(map); SetMap(map); @@ -815,7 +815,7 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) WorldDatabase.CommitTransaction(trans); } -bool GameObject::LoadGameObjectFromDB(uint32 spawnId, Map* map, bool addToMap) +bool GameObject::LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap) { GameObjectData const* data = sObjectMgr->GetGOData(spawnId); @@ -1152,7 +1152,7 @@ void GameObject::SetGoArtKit(uint8 kit) data->artKit = kit; } -void GameObject::SetGoArtKit(uint8 artkit, GameObject* go, uint32 lowguid) +void GameObject::SetGoArtKit(uint8 artkit, GameObject* go, ObjectGuid::LowType lowguid) { const GameObjectData* data = NULL; if (go) diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index b91f1b6eeee..a744efbe1e3 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -652,7 +652,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map void RemoveFromWorld() override; void CleanupsBeforeDelete(bool finalCleanup = true) override; - bool Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit = 0); + bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit = 0); void Update(uint32 p_time) override; GameObjectTemplate const* GetGOInfo() const { return m_goInfo; } GameObjectData const* GetGOData() const { return m_goData; } @@ -662,7 +662,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map bool IsDynTransport() const; bool IsDestructibleBuilding() const; - uint32 GetSpawnId() const { return m_spawnId; } + ObjectGuid::LowType GetSpawnId() const { return m_spawnId; } void UpdateRotationFields(float rotation2 = 0.0f, float rotation3 = 0.0f); @@ -671,8 +671,8 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map void SaveToDB(); void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); - bool LoadFromDB(uint32 spawnId, Map* map) { return LoadGameObjectFromDB(spawnId, map, false); } - bool LoadGameObjectFromDB(uint32 spawnId, Map* map, bool addToMap = true); + bool LoadFromDB(ObjectGuid::LowType spawnId, Map* map) { return LoadGameObjectFromDB(spawnId, map, false); } + bool LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap = true); void DeleteFromDB(); void SetOwnerGUID(ObjectGuid owner) @@ -733,7 +733,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map void SetGoArtKit(uint8 artkit); uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); } void SetGoAnimProgress(uint8 animprogress) { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); } - static void SetGoArtKit(uint8 artkit, GameObject* go, uint32 lowguid = 0); + static void SetGoArtKit(uint8 artkit, GameObject* go, ObjectGuid::LowType lowguid = 0); void SetPhaseMask(uint32 newPhaseMask, bool update) override; void EnableCollision(bool enable); @@ -751,10 +751,10 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map void RemoveLootMode(uint16 lootMode) { m_LootMode &= ~lootMode; } void ResetLootMode() { m_LootMode = LOOT_MODE_DEFAULT; } - void AddToSkillupList(uint32 PlayerGuidLow) { m_SkillupList.push_back(PlayerGuidLow); } - bool IsInSkillupList(uint32 PlayerGuidLow) const + void AddToSkillupList(ObjectGuid::LowType PlayerGuidLow) { m_SkillupList.push_back(PlayerGuidLow); } + bool IsInSkillupList(ObjectGuid::LowType PlayerGuidLow) const { - for (std::list<uint32>::const_iterator i = m_SkillupList.begin(); i != m_SkillupList.end(); ++i) + for (std::list<ObjectGuid::LowType>::const_iterator i = m_SkillupList.begin(); i != m_SkillupList.end(); ++i) if (*i == PlayerGuidLow) return true; @@ -778,7 +778,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map bool IsLootAllowedFor(Player const* player) const; bool HasLootRecipient() const { return !m_lootRecipient.IsEmpty() || m_lootRecipientGroup; } uint32 m_groupLootTimer; // (msecs)timer used for group loot - uint32 lootingGroupLowGUID; // used to find group which is looting + ObjectGuid::LowType lootingGroupLowGUID; // used to find group which is looting bool hasQuest(uint32 quest_id) const override; bool hasInvolvedQuest(uint32 quest_id) const override; @@ -861,7 +861,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map bool m_spawnedByDefault; time_t m_cooldownTime; // used as internal reaction delay time store (not state change reaction). // For traps this: spell casting cooldown, for doors/buttons: reset time. - std::list<uint32> m_SkillupList; + std::list<ObjectGuid::LowType> m_SkillupList; ObjectGuid m_ritualOwnerGUID; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner) GuidSet m_unique_users; @@ -870,7 +870,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map typedef std::map<uint32, ObjectGuid> ChairSlotAndUser; ChairSlotAndUser ChairListSlots; - uint32 m_spawnId; ///< For new or temporary gameobjects is 0 for saved it is lowguid + ObjectGuid::LowType m_spawnId; ///< For new or temporary gameobjects is 0 for saved it is lowguid GameObjectTemplate const* m_goInfo; GameObjectData const* m_goData; GameObjectValue m_goValue; diff --git a/src/server/game/Entities/Item/Container/Bag.cpp b/src/server/game/Entities/Item/Container/Bag.cpp index 69a77dd9213..1d2fd9b2804 100644 --- a/src/server/game/Entities/Item/Container/Bag.cpp +++ b/src/server/game/Entities/Item/Container/Bag.cpp @@ -69,7 +69,7 @@ void Bag::RemoveFromWorld() Item::RemoveFromWorld(); } -bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner) +bool Bag::Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner) { ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(itemid); @@ -109,7 +109,7 @@ void Bag::SaveToDB(SQLTransaction& trans) Item::SaveToDB(trans); } -bool Bag::LoadFromDB(uint32 guid, ObjectGuid owner_guid, Field* fields, uint32 entry) +bool Bag::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry) { if (!Item::LoadFromDB(guid, owner_guid, fields, entry)) return false; diff --git a/src/server/game/Entities/Item/Container/Bag.h b/src/server/game/Entities/Item/Container/Bag.h index 11bff67855d..ead059030b6 100644 --- a/src/server/game/Entities/Item/Container/Bag.h +++ b/src/server/game/Entities/Item/Container/Bag.h @@ -35,7 +35,7 @@ class Bag : public Item void AddToWorld() override; void RemoveFromWorld() override; - bool Create(uint32 guidlow, uint32 itemid, Player const* owner) override; + bool Create(ObjectGuid::LowType guidlow, ObjectGuid::LowType itemid, Player const* owner) override; void Clear(); void StoreItem(uint8 slot, Item* pItem, bool update); @@ -54,7 +54,7 @@ class Bag : public Item // overwrite virtual Item::SaveToDB void SaveToDB(SQLTransaction& trans) override; // overwrite virtual Item::LoadFromDB - bool LoadFromDB(uint32 guid, ObjectGuid owner_guid, Field* fields, uint32 entry) override; + bool LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry) override; // overwrite virtual Item::DeleteFromDB void DeleteFromDB(SQLTransaction& trans) override; diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index f5eb9972af5..9a6af376e6d 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -255,7 +255,7 @@ Item::Item() m_paidExtendedCost = 0; } -bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner) +bool Item::Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner) { Object::_Create(guidlow, 0, HighGuid::Item); @@ -317,7 +317,7 @@ void Item::SaveToDB(SQLTransaction& trans) if (!isInTransaction) trans = CharacterDatabase.BeginTransaction(); - uint32 guid = GetGUID().GetCounter(); + ObjectGuid::LowType guid = GetGUID().GetCounter(); switch (uState) { case ITEM_NEW: @@ -398,7 +398,7 @@ void Item::SaveToDB(SQLTransaction& trans) CharacterDatabase.CommitTransaction(trans); } -bool Item::LoadFromDB(uint32 guid, ObjectGuid owner_guid, Field* fields, uint32 entry) +bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry) { // 0 1 2 3 4 5 6 7 8 9 10 //result = CharacterDatabase.PQuery("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text FROM item_instance WHERE guid = '%u'", guid); @@ -480,7 +480,7 @@ bool Item::LoadFromDB(uint32 guid, ObjectGuid owner_guid, Field* fields, uint32 } /*static*/ -void Item::DeleteFromDB(SQLTransaction& trans, uint32 itemGuid) +void Item::DeleteFromDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE); stmt->setUInt32(0, itemGuid); @@ -497,7 +497,7 @@ void Item::DeleteFromDB(SQLTransaction& trans) } /*static*/ -void Item::DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid) +void Item::DeleteFromInventoryDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM); stmt->setUInt32(0, itemGuid); @@ -1254,7 +1254,7 @@ void Item::ItemContainerSaveLootToDB() if (loot.isLooted()) // no money and no loot return; - uint32 container_id = GetGUID().GetCounter(); + ObjectGuid::LowType container_id = GetGUID().GetCounter(); SQLTransaction trans = CharacterDatabase.BeginTransaction(); loot.containerID = container_id; // Save this for when a LootItem is removed @@ -1322,7 +1322,7 @@ bool Item::ItemContainerLoadLootFromDB() // Default. If there are no records for this item then it will be rolled for in Player::SendLoot() m_lootGenerated = false; - uint32 container_id = GetGUID().GetCounter(); + ObjectGuid::LowType container_id = GetGUID().GetCounter(); // Save this for later use loot.containerID = container_id; @@ -1398,7 +1398,7 @@ bool Item::ItemContainerLoadLootFromDB() void Item::ItemContainerDeleteLootItemsFromDB() { // Deletes items associated with an openable item from the DB - uint32 containerId = GetGUID().GetCounter(); + ObjectGuid::LowType containerId = GetGUID().GetCounter(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEMS); stmt->setUInt32(0, containerId); SQLTransaction trans = CharacterDatabase.BeginTransaction(); @@ -1409,7 +1409,7 @@ void Item::ItemContainerDeleteLootItemsFromDB() void Item::ItemContainerDeleteLootItemFromDB(uint32 itemID) { // Deletes a single item associated with an openable item from the DB - uint32 containerId = GetGUID().GetCounter(); + ObjectGuid::LowType containerId = GetGUID().GetCounter(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_ITEM); stmt->setUInt32(0, containerId); stmt->setUInt32(1, itemID); @@ -1421,7 +1421,7 @@ void Item::ItemContainerDeleteLootItemFromDB(uint32 itemID) void Item::ItemContainerDeleteLootMoneyFromDB() { // Deletes the money loot associated with an openable item from the DB - uint32 containerId = GetGUID().GetCounter(); + ObjectGuid::LowType containerId = GetGUID().GetCounter(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_MONEY); stmt->setUInt32(0, containerId); SQLTransaction trans = CharacterDatabase.BeginTransaction(); diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h index ad74906b4c9..a268334b212 100644 --- a/src/server/game/Entities/Item/Item.h +++ b/src/server/game/Entities/Item/Item.h @@ -211,7 +211,7 @@ class Item : public Object Item(); - virtual bool Create(uint32 guidlow, uint32 itemid, Player const* owner); + virtual bool Create(ObjectGuid::LowType guidlow, ObjectGuid::LowType itemid, Player const* owner); ItemTemplate const* GetTemplate() const; @@ -225,10 +225,10 @@ class Item : public Object bool IsBindedNotWith(Player const* player) const; bool IsBoundByEnchant() const; virtual void SaveToDB(SQLTransaction& trans); - virtual bool LoadFromDB(uint32 guid, ObjectGuid owner_guid, Field* fields, uint32 entry); - static void DeleteFromDB(SQLTransaction& trans, uint32 itemGuid); + virtual bool LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry); + static void DeleteFromDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid); virtual void DeleteFromDB(SQLTransaction& trans); - static void DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid); + static void DeleteFromInventoryDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid); // Lootable items and their contents void ItemContainerSaveLootToDB(); @@ -331,7 +331,7 @@ class Item : public Object // Item Refund system void SetNotRefundable(Player* owner, bool changestate = true, SQLTransaction* trans = NULL); - void SetRefundRecipient(uint32 pGuidLow) { m_refundRecipient = pGuidLow; } + void SetRefundRecipient(ObjectGuid::LowType pGuidLow) { m_refundRecipient = pGuidLow; } void SetPaidMoney(uint32 money) { m_paidMoney = money; } void SetPaidExtendedCost(uint32 iece) { m_paidExtendedCost = iece; } @@ -362,7 +362,7 @@ class Item : public Object int16 uQueuePos; bool mb_in_trade; // true if item is currently in trade-window time_t m_lastPlayedTimeUpdate; - uint32 m_refundRecipient; + ObjectGuid::LowType m_refundRecipient; uint32 m_paidMoney; uint32 m_paidExtendedCost; AllowedLooterSet allowedGUIDs; diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 21a65440a55..e4d9e61bca3 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -103,7 +103,7 @@ void Object::_InitValues() m_objectUpdated = false; } -void Object::_Create(uint32 guidlow, uint32 entry, HighGuid guidhigh) +void Object::_Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh) { if (!m_uint32Values) _InitValues(); @@ -1066,7 +1066,7 @@ void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/) transport->RemovePassenger(this); } -void WorldObject::_Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask) +void WorldObject::_Create(ObjectGuid::LowType guidlow, HighGuid guidhigh, uint32 phaseMask) { Object::_Create(guidlow, 0, guidhigh); m_phaseMask = phaseMask; diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 43d1ecdeabd..c9e3d069218 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -204,7 +204,7 @@ class Object Object(); void _InitValues(); - void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh); + void _Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh); std::string _ConcatFields(uint16 startIndex, uint16 size) const; void _LoadIntoDataField(std::string const& data, uint32 startOffset, uint32 count); @@ -431,7 +431,7 @@ class WorldObject : public Object, public WorldLocation virtual void Update (uint32 /*time_diff*/) { } - void _Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask); + void _Create(ObjectGuid::LowType guidlow, HighGuid guidhigh, uint32 phaseMask); virtual void RemoveFromWorld() override; void GetNearPoint2D(float &x, float &y, float distance, float absAngle) const; diff --git a/src/server/game/Entities/Object/ObjectGuid.h b/src/server/game/Entities/Object/ObjectGuid.h index 705cc3eac3e..74fffe09796 100644 --- a/src/server/game/Entities/Object/ObjectGuid.h +++ b/src/server/game/Entities/Object/ObjectGuid.h @@ -21,10 +21,8 @@ #include "Common.h" #include "ByteBuffer.h" - #include <type_traits> #include <functional> -#include <unordered_set> enum TypeID { @@ -130,11 +128,6 @@ class ObjectGuid explicit ObjectGuid(uint64 guid) : _guid(guid) { } ObjectGuid(HighGuid hi, uint32 entry, LowType counter) : _guid(counter ? uint64(counter) | (uint64(entry) << 24) | (uint64(hi) << 48) : 0) { } ObjectGuid(HighGuid hi, LowType counter) : _guid(counter ? uint64(counter) | (uint64(hi) << 48) : 0) { } - ObjectGuid(ObjectGuid const& r) : _guid(r._guid) { } - ObjectGuid(ObjectGuid&& r) : _guid(r._guid) { } - - ObjectGuid& operator=(ObjectGuid const& r) { _guid = r._guid; return *this; } - ObjectGuid& operator=(ObjectGuid&& r) { _guid = r._guid; return *this; } operator uint64() const { return _guid; } PackedGuidReader ReadAsPacked() { return PackedGuidReader(*this); } @@ -154,14 +147,14 @@ class ObjectGuid : LowType(_guid & UI64LIT(0x00000000FFFFFFFF)); } - static uint32 GetMaxCounter(HighGuid high) + static LowType GetMaxCounter(HighGuid high) { return HasEntry(high) - ? uint32(0x00FFFFFF) - : uint32(0xFFFFFFFF); + ? LowType(0x00FFFFFF) + : LowType(0xFFFFFFFF); } - uint32 GetMaxCounter() const { return GetMaxCounter(GetHigh()); } + ObjectGuid::LowType GetMaxCounter() const { return GetMaxCounter(GetHigh()); } bool IsEmpty() const { return _guid == 0; } bool IsCreature() const { return GetHigh() == HighGuid::Unit; } @@ -283,13 +276,13 @@ class ObjectGuidGeneratorBase public: ObjectGuidGeneratorBase(ObjectGuid::LowType start = 1) : _nextGuid(start) { } - virtual void Set(uint32 val) { _nextGuid = val; } + virtual void Set(ObjectGuid::LowType val) { _nextGuid = val; } virtual ObjectGuid::LowType Generate() = 0; ObjectGuid::LowType GetNextAfterMaxUsed() const { return _nextGuid; } protected: static void HandleCounterOverflow(HighGuid high); - uint64 _nextGuid; + ObjectGuid::LowType _nextGuid; }; template<HighGuid high> diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 57fc56af89c..0121194e327 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -98,7 +98,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c { m_loading = true; - uint32 ownerid = owner->GetGUID().GetCounter(); + ObjectGuid::LowType ownerid = owner->GetGUID().GetCounter(); PreparedStatement* stmt; PreparedQueryResult result; @@ -174,7 +174,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c } Map* map = owner->GetMap(); - uint32 guid = map->GenerateLowGuid<HighGuid::Pet>(); + ObjectGuid::LowType guid = map->GenerateLowGuid<HighGuid::Pet>(); if (!Create(guid, map, owner->GetPhaseMask(), petEntry, petId)) return false; @@ -415,7 +415,7 @@ void Pet::SavePetToDB(PetSaveMode mode) // current/stable/not_in_slot if (mode >= PET_SAVE_AS_CURRENT) { - uint32 ownerLowGUID = GetOwnerGUID().GetCounter(); + ObjectGuid::LowType ownerLowGUID = GetOwnerGUID().GetCounter(); std::string name = m_name; CharacterDatabase.EscapeString(name); trans = CharacterDatabase.BeginTransaction(); @@ -485,7 +485,7 @@ void Pet::SavePetToDB(PetSaveMode mode) } } -void Pet::DeleteFromDB(uint32 guidlow) +void Pet::DeleteFromDB(ObjectGuid::LowType guidlow) { SQLTransaction trans = CharacterDatabase.BeginTransaction(); @@ -807,7 +807,7 @@ bool Pet::CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner) bool Pet::CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask) { TC_LOG_DEBUG("entities.pet", "Pet::CreateBaseForTamed"); - uint32 guid=map->GenerateLowGuid<HighGuid::Pet>(); + ObjectGuid::LowType guid=map->GenerateLowGuid<HighGuid::Pet>(); uint32 petId = sObjectMgr->GeneratePetNumber(); if (!Create(guid, map, phaseMask, cinfo->Entry, petId)) return false; @@ -1835,7 +1835,7 @@ bool Pet::IsPermanentPetFor(Player* owner) const } } -bool Pet::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 petId) +bool Pet::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 petId) { ASSERT(map); SetMap(map); diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index e47bf220195..85c1f83d4a7 100644 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -55,7 +55,7 @@ class Pet : public Guardian bool IsPermanentPetFor(Player* owner) const; // pet have tab in character windows and set UNIT_FIELD_PETNUMBER - bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number); + bool Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number); bool CreateBaseAtCreature(Creature* creature); bool CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner); bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask); @@ -63,7 +63,7 @@ class Pet : public Guardian bool IsLoading() const override { return m_loading;} void SavePetToDB(PetSaveMode mode); void Remove(PetSaveMode mode, bool returnreagent = false); - static void DeleteFromDB(uint32 guidlow); + static void DeleteFromDB(ObjectGuid::LowType guidlow); void setDeathState(DeathState s) override; // overwrite virtual Creature::setDeathState and Unit::setDeathState void Update(uint32 diff) override; // overwrite virtual Creature::Update and Unit::Update diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 1be3c2454b2..2f78280a409 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -504,7 +504,7 @@ inline void KillRewarder::_InitXP(Player* player) // * otherwise, not in PvP; // * not if killer is on vehicle. if (_isBattleGround || (!_isPvP && !_killer->GetVehicle())) - _xp = Trinity::XP::Gain(player, _victim); + _xp = Trinity::XP::Gain(player, _victim, _isBattleGround); } inline void KillRewarder::_RewardHonor(Player* player) @@ -957,7 +957,7 @@ void Player::CleanupsBeforeDelete(bool finalCleanup) itr->second.save->RemovePlayer(this); } -bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo) +bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo) { //FIXME: outfitId not used in player creating /// @todo need more checks against packet modifications @@ -1961,7 +1961,7 @@ bool Player::BuildEnumData(PreparedQueryResult result, WorldPacket* data) Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint8 plrRace = fields[2].GetUInt8(); uint8 plrClass = fields[3].GetUInt8(); uint8 gender = fields[4].GetUInt8(); @@ -3416,7 +3416,7 @@ void Player::RemoveMail(uint32 id) } } -void Player::SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError, uint32 item_guid, uint32 item_count) +void Player::SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError, ObjectGuid::LowType item_guid, uint32 item_count) { WorldPacket data(SMSG_SEND_MAIL_RESULT, (4+4+4+(mailError == MAIL_ERR_EQUIP_ERROR?4:(mailAction == MAIL_ITEM_TAKEN?4+4:0)))); data << (uint32) mailId; @@ -3551,7 +3551,7 @@ bool Player::AddTalent(uint32 spellId, uint8 spec, bool learning) return false; } -bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading /*= false*/, bool fromSkill /*= false*/) +bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading /*= false*/, uint32 fromSkill /*= 0*/) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo) @@ -3809,10 +3809,10 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent SkillLineAbilityMapBounds skill_bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellId); - // add dependent skills if this spell is not learned from adding skill already - if (!fromSkill) + if (SpellLearnSkillNode const* spellLearnSkill = sSpellMgr->GetSpellLearnSkill(spellId)) { - if (SpellLearnSkillNode const* spellLearnSkill = sSpellMgr->GetSpellLearnSkill(spellId)) + // add dependent skills if this spell is not learned from adding skill already + if (spellLearnSkill->skill != fromSkill) { uint32 skill_value = GetPureSkillValue(spellLearnSkill->skill); uint32 skill_max_value = GetPureMaxSkillValue(spellLearnSkill->skill); @@ -3827,26 +3827,29 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent SetSkill(spellLearnSkill->skill, spellLearnSkill->step, skill_value, skill_max_value); } - else + } + else + { + // not ranked skills + for (SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx) { - // not ranked skills - for (SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx) - { - SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId); - if (!pSkill) - continue; + SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId); + if (!pSkill) + continue; - ///@todo: confirm if rogues start with lockpicking skill at level 1 but only receive the spell to use it at level 16 - // Also added for runeforging. It's already confirmed this happens upon learning for Death Knights, not from character creation. - if ((_spell_idx->second->AutolearnType == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN && !HasSkill(pSkill->id)) || ((pSkill->id == SKILL_LOCKPICKING || pSkill->id == SKILL_RUNEFORGING) && _spell_idx->second->max_value == 0)) - LearnDefaultSkill(pSkill->id, 0); + if (pSkill->id == fromSkill) + continue; - if (pSkill->id == SKILL_MOUNTS && !Has310Flyer(false)) - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED && - spellInfo->Effects[i].CalcValue() == 310) - SetHas310Flyer(true); - } + ///@todo: confirm if rogues start with lockpicking skill at level 1 but only receive the spell to use it at level 16 + // Also added for runeforging. It's already confirmed this happens upon learning for Death Knights, not from character creation. + if ((_spell_idx->second->AutolearnType == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN && !HasSkill(pSkill->id)) || ((pSkill->id == SKILL_LOCKPICKING || pSkill->id == SKILL_RUNEFORGING) && _spell_idx->second->max_value == 0)) + LearnDefaultSkill(pSkill->id, 0); + + if (pSkill->id == SKILL_MOUNTS && !Has310Flyer(false)) + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED && + spellInfo->Effects[i].CalcValue() == 310) + SetHas310Flyer(true); } } @@ -3912,14 +3915,14 @@ bool Player::IsNeedCastPassiveSpellAtLearn(SpellInfo const* spellInfo) const // note: form passives activated with shapeshift spells be implemented by HandleShapeshiftBoosts instead of spell_learn_spell // talent dependent passives activated at form apply have proper stance data ShapeshiftForm form = GetShapeshiftForm(); - bool need_cast = (!spellInfo->Stances || (form && (spellInfo->Stances & (1 << (form - 1)))) || + bool need_cast = (!spellInfo->Stances || (form && (spellInfo->Stances & (UI64LIT(1) << (form - 1)))) || (!form && spellInfo->HasAttribute(SPELL_ATTR2_NOT_NEED_SHAPESHIFT))); //Check CasterAuraStates return need_cast && (!spellInfo->CasterAuraState || HasAuraState(AuraStateType(spellInfo->CasterAuraState))); } -void Player::LearnSpell(uint32 spell_id, bool dependent, bool fromSkill /*= false*/) +void Player::LearnSpell(uint32 spell_id, bool dependent, uint32 fromSkill /*= 0*/) { PlayerSpellMap::iterator itr = m_spells.find(spell_id); @@ -4523,23 +4526,23 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe updateRealmChars = false; // Convert guid to low GUID for CharacterNameData, but also other methods on success - uint32 guid = playerguid.GetCounter(); + ObjectGuid::LowType guid = playerguid.GetCounter(); uint32 charDelete_method = sWorld->getIntConfig(CONFIG_CHARDELETE_METHOD); if (deleteFinally) charDelete_method = CHAR_DELETE_REMOVE; - else if (CharacterNameData const* nameData = sWorld->GetCharacterNameData(playerguid)) // To avoid a query, we select loaded data. If it doesn't exist, return. + else if (CharacterInfo const* nameData = sWorld->GetCharacterInfo(playerguid)) // To avoid a query, we select loaded data. If it doesn't exist, return. { // Define the required variables - uint32 charDelete_minLvl = sWorld->getIntConfig(nameData->m_class != CLASS_DEATH_KNIGHT ? CONFIG_CHARDELETE_MIN_LEVEL : CONFIG_CHARDELETE_HEROIC_MIN_LEVEL); + uint32 charDelete_minLvl = sWorld->getIntConfig(nameData->Class != CLASS_DEATH_KNIGHT ? CONFIG_CHARDELETE_MIN_LEVEL : CONFIG_CHARDELETE_HEROIC_MIN_LEVEL); // if we want to finalize the character removal or the character does not meet the level requirement of either heroic or non-heroic settings, // we set it to mode CHAR_DELETE_REMOVE - if (nameData->m_level < charDelete_minLvl) + if (nameData->Level < charDelete_minLvl) charDelete_method = CHAR_DELETE_REMOVE; } - if (uint32 guildId = GetGuildIdFromDB(playerguid)) + if (ObjectGuid::LowType guildId = GetGuildIdFromDB(playerguid)) if (Guild* guild = sGuildMgr->GetGuildById(guildId)) guild->DeleteMember(playerguid, false, false, true); @@ -4617,7 +4620,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe do { Field* itemFields = resultItems->Fetch(); - uint32 item_guidlow = itemFields[11].GetUInt32(); + ObjectGuid::LowType item_guidlow = itemFields[11].GetUInt32(); uint32 item_template = itemFields[12].GetUInt32(); ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(item_template); @@ -4664,7 +4667,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe { do { - uint32 petguidlow = (*resultPets)[0].GetUInt32(); + ObjectGuid::LowType petguidlow = (*resultPets)[0].GetUInt32(); Pet::DeleteFromDB(petguidlow); } while (resultPets->NextRow()); } @@ -4862,7 +4865,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe if (updateRealmChars) sWorld->UpdateRealmCharCount(accountId); - sWorld->DeleteCharacterNameData(playerguid); + sWorld->DeleteCharacterInfo(playerguid); } /** @@ -5164,12 +5167,13 @@ Corpse* Player::CreateCorpse() } } + // register for player, but not show + GetMap()->AddCorpse(corpse); + // we do not need to save corpses for BG/arenas if (!GetMap()->IsBattlegroundOrArena()) corpse->SaveToDB(); - // register for player, but not show - GetMap()->AddCorpse(corpse); return corpse; } @@ -6916,7 +6920,7 @@ void Player::RewardReputation(Unit* victim, float rate) { // support for: Championing - http://www.wowwiki.com/Championing Map const* map = GetMap(); - if (map && map->IsNonRaidDungeon()) + if (map->IsNonRaidDungeon()) if (LFGDungeonEntry const* dungeon = GetLFGDungeon(map->GetId(), map->GetDifficulty())) if (dungeon->reclevel == 80) ChampioningFaction = GetChampioningFaction(); @@ -7232,7 +7236,7 @@ void Player::ModifyArenaPoints(int32 value, SQLTransaction trans) } } -uint32 Player::GetGuildIdFromDB(ObjectGuid guid) +ObjectGuid::LowType Player::GetGuildIdFromDB(ObjectGuid guid) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_MEMBER); stmt->setUInt32(0, guid.GetCounter()); @@ -7286,7 +7290,7 @@ uint32 Player::GetArenaTeamIdFromDB(ObjectGuid guid, uint8 type) uint32 Player::GetZoneIdFromDB(ObjectGuid guid) { - uint32 guidLow = guid.GetCounter(); + ObjectGuid::LowType guidLow = guid.GetCounter(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_ZONE); stmt->setUInt32(0, guidLow); PreparedQueryResult result = CharacterDatabase.Query(stmt); @@ -7610,20 +7614,6 @@ void Player::DuelComplete(DuelCompleteType type) duel->opponent->SetGuidValue(PLAYER_DUEL_ARBITER, ObjectGuid::Empty); duel->opponent->SetUInt32Value(PLAYER_DUEL_TEAM, 0); - if (sWorld->getBoolConfig(CONFIG_RESET_COOLDOWN_AFTER_DUEL) && - type != DUEL_INTERRUPTED) - { - if (!HasCoolDownBeforeDuel()) - RemoveArenaSpellCooldowns(true); - else - ChatHandler(GetSession()).PSendSysMessage(LANG_COOLDOWN_NOT_RESET_AFTER_DUEL); - - if (!duel->opponent->HasCoolDownBeforeDuel()) - duel->opponent->RemoveArenaSpellCooldowns(true); - else - ChatHandler(duel->opponent->GetSession()).PSendSysMessage(LANG_COOLDOWN_NOT_RESET_AFTER_DUEL); - } - delete duel->opponent->duel; duel->opponent->duel = NULL; delete duel; @@ -8111,7 +8101,7 @@ void Player::ApplyItemEquipSpell(Item* item, bool apply, bool form_change) _Spell const& spellData = proto->Spells[i]; // no spell - if (!spellData.SpellId) + if (spellData.SpellId <= 0) continue; // wrong triggering type @@ -8239,7 +8229,7 @@ void Player::CastItemCombatSpell(Unit* target, WeaponAttackType attType, uint32 _Spell const& spellData = proto->Spells[i]; // no spell - if (!spellData.SpellId) + if (spellData.SpellId <= 0) continue; // wrong triggering type @@ -8368,7 +8358,7 @@ void Player::CastItemUseSpell(Item* item, SpellCastTargets const& targets, uint8 _Spell const& spellData = proto->Spells[i]; // no spell - if (!spellData.SpellId) + if (spellData.SpellId <= 0) continue; // wrong triggering type @@ -15653,8 +15643,7 @@ bool Player::SatisfyQuestStatus(Quest const* qInfo, bool msg) bool Player::SatisfyQuestConditions(Quest const* qInfo, bool msg) { - ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_QUEST_ACCEPT, qInfo->GetQuestId()); - if (!sConditionMgr->IsObjectMeetToConditions(this, conditions)) + if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_QUEST_ACCEPT, qInfo->GetQuestId(), this)) { if (msg) { @@ -15920,6 +15909,16 @@ bool Player::GetQuestRewardStatus(uint32 quest_id) const Quest const* qInfo = sObjectMgr->GetQuestTemplate(quest_id); if (qInfo) { + if (qInfo->IsSeasonal() && !qInfo->IsRepeatable()) + { + uint16 eventId = sGameEventMgr->GetEventIdForQuest(qInfo); + if (m_seasonalquests.find(eventId) != m_seasonalquests.end()) + return m_seasonalquests.find(eventId)->second.find(quest_id) != m_seasonalquests.find(eventId)->second.end(); + + return false; + } + + // for repeatable quests: rewarded field is set after first reward only to prevent getting XP more than once if (!qInfo->IsRepeatable()) return m_RewardedQuests.find(quest_id) != m_RewardedQuests.end(); @@ -15938,8 +15937,17 @@ QuestStatus Player::GetQuestStatus(uint32 quest_id) const return itr->second.Status; if (Quest const* qInfo = sObjectMgr->GetQuestTemplate(quest_id)) + { + if (qInfo->IsSeasonal() && !qInfo->IsRepeatable()) + { + uint16 eventId = sGameEventMgr->GetEventIdForQuest(qInfo); + if (m_seasonalquests.find(eventId) == m_seasonalquests.end() || m_seasonalquests.find(eventId)->second.find(quest_id) == m_seasonalquests.find(eventId)->second.end()) + return QUEST_STATUS_NONE; + } + if (!qInfo->IsRepeatable() && m_RewardedQuests.find(quest_id) != m_RewardedQuests.end()) return QUEST_STATUS_REWARDED; + } } return QUEST_STATUS_NONE; } @@ -16066,8 +16074,7 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver) if (!quest) continue; - ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK, quest->GetQuestId()); - if (!sConditionMgr->IsObjectMeetToConditions(this, conditions)) + if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK, quest->GetQuestId(), this)) continue; QuestStatus status = GetQuestStatus(questId); @@ -16094,8 +16101,7 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver) if (!quest) continue; - ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK, quest->GetQuestId()); - if (!sConditionMgr->IsObjectMeetToConditions(this, conditions)) + if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK, quest->GetQuestId(), this)) continue; QuestStatus status = GetQuestStatus(questId); @@ -16895,7 +16901,7 @@ bool Player::HasPvPForcingQuest() const /*** LOAD SYSTEM ***/ /*********************************************************/ -void Player::Initialize(uint32 guid) +void Player::Initialize(ObjectGuid::LowType guid) { Object::_Create(guid, 0, HighGuid::Player); } @@ -17111,7 +17117,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder) m_name = fields[2].GetString(); // check name limitations - if (ObjectMgr::CheckPlayerName(m_name) != CHAR_NAME_SUCCESS || + if (ObjectMgr::CheckPlayerName(m_name, GetSession()->GetSessionDbcLocale()) != CHAR_NAME_SUCCESS || (!GetSession()->HasPermission(rbac::RBAC_PERM_SKIP_CHECK_CHARACTER_CREATION_RESERVEDNAME) && sObjectMgr->IsReservedName(m_name))) { @@ -17218,7 +17224,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder) InitPrimaryProfessions(); // to max set before any spell loaded // init saved position, and fix it later if problematic - uint32 transLowGUID = fields[30].GetUInt32(); + ObjectGuid::LowType transLowGUID = fields[30].GetUInt32(); Relocate(fields[12].GetFloat(), fields[13].GetFloat(), fields[14].GetFloat(), fields[16].GetFloat()); uint32 mapId = fields[15].GetUInt16(); uint32 instanceId = fields[58].GetUInt32(); @@ -17447,7 +17453,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder) } else if (map->IsDungeon()) // if map is dungeon... { - if (!((InstanceMap*)map)->CanEnter(this)) // ... and can't enter map, then look for entry point. + if (!((InstanceMap*)map)->CanEnter(this) || !CheckInstanceLoginValid(map)) // ... and can't enter map, then look for entry point. { areaTrigger = sObjectMgr->GetGoBackTrigger(mapId); check = true; @@ -17474,6 +17480,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder) { TC_LOG_ERROR("entities.player", "Player %s %s Map: %u, X: %f, Y: %f, Z: %f, O: %f. Areatrigger not found.", m_name.c_str(), guid.ToString().c_str(), mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + RelocateToHomebind(); map = NULL; } } @@ -17970,8 +17977,8 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) { uint32 zoneId = GetZoneId(); - std::map<uint32, Bag*> bagMap; // fast guid lookup for bags - std::map<uint32, Item*> invalidBagMap; // fast guid lookup for bags + std::map<ObjectGuid::LowType, Bag*> bagMap; // fast guid lookup for bags + std::map<ObjectGuid::LowType, Item*> invalidBagMap; // fast guid lookup for bags std::list<Item*> problematicItems; SQLTransaction trans = CharacterDatabase.BeginTransaction(); @@ -17982,7 +17989,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) Field* fields = result->Fetch(); if (Item* item = _LoadItem(trans, zoneId, timeDiff, fields)) { - uint32 bagGuid = fields[11].GetUInt32(); + ObjectGuid::LowType bagGuid = fields[11].GetUInt32(); uint8 slot = fields[12].GetUInt8(); uint8 err = EQUIP_ERR_OK; @@ -18030,7 +18037,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) { item->SetSlot(NULL_SLOT); // Item is in the bag, find the bag - std::map<uint32, Bag*>::iterator itr = bagMap.find(bagGuid); + std::map<ObjectGuid::LowType, Bag*>::iterator itr = bagMap.find(bagGuid); if (itr != bagMap.end()) { ItemPosCountVec dest; @@ -18040,7 +18047,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) } else if (invalidBagMap.find(bagGuid) != invalidBagMap.end()) { - std::map<uint32, Item*>::iterator invalidBagItr = invalidBagMap.find(bagGuid); + std::map<ObjectGuid::LowType, Item*>::iterator invalidBagItr = invalidBagMap.find(bagGuid); if (std::find(problematicItems.begin(), problematicItems.end(), invalidBagItr->second) != problematicItems.end()) err = EQUIP_ERR_INT_BAG_ERROR; } @@ -18092,7 +18099,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, Field* fields) { Item* item = NULL; - uint32 itemGuid = fields[13].GetUInt32(); + ObjectGuid::LowType itemGuid = fields[13].GetUInt32(); uint32 itemEntry = fields[14].GetUInt32(); if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemEntry)) { @@ -18230,7 +18237,7 @@ void Player::_LoadMailedItems(Mail* mail) { Field* fields = result->Fetch(); - uint32 itemGuid = fields[11].GetUInt32(); + ObjectGuid::LowType itemGuid = fields[11].GetUInt32(); uint32 itemTemplate = fields[12].GetUInt32(); mail->AddItem(itemGuid, itemTemplate); @@ -18822,9 +18829,11 @@ void Player::BindToInstance() WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4); data << uint32(0); GetSession()->SendPacket(&data); - BindToInstance(mapSave, true); - - GetSession()->SendCalendarRaidLockout(mapSave, true); + if (!IsGameMaster()) + { + BindToInstance(mapSave, true); + GetSession()->SendCalendarRaidLockout(mapSave, true); + } } void Player::SetPendingBind(uint32 instanceId, uint32 bindTimer) @@ -19004,15 +19013,12 @@ bool Player::Satisfy(AccessRequirement const* ar, uint32 target_map, bool report return true; } -bool Player::CheckInstanceLoginValid() +bool Player::CheckInstanceLoginValid(Map* map) { - if (!FindMap()) - return false; - - if (!GetMap()->IsDungeon() || IsGameMaster()) + if (!map->IsDungeon() || IsGameMaster()) return true; - if (GetMap()->IsRaid()) + if (map->IsRaid()) { // cannot be in raid instance without a group if (!GetGroup()) @@ -19021,12 +19027,12 @@ bool Player::CheckInstanceLoginValid() else { // cannot be in normal instance without a group and more players than 1 in instance - if (!GetGroup() && GetMap()->GetPlayersCountExceptGMs() > 1) + if (!GetGroup() && map->GetPlayersCountExceptGMs() > 1) return false; } // do checks for satisfy accessreqs, instance full, encounter in progress (raid), perm bind group != perm bind player - return sMapMgr->CanPlayerEnter(GetMap()->GetId(), this, true); + return sMapMgr->CanPlayerEnter(map->GetId(), this, true); } bool Player::CheckInstanceCount(uint32 instanceId) const @@ -19139,7 +19145,7 @@ void Player::SaveToDB(bool create /*=false*/) stmt->setString(index++, GetName()); stmt->setUInt8(index++, getRace()); stmt->setUInt8(index++, getClass()); - stmt->setUInt8(index++, getGender()); + stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_3, 0)); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 changes with every transform effect stmt->setUInt8(index++, getLevel()); stmt->setUInt32(index++, GetUInt32Value(PLAYER_XP)); stmt->setUInt32(index++, GetMoney()); @@ -19157,7 +19163,7 @@ void Player::SaveToDB(bool create /*=false*/) stmt->setFloat(index++, finiteAlways(GetTransOffsetY())); stmt->setFloat(index++, finiteAlways(GetTransOffsetZ())); stmt->setFloat(index++, finiteAlways(GetTransOffsetO())); - uint32 transLowGUID = 0; + ObjectGuid::LowType transLowGUID = 0; if (GetTransport()) transLowGUID = GetTransport()->GetGUID().GetCounter(); stmt->setUInt32(index++, transLowGUID); @@ -19244,7 +19250,7 @@ void Player::SaveToDB(bool create /*=false*/) stmt->setString(index++, GetName()); stmt->setUInt8(index++, getRace()); stmt->setUInt8(index++, getClass()); - stmt->setUInt8(index++, getGender()); + stmt->setUInt8(index++, GetByteValue(PLAYER_BYTES_3, 0)); // save gender from PLAYER_BYTES_3, UNIT_BYTES_0 changes with every transform effect stmt->setUInt8(index++, getLevel()); stmt->setUInt32(index++, GetUInt32Value(PLAYER_XP)); stmt->setUInt32(index++, GetMoney()); @@ -19277,7 +19283,7 @@ void Player::SaveToDB(bool create /*=false*/) stmt->setFloat(index++, finiteAlways(GetTransOffsetY())); stmt->setFloat(index++, finiteAlways(GetTransOffsetZ())); stmt->setFloat(index++, finiteAlways(GetTransOffsetO())); - uint32 transLowGUID = 0; + ObjectGuid::LowType transLowGUID = 0; if (GetTransport()) transLowGUID = GetTransport()->GetGUID().GetCounter(); stmt->setUInt32(index++, transLowGUID); @@ -19573,7 +19579,7 @@ void Player::_SaveInventory(SQLTransaction& trans) if (m_itemUpdateQueue.empty()) return; - uint32 lowGuid = GetGUID().GetCounter(); + ObjectGuid::LowType lowGuid = GetGUID().GetCounter(); for (size_t i = 0; i < m_itemUpdateQueue.size(); ++i) { Item* item = m_itemUpdateQueue[i]; @@ -19581,14 +19587,14 @@ void Player::_SaveInventory(SQLTransaction& trans) continue; Bag* container = item->GetContainer(); - uint32 bag_guid = container ? container->GetGUID().GetCounter() : 0; + ObjectGuid::LowType bag_guid = container ? container->GetGUID().GetCounter() : 0; if (item->GetState() != ITEM_REMOVED) { Item* test = GetItemByPos(item->GetBagSlot(), item->GetSlot()); if (test == NULL) { - uint32 bagTestGUID = 0; + ObjectGuid::LowType bagTestGUID = 0; if (Item* test2 = GetItemByPos(INVENTORY_SLOT_BAG_0, item->GetBagSlot())) bagTestGUID = test2->GetGUID().GetCounter(); TC_LOG_ERROR("entities.player", "Player(GUID: %u Name: %s)::_SaveInventory - the bag(%u) and slot(%u) values for the item with guid %u (state %d) are incorrect, the player doesn't have an item at that position!", lowGuid, GetName().c_str(), item->GetBagSlot(), item->GetSlot(), item->GetGUID().GetCounter(), (int32)item->GetState()); @@ -20255,7 +20261,7 @@ void Player::ResetInstances(uint8 method, bool isRaid) // if the map is loaded, reset it Map* map = sMapMgr->FindMap(p->GetMapId(), p->GetInstanceId()); if (map && map->IsDungeon()) - if (!((InstanceMap*)map)->Reset(method)) + if (!map->ToInstanceMap()->Reset(method)) { ++itr; continue; @@ -20676,8 +20682,7 @@ void Player::VehicleSpellInitialize() continue; } - ConditionList conditions = sConditionMgr->GetConditionsForVehicleSpell(vehicle->GetEntry(), spellId); - if (!sConditionMgr->IsObjectMeetToConditions(this, vehicle, conditions)) + if (!sConditionMgr->IsObjectMeetingVehicleSpellConditions(vehicle->GetEntry(), spellId, this, vehicle)) { TC_LOG_DEBUG("condition", "VehicleSpellInitialize: conditions not met for Vehicle entry %u spell %u", vehicle->ToCreature()->GetEntry(), spellId); data << uint16(0) << uint8(0) << uint8(i+8); @@ -21529,8 +21534,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin return false; } - ConditionList conditions = sConditionMgr->GetConditionsForNpcVendorEvent(creature->GetEntry(), item); - if (!sConditionMgr->IsObjectMeetToConditions(this, creature, conditions)) + if (!sConditionMgr->IsObjectMeetingVendorItemConditions(creature->GetEntry(), item, this, creature)) { TC_LOG_DEBUG("condition", "BuyItemFromVendor: conditions not met for creature entry %u item %u", creature->GetEntry(), item); SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, item, 0); @@ -22045,6 +22049,16 @@ void Player::LeaveBattleground(bool teleportToEntryPoint) CastSpell(this, 26013, true); // Deserter } } + + // track if player leaves the BG while inside it + if (bg->isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS) && + (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN)) + { + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK); + stmt->setUInt32(0, GetGUID().GetCounter()); + stmt->setUInt8(1, BG_DESERTION_TYPE_LEAVE_BG); + CharacterDatabase.Execute(stmt); + } } } @@ -22699,7 +22713,7 @@ void Player::ApplyEquipCooldown(Item* pItem) _Spell const& spellData = pItem->GetTemplate()->Spells[i]; // no spell - if (!spellData.SpellId) + if (spellData.SpellId <= 0) continue; // wrong triggering type (note: ITEM_SPELLTRIGGER_ON_NO_DELAY_USE not have cooldown) @@ -22707,7 +22721,7 @@ void Player::ApplyEquipCooldown(Item* pItem) continue; // Don't replace longer cooldowns by equip cooldown if we have any. - if (GetSpellHistory()->GetRemainingCooldown(spellData.SpellId) > 30 * IN_MILLISECONDS) + if (GetSpellHistory()->GetRemainingCooldown(sSpellMgr->EnsureSpellInfo(spellData.SpellId)) > 30 * IN_MILLISECONDS) continue; GetSpellHistory()->AddCooldown(spellData.SpellId, pItem->GetEntry(), std::chrono::seconds(30)); @@ -22981,9 +22995,9 @@ void Player::LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue) RemoveSpell(ability->spellId); // need learn else if (!IsInWorld()) - AddSpell(ability->spellId, true, true, true, false, false, true); + AddSpell(ability->spellId, true, true, true, false, false, ability->skillId); else - LearnSpell(ability->spellId, true, true); + LearnSpell(ability->spellId, true, ability->skillId); } } @@ -23334,16 +23348,18 @@ void Player::UpdateForQuestWorldObjects() { //! This code doesn't look right, but it was logically converted to condition system to do the exact //! same thing it did before. It definitely needs to be overlooked for intended functionality. - ConditionList conds = sConditionMgr->GetConditionsForSpellClickEvent(obj->GetEntry(), _itr->second.spellId); - bool buildUpdateBlock = false; - for (ConditionList::const_iterator jtr = conds.begin(); jtr != conds.end() && !buildUpdateBlock; ++jtr) - if ((*jtr)->ConditionType == CONDITION_QUESTREWARDED || (*jtr)->ConditionType == CONDITION_QUESTTAKEN) - buildUpdateBlock = true; - - if (buildUpdateBlock) + if (ConditionContainer const* conds = sConditionMgr->GetConditionsForSpellClickEvent(obj->GetEntry(), _itr->second.spellId)) { - obj->BuildValuesUpdateBlockForPlayer(&udata, this); - break; + bool buildUpdateBlock = false; + for (ConditionContainer::const_iterator jtr = conds->begin(); jtr != conds->end() && !buildUpdateBlock; ++jtr) + if ((*jtr)->ConditionType == CONDITION_QUESTREWARDED || (*jtr)->ConditionType == CONDITION_QUESTTAKEN) + buildUpdateBlock = true; + + if (buildUpdateBlock) + { + obj->BuildValuesUpdateBlockForPlayer(&udata, this); + break; + } } } } @@ -25268,9 +25284,7 @@ bool Player::CanSeeSpellClickOn(Creature const* c) const if (!itr->second.IsFitToRequirements(this, c)) return false; - ConditionList conds = sConditionMgr->GetConditionsForSpellClickEvent(c->GetEntry(), itr->second.spellId); - ConditionSourceInfo info = ConditionSourceInfo(const_cast<Player*>(this), const_cast<Creature*>(c)); - if (sConditionMgr->IsObjectMeetToConditions(info, conds)) + if (sConditionMgr->IsObjectMeetingSpellClickConditions(c->GetEntry(), itr->second.spellId, const_cast<Player*>(this), const_cast<Creature*>(c))) return true; } diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 0c1fdd8f03d..75f04cb0d7b 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -285,7 +285,7 @@ struct PvPInfo struct DuelInfo { - DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0), isMounted(false), hasCoolDownBeforeDuel(false) { } + DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0), isMounted(false) { } Player* initiator; Player* opponent; @@ -293,7 +293,6 @@ struct DuelInfo time_t startTime; time_t outOfBound; bool isMounted; - bool hasCoolDownBeforeDuel; }; struct Areas @@ -1118,7 +1117,7 @@ class Player : public Unit, public GridObject<Player> void SetSummonPoint(uint32 mapid, float x, float y, float z); void SummonIfPossible(bool agree); - bool Create(uint32 guidlow, CharacterCreateInfo* createInfo); + bool Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo); void Update(uint32 time) override; @@ -1484,7 +1483,7 @@ class Player : public Unit, public GridObject<Player> bool LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder); bool IsLoading() const override; - void Initialize(uint32 guid); + void Initialize(ObjectGuid::LowType guid); static uint32 GetUInt32ValueFromArray(Tokenizer const& data, uint16 index); static float GetFloatValueFromArray(Tokenizer const& data, uint16 index); static uint32 GetZoneIdFromDB(ObjectGuid guid); @@ -1550,7 +1549,7 @@ class Player : public Unit, public GridObject<Player> void ClearComboPoints(); void SendComboPoints(); - void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, uint32 item_guid = 0, uint32 item_count = 0); + void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, ObjectGuid::LowType item_guid = 0, uint32 item_count = 0); void SendNewMail(); void UpdateNextMailTimeAndUnreads(); void AddNewMailDeliverTime(time_t deliver_time); @@ -1596,8 +1595,8 @@ class Player : public Unit, public GridObject<Player> void SendProficiency(ItemClass itemClass, uint32 itemSubclassMask); void SendInitialSpells(); - bool AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading = false, bool fromSkill = false); - void LearnSpell(uint32 spell_id, bool dependent, bool fromSkill = false); + bool AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading = false, uint32 fromSkill = 0); + void LearnSpell(uint32 spell_id, bool dependent, uint32 fromSkill = 0); void RemoveSpell(uint32 spell_id, bool disabled = false, bool learn_low_rank = true); void ResetSpells(bool myClassOnly = false); void LearnCustomSpells(); @@ -1716,7 +1715,7 @@ class Player : public Unit, public GridObject<Player> void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } uint32 GetGuildId() const { return GetUInt32Value(PLAYER_GUILDID); } Guild* GetGuild(); - static uint32 GetGuildIdFromDB(ObjectGuid guid); + static ObjectGuid::LowType GetGuildIdFromDB(ObjectGuid guid); static uint8 GetRankFromDB(ObjectGuid guid); int GetGuildIdInvited() const { return m_GuildIdInvited; } static void RemovePetitionsAndSigns(ObjectGuid guid, uint32 type); @@ -1948,9 +1947,6 @@ class Player : public Unit, public GridObject<Player> void SetHonorPoints(uint32 value); void SetArenaPoints(uint32 value); - bool HasCoolDownBeforeDuel() const { return duel->hasCoolDownBeforeDuel; } - void UpdateHasCoolDownBeforeDuel() { duel->hasCoolDownBeforeDuel = GetSpellHistory()->GetArenaCooldownsSize() > 0; } - //End of PvP System void SetDrunkValue(uint8 newDrunkValue, uint32 itemId = 0); @@ -2202,7 +2198,7 @@ class Player : public Unit, public GridObject<Player> void SendSavedInstances(); static void ConvertInstancesToGroup(Player* player, Group* group, bool switchLeader); bool Satisfy(AccessRequirement const* ar, uint32 target_map, bool report = false); - bool CheckInstanceLoginValid(); + bool CheckInstanceLoginValid(Map* map); bool CheckInstanceCount(uint32 instanceId) const; void AddInstanceEnterTime(uint32 instanceId, time_t enterTime); @@ -2374,7 +2370,6 @@ class Player : public Unit, public GridObject<Player> void _LoadGroup(PreparedQueryResult result); void _LoadSkills(PreparedQueryResult result); void _LoadSpells(PreparedQueryResult result); - void _LoadFriendList(PreparedQueryResult result); bool _LoadHomeBind(PreparedQueryResult result); void _LoadDeclinedNames(PreparedQueryResult result); void _LoadArenaTeamInfo(PreparedQueryResult result); diff --git a/src/server/game/Entities/Player/SocialMgr.cpp b/src/server/game/Entities/Player/SocialMgr.cpp index e7989c405a8..b65584a4357 100644 --- a/src/server/game/Entities/Player/SocialMgr.cpp +++ b/src/server/game/Entities/Player/SocialMgr.cpp @@ -40,7 +40,7 @@ uint32 PlayerSocial::GetNumberOfSocialsWithFlag(SocialFlag flag) return counter; } -bool PlayerSocial::AddToSocialList(uint32 friendGuid, bool ignore) +bool PlayerSocial::AddToSocialList(ObjectGuid::LowType friendGuid, bool ignore) { // check client limits if (ignore) @@ -88,7 +88,7 @@ bool PlayerSocial::AddToSocialList(uint32 friendGuid, bool ignore) return true; } -void PlayerSocial::RemoveFromSocialList(uint32 friendGuid, bool ignore) +void PlayerSocial::RemoveFromSocialList(ObjectGuid::LowType friendGuid, bool ignore) { PlayerSocialMap::iterator itr = m_playerSocialMap.find(friendGuid); if (itr == m_playerSocialMap.end()) // not exist @@ -122,7 +122,7 @@ void PlayerSocial::RemoveFromSocialList(uint32 friendGuid, bool ignore) } } -void PlayerSocial::SetFriendNote(uint32 friendGuid, std::string note) +void PlayerSocial::SetFriendNote(ObjectGuid::LowType friendGuid, std::string note) { PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friendGuid); if (itr == m_playerSocialMap.end()) // not exist @@ -175,7 +175,7 @@ void PlayerSocial::SendSocialList(Player* player) TC_LOG_DEBUG("network", "WORLD: Sent SMSG_CONTACT_LIST"); } -bool PlayerSocial::HasFriend(uint32 friendGuid) +bool PlayerSocial::HasFriend(ObjectGuid::LowType friendGuid) { PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friendGuid); if (itr != m_playerSocialMap.end()) @@ -183,7 +183,7 @@ bool PlayerSocial::HasFriend(uint32 friendGuid) return false; } -bool PlayerSocial::HasIgnore(uint32 ignore_guid) +bool PlayerSocial::HasIgnore(ObjectGuid::LowType ignore_guid) { PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(ignore_guid); if (itr != m_playerSocialMap.end()) @@ -195,7 +195,7 @@ SocialMgr::SocialMgr() { } SocialMgr::~SocialMgr() { } -void SocialMgr::GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &friendInfo) +void SocialMgr::GetFriendInfo(Player* player, ObjectGuid::LowType friendGUID, FriendInfo &friendInfo) { if (!player) return; @@ -239,14 +239,14 @@ void SocialMgr::GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &fri } } -void SocialMgr::MakeFriendStatusPacket(FriendsResult result, uint32 guid, WorldPacket* data) +void SocialMgr::MakeFriendStatusPacket(FriendsResult result, ObjectGuid::LowType guid, WorldPacket* data) { data->Initialize(SMSG_FRIEND_STATUS, 9); *data << uint8(result); *data << uint64(guid); } -void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, uint32 friendGuid, bool broadcast) +void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, ObjectGuid::LowType friendGuid, bool broadcast) { FriendInfo fi; @@ -310,7 +310,7 @@ void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet) } } -PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, uint32 guid) +PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, ObjectGuid::LowType guid) { PlayerSocial *social = &m_socialMap[guid]; social->SetPlayerGUID(guid); @@ -318,7 +318,7 @@ PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, uint32 guid) if (!result) return social; - uint32 friendGuid = 0; + ObjectGuid::LowType friendGuid = 0; uint8 flags = 0; std::string note = ""; diff --git a/src/server/game/Entities/Player/SocialMgr.h b/src/server/game/Entities/Player/SocialMgr.h index 5bf336a9abe..887b5de58df 100644 --- a/src/server/game/Entities/Player/SocialMgr.h +++ b/src/server/game/Entities/Player/SocialMgr.h @@ -21,6 +21,7 @@ #include "DatabaseEnv.h" #include "Common.h" +#include "ObjectGuid.h" class SocialMgr; class PlayerSocial; @@ -60,8 +61,8 @@ struct FriendInfo { } }; -typedef std::map<uint32, FriendInfo> PlayerSocialMap; -typedef std::map<uint32, PlayerSocial> SocialMap; +typedef std::map<ObjectGuid::LowType, FriendInfo> PlayerSocialMap; +typedef std::map<ObjectGuid::LowType, PlayerSocial> SocialMap; /// Results of friend related commands enum FriendsResult @@ -104,20 +105,20 @@ class PlayerSocial public: PlayerSocial(); // adding/removing - bool AddToSocialList(uint32 friend_guid, bool ignore); - void RemoveFromSocialList(uint32 friend_guid, bool ignore); - void SetFriendNote(uint32 friendGuid, std::string note); + bool AddToSocialList(ObjectGuid::LowType friendGuid, bool ignore); + void RemoveFromSocialList(ObjectGuid::LowType friend_guid, bool ignore); + void SetFriendNote(ObjectGuid::LowType friendGuid, std::string note); // Packet send's void SendSocialList(Player* player); // Misc - bool HasFriend(uint32 friend_guid); - bool HasIgnore(uint32 ignore_guid); - uint32 GetPlayerGUID() const { return m_playerGUID; } - void SetPlayerGUID(uint32 guid) { m_playerGUID = guid; } + bool HasFriend(ObjectGuid::LowType friend_guid); + bool HasIgnore(ObjectGuid::LowType ignore_guid); + ObjectGuid::LowType GetPlayerGUID() const { return m_playerGUID; } + void SetPlayerGUID(ObjectGuid::LowType guid) { m_playerGUID = guid; } uint32 GetNumberOfSocialsWithFlag(SocialFlag flag); private: PlayerSocialMap m_playerSocialMap; - uint32 m_playerGUID; + ObjectGuid::LowType m_playerGUID; }; class SocialMgr @@ -134,15 +135,15 @@ class SocialMgr } // Misc - void RemovePlayerSocial(uint32 guid) { m_socialMap.erase(guid); } + void RemovePlayerSocial(ObjectGuid::LowType guid) { m_socialMap.erase(guid); } - void GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &friendInfo); + void GetFriendInfo(Player* player, ObjectGuid::LowType friendGUID, FriendInfo &friendInfo); // Packet management - void MakeFriendStatusPacket(FriendsResult result, uint32 friend_guid, WorldPacket* data); - void SendFriendStatus(Player* player, FriendsResult result, uint32 friend_guid, bool broadcast); + void MakeFriendStatusPacket(FriendsResult result, ObjectGuid::LowType friend_guid, WorldPacket* data); + void SendFriendStatus(Player* player, FriendsResult result, ObjectGuid::LowType friend_guid, bool broadcast); void BroadcastToFriendListers(Player* player, WorldPacket* packet); // Loading - PlayerSocial *LoadFromDB(PreparedQueryResult result, uint32 guid); + PlayerSocial *LoadFromDB(PreparedQueryResult result, ObjectGuid::LowType guid); private: SocialMap m_socialMap; }; diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index 144805b88b5..99459dce81e 100644 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -43,7 +43,7 @@ Transport::~Transport() UnloadStaticPassengers(); } -bool Transport::Create(uint32 guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress) +bool Transport::Create(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress) { Relocate(x, y, z, ang); @@ -281,7 +281,7 @@ void Transport::RemovePassenger(WorldObject* passenger) } } -Creature* Transport::CreateNPCPassenger(uint32 guid, CreatureData const* data) +Creature* Transport::CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const* data) { Map* map = GetMap(); Creature* creature = new Creature(); @@ -328,7 +328,7 @@ Creature* Transport::CreateNPCPassenger(uint32 guid, CreatureData const* data) return creature; } -GameObject* Transport::CreateGOPassenger(uint32 guid, GameObjectData const* data) +GameObject* Transport::CreateGOPassenger(ObjectGuid::LowType guid, GameObjectData const* data) { Map* map = GetMap(); GameObject* go = new GameObject(); diff --git a/src/server/game/Entities/Transport/Transport.h b/src/server/game/Entities/Transport/Transport.h index c56ceb1696d..3a2d0e4a7bd 100644 --- a/src/server/game/Entities/Transport/Transport.h +++ b/src/server/game/Entities/Transport/Transport.h @@ -27,7 +27,7 @@ struct CreatureData; class Transport : public GameObject, public TransportBase { - friend Transport* TransportMgr::CreateTransport(uint32, uint32, Map*); + friend Transport* TransportMgr::CreateTransport(uint32, ObjectGuid::LowType, Map*); Transport(); public: @@ -35,7 +35,7 @@ class Transport : public GameObject, public TransportBase ~Transport(); - bool Create(uint32 guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress); + bool Create(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress); void CleanupsBeforeDelete(bool finalCleanup = true) override; void Update(uint32 diff) override; @@ -47,8 +47,8 @@ class Transport : public GameObject, public TransportBase void RemovePassenger(WorldObject* passenger); PassengerSet const& GetPassengers() const { return _passengers; } - Creature* CreateNPCPassenger(uint32 guid, CreatureData const* data); - GameObject* CreateGOPassenger(uint32 guid, GameObjectData const* data); + Creature* CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const* data); + GameObject* CreateGOPassenger(ObjectGuid::LowType guid, GameObjectData const* data); /** * @fn bool Transport::SummonPassenger(uint64, Position const&, TempSummonType, SummonPropertiesEntry const*, uint32, Unit*, uint32, uint32) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index f01828661a3..6b234df5860 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3908,20 +3908,27 @@ void Unit::RemoveAurasWithAttribute(uint32 flags) void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase) { // single target auras from other casters - for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) + // Iterate m_ownedAuras - aura is marked as single target in Unit::AddAura (and pushed to m_ownedAuras). + // m_appliedAuras will NOT contain the aura before first Unit::Update after adding it to m_ownedAuras. + // Quickly removing such an aura will lead to it not being unregistered from caster's single cast auras container + // leading to assertion failures if the aura was cast on a player that can + // (and is changing map at the point where this function is called). + // Such situation occurs when player is logging in inside an instance and fails the entry check for any reason. + // The aura that was loaded from db (indirectly, via linked casts) gets removed before it has a chance + // to register in m_appliedAuras + for (AuraMap::iterator iter = m_ownedAuras.begin(); iter != m_ownedAuras.end();) { - AuraApplication const* aurApp = iter->second; - Aura const* aura = aurApp->GetBase(); + Aura const* aura = iter->second; - if (aura->GetCasterGUID() != GetGUID() && aura->GetSpellInfo()->IsSingleTarget()) + if (aura->GetCasterGUID() != GetGUID() && aura->IsSingleTarget()) { if (!newPhase) - RemoveAura(iter); + RemoveOwnedAura(iter); else { Unit* caster = aura->GetCaster(); if (!caster || !caster->InSamePhase(newPhase)) - RemoveAura(iter); + RemoveOwnedAura(iter); else ++iter; } @@ -13422,7 +13429,7 @@ void Unit::SetLevel(uint8 lvl) if (player->GetGroup()) player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_LEVEL); - sWorld->UpdateCharacterNameDataLevel(GetGUID(), lvl); + sWorld->UpdateCharacterInfoLevel(GetGUID(), lvl); } } @@ -14174,9 +14181,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u continue; // do checks using conditions table - ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL_PROC, spellProto->Id); - ConditionSourceInfo condInfo = ConditionSourceInfo(eventInfo.GetActor(), eventInfo.GetActionTarget()); - if (!sConditionMgr->IsObjectMeetToConditions(condInfo, conditions)) + if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPELL_PROC, spellProto->Id, eventInfo.GetActor(), eventInfo.GetActionTarget())) continue; // AuraScript Hook @@ -14645,6 +14650,9 @@ bool Unit::IsPolymorphed() const void Unit::SetDisplayId(uint32 modelId) { SetUInt32Value(UNIT_FIELD_DISPLAYID, modelId); + // Set Gender by modelId + if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(modelId)) + SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender); } void Unit::RestoreDisplayId() @@ -16877,9 +16885,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId) continue; //! Check database conditions - ConditionList conds = sConditionMgr->GetConditionsForSpellClickEvent(spellClickEntry, itr->second.spellId); - ConditionSourceInfo info = ConditionSourceInfo(clicker, this); - if (!sConditionMgr->IsObjectMeetToConditions(info, conds)) + if (!sConditionMgr->IsObjectMeetingSpellClickConditions(spellClickEntry, itr->second.spellId, clicker, this)) continue; Unit* caster = (itr->second.castFlags & NPC_CLICK_CAST_CASTER_CLICKER) ? clicker : this; diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index 8f2d0491a91..9e5e7ff9990 100644 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -371,7 +371,7 @@ void GameEventMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); int16 event_id = fields[1].GetInt8(); int32 internal_event_id = mGameEvent.size() + event_id - 1; @@ -417,7 +417,7 @@ void GameEventMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); int16 event_id = fields[1].GetInt8(); int32 internal_event_id = mGameEvent.size() + event_id - 1; @@ -463,7 +463,7 @@ void GameEventMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); uint16 event_id = fields[2].GetUInt8(); @@ -712,7 +712,7 @@ void GameEventMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint16 event_id = fields[1].GetUInt8(); uint32 npcflag = fields[2].GetUInt32(); @@ -798,7 +798,7 @@ void GameEventMgr::LoadFromDB() NPCVendorList& vendors = mGameEventVendors[event_id]; NPCVendorEntry newEntry; - uint32 guid = fields[1].GetUInt32(); + ObjectGuid::LowType guid = fields[1].GetUInt32(); newEntry.item = fields[2].GetUInt32(); newEntry.maxcount = fields[3].GetUInt32(); newEntry.incrtime = fields[4].GetUInt32(); @@ -917,7 +917,7 @@ void GameEventMgr::LoadFromDB() uint32 GameEventMgr::GetNPCFlag(Creature* cr) { uint32 mask = 0; - uint32 guid = cr->GetSpawnId(); + ObjectGuid::LowType guid = cr->GetSpawnId(); for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr) { @@ -1400,7 +1400,7 @@ bool GameEventMgr::hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 e } return false; } -bool GameEventMgr::hasCreatureActiveEventExcept(uint32 creature_id, uint16 event_id) +bool GameEventMgr::hasCreatureActiveEventExcept(ObjectGuid::LowType creature_id, uint16 event_id) { for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr) { @@ -1416,7 +1416,7 @@ bool GameEventMgr::hasCreatureActiveEventExcept(uint32 creature_id, uint16 event } return false; } -bool GameEventMgr::hasGameObjectActiveEventExcept(uint32 go_id, uint16 event_id) +bool GameEventMgr::hasGameObjectActiveEventExcept(ObjectGuid::LowType go_id, uint16 event_id) { for (ActiveEvents::iterator e_itr = m_ActiveEvents.begin(); e_itr != m_ActiveEvents.end(); ++e_itr) { diff --git a/src/server/game/Events/GameEventMgr.h b/src/server/game/Events/GameEventMgr.h index eb29e463a4d..57f30eb4015 100644 --- a/src/server/game/Events/GameEventMgr.h +++ b/src/server/game/Events/GameEventMgr.h @@ -20,6 +20,7 @@ #define TRINITY_GAMEEVENT_MGR_H #include "Common.h" +#include "ObjectGuid.h" #include "SharedDefines.h" #include "Define.h" @@ -144,14 +145,14 @@ class GameEventMgr void SaveWorldEventStateToDB(uint16 event_id); bool hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 event_id); bool hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 event_id); - bool hasCreatureActiveEventExcept(uint32 creature_guid, uint16 event_id); - bool hasGameObjectActiveEventExcept(uint32 go_guid, uint16 event_id); + bool hasCreatureActiveEventExcept(ObjectGuid::LowType creature_guid, uint16 event_id); + bool hasGameObjectActiveEventExcept(ObjectGuid::LowType go_guid, uint16 event_id); - typedef std::list<uint32> GuidList; + typedef std::list<ObjectGuid::LowType> GuidList; typedef std::list<uint32> IdList; typedef std::vector<GuidList> GameEventGuidMap; typedef std::vector<IdList> GameEventIdMap; - typedef std::pair<uint32, ModelEquip> ModelEquipPair; + typedef std::pair<ObjectGuid::LowType, ModelEquip> ModelEquipPair; typedef std::list<ModelEquipPair> ModelEquipList; typedef std::vector<ModelEquipList> GameEventModelEquipMap; typedef std::pair<uint32, uint32> QuestRelation; @@ -160,7 +161,7 @@ class GameEventMgr typedef std::list<NPCVendorEntry> NPCVendorList; typedef std::vector<NPCVendorList> GameEventNPCVendorMap; typedef std::map<uint32 /*quest id*/, GameEventQuestToEventConditionNum> QuestIdToEventConditionMap; - typedef std::pair<uint32 /*guid*/, uint32 /*npcflag*/> GuidNPCFlagPair; + typedef std::pair<ObjectGuid::LowType /*guid*/, uint32 /*npcflag*/> GuidNPCFlagPair; typedef std::list<GuidNPCFlagPair> NPCFlagList; typedef std::vector<NPCFlagList> GameEventNPCFlagMap; typedef std::vector<uint32> GameEventBitmask; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index b5d8d08a6a4..7a9302699b2 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -291,8 +291,8 @@ void ObjectMgr::LoadCreatureLocales() _creatureLocaleStore.clear(); // need for reload case - QueryResult result = WorldDatabase.Query("SELECT entry, name_loc1, subname_loc1, name_loc2, subname_loc2, name_loc3, subname_loc3, name_loc4, subname_loc4, name_loc5, subname_loc5, name_loc6, subname_loc6, name_loc7, subname_loc7, name_loc8, subname_loc8 FROM locales_creature"); - + // 0 1 2 3 + QueryResult result = WorldDatabase.Query("SELECT entry, locale, Name, Title FROM creature_template_locale"); if (!result) return; @@ -300,16 +300,20 @@ void ObjectMgr::LoadCreatureLocales() { Field* fields = result->Fetch(); - uint32 entry = fields[0].GetUInt32(); + uint32 id = fields[0].GetUInt32(); + std::string localeName = fields[1].GetString(); - CreatureLocale& data = _creatureLocaleStore[entry]; + std::string name = fields[2].GetString(); + std::string title = fields[3].GetString(); + + CreatureLocale& data = _creatureLocaleStore[id]; + LocaleConstant locale = GetLocaleByName(localeName); + if (locale == LOCALE_enUS) + continue; + + AddLocaleString(name, locale, data.Name); + AddLocaleString(title, locale, data.Title); - for (uint8 i = TOTAL_LOCALES - 1; i > 0; --i) - { - LocaleConstant locale = (LocaleConstant) i; - AddLocaleString(fields[1 + 2 * (i - 1)].GetString(), locale, data.Name); - AddLocaleString(fields[1 + 2 * (i - 1) + 1].GetString(), locale, data.SubName); - } } while (result->NextRow()); TC_LOG_INFO("server.loading", ">> Loaded %u creature locale strings in %u ms", uint32(_creatureLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime)); @@ -442,7 +446,7 @@ void ObjectMgr::LoadCreatureTemplate(Field* fields) creatureTemplate.Modelid3 = fields[8].GetUInt32(); creatureTemplate.Modelid4 = fields[9].GetUInt32(); creatureTemplate.Name = fields[10].GetString(); - creatureTemplate.SubName = fields[11].GetString(); + creatureTemplate.Title = fields[11].GetString(); creatureTemplate.IconName = fields[12].GetString(); creatureTemplate.GossipMenuId = fields[13].GetUInt32(); creatureTemplate.minlevel = fields[14].GetUInt8(); @@ -961,7 +965,7 @@ void ObjectMgr::LoadCreatureAddons() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); CreatureData const* creData = GetCreatureData(guid); if (!creData) @@ -1084,7 +1088,7 @@ GameObjectAddon const* ObjectMgr::GetGameObjectAddon(ObjectGuid::LowType lowguid return NULL; } -CreatureAddon const* ObjectMgr::GetCreatureAddon(uint32 lowguid) +CreatureAddon const* ObjectMgr::GetCreatureAddon(ObjectGuid::LowType lowguid) { CreatureAddonContainer::const_iterator itr = _creatureAddonStore.find(lowguid); if (itr != _creatureAddonStore.end()) @@ -1338,8 +1342,8 @@ void ObjectMgr::LoadLinkedRespawn() { Field* fields = result->Fetch(); - uint32 guidLow = fields[0].GetUInt32(); - uint32 linkedGuidLow = fields[1].GetUInt32(); + ObjectGuid::LowType guidLow = fields[0].GetUInt32(); + ObjectGuid::LowType linkedGuidLow = fields[1].GetUInt32(); uint8 linkType = fields[2].GetUInt8(); ObjectGuid guid, linkedGuid; @@ -1504,7 +1508,7 @@ void ObjectMgr::LoadLinkedRespawn() TC_LOG_INFO("server.loading", ">> Loaded " UI64FMTD " linked respawns in %u ms", uint64(_linkedRespawnStore.size()), GetMSTimeDiffToNow(oldMSTime)); } -bool ObjectMgr::SetCreatureLinkedRespawn(uint32 guidLow, uint32 linkedGuidLow) +bool ObjectMgr::SetCreatureLinkedRespawn(ObjectGuid::LowType guidLow, ObjectGuid::LowType linkedGuidLow) { if (!guidLow) return false; @@ -1672,7 +1676,7 @@ void ObjectMgr::LoadCreatures() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); CreatureTemplate const* cInfo = GetCreatureTemplate(entry); @@ -1803,7 +1807,7 @@ void ObjectMgr::LoadCreatures() TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " creatures in %u ms", _creatureDataStore.size(), GetMSTimeDiffToNow(oldMSTime)); } -void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data) +void ObjectMgr::AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const* data) { uint8 mask = data->spawnMask; for (uint8 i = 0; mask != 0; i++, mask >>= 1) @@ -1817,7 +1821,7 @@ void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data) } } -void ObjectMgr::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data) +void ObjectMgr::RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const* data) { uint8 mask = data->spawnMask; for (uint8 i = 0; mask != 0; i++, mask >>= 1) @@ -1831,7 +1835,7 @@ void ObjectMgr::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data) } } -uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay, float rotation0, float rotation1, float rotation2, float rotation3) +ObjectGuid::LowType ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay, float rotation0, float rotation1, float rotation2, float rotation3) { GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry); if (!goinfo) @@ -1841,7 +1845,7 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float if (!map) return 0; - uint32 guid = GenerateGameObjectSpawnId(); + ObjectGuid::LowType guid = GenerateGameObjectSpawnId(); GameObjectData& data = NewGOData(guid); data.id = entry; @@ -1883,7 +1887,7 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float } -uint32 ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay /*= 0*/) +ObjectGuid::LowType ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay /*= 0*/) { CreatureTemplate const* cInfo = GetCreatureTemplate(entry); if (!cInfo) @@ -1895,7 +1899,7 @@ uint32 ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, float x, float y, if (!map) return 0; - uint32 guid = GenerateCreatureSpawnId(); + ObjectGuid::LowType guid = GenerateCreatureSpawnId(); CreatureData& data = NewOrExistCreatureData(guid); data.id = entry; data.mapid = mapId; @@ -1966,7 +1970,7 @@ void ObjectMgr::LoadGameobjects() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); GameObjectTemplate const* gInfo = GetGameObjectTemplate(entry); @@ -2094,7 +2098,7 @@ void ObjectMgr::LoadGameobjects() TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " gameobjects in %u ms", _gameObjectDataStore.size(), GetMSTimeDiffToNow(oldMSTime)); } -void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data) +void ObjectMgr::AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData const* data) { uint8 mask = data->spawnMask; for (uint8 i = 0; mask != 0; i++, mask >>= 1) @@ -2108,7 +2112,7 @@ void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data) } } -void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data) +void ObjectMgr::RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectData const* data) { uint8 mask = data->spawnMask; for (uint8 i = 0; mask != 0; i++, mask >>= 1) @@ -2122,7 +2126,7 @@ void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data } } -Player* ObjectMgr::GetPlayerByLowGUID(uint32 lowguid) const +Player* ObjectMgr::GetPlayerByLowGUID(ObjectGuid::LowType lowguid) const { ObjectGuid guid(HighGuid::Player, lowguid); return ObjectAccessor::FindPlayer(guid); @@ -2192,23 +2196,10 @@ uint32 ObjectMgr::GetPlayerTeamByGUID(ObjectGuid guid) const uint32 ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid guid) const { - // prevent DB access for online player - if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) - { - return player->GetSession()->GetAccountId(); - } - - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_BY_GUID); + if (CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(guid)) + return characterInfo->AccountId; - stmt->setUInt32(0, guid.GetCounter()); - - PreparedQueryResult result = CharacterDatabase.Query(stmt); - if (result) - { - uint32 acc = (*result)[0].GetUInt32(); - return acc; - } return 0; } @@ -2530,7 +2521,7 @@ void ObjectMgr::LoadItemTemplates() if (!req) for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j) { - if (itemTemplate.Spells[j].SpellId) + if (itemTemplate.Spells[j].SpellId > 0) { req = true; break; @@ -2715,15 +2706,6 @@ void ObjectMgr::LoadItemTemplates() TC_LOG_ERROR("sql.sql", "Item (Entry: %u) has broken spell in spellid_%d (%d)", entry, j+1, itemTemplate.Spells[j].SpellId); itemTemplate.Spells[j].SpellId = 0; } - - if (spellInfo && itemTemplate.Spells[j].SpellCategory - && itemTemplate.Spells[j].SpellCategory != SPELL_CATEGORY_FOOD) - { - bool added = sSpellsByCategoryStore[itemTemplate.Spells[j].SpellCategory].insert(itemTemplate.Spells[j].SpellId).second; - if (added) - TC_LOG_DEBUG("sql.sql", "Item(Entry: %u) spellid_%d (%d) category %u added to sSpellsByCategoryStore", - entry, j + 1, itemTemplate.Spells[j].SpellId, itemTemplate.Spells[j].SpellCategory); - } } } } @@ -6542,6 +6524,8 @@ void ObjectMgr::LoadGameObjectLocales() GameObjectLocale& data = _gameObjectLocaleStore[id]; LocaleConstant locale = GetLocaleByName(localeName); + if (locale == LOCALE_enUS) + continue; AddLocaleString(name, locale, data.Name); AddLocaleString(castBarCaption, locale, data.CastBarCaption); @@ -7338,7 +7322,7 @@ void ObjectMgr::LoadNPCSpellClickSpells() TC_LOG_INFO("server.loading", ">> Loaded %u spellclick definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } -void ObjectMgr::DeleteCreatureData(uint32 guid) +void ObjectMgr::DeleteCreatureData(ObjectGuid::LowType guid) { // remove mapid*cellid -> guid_set map CreatureData const* data = GetCreatureData(guid); @@ -7348,7 +7332,7 @@ void ObjectMgr::DeleteCreatureData(uint32 guid) _creatureDataStore.erase(guid); } -void ObjectMgr::DeleteGOData(uint32 guid) +void ObjectMgr::DeleteGOData(ObjectGuid::LowType guid) { // remove mapid*cellid -> guid_set map GameObjectData const* data = GetGOData(guid); @@ -7584,7 +7568,7 @@ bool isValidString(const std::wstring& wstr, uint32 strictMask, bool numericOrSp return false; } -ResponseCodes ObjectMgr::CheckPlayerName(const std::string& name, bool create) +ResponseCodes ObjectMgr::CheckPlayerName(std::string const& name, LocaleConstant locale, bool create /*= false*/) { std::wstring wname; if (!Utf8toWStr(name, wname)) @@ -7606,7 +7590,7 @@ ResponseCodes ObjectMgr::CheckPlayerName(const std::string& name, bool create) if (wname[i] == wname[i-1] && wname[i] == wname[i-2]) return CHAR_NAME_THREE_CONSECUTIVE; - return CHAR_NAME_SUCCESS; + return ValidateName(name, locale); } bool ObjectMgr::IsValidCharterName(const std::string& name) @@ -7627,7 +7611,7 @@ bool ObjectMgr::IsValidCharterName(const std::string& name) return isValidString(wname, strictMask, true); } -PetNameInvalidReason ObjectMgr::CheckPetName(const std::string& name) +PetNameInvalidReason ObjectMgr::CheckPetName(const std::string& name, LocaleConstant locale) { std::wstring wname; if (!Utf8toWStr(name, wname)) @@ -7644,6 +7628,17 @@ PetNameInvalidReason ObjectMgr::CheckPetName(const std::string& name) if (!isValidString(wname, strictMask, false)) return PET_NAME_MIXED_LANGUAGES; + switch (ValidateName(name, locale)) + { + case CHAR_NAME_PROFANE: + return PET_NAME_PROFANE; + case CHAR_NAME_RESERVED: + return PET_NAME_RESERVED; + case RESPONSE_FAILURE: + return PET_NAME_INVALID; + default: + break; + } return PET_NAME_SUCCESS; } diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 462370001dd..033ea482912 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -258,7 +258,7 @@ struct ScriptInfo struct // SCRIPT_COMMAND_RESPAWN_GAMEOBJECT (9) { - uint32 GOGuid; // datalong + ObjectGuid::LowType GOGuid; // datalong uint32 DespawnDelay; // datalong2 } RespawnGameobject; @@ -277,7 +277,7 @@ struct ScriptInfo struct // SCRIPT_COMMAND_CLOSE_DOOR (12) // SCRIPT_COMMAND_OPEN_DOOR (11) { - uint32 GOGuid; // datalong + ObjectGuid::LowType GOGuid; // datalong uint32 ResetDelay; // datalong2 } ToggleDoor; @@ -463,8 +463,8 @@ struct TrinityString }; typedef std::map<ObjectGuid, ObjectGuid> LinkedRespawnContainer; -typedef std::unordered_map<uint32, CreatureData> CreatureDataContainer; -typedef std::unordered_map<uint32, GameObjectData> GameObjectDataContainer; +typedef std::unordered_map<ObjectGuid::LowType, CreatureData> CreatureDataContainer; +typedef std::unordered_map<ObjectGuid::LowType, GameObjectData> GameObjectDataContainer; typedef std::map<TempSummonGroupKey, std::vector<TempSummonData> > TempSummonDataContainer; typedef std::unordered_map<uint32, CreatureLocale> CreatureLocaleContainer; typedef std::unordered_map<uint32, GameObjectLocale> GameObjectLocaleContainer; @@ -564,14 +564,14 @@ struct GossipMenuItems uint32 BoxMoney; std::string BoxText; uint32 BoxBroadcastTextId; - ConditionList Conditions; + ConditionContainer Conditions; }; struct GossipMenus { uint32 entry; uint32 text_id; - ConditionList conditions; + ConditionContainer conditions; }; typedef std::multimap<uint32, GossipMenus> GossipMenusContainer; @@ -706,7 +706,7 @@ class ObjectMgr typedef std::map<uint32, uint32> CharacterConversionMap; - Player* GetPlayerByLowGUID(uint32 lowguid) const; + Player* GetPlayerByLowGUID(ObjectGuid::LowType lowguid) const; GameObjectTemplate const* GetGameObjectTemplate(uint32 entry); GameObjectTemplateContainer const* GetGameObjectTemplates() const { return &_gameObjectTemplateStore; } @@ -722,7 +722,7 @@ class ObjectMgr static uint32 ChooseDisplayId(CreatureTemplate const* cinfo, CreatureData const* data = NULL); static void ChooseCreatureFlags(CreatureTemplate const* cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, CreatureData const* data = NULL); EquipmentInfo const* GetEquipmentInfo(uint32 entry, int8& id); - CreatureAddon const* GetCreatureAddon(uint32 lowguid); + CreatureAddon const* GetCreatureAddon(ObjectGuid::LowType lowguid); GameObjectAddon const* GetGameObjectAddon(ObjectGuid::LowType lowguid); CreatureAddon const* GetCreatureTemplateAddon(uint32 entry); ItemTemplate const* GetItemTemplate(uint32 entry); @@ -778,7 +778,7 @@ class ObjectMgr * If the player is online, the name is retrieved immediately otherwise * a database query is done. * - * @remark Use sWorld->GetCharacterNameData because it doesn't require a database query when player is offline + * @remark Use sWorld->GetCharacterInfo because it doesn't require a database query when player is offline * * @param guid player full guid * @param name returned name @@ -984,7 +984,7 @@ class ObjectMgr void LoadTempSummons(); void LoadCreatures(); void LoadLinkedRespawn(); - bool SetCreatureLinkedRespawn(uint32 guid, uint32 linkedGuid); + bool SetCreatureLinkedRespawn(ObjectGuid::LowType guid, ObjectGuid::LowType linkedGuid); void LoadCreatureAddons(); void LoadGameObjectAddons(); void LoadCreatureModelInfo(); @@ -1127,14 +1127,14 @@ class ObjectMgr return NULL; } - CreatureData const* GetCreatureData(uint32 guid) const + CreatureData const* GetCreatureData(ObjectGuid::LowType guid) const { CreatureDataContainer::const_iterator itr = _creatureDataStore.find(guid); if (itr == _creatureDataStore.end()) return NULL; return &itr->second; } - CreatureData& NewOrExistCreatureData(uint32 guid) { return _creatureDataStore[guid]; } - void DeleteCreatureData(uint32 guid); + CreatureData& NewOrExistCreatureData(ObjectGuid::LowType guid) { return _creatureDataStore[guid]; } + void DeleteCreatureData(ObjectGuid::LowType guid); ObjectGuid GetLinkedRespawnGuid(ObjectGuid guid) const { LinkedRespawnContainer::const_iterator itr = _linkedRespawnStore.find(guid); @@ -1196,14 +1196,14 @@ class ObjectMgr return &itr->second; } - GameObjectData const* GetGOData(uint32 guid) const + GameObjectData const* GetGOData(ObjectGuid::LowType guid) const { GameObjectDataContainer::const_iterator itr = _gameObjectDataStore.find(guid); if (itr == _gameObjectDataStore.end()) return NULL; return &itr->second; } - GameObjectData& NewGOData(uint32 guid) { return _gameObjectDataStore[guid]; } - void DeleteGOData(uint32 guid); + GameObjectData& NewGOData(ObjectGuid::LowType guid) { return _gameObjectDataStore[guid]; } + void DeleteGOData(ObjectGuid::LowType guid); TrinityString const* GetTrinityString(uint32 entry) const { @@ -1218,20 +1218,20 @@ class ObjectMgr void SetDBCLocaleIndex(LocaleConstant locale) { DBCLocaleIndex = locale; } // grid objects - void AddCreatureToGrid(uint32 guid, CreatureData const* data); - void RemoveCreatureFromGrid(uint32 guid, CreatureData const* data); - void AddGameobjectToGrid(uint32 guid, GameObjectData const* data); - void RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data); - uint32 AddGOData(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0, float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0); - uint32 AddCreatureData(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0); + void AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const* data); + void RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const* data); + void AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData const* data); + void RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectData const* data); + ObjectGuid::LowType AddGOData(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0, float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0); + ObjectGuid::LowType AddCreatureData(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0); // reserved names void LoadReservedPlayersNames(); bool IsReservedName(std::string const& name) const; // name with valid structure and symbols - static ResponseCodes CheckPlayerName(std::string const& name, bool create = false); - static PetNameInvalidReason CheckPetName(std::string const& name); + static ResponseCodes CheckPlayerName(std::string const& name, LocaleConstant locale, bool create = false); + static PetNameInvalidReason CheckPetName(std::string const& name, LocaleConstant locale); static bool IsValidCharterName(std::string const& name); static bool CheckDeclinedNames(const std::wstring& w_ownname, DeclinedName const& names); @@ -1439,7 +1439,7 @@ class ObjectMgr CreatureTemplateContainer _creatureTemplateStore; CreatureModelContainer _creatureModelStore; CreatureAddonContainer _creatureAddonStore; - CreatureAddonContainer _creatureTemplateAddonStore; + CreatureAddonTemplateContainer _creatureTemplateAddonStore; GameObjectAddonContainer _gameObjectAddonStore; GameObjectQuestItemMap _gameObjectQuestItemStore; CreatureQuestItemMap _creatureQuestItemStore; diff --git a/src/server/game/Grids/ObjectGridLoader.cpp b/src/server/game/Grids/ObjectGridLoader.cpp index de0ab490e9c..2c292c43785 100644 --- a/src/server/game/Grids/ObjectGridLoader.cpp +++ b/src/server/game/Grids/ObjectGridLoader.cpp @@ -118,7 +118,7 @@ void LoadHelper(CellGuidSet const& guid_set, CellCoord &cell, GridRefManager<T> for (CellGuidSet::const_iterator i_guid = guid_set.begin(); i_guid != guid_set.end(); ++i_guid) { T* obj = new T; - uint32 guid = *i_guid; + ObjectGuid::LowType guid = *i_guid; //TC_LOG_INFO("misc", "DEBUG: LoadHelper from table: %s for (guid: %u) Loading", table, guid); if (!obj->LoadFromDB(guid, map)) { @@ -152,7 +152,12 @@ void ObjectWorldLoader::Visit(CorpseMapType& /*m*/) for (Corpse* corpse : *corpses) { corpse->AddToWorld(); - i_grid.GetGridType(i_cell.CellX(), i_cell.CellY()).AddWorldObject(corpse); + GridType& cell = i_grid.GetGridType(i_cell.CellX(), i_cell.CellY()); + if (corpse->IsWorldObject()) + cell.AddWorldObject(corpse); + else + cell.AddGridObject(corpse); + ++i_corpses; } } @@ -230,7 +235,7 @@ void ObjectGridCleaner::Visit(GridRefManager<T> &m) template void ObjectGridUnloader::Visit(CreatureMapType &); template void ObjectGridUnloader::Visit(GameObjectMapType &); template void ObjectGridUnloader::Visit(DynamicObjectMapType &); -template void ObjectGridUnloader::Visit(CorpseMapType &); + template void ObjectGridCleaner::Visit(CreatureMapType &); template void ObjectGridCleaner::Visit<GameObject>(GameObjectMapType &); template void ObjectGridCleaner::Visit<DynamicObject>(DynamicObjectMapType &); diff --git a/src/server/game/Grids/ObjectGridLoader.h b/src/server/game/Grids/ObjectGridLoader.h index 54dadaefdb3..126ebd0d0a3 100644 --- a/src/server/game/Grids/ObjectGridLoader.h +++ b/src/server/game/Grids/ObjectGridLoader.h @@ -82,6 +82,7 @@ class ObjectGridCleaner class ObjectGridUnloader { public: + void Visit(CorpseMapType& /*m*/) { } // corpses are deleted with Map template<class T> void Visit(GridRefManager<T> &m); }; #endif diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index cc9ef29a8e8..5f500156f58 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -91,7 +91,7 @@ Group::~Group() bool Group::Create(Player* leader) { ObjectGuid leaderGuid = leader->GetGUID(); - uint32 lowguid = sGroupMgr->GenerateGroupId(); + ObjectGuid::LowType lowguid = sGroupMgr->GenerateGroupId(); m_guid = ObjectGuid(HighGuid::Group, lowguid); m_leaderGuid = leaderGuid; @@ -198,7 +198,7 @@ void Group::LoadGroupFromDB(Field* fields) sLFGMgr->_LoadFromDB(fields, GetGUID()); } -void Group::LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles) +void Group::LoadMemberFromDB(ObjectGuid::LowType guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles) { MemberSlot member; member.guid = ObjectGuid(HighGuid::Player, guidLow); @@ -2224,7 +2224,7 @@ ObjectGuid Group::GetGUID() const return m_guid; } -uint32 Group::GetLowGUID() const +ObjectGuid::LowType Group::GetLowGUID() const { return m_guid.GetCounter(); } diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h index 732afce9517..b814ab08026 100644 --- a/src/server/game/Groups/Group.h +++ b/src/server/game/Groups/Group.h @@ -186,7 +186,7 @@ class Group // group manipulation methods bool Create(Player* leader); void LoadGroupFromDB(Field* field); - void LoadMemberFromDB(uint32 guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles); + void LoadMemberFromDB(ObjectGuid::LowType guidLow, uint8 memberFlags, uint8 subgroup, uint8 roles); bool AddInvite(Player* player); void RemoveInvite(Player* player); void RemoveAllInvites(); @@ -211,7 +211,7 @@ class Group bool IsCreated() const; ObjectGuid GetLeaderGUID() const; ObjectGuid GetGUID() const; - uint32 GetLowGUID() const; + ObjectGuid::LowType GetLowGUID() const; const char * GetLeaderName() const; LootMethod GetLootMethod() const; ObjectGuid GetLooterGuid() const; diff --git a/src/server/game/Groups/GroupMgr.cpp b/src/server/game/Groups/GroupMgr.cpp index ab80a208765..b8c8157b6d9 100644 --- a/src/server/game/Groups/GroupMgr.cpp +++ b/src/server/game/Groups/GroupMgr.cpp @@ -82,7 +82,7 @@ Group* GroupMgr::GetGroupByDbStoreId(uint32 storageId) const return NULL; } -uint32 GroupMgr::GenerateGroupId() +ObjectGuid::LowType GroupMgr::GenerateGroupId() { if (NextGroupId >= 0xFFFFFFFE) { @@ -92,7 +92,7 @@ uint32 GroupMgr::GenerateGroupId() return NextGroupId++; } -Group* GroupMgr::GetGroupByGUID(uint32 groupId) const +Group* GroupMgr::GetGroupByGUID(ObjectGuid::LowType groupId) const { GroupContainer::const_iterator itr = GroupStore.find(groupId); if (itr != GroupStore.end()) diff --git a/src/server/game/Groups/GroupMgr.h b/src/server/game/Groups/GroupMgr.h index 737c1771c14..ec02de16bc2 100644 --- a/src/server/game/Groups/GroupMgr.h +++ b/src/server/game/Groups/GroupMgr.h @@ -33,10 +33,10 @@ public: return &instance; } - typedef std::map<uint32, Group*> GroupContainer; + typedef std::map<ObjectGuid::LowType, Group*> GroupContainer; typedef std::vector<Group*> GroupDbContainer; - Group* GetGroupByGUID(uint32 guid) const; + Group* GetGroupByGUID(ObjectGuid::LowType guid) const; uint32 GenerateNewGroupDbStoreId(); void RegisterGroupDbStoreId(uint32 storageId, Group* group); @@ -46,13 +46,13 @@ public: void SetGroupDbStoreSize(uint32 newSize) { GroupDbStore.resize(newSize); } void LoadGroups(); - uint32 GenerateGroupId(); + ObjectGuid::LowType GenerateGroupId(); void AddGroup(Group* group); void RemoveGroup(Group* group); protected: - uint32 NextGroupId; + ObjectGuid::LowType NextGroupId; uint32 NextGroupDbStoreId; GroupContainer GroupStore; GroupDbContainer GroupDbStore; diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index fab22b30f47..d2fcad512bb 100644 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -395,7 +395,7 @@ void Guild::BankTab::LoadFromDB(Field* fields) bool Guild::BankTab::LoadItemFromDB(Field* fields) { uint8 slotId = fields[13].GetUInt8(); - uint32 itemGuid = fields[14].GetUInt32(); + ObjectGuid::LowType itemGuid = fields[14].GetUInt32(); uint32 itemEntry = fields[15].GetUInt32(); if (slotId >= GUILD_BANK_MAX_SLOTS) { @@ -784,7 +784,7 @@ void EmblemInfo::WritePacket(WorldPacket& data) const data << uint32(m_backgroundColor); } -void EmblemInfo::SaveToDB(uint32 guildId) const +void EmblemInfo::SaveToDB(ObjectGuid::LowType guildId) const { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_EMBLEM_INFO); stmt->setUInt32(0, m_style); @@ -1972,7 +1972,7 @@ void Guild::LoadRankFromDB(Field* fields) bool Guild::LoadMemberFromDB(Field* fields) { - uint32 lowguid = fields[1].GetUInt32(); + ObjectGuid::LowType lowguid = fields[1].GetUInt32(); Member *member = new Member(m_id, ObjectGuid(HighGuid::Player, lowguid), fields[2].GetUInt8()); if (!member->LoadFromDB(fields)) { @@ -2019,7 +2019,7 @@ bool Guild::LoadBankEventLogFromDB(Field* fields) LogHolder* pLog = m_bankEventLog[tabId]; if (pLog->CanInsert()) { - uint32 guid = fields[2].GetUInt32(); + ObjectGuid::LowType guid = fields[2].GetUInt32(); GuildBankEventLogTypes eventType = GuildBankEventLogTypes(fields[3].GetUInt8()); if (BankEventLogEntry::IsMoneyEvent(eventType)) { @@ -2222,7 +2222,7 @@ bool Guild::AddMember(ObjectGuid guid, uint8 rankId) // This will be prevent attempt to join many guilds and corrupt guild data integrity Player::RemovePetitionsAndSigns(guid, GUILD_CHARTER_TYPE); - uint32 lowguid = guid.GetCounter(); + ObjectGuid::LowType lowguid = guid.GetCounter(); // If rank was not passed, assign lowest possible rank if (rankId == GUILD_RANK_NONE) @@ -2284,7 +2284,7 @@ bool Guild::AddMember(ObjectGuid guid, uint8 rankId) void Guild::DeleteMember(ObjectGuid guid, bool isDisbanding, bool isKicked, bool canDeleteGuild) { - uint32 lowguid = guid.GetCounter(); + ObjectGuid::LowType lowguid = guid.GetCounter(); Player* player = ObjectAccessor::FindConnectedPlayer(guid); // Guild master can be deleted when loading guild and guid doesn't exist in characters table @@ -2635,7 +2635,7 @@ inline bool Guild::_MemberHasTabRights(ObjectGuid guid, uint8 tabId, uint32 righ } // Add new event log record -inline void Guild::_LogEvent(GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) +inline void Guild::_LogEvent(GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank) { SQLTransaction trans = CharacterDatabase.BeginTransaction(); m_eventLog->AddEvent(trans, new EventLogEntry(m_id, m_eventLog->GetNextGUID(), eventType, playerGuid1, playerGuid2, newRank)); @@ -2645,7 +2645,7 @@ inline void Guild::_LogEvent(GuildEventLogTypes eventType, uint32 playerGuid1, u } // Add new bank event log record -void Guild::_LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, uint32 lowguid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) +void Guild::_LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType lowguid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) { if (tabId > GUILD_BANK_MAX_TABS) return; diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index b0ea9e1f4e5..ca5ea95ee2c 100644 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -229,7 +229,7 @@ public: EmblemInfo() : m_style(0), m_color(0), m_borderStyle(0), m_borderColor(0), m_backgroundColor(0) { } void LoadFromDB(Field* fields); - void SaveToDB(uint32 guildId) const; + void SaveToDB(ObjectGuid::LowType guildId) const; void ReadPacket(WorldPacket& recv); void WritePacket(WorldPacket& data) const; @@ -286,7 +286,7 @@ private: class Member { public: - Member(uint32 guildId, ObjectGuid guid, uint8 rankId) : + Member(ObjectGuid::LowType guildId, ObjectGuid guid, uint8 rankId) : m_guildId(guildId), m_guid(guid), m_zoneId(0), @@ -345,7 +345,7 @@ private: inline Player* FindConnectedPlayer() const { return ObjectAccessor::FindConnectedPlayer(m_guid); } private: - uint32 m_guildId; + ObjectGuid::LowType m_guildId; // Fields from characters table ObjectGuid m_guid; std::string m_name; @@ -367,8 +367,8 @@ private: class LogEntry { public: - LogEntry(uint32 guildId, uint32 guid) : m_guildId(guildId), m_guid(guid), m_timestamp(::time(NULL)) { } - LogEntry(uint32 guildId, uint32 guid, time_t timestamp) : m_guildId(guildId), m_guid(guid), m_timestamp(timestamp) { } + LogEntry(ObjectGuid::LowType guildId, uint32 guid) : m_guildId(guildId), m_guid(guid), m_timestamp(::time(NULL)) { } + LogEntry(ObjectGuid::LowType guildId, uint32 guid, time_t timestamp) : m_guildId(guildId), m_guid(guid), m_timestamp(timestamp) { } virtual ~LogEntry() { } uint32 GetGUID() const { return m_guid; } @@ -378,7 +378,7 @@ private: virtual void WritePacket(WorldPacket& data) const = 0; protected: - uint32 m_guildId; + ObjectGuid::LowType m_guildId; uint32 m_guid; uint64 m_timestamp; }; @@ -387,10 +387,10 @@ private: class EventLogEntry : public LogEntry { public: - EventLogEntry(uint32 guildId, uint32 guid, GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) : + EventLogEntry(ObjectGuid::LowType guildId, uint32 guid, GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank) : LogEntry(guildId, guid), m_eventType(eventType), m_playerGuid1(playerGuid1), m_playerGuid2(playerGuid2), m_newRank(newRank) { } - EventLogEntry(uint32 guildId, uint32 guid, time_t timestamp, GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) : + EventLogEntry(ObjectGuid::LowType guildId, uint32 guid, time_t timestamp, GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank) : LogEntry(guildId, guid, timestamp), m_eventType(eventType), m_playerGuid1(playerGuid1), m_playerGuid2(playerGuid2), m_newRank(newRank) { } ~EventLogEntry() { } @@ -400,8 +400,8 @@ private: private: GuildEventLogTypes m_eventType; - uint32 m_playerGuid1; - uint32 m_playerGuid2; + ObjectGuid::LowType m_playerGuid1; + ObjectGuid::LowType m_playerGuid2; uint8 m_newRank; }; @@ -417,11 +417,11 @@ private: eventType == GUILD_BANK_LOG_REPAIR_MONEY; } - BankEventLogEntry(uint32 guildId, uint32 guid, GuildBankEventLogTypes eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) : + BankEventLogEntry(ObjectGuid::LowType guildId, uint32 guid, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) : LogEntry(guildId, guid), m_eventType(eventType), m_bankTabId(tabId), m_playerGuid(playerGuid), m_itemOrMoney(itemOrMoney), m_itemStackCount(itemStackCount), m_destTabId(destTabId) { } - BankEventLogEntry(uint32 guildId, uint32 guid, time_t timestamp, uint8 tabId, GuildBankEventLogTypes eventType, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) : + BankEventLogEntry(ObjectGuid::LowType guildId, uint32 guid, time_t timestamp, uint8 tabId, GuildBankEventLogTypes eventType, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) : LogEntry(guildId, guid, timestamp), m_eventType(eventType), m_bankTabId(tabId), m_playerGuid(playerGuid), m_itemOrMoney(itemOrMoney), m_itemStackCount(itemStackCount), m_destTabId(destTabId) { } @@ -433,7 +433,7 @@ private: private: GuildBankEventLogTypes m_eventType; uint8 m_bankTabId; - uint32 m_playerGuid; + ObjectGuid::LowType m_playerGuid; uint32 m_itemOrMoney; uint16 m_itemStackCount; uint8 m_destTabId; @@ -470,8 +470,8 @@ private: { public: RankInfo(): m_guildId(0), m_rankId(GUILD_RANK_NONE), m_rights(GR_RIGHT_EMPTY), m_bankMoneyPerDay(0) { } - RankInfo(uint32 guildId) : m_guildId(guildId), m_rankId(GUILD_RANK_NONE), m_rights(GR_RIGHT_EMPTY), m_bankMoneyPerDay(0) { } - RankInfo(uint32 guildId, uint8 rankId, std::string const& name, uint32 rights, uint32 money) : + RankInfo(ObjectGuid::LowType guildId) : m_guildId(guildId), m_rankId(GUILD_RANK_NONE), m_rights(GR_RIGHT_EMPTY), m_bankMoneyPerDay(0) { } + RankInfo(ObjectGuid::LowType guildId, uint8 rankId, std::string const& name, uint32 rights, uint32 money) : m_guildId(guildId), m_rankId(rankId), m_name(name), m_rights(rights), m_bankMoneyPerDay(rankId != GR_GUILDMASTER ? money : GUILD_WITHDRAW_MONEY_UNLIMITED) { } @@ -505,7 +505,7 @@ private: void CreateMissingTabsIfNeeded(uint8 ranks, SQLTransaction& trans, bool logOnCreate = false); private: - uint32 m_guildId; + ObjectGuid::LowType m_guildId; uint8 m_rankId; std::string m_name; @@ -517,7 +517,7 @@ private: class BankTab { public: - BankTab(uint32 guildId, uint8 tabId) : m_guildId(guildId), m_tabId(tabId) + BankTab(ObjectGuid::LowType guildId, uint8 tabId) : m_guildId(guildId), m_tabId(tabId) { memset(m_items, 0, GUILD_BANK_MAX_SLOTS * sizeof(Item*)); } @@ -542,7 +542,7 @@ private: bool SetItem(SQLTransaction& trans, uint8 slotId, Item* pItem); private: - uint32 m_guildId; + ObjectGuid::LowType m_guildId; uint8 m_tabId; Item* m_items[GUILD_BANK_MAX_SLOTS]; @@ -653,7 +653,7 @@ public: void Disband(); // Getters - uint32 GetId() const { return m_id; } + ObjectGuid::LowType GetId() const { return m_id; } ObjectGuid GetLeaderGUID() const { return m_leaderGuid; } std::string const& GetName() const { return m_name; } std::string const& GetMOTD() const { return m_motd; } @@ -745,7 +745,7 @@ public: void ResetTimes(); protected: - uint32 m_id; + ObjectGuid::LowType m_id; std::string m_name; ObjectGuid m_leaderGuid; std::string m_motd; @@ -803,7 +803,7 @@ private: return NULL; } - inline void _DeleteMemberFromDB(uint32 lowguid) const + inline void _DeleteMemberFromDB(ObjectGuid::LowType lowguid) const { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_MEMBER); stmt->setUInt32(0, lowguid); @@ -838,8 +838,8 @@ private: void _UpdateMemberWithdrawSlots(SQLTransaction& trans, ObjectGuid guid, uint8 tabId); bool _MemberHasTabRights(ObjectGuid guid, uint8 tabId, uint32 rights) const; - void _LogEvent(GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2 = 0, uint8 newRank = 0); - void _LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount = 0, uint8 destTabId = 0); + void _LogEvent(GuildEventLogTypes eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2 = 0, uint8 newRank = 0); + void _LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount = 0, uint8 destTabId = 0); Item* _GetItem(uint8 tabId, uint8 slotId) const; void _RemoveItem(SQLTransaction& trans, uint8 tabId, uint8 slotId); diff --git a/src/server/game/Guilds/GuildMgr.cpp b/src/server/game/Guilds/GuildMgr.cpp index 2603a60ee0e..6a75761ded0 100644 --- a/src/server/game/Guilds/GuildMgr.cpp +++ b/src/server/game/Guilds/GuildMgr.cpp @@ -32,12 +32,12 @@ void GuildMgr::AddGuild(Guild* guild) GuildStore[guild->GetId()] = guild; } -void GuildMgr::RemoveGuild(uint32 guildId) +void GuildMgr::RemoveGuild(ObjectGuid::LowType guildId) { GuildStore.erase(guildId); } -uint32 GuildMgr::GenerateGuildId() +ObjectGuid::LowType GuildMgr::GenerateGuildId() { if (NextGuildId >= 0xFFFFFFFE) { @@ -48,7 +48,7 @@ uint32 GuildMgr::GenerateGuildId() } // Guild collection -Guild* GuildMgr::GetGuildById(uint32 guildId) const +Guild* GuildMgr::GetGuildById(ObjectGuid::LowType guildId) const { GuildContainer::const_iterator itr = GuildStore.find(guildId); if (itr != GuildStore.end()) @@ -71,7 +71,7 @@ Guild* GuildMgr::GetGuildByName(const std::string& guildName) const return NULL; } -std::string GuildMgr::GetGuildNameById(uint32 guildId) const +std::string GuildMgr::GetGuildNameById(ObjectGuid::LowType guildId) const { if (Guild* guild = GetGuildById(guildId)) return guild->GetName(); diff --git a/src/server/game/Guilds/GuildMgr.h b/src/server/game/Guilds/GuildMgr.h index 2a73d53a740..1450769c578 100644 --- a/src/server/game/Guilds/GuildMgr.h +++ b/src/server/game/Guilds/GuildMgr.h @@ -34,21 +34,21 @@ public: } Guild* GetGuildByLeader(ObjectGuid guid) const; - Guild* GetGuildById(uint32 guildId) const; + Guild* GetGuildById(ObjectGuid::LowType guildId) const; Guild* GetGuildByName(std::string const& guildName) const; - std::string GetGuildNameById(uint32 guildId) const; + std::string GetGuildNameById(ObjectGuid::LowType guildId) const; void LoadGuilds(); void AddGuild(Guild* guild); - void RemoveGuild(uint32 guildId); + void RemoveGuild(ObjectGuid::LowType guildId); - uint32 GenerateGuildId(); - void SetNextGuildId(uint32 Id) { NextGuildId = Id; } + ObjectGuid::LowType GenerateGuildId(); + void SetNextGuildId(ObjectGuid::LowType Id) { NextGuildId = Id; } void ResetTimes(); protected: - typedef std::unordered_map<uint32, Guild*> GuildContainer; - uint32 NextGuildId; + typedef std::unordered_map<ObjectGuid::LowType, Guild*> GuildContainer; + ObjectGuid::LowType NextGuildId; GuildContainer GuildStore; }; diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp index 0293901c9e3..8ecf86680ca 100644 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -265,6 +265,8 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData) if (!auctioneerData) { TC_LOG_ERROR("misc", "Data for auctioneer not found (%s)", auctioneer.ToString().c_str()); + SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR); + delete AH; return; } @@ -272,6 +274,8 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData) if (!auctioneerInfo) { TC_LOG_ERROR("misc", "Non existing auctioneer (%s)", auctioneer.ToString().c_str()); + SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR); + delete AH; return; } diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp index fec0b8e0d40..d4291e34df6 100644 --- a/src/server/game/Handlers/BattleGroundHandler.cpp +++ b/src/server/game/Handlers/BattleGroundHandler.cpp @@ -506,6 +506,16 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData) sBattlegroundMgr->ScheduleQueueUpdate(ginfo.ArenaMatchmakerRating, ginfo.ArenaType, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId()); SendPacket(&data); TC_LOG_DEBUG("bg.battleground", "Battleground: player %s (%u) left queue for bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUID().GetCounter(), bg->GetTypeID(), bgQueueTypeId); + + // track if player refuses to join the BG after being invited + if (bg->isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS) && + (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN)) + { + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK); + stmt->setUInt32(0, _player->GetGUID().GetCounter()); + stmt->setUInt8(1, BG_DESERTION_TYPE_LEAVE_QUEUE); + CharacterDatabase.Execute(stmt); + } } } diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index ba22ab6aa07..e5b32f548f9 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -65,7 +65,7 @@ bool LoginQueryHolder::Initialize() SetSize(MAX_PLAYER_LOGIN_QUERY); bool res = true; - uint32 lowGuid = m_guid.GetCounter(); + ObjectGuid::LowType lowGuid = m_guid.GetCounter(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER); stmt->setUInt32(0, lowGuid); @@ -231,8 +231,8 @@ void WorldSession::HandleCharEnum(PreparedQueryResult result) if (!(*result)[20].GetUInt32()) _legitCharacters.insert(guid); - if (!sWorld->HasCharacterNameData(guid)) // This can happen if characters are inserted into the database manually. Core hasn't loaded name data yet. - sWorld->AddCharacterNameData(guid, (*result)[1].GetString(), (*result)[4].GetUInt8(), (*result)[2].GetUInt8(), (*result)[3].GetUInt8(), (*result)[7].GetUInt8()); + if (!sWorld->HasCharacterInfo(guid)) // This can happen if characters are inserted into the database manually. Core hasn't loaded name data yet. + sWorld->AddCharacterInfo(guid, GetAccountId(), (*result)[1].GetString(), (*result)[4].GetUInt8(), (*result)[2].GetUInt8(), (*result)[3].GetUInt8(), (*result)[7].GetUInt8()); ++num; } } @@ -363,7 +363,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData) } // check name limitations - ResponseCodes res = ObjectMgr::CheckPlayerName(createInfo.Name, true); + ResponseCodes res = ObjectMgr::CheckPlayerName(createInfo.Name, GetSessionDbcLocale(), true); if (res != CHAR_NAME_SUCCESS) { SendCharCreate(res); @@ -433,14 +433,11 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte } case 1: { - uint16 acctCharCount = 0; + uint64 acctCharCount = 0; if (result) { Field* fields = result->Fetch(); - // SELECT SUM(x) is MYSQL_TYPE_NEWDECIMAL - needs to be read as string - const char* ch = fields[0].GetCString(); - if (ch) - acctCharCount = atoi(ch); + acctCharCount = uint64(fields[0].GetDouble()); } if (acctCharCount >= sWorld->getIntConfig(CONFIG_CHARACTERS_PER_ACCOUNT)) @@ -645,7 +642,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte TC_LOG_INFO("entities.player.character", "Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), GetRemoteAddress().c_str(), createInfo->Name.c_str(), newChar.GetGUID().GetCounter()); sScriptMgr->OnPlayerCreate(&newChar); - sWorld->AddCharacterNameData(newChar.GetGUID(), newChar.GetName(), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel()); + sWorld->AddCharacterInfo(newChar.GetGUID(), GetAccountId(), newChar.GetName(), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel()); newChar.CleanupsBeforeDelete(); delete createInfo; @@ -887,7 +884,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) } } - if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar) || !pCurrChar->CheckInstanceLoginValid()) + if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar)) { AreaTrigger const* at = sObjectMgr->GetGoBackTrigger(pCurrChar->GetMapId()); if (at) @@ -1095,7 +1092,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recvData) return; } - ResponseCodes res = ObjectMgr::CheckPlayerName(renameInfo.Name, true); + ResponseCodes res = ObjectMgr::CheckPlayerName(renameInfo.Name, GetSessionDbcLocale(), true); if (res != CHAR_NAME_SUCCESS) { SendCharRename(res, renameInfo); @@ -1134,7 +1131,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult resu Field* fields = result->Fetch(); - uint32 guidLow = fields[0].GetUInt32(); + ObjectGuid::LowType guidLow = fields[0].GetUInt32(); std::string oldName = fields[1].GetString(); // Update name and at_login flag in the db @@ -1157,7 +1154,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult resu SendCharRename(RESPONSE_SUCCESS, *renameInfo); - sWorld->UpdateCharacterNameData(renameInfo->Guid, renameInfo->Name); + sWorld->UpdateCharacterInfo(renameInfo->Guid, renameInfo->Name); } void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData) @@ -1394,7 +1391,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData) return; } - ResponseCodes res = ObjectMgr::CheckPlayerName(customizeInfo.Name, true); + ResponseCodes res = ObjectMgr::CheckPlayerName(customizeInfo.Name, GetSessionDbcLocale(), true); if (res != CHAR_NAME_SUCCESS) { SendCharCustomize(res, customizeInfo); @@ -1447,7 +1444,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData) CharacterDatabase.CommitTransaction(trans); - sWorld->UpdateCharacterNameData(customizeInfo.Guid, customizeInfo.Name, customizeInfo.Gender); + sWorld->UpdateCharacterInfo(customizeInfo.Guid, customizeInfo.Name, customizeInfo.Gender); SendCharCustomize(RESPONSE_SUCCESS, customizeInfo); } @@ -1593,19 +1590,19 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) >> factionChangeInfo.Face >> factionChangeInfo.Race; - uint32 lowGuid = factionChangeInfo.Guid.GetCounter(); + ObjectGuid::LowType lowGuid = factionChangeInfo.Guid.GetCounter(); // get the players old (at this moment current) race - CharacterNameData const* nameData = sWorld->GetCharacterNameData(factionChangeInfo.Guid); + CharacterInfo const* nameData = sWorld->GetCharacterInfo(factionChangeInfo.Guid); if (!nameData) { SendCharFactionChange(CHAR_CREATE_ERROR, factionChangeInfo); return; } - uint8 oldRace = nameData->m_race; - uint8 playerClass = nameData->m_class; - uint8 level = nameData->m_level; + uint8 oldRace = nameData->Race; + uint8 playerClass = nameData->Class; + uint8 level = nameData->Level; // TO Do: Make async PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_AT_LOGIN_TITLES); @@ -1652,7 +1649,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) return; } - ResponseCodes res = ObjectMgr::CheckPlayerName(factionChangeInfo.Name, true); + ResponseCodes res = ObjectMgr::CheckPlayerName(factionChangeInfo.Name, GetSessionDbcLocale(), true); if (res != CHAR_NAME_SUCCESS) { SendCharFactionChange(res, factionChangeInfo); @@ -1695,7 +1692,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) stmt->setUInt32(0, lowGuid); trans->Append(stmt); - sWorld->UpdateCharacterNameData(factionChangeInfo.Guid, factionChangeInfo.Name, factionChangeInfo.Gender, factionChangeInfo.Race); + sWorld->UpdateCharacterInfo(factionChangeInfo.Guid, factionChangeInfo.Name, factionChangeInfo.Gender, factionChangeInfo.Race); if (oldRace != factionChangeInfo.Race) { diff --git a/src/server/game/Handlers/DuelHandler.cpp b/src/server/game/Handlers/DuelHandler.cpp index 6e8ff5547d7..2f39a91afbe 100644 --- a/src/server/game/Handlers/DuelHandler.cpp +++ b/src/server/game/Handlers/DuelHandler.cpp @@ -43,9 +43,6 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket) TC_LOG_DEBUG("network", "Player 1 is: %u (%s)", player->GetGUID().GetCounter(), player->GetName().c_str()); TC_LOG_DEBUG("network", "Player 2 is: %u (%s)", plTarget->GetGUID().GetCounter(), plTarget->GetName().c_str()); - player->UpdateHasCoolDownBeforeDuel(); - plTarget->UpdateHasCoolDownBeforeDuel(); - time_t now = time(NULL); player->duel->startTimer = now; plTarget->duel->startTimer = now; diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index 13987c983f7..b1f46c381bf 100644 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -786,8 +786,7 @@ void WorldSession::SendListInventory(ObjectGuid vendorGuid) if (!_player->IsGameMaster() && !leftInStock) continue; - ConditionList conditions = sConditionMgr->GetConditionsForNpcVendorEvent(vendor->GetEntry(), item->item); - if (!sConditionMgr->IsObjectMeetToConditions(_player, vendor, conditions)) + if (!sConditionMgr->IsObjectMeetingVendorItemConditions(vendor->GetEntry(), item->item, _player, vendor)) { TC_LOG_DEBUG("condition", "SendListInventory: conditions not met for creature entry %u item %u", vendor->GetEntry(), item->item); continue; diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index 4495c044c61..8c3c3e9082b 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -600,7 +600,7 @@ void WorldSession::HandlePetRename(WorldPacket& recvData) pet->GetOwnerGUID() != _player->GetGUID() || !pet->GetCharmInfo()) return; - PetNameInvalidReason res = ObjectMgr::CheckPetName(name); + PetNameInvalidReason res = ObjectMgr::CheckPetName(name, GetSessionDbcLocale()); if (res != PET_NAME_SUCCESS) { SendPetNameInvalid(res, name, NULL); diff --git a/src/server/game/Handlers/PetitionsHandler.cpp b/src/server/game/Handlers/PetitionsHandler.cpp index c7a3f419d62..952659dcea5 100644 --- a/src/server/game/Handlers/PetitionsHandler.cpp +++ b/src/server/game/Handlers/PetitionsHandler.cpp @@ -243,7 +243,7 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData) ObjectGuid petitionguid; recvData >> petitionguid; // petition guid - uint32 petitionGuidLow = petitionguid.GetCounter(); + ObjectGuid::LowType petitionGuidLow = petitionguid.GetCounter(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_TYPE); @@ -284,7 +284,7 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData) for (uint8 i = 1; i <= signs; ++i) { Field* fields2 = result->Fetch(); - uint32 lowGuid = fields2[0].GetUInt32(); + ObjectGuid::LowType lowGuid = fields2[0].GetUInt32(); data << ObjectGuid(HighGuid::Player, 0, lowGuid); // Player GUID data << uint32(0); // there 0 ... @@ -298,7 +298,7 @@ void WorldSession::HandlePetitionQueryOpcode(WorldPacket& recvData) { TC_LOG_DEBUG("network", "Received opcode CMSG_PETITION_QUERY"); // ok - uint32 guildguid; + ObjectGuid::LowType guildguid; ObjectGuid petitionguid; recvData >> guildguid; // in Trinity always same as GUID_LOPART(petitionguid) recvData >> petitionguid; // petition guid @@ -470,7 +470,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket& recvData) uint64 signs = fields[1].GetUInt64(); uint8 type = fields[2].GetUInt8(); - uint32 playerGuid = _player->GetGUID().GetCounter(); + ObjectGuid::LowType playerGuid = _player->GetGUID().GetCounter(); if (ownerGuid == _player->GetGUID()) return; @@ -735,7 +735,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recvData) TC_LOG_DEBUG("network", "Petition %s turned in by %u", petitionGuid.ToString().c_str(), _player->GetGUID().GetCounter()); // Get petition data from db - uint32 ownerguidlo; + ObjectGuid::LowType ownerguidlo; uint32 type; std::string name; diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp index 6d896bee26c..153ce736946 100644 --- a/src/server/game/Handlers/QueryHandler.cpp +++ b/src/server/game/Handlers/QueryHandler.cpp @@ -31,7 +31,7 @@ void WorldSession::SendNameQueryOpcode(ObjectGuid guid) { Player* player = ObjectAccessor::FindConnectedPlayer(guid); - CharacterNameData const* nameData = sWorld->GetCharacterNameData(guid); + CharacterInfo const* nameData = sWorld->GetCharacterInfo(guid); WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+10)); data << guid.WriteAsPacked(); @@ -43,11 +43,11 @@ void WorldSession::SendNameQueryOpcode(ObjectGuid guid) } data << uint8(0); // name known - data << nameData->m_name; // played name + data << nameData->Name; // played name data << uint8(0); // realm name - only set for cross realm interaction (such as Battlegrounds) - data << uint8(nameData->m_race); - data << uint8(nameData->m_gender); - data << uint8(nameData->m_class); + data << uint8(nameData->Race); + data << uint8(nameData->Sex); + data << uint8(nameData->Class); if (DeclinedName const* names = (player ? player->GetDeclinedNames() : NULL)) { @@ -96,9 +96,9 @@ void WorldSession::HandleCreatureQueryOpcode(WorldPacket& recvData) CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(entry); if (ci) { - std::string Name, SubName; + std::string Name, Title; Name = ci->Name; - SubName = ci->SubName; + Title = ci->Title; int loc_idx = GetSessionDbLocaleIndex(); if (loc_idx >= 0) @@ -106,7 +106,7 @@ void WorldSession::HandleCreatureQueryOpcode(WorldPacket& recvData) if (CreatureLocale const* cl = sObjectMgr->GetCreatureLocale(entry)) { ObjectMgr::GetLocaleString(cl->Name, loc_idx, Name); - ObjectMgr::GetLocaleString(cl->SubName, loc_idx, SubName); + ObjectMgr::GetLocaleString(cl->Title, loc_idx, Title); } } TC_LOG_DEBUG("network", "WORLD: CMSG_CREATURE_QUERY '%s' - Entry: %u.", ci->Name.c_str(), entry); @@ -115,7 +115,7 @@ void WorldSession::HandleCreatureQueryOpcode(WorldPacket& recvData) data << uint32(entry); // creature entry data << Name; data << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4, always empty - data << SubName; + data << Title; data << ci->IconName; // "Directions" for guard, string for Icons 2.3.0 data << uint32(ci->type_flags); // flags data << uint32(ci->type); // CreatureType.dbc diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp index 91bc8309b18..fd7c4439c8f 100644 --- a/src/server/game/Handlers/QuestHandler.cpp +++ b/src/server/game/Handlers/QuestHandler.cpp @@ -124,8 +124,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvData) if (Player* playerQuestObject = object->ToPlayer()) { - if ((_player->GetDivider() && _player->GetDivider() != guid) || - ((object != _player && !playerQuestObject->CanShareQuest(questId)))) + if ((_player->GetDivider() && _player->GetDivider() != guid) || !playerQuestObject->CanShareQuest(questId)) { CLOSE_GOSSIP_CLEAR_DIVIDER(); return; diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp index 5d44f3ec696..a8cf42ea49e 100644 --- a/src/server/game/Instances/InstanceScript.cpp +++ b/src/server/game/Instances/InstanceScript.cpp @@ -652,3 +652,25 @@ void InstanceScript::UpdateEncounterState(EncounterCreditType type, uint32 credi } } } + +std::string InstanceScript::GetBossStateName(uint8 state) +{ + // See enum EncounterState in InstanceScript.h + switch (state) + { + case NOT_STARTED: + return "NOT_STARTED"; + case IN_PROGRESS: + return "IN_PROGRESS"; + case FAIL: + return "FAIL"; + case DONE: + return "DONE"; + case SPECIAL: + return "SPECIAL"; + case TO_BE_DECIDED: + return "TO_BE_DECIDED"; + default: + return "INVALID"; + } +} diff --git a/src/server/game/Instances/InstanceScript.h b/src/server/game/Instances/InstanceScript.h index e832d7cdffe..93dafea0413 100644 --- a/src/server/game/Instances/InstanceScript.h +++ b/src/server/game/Instances/InstanceScript.h @@ -220,6 +220,7 @@ class InstanceScript : public ZoneScript virtual bool SetBossState(uint32 id, EncounterState state); EncounterState GetBossState(uint32 id) const { return id < bosses.size() ? bosses[id].state : TO_BE_DECIDED; } + static std::string GetBossStateName(uint8 state); BossBoundaryMap const* GetBossBoundary(uint32 id) const { return id < bosses.size() ? &bosses[id].boundary : NULL; } // Achievement criteria additional requirements check diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp index 22ebe6c679e..b7a19a72bf5 100644 --- a/src/server/game/Loot/LootMgr.cpp +++ b/src/server/game/Loot/LootMgr.cpp @@ -95,7 +95,7 @@ class LootTemplate::LootGroup // A set of loot def void CheckLootRefs(LootTemplateMap const& store, LootIdSet* ref_set) const; LootStoreItemList* GetExplicitlyChancedItemList() { return &ExplicitlyChanced; } LootStoreItemList* GetEqualChancedItemList() { return &EqualChanced; } - void CopyConditions(ConditionList conditions); + void CopyConditions(ConditionContainer conditions); private: LootStoreItemList ExplicitlyChanced; // Entries with chances defined in DB LootStoreItemList EqualChanced; // Zero chances - every entry takes the same chance @@ -218,7 +218,7 @@ void LootStore::ResetConditions() { for (LootTemplateMap::iterator itr = m_LootTemplates.begin(); itr != m_LootTemplates.end(); ++itr) { - ConditionList empty; + ConditionContainer empty; itr->second->CopyConditions(empty); } } @@ -481,7 +481,7 @@ bool Loot::FillLoot(uint32 lootId, LootStore const& store, Player* lootOwner, bo void Loot::FillNotNormalLootFor(Player* player, bool presentAtLooting) { - uint32 plguid = player->GetGUID().GetCounter(); + ObjectGuid::LowType plguid = player->GetGUID().GetCounter(); QuestItemMap::const_iterator qmapitr = PlayerQuestItems.find(plguid); if (qmapitr == PlayerQuestItems.end()) @@ -1155,7 +1155,7 @@ bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const* player) const return false; } -void LootTemplate::LootGroup::CopyConditions(ConditionList /*conditions*/) +void LootTemplate::LootGroup::CopyConditions(ConditionContainer /*conditions*/) { for (LootStoreItemList::iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) (*i)->conditions.clear(); @@ -1260,7 +1260,7 @@ void LootTemplate::AddEntry(LootStoreItem* item) Entries.push_back(item); } -void LootTemplate::CopyConditions(const ConditionList& conditions) +void LootTemplate::CopyConditions(const ConditionContainer& conditions) { for (LootStoreItemList::iterator i = Entries.begin(); i != Entries.end(); ++i) (*i)->conditions.clear(); diff --git a/src/server/game/Loot/LootMgr.h b/src/server/game/Loot/LootMgr.h index 7d7580fd49f..08cd224cd0b 100644 --- a/src/server/game/Loot/LootMgr.h +++ b/src/server/game/Loot/LootMgr.h @@ -132,7 +132,7 @@ struct LootStoreItem uint8 groupid : 7; uint8 mincount; // mincount for drop items uint8 maxcount; // max drop count for the item mincount or Ref multiplicator - ConditionList conditions; // additional loot condition + ConditionContainer conditions; // additional loot condition // Constructor // displayid is filled in IsValid() which must be called after @@ -146,14 +146,14 @@ struct LootStoreItem // Checks correctness of values }; -typedef std::set<uint32> AllowedLooterSet; +typedef std::set<ObjectGuid::LowType> AllowedLooterSet; struct LootItem { uint32 itemid; uint32 randomSuffix; int32 randomPropertyId; - ConditionList conditions; // additional loot condition + ConditionContainer conditions; // additional loot condition AllowedLooterSet allowedGUIDs; uint8 count : 8; bool is_looted : 1; @@ -252,7 +252,7 @@ class LootTemplate void AddEntry(LootStoreItem* item); // Rolls for every item in the template and adds the rolled items the the loot void Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId = 0) const; - void CopyConditions(const ConditionList& conditions); + void CopyConditions(const ConditionContainer& conditions); void CopyConditions(LootItem* li) const; // True if template includes at least 1 quest drop entry diff --git a/src/server/game/Mails/Mail.cpp b/src/server/game/Mails/Mail.cpp index fd9392fb62f..78cd4d3692c 100644 --- a/src/server/game/Mails/Mail.cpp +++ b/src/server/game/Mails/Mail.cpp @@ -72,7 +72,7 @@ MailSender::MailSender(Player* sender) MailReceiver::MailReceiver(Player* receiver) : m_receiver(receiver), m_receiver_lowguid(receiver->GetGUID().GetCounter()) { } -MailReceiver::MailReceiver(Player* receiver, uint32 receiver_lowguid) : m_receiver(receiver), m_receiver_lowguid(receiver_lowguid) +MailReceiver::MailReceiver(Player* receiver, ObjectGuid::LowType receiver_lowguid) : m_receiver(receiver), m_receiver_lowguid(receiver_lowguid) { ASSERT(!receiver || receiver->GetGUID().GetCounter() == receiver_lowguid); } @@ -127,7 +127,7 @@ void MailDraft::deleteIncludedItems(SQLTransaction& trans, bool inDB /*= false*/ m_items.clear(); } -void MailDraft::SendReturnToSender(uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid, SQLTransaction& trans) +void MailDraft::SendReturnToSender(uint32 sender_acc, ObjectGuid::LowType sender_guid, ObjectGuid::LowType receiver_guid, SQLTransaction& trans) { ObjectGuid receiverGuid(HighGuid::Player, receiver_guid); Player* receiver = ObjectAccessor::FindConnectedPlayer(receiverGuid); diff --git a/src/server/game/Mails/Mail.h b/src/server/game/Mails/Mail.h index f4f155c5926..f044996bd0a 100644 --- a/src/server/game/Mails/Mail.h +++ b/src/server/game/Mails/Mail.h @@ -20,6 +20,7 @@ #define TRINITY_MAIL_H #include "Common.h" +#include "ObjectGuid.h" #include <map> struct AuctionEntry; @@ -81,7 +82,7 @@ enum MailShowFlags class MailSender { public: // Constructors - MailSender(MailMessageType messageType, uint32 sender_guidlow_or_entry, MailStationery stationery = MAIL_STATIONERY_DEFAULT) + MailSender(MailMessageType messageType, ObjectGuid::LowType sender_guidlow_or_entry, MailStationery stationery = MAIL_STATIONERY_DEFAULT) : m_messageType(messageType), m_senderId(sender_guidlow_or_entry), m_stationery(stationery) { } @@ -91,31 +92,31 @@ class MailSender MailSender(Player* sender); public: // Accessors MailMessageType GetMailMessageType() const { return m_messageType; } - uint32 GetSenderId() const { return m_senderId; } + ObjectGuid::LowType GetSenderId() const { return m_senderId; } MailStationery GetStationery() const { return m_stationery; } private: MailMessageType m_messageType; - uint32 m_senderId; // player low guid or other object entry + ObjectGuid::LowType m_senderId; // player low guid or other object entry MailStationery m_stationery; }; class MailReceiver { public: // Constructors - explicit MailReceiver(uint32 receiver_lowguid) : m_receiver(NULL), m_receiver_lowguid(receiver_lowguid) { } + explicit MailReceiver(ObjectGuid::LowType receiver_lowguid) : m_receiver(NULL), m_receiver_lowguid(receiver_lowguid) { } MailReceiver(Player* receiver); - MailReceiver(Player* receiver, uint32 receiver_lowguid); + MailReceiver(Player* receiver, ObjectGuid::LowType receiver_lowguid); public: // Accessors Player* GetPlayer() const { return m_receiver; } - uint32 GetPlayerGUIDLow() const { return m_receiver_lowguid; } + ObjectGuid::LowType GetPlayerGUIDLow() const { return m_receiver_lowguid; } private: Player* m_receiver; - uint32 m_receiver_lowguid; + ObjectGuid::LowType m_receiver_lowguid; }; class MailDraft { - typedef std::map<uint32, Item*> MailItemMap; + typedef std::map<ObjectGuid::LowType, Item*> MailItemMap; public: // Constructors explicit MailDraft(uint16 mailTemplateId, bool need_items = true) @@ -136,7 +137,7 @@ class MailDraft MailDraft& AddCOD(uint32 COD) { m_COD = COD; return *this; } public: // finishers - void SendReturnToSender(uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid, SQLTransaction& trans); + void SendReturnToSender(uint32 sender_acc, ObjectGuid::LowType sender_guid, ObjectGuid::LowType receiver_guid, SQLTransaction& trans); void SendMailTo(SQLTransaction& trans, MailReceiver const& receiver, MailSender const& sender, MailCheckMask checked = MAIL_CHECK_MASK_NONE, uint32 deliver_delay = 0); private: @@ -156,7 +157,7 @@ class MailDraft struct MailItemInfo { - uint32 item_guid; + ObjectGuid::LowType item_guid; uint32 item_template; }; typedef std::vector<MailItemInfo> MailItemInfoVec; @@ -167,12 +168,12 @@ struct Mail uint8 messageType; uint8 stationery; uint16 mailTemplateId; - uint32 sender; - uint32 receiver; + ObjectGuid::LowType sender; + ObjectGuid::LowType receiver; std::string subject; std::string body; std::vector<MailItemInfo> items; - std::vector<uint32> removedItems; + std::vector<ObjectGuid::LowType> removedItems; time_t expire_time; time_t deliver_time; uint32 money; @@ -180,7 +181,7 @@ struct Mail uint32 checked; MailState state; - void AddItem(uint32 itemGuidLow, uint32 item_template) + void AddItem(ObjectGuid::LowType itemGuidLow, uint32 item_template) { MailItemInfo mii; mii.item_guid = itemGuidLow; @@ -188,7 +189,7 @@ struct Mail items.push_back(mii); } - bool RemoveItem(uint32 item_guid) + bool RemoveItem(ObjectGuid::LowType item_guid) { for (MailItemInfoVec::iterator itr = items.begin(); itr != items.end(); ++itr) { diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 2af77ffdec3..4893b742a16 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -299,6 +299,25 @@ void Map::AddToGrid(DynamicObject* obj, Cell const& cell) obj->SetCurrentCell(cell); } +template<> +void Map::AddToGrid(Corpse* obj, Cell const& cell) +{ + NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); + if (obj->IsWorldObject()) + { + // Corpses are a special object type - they can be added to grid via a call to AddToMap + // or loaded through ObjectGridLoader. + // Both corpses loaded from database and these freshly generated by Player::CreateCoprse are added to _corpsesByCell + // ObjectGridLoader loads all corpses from _corpsesByCell even if they were already added to grid before it was loaded + // so we need to explicitly check it here (Map::AddToGrid is only called from Player::BuildPlayerRepop, not from ObjectGridLoader) + // to avoid failing an assertion in GridObject::AddToGrid + if (grid->isGridObjectDataLoaded()) + grid->GetGridType(cell.CellX(), cell.CellY()).AddWorldObject(obj); + } + else + grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj); // bones. nothing special here +} + template<class T> void Map::SwitchGridContainers(T* /*obj*/, bool /*on*/) { } @@ -1601,6 +1620,20 @@ void Map::UnloadAll() RemoveFromMap<Transport>(transport, true); } + + for (auto& cellCorpsePair : _corpsesByCell) + { + for (Corpse* corpse : cellCorpsePair.second) + { + corpse->RemoveFromWorld(); + corpse->ResetMap(); + delete corpse; + } + } + + _corpsesByCell.clear(); + _corpsesByPlayer.clear(); + _corpseBones.clear(); } // ***************************** @@ -3216,8 +3249,8 @@ void InstanceMap::PermBindAllPlayers(Player* source) WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4); data << uint32(0); player->GetSession()->SendPacket(&data); - - player->GetSession()->SendCalendarRaidLockout(save, true); + if (!player->IsGameMaster()) + player->GetSession()->SendCalendarRaidLockout(save, true); } // if the leader is not in the instance the group will not get a perm bind @@ -3396,7 +3429,7 @@ void Map::UpdateIteratorBack(Player* player) m_mapRefIter = m_mapRefIter->nocheck_prev(); } -void Map::SaveCreatureRespawnTime(uint32 dbGuid, time_t respawnTime) +void Map::SaveCreatureRespawnTime(ObjectGuid::LowType dbGuid, time_t respawnTime) { if (!respawnTime) { @@ -3415,7 +3448,7 @@ void Map::SaveCreatureRespawnTime(uint32 dbGuid, time_t respawnTime) CharacterDatabase.Execute(stmt); } -void Map::RemoveCreatureRespawnTime(uint32 dbGuid) +void Map::RemoveCreatureRespawnTime(ObjectGuid::LowType dbGuid) { _creatureRespawnTimes.erase(dbGuid); @@ -3426,7 +3459,7 @@ void Map::RemoveCreatureRespawnTime(uint32 dbGuid) CharacterDatabase.Execute(stmt); } -void Map::SaveGORespawnTime(uint32 dbGuid, time_t respawnTime) +void Map::SaveGORespawnTime(ObjectGuid::LowType dbGuid, time_t respawnTime) { if (!respawnTime) { @@ -3445,7 +3478,7 @@ void Map::SaveGORespawnTime(uint32 dbGuid, time_t respawnTime) CharacterDatabase.Execute(stmt); } -void Map::RemoveGORespawnTime(uint32 dbGuid) +void Map::RemoveGORespawnTime(ObjectGuid::LowType dbGuid) { _goRespawnTimes.erase(dbGuid); @@ -3466,7 +3499,7 @@ void Map::LoadRespawnTimes() do { Field* fields = result->Fetch(); - uint32 loguid = fields[0].GetUInt32(); + ObjectGuid::LowType loguid = fields[0].GetUInt32(); uint32 respawnTime = fields[1].GetUInt32(); _creatureRespawnTimes[loguid] = time_t(respawnTime); @@ -3481,7 +3514,7 @@ void Map::LoadRespawnTimes() do { Field* fields = result->Fetch(); - uint32 loguid = fields[0].GetUInt32(); + ObjectGuid::LowType loguid = fields[0].GetUInt32(); uint32 respawnTime = fields[1].GetUInt32(); _goRespawnTimes[loguid] = time_t(respawnTime); @@ -3542,7 +3575,7 @@ void Map::LoadCorpseData() { Field* fields = result->Fetch(); CorpseType type = CorpseType(fields[13].GetUInt8()); - uint32 guid = fields[16].GetUInt32(); + ObjectGuid::LowType guid = fields[16].GetUInt32(); if (type >= MAX_CORPSE_TYPE || type == CORPSE_BONES) { TC_LOG_ERROR("misc", "Corpse (guid: %u) have wrong corpse type (%u), not loading.", guid, type); @@ -3575,14 +3608,16 @@ void Map::AddCorpse(Corpse* corpse) { corpse->SetMap(this); - CellCoord cellCoord = Trinity::ComputeCellCoord(corpse->GetPositionX(), corpse->GetPositionY()); - _corpsesByCell[cellCoord.GetId()].insert(corpse); - _corpsesByPlayer[corpse->GetOwnerGUID()] = corpse; + _corpsesByCell[corpse->GetCellCoord().GetId()].insert(corpse); + if (corpse->GetType() != CORPSE_BONES) + _corpsesByPlayer[corpse->GetOwnerGUID()] = corpse; + else + _corpseBones.insert(corpse); } void Map::RemoveCorpse(Corpse* corpse) { - ASSERT(corpse && corpse->GetType() != CORPSE_BONES); + ASSERT(corpse); corpse->DestroyForNearbyPlayers(); if (corpse->IsInGrid()) @@ -3593,9 +3628,11 @@ void Map::RemoveCorpse(Corpse* corpse) corpse->ResetMap(); } - CellCoord cellCoord = Trinity::ComputeCellCoord(corpse->GetPositionX(), corpse->GetPositionY()); - _corpsesByCell[cellCoord.GetId()].erase(corpse); - _corpsesByPlayer.erase(corpse->GetOwnerGUID()); + _corpsesByCell[corpse->GetCellCoord().GetId()].erase(corpse); + if (corpse->GetType() != CORPSE_BONES) + _corpsesByPlayer.erase(corpse->GetOwnerGUID()); + else + _corpseBones.erase(corpse); } Corpse* Map::ConvertCorpseToBones(ObjectGuid const& ownerGuid, bool insignia /*= false*/) @@ -3621,12 +3658,12 @@ Corpse* Map::ConvertCorpseToBones(ObjectGuid const& ownerGuid, bool insignia /*= { // Create bones, don't change Corpse bones = new Corpse(); - bones->Create(corpse->GetGUID().GetCounter(), this); + bones->Create(corpse->GetGUID().GetCounter()); for (uint8 i = OBJECT_FIELD_TYPE + 1; i < CORPSE_END; ++i) // don't overwrite guid and object type bones->SetUInt32Value(i, corpse->GetUInt32Value(i)); - bones->SetGridCoord(corpse->GetGridCoord()); + bones->SetCellCoord(corpse->GetCellCoord()); bones->Relocate(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetOrientation()); bones->SetPhaseMask(corpse->GetPhaseMask(), false); @@ -3637,6 +3674,8 @@ Corpse* Map::ConvertCorpseToBones(ObjectGuid const& ownerGuid, bool insignia /*= if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i)) bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0); + AddCorpse(bones); + // add bones in grid store if grid loaded where corpse placed AddToMap(bones); } @@ -3660,6 +3699,17 @@ void Map::RemoveOldCorpses() for (ObjectGuid const& ownerGuid : corpses) ConvertCorpseToBones(ownerGuid); + + std::vector<Corpse*> expiredBones; + for (Corpse* bones : _corpseBones) + if (bones->IsExpired(now)) + expiredBones.push_back(bones); + + for (Corpse* bones : expiredBones) + { + RemoveCorpse(bones); + delete bones; + } } void Map::SendZoneDynamicInfo(Player* player) diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 2ba5e10c82c..0962bcc9d6c 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -499,28 +499,28 @@ class Map : public GridRefManager<NGridType> RESPAWN TIMES */ time_t GetLinkedRespawnTime(ObjectGuid guid) const; - time_t GetCreatureRespawnTime(uint32 dbGuid) const + time_t GetCreatureRespawnTime(ObjectGuid::LowType dbGuid) const { - std::unordered_map<uint32 /*dbGUID*/, time_t>::const_iterator itr = _creatureRespawnTimes.find(dbGuid); + std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t>::const_iterator itr = _creatureRespawnTimes.find(dbGuid); if (itr != _creatureRespawnTimes.end()) return itr->second; return time_t(0); } - time_t GetGORespawnTime(uint32 dbGuid) const + time_t GetGORespawnTime(ObjectGuid::LowType dbGuid) const { - std::unordered_map<uint32 /*dbGUID*/, time_t>::const_iterator itr = _goRespawnTimes.find(dbGuid); + std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t>::const_iterator itr = _goRespawnTimes.find(dbGuid); if (itr != _goRespawnTimes.end()) return itr->second; return time_t(0); } - void SaveCreatureRespawnTime(uint32 dbGuid, time_t respawnTime); - void RemoveCreatureRespawnTime(uint32 dbGuid); - void SaveGORespawnTime(uint32 dbGuid, time_t respawnTime); - void RemoveGORespawnTime(uint32 dbGuid); + void SaveCreatureRespawnTime(ObjectGuid::LowType dbGuid, time_t respawnTime); + void RemoveCreatureRespawnTime(ObjectGuid::LowType dbGuid); + void SaveGORespawnTime(ObjectGuid::LowType dbGuid, time_t respawnTime); + void RemoveGORespawnTime(ObjectGuid::LowType dbGuid); void LoadRespawnTimes(); void DeleteRespawnTimes(); @@ -561,7 +561,7 @@ class Map : public GridRefManager<NGridType> { _updateObjects.insert(obj); } - + void RemoveUpdateObject(Object* obj) { _updateObjects.erase(obj); @@ -659,7 +659,7 @@ class Map : public GridRefManager<NGridType> Creature* _GetScriptCreature(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const; WorldObject* _GetScriptWorldObject(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const; void _ScriptProcessDoor(Object* source, Object* target, const ScriptInfo* scriptInfo) const; - GameObject* _FindGameObject(WorldObject* pWorldObject, uint32 guid) const; + GameObject* _FindGameObject(WorldObject* pWorldObject, ObjectGuid::LowType guid) const; time_t i_gridExpiry; @@ -711,8 +711,8 @@ class Map : public GridRefManager<NGridType> m_activeNonPlayers.erase(obj); } - std::unordered_map<uint32 /*dbGUID*/, time_t> _creatureRespawnTimes; - std::unordered_map<uint32 /*dbGUID*/, time_t> _goRespawnTimes; + std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t> _creatureRespawnTimes; + std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t> _goRespawnTimes; ZoneDynamicInfoMap _zoneDynamicInfo; uint32 _defaultLight; @@ -733,6 +733,7 @@ class Map : public GridRefManager<NGridType> GameObjectBySpawnIdContainer _gameobjectBySpawnIdStore; std::unordered_map<uint32/*cellId*/, std::unordered_set<Corpse*>> _corpsesByCell; std::unordered_map<ObjectGuid, Corpse*> _corpsesByPlayer; + std::unordered_set<Corpse*> _corpseBones; std::unordered_set<Object*> _updateObjects; }; diff --git a/src/server/game/Maps/TransportMgr.cpp b/src/server/game/Maps/TransportMgr.cpp index cac6e3b91ea..84eba74c6dc 100644 --- a/src/server/game/Maps/TransportMgr.cpp +++ b/src/server/game/Maps/TransportMgr.cpp @@ -348,7 +348,7 @@ void TransportMgr::AddPathNodeToTransport(uint32 transportEntry, uint32 timeSeg, animNode.Path[timeSeg] = node; } -Transport* TransportMgr::CreateTransport(uint32 entry, uint32 guid /*= 0*/, Map* map /*= NULL*/) +Transport* TransportMgr::CreateTransport(uint32 entry, ObjectGuid::LowType guid /*= 0*/, Map* map /*= NULL*/) { // instance case, execute GetGameObjectEntry hook if (map) @@ -425,7 +425,7 @@ void TransportMgr::SpawnContinentTransports() do { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); if (TransportTemplate const* tInfo = GetTransportTemplate(entry)) diff --git a/src/server/game/Maps/TransportMgr.h b/src/server/game/Maps/TransportMgr.h index c273ea7fb15..d100f60c604 100644 --- a/src/server/game/Maps/TransportMgr.h +++ b/src/server/game/Maps/TransportMgr.h @@ -21,6 +21,7 @@ #include <G3D/Quat.h> #include "Spline.h" #include "DBCStores.h" +#include "ObjectGuid.h" struct KeyFrame; struct GameObjectTemplate; @@ -111,7 +112,7 @@ class TransportMgr void LoadTransportTemplates(); // Creates a transport using given GameObject template entry - Transport* CreateTransport(uint32 entry, uint32 guid = 0, Map* map = NULL); + Transport* CreateTransport(uint32 entry, ObjectGuid::LowType guid = 0, Map* map = NULL); // Spawns all continent transports, used at core startup void SpawnContinentTransports(); diff --git a/src/server/game/Miscellaneous/Formulas.h b/src/server/game/Miscellaneous/Formulas.h index ba39723b19d..6edc3d74a5d 100644 --- a/src/server/game/Miscellaneous/Formulas.h +++ b/src/server/game/Miscellaneous/Formulas.h @@ -158,7 +158,7 @@ namespace Trinity return baseGain; } - inline uint32 Gain(Player* player, Unit* u) + inline uint32 Gain(Player* player, Unit* u, bool isBattleGround = false) { Creature* creature = u->ToCreature(); uint32 gain = 0; @@ -175,7 +175,7 @@ namespace Trinity if (creature->isElite()) { // Elites in instances have a 2.75x XP bonus instead of the regular 2x world bonus. - if (u->GetMap() && u->GetMap()->IsDungeon()) + if (u->GetMap()->IsDungeon()) xpMod *= 2.75f; else xpMod *= 2.0f; @@ -184,7 +184,7 @@ namespace Trinity xpMod *= creature->GetCreatureTemplate()->ModExperience; } - xpMod *= sWorld->getRate(RATE_XP_KILL); + xpMod *= isBattleGround ? sWorld->getRate(RATE_XP_BG_KILL) : sWorld->getRate(RATE_XP_KILL); gain = uint32(gain * xpMod); } diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index d374c8c509a..de117905b3d 100644 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -1202,8 +1202,7 @@ enum TrinityStrings LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD = 11007, LANG_NPCINFO_INHABIT_TYPE = 11008, - LANG_NPCINFO_FLAGS_EXTRA = 11009, + LANG_NPCINFO_FLAGS_EXTRA = 11009 - LANG_COOLDOWN_NOT_RESET_AFTER_DUEL = 11010 }; #endif diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.cpp b/src/server/game/OutdoorPvP/OutdoorPvP.cpp index d914ef01108..9046d9e6991 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvP.cpp @@ -85,7 +85,7 @@ void OPvPCapturePoint::SendChangePhase() SendUpdateWorldState(m_capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct); } -void OPvPCapturePoint::AddGO(uint32 type, uint32 guid, uint32 entry) +void OPvPCapturePoint::AddGO(uint32 type, ObjectGuid::LowType guid, uint32 entry) { if (!entry) { @@ -99,7 +99,7 @@ void OPvPCapturePoint::AddGO(uint32 type, uint32 guid, uint32 entry) m_ObjectTypes[m_Objects[type]] = type; } -void OPvPCapturePoint::AddCre(uint32 type, uint32 guid, uint32 entry) +void OPvPCapturePoint::AddCre(uint32 type, ObjectGuid::LowType guid, uint32 entry) { if (!entry) { @@ -115,7 +115,7 @@ void OPvPCapturePoint::AddCre(uint32 type, uint32 guid, uint32 entry) bool OPvPCapturePoint::AddObject(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3) { - if (uint32 guid = sObjectMgr->AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3)) + if (ObjectGuid::LowType guid = sObjectMgr->AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3)) { AddGO(type, guid, entry); return true; @@ -126,7 +126,7 @@ bool OPvPCapturePoint::AddObject(uint32 type, uint32 entry, uint32 map, float x, bool OPvPCapturePoint::AddCreature(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, TeamId /*teamId = TEAM_NEUTRAL*/, uint32 spawntimedelay /*= 0*/) { - if (uint32 guid = sObjectMgr->AddCreatureData(entry, map, x, y, z, o, spawntimedelay)) + if (ObjectGuid::LowType guid = sObjectMgr->AddCreatureData(entry, map, x, y, z, o, spawntimedelay)) { AddCre(type, guid, entry); return true; diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.h b/src/server/game/OutdoorPvP/OutdoorPvP.h index d075da19ebc..b35147a8502 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvP.h +++ b/src/server/game/OutdoorPvP/OutdoorPvP.h @@ -128,12 +128,12 @@ class OPvPCapturePoint virtual void DeleteSpawns(); - uint32 m_capturePointSpawnId; + ObjectGuid::LowType m_capturePointSpawnId; GameObject* m_capturePoint; - void AddGO(uint32 type, uint32 guid, uint32 entry = 0); - void AddCre(uint32 type, uint32 guid, uint32 entry = 0); + void AddGO(uint32 type, ObjectGuid::LowType guid, uint32 entry = 0); + void AddCre(uint32 type, ObjectGuid::LowType guid, uint32 entry = 0); bool SetCapturePointData(uint32 entry, uint32 map, float x, float y, float z, float o = 0, float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0); @@ -178,10 +178,10 @@ class OPvPCapturePoint // map to store the various gameobjects and creatures spawned by the objective // type, guid - std::map<uint32, uint32> m_Objects; - std::map<uint32, uint32> m_Creatures; - std::map<uint32, uint32> m_ObjectTypes; - std::map<uint32, uint32> m_CreatureTypes; + std::map<uint32, ObjectGuid::LowType> m_Objects; + std::map<uint32, ObjectGuid::LowType> m_Creatures; + std::map<ObjectGuid::LowType, uint32> m_ObjectTypes; + std::map<ObjectGuid::LowType, uint32> m_CreatureTypes; }; // base class for specific outdoor pvp handlers @@ -200,7 +200,7 @@ class OutdoorPvP : public ZoneScript // deletes all gos/creatures spawned by the pvp void DeleteSpawns(); - typedef std::map<uint32/*spawnId*/, OPvPCapturePoint*> OPvPCapturePointMap; + typedef std::map<ObjectGuid::LowType/*spawnId*/, OPvPCapturePoint*> OPvPCapturePointMap; typedef std::pair<ObjectGuid::LowType, GameObject*> GoScriptPair; typedef std::pair<ObjectGuid::LowType, Creature*> CreatureScriptPair; @@ -292,7 +292,7 @@ class OutdoorPvP : public ZoneScript m_capturePoints[cp->m_capturePointSpawnId] = cp; } - OPvPCapturePoint * GetCapturePoint(uint32 guid) const + OPvPCapturePoint * GetCapturePoint(ObjectGuid::LowType guid) const { OutdoorPvP::OPvPCapturePointMap::const_iterator itr = m_capturePoints.find(guid); if (itr != m_capturePoints.end()) diff --git a/src/server/game/Pools/PoolMgr.cpp b/src/server/game/Pools/PoolMgr.cpp index 8f3d4a758f3..1e7826f280b 100644 --- a/src/server/game/Pools/PoolMgr.cpp +++ b/src/server/game/Pools/PoolMgr.cpp @@ -184,7 +184,7 @@ PoolObject* PoolGroup<T>::RollOne(ActivePoolData& spawns, uint32 triggerFrom) // If no guid is passed, the pool is just removed (event end case) // If guid is filled, cache will be used and no removal will occur, it just fill the cache template<class T> -void PoolGroup<T>::DespawnObject(ActivePoolData& spawns, uint32 guid) +void PoolGroup<T>::DespawnObject(ActivePoolData& spawns, ObjectGuid::LowType guid) { for (size_t i=0; i < EqualChanced.size(); ++i) { @@ -215,7 +215,7 @@ void PoolGroup<T>::DespawnObject(ActivePoolData& spawns, uint32 guid) // Method that is actualy doing the removal job on one creature template<> -void PoolGroup<Creature>::Despawn1Object(uint32 guid) +void PoolGroup<Creature>::Despawn1Object(ObjectGuid::LowType guid) { if (CreatureData const* data = sObjectMgr->GetCreatureData(guid)) { @@ -237,7 +237,7 @@ void PoolGroup<Creature>::Despawn1Object(uint32 guid) // Same on one gameobject template<> -void PoolGroup<GameObject>::Despawn1Object(uint32 guid) +void PoolGroup<GameObject>::Despawn1Object(ObjectGuid::LowType guid) { if (GameObjectData const* data = sObjectMgr->GetGOData(guid)) { @@ -621,7 +621,7 @@ void PoolMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 pool_id = fields[1].GetUInt32(); float chance = fields[2].GetFloat(); @@ -677,7 +677,7 @@ void PoolMgr::LoadFromDB() { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 pool_id = fields[1].GetUInt32(); float chance = fields[2].GetFloat(); diff --git a/src/server/game/Pools/PoolMgr.h b/src/server/game/Pools/PoolMgr.h index 4ffcbe1faac..e165f9bd397 100644 --- a/src/server/game/Pools/PoolMgr.h +++ b/src/server/game/Pools/PoolMgr.h @@ -31,16 +31,16 @@ struct PoolTemplateData struct PoolObject { - uint32 guid; + ObjectGuid::LowType guid; float chance; - PoolObject(uint32 _guid, float _chance) : guid(_guid), chance(std::fabs(_chance)) { } + PoolObject(ObjectGuid::LowType _guid, float _chance) : guid(_guid), chance(std::fabs(_chance)) { } }; class Pool // for Pool of Pool case { }; -typedef std::set<uint32> ActivePoolObjects; +typedef std::set<ObjectGuid::LowType> ActivePoolObjects; typedef std::map<uint32, uint32> ActivePoolPools; class ActivePoolData @@ -77,8 +77,8 @@ class PoolGroup void AddEntry(PoolObject& poolitem, uint32 maxentries); bool CheckPool() const; PoolObject* RollOne(ActivePoolData& spawns, uint32 triggerFrom); - void DespawnObject(ActivePoolData& spawns, uint32 guid=0); - void Despawn1Object(uint32 guid); + void DespawnObject(ActivePoolData& spawns, ObjectGuid::LowType guid=0); + void Despawn1Object(ObjectGuid::LowType guid); void SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 triggerFrom); void Spawn1Object(PoolObject* obj); diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp index a369750b0c6..63006bc6ed6 100644 --- a/src/server/game/Scripting/MapScripts.cpp +++ b/src/server/game/Scripting/MapScripts.cpp @@ -220,7 +220,7 @@ inline WorldObject* Map::_GetScriptWorldObject(Object* obj, bool isSource, const inline void Map::_ScriptProcessDoor(Object* source, Object* target, const ScriptInfo* scriptInfo) const { bool bOpen = false; - uint32 guid = scriptInfo->ToggleDoor.GOGuid; + ObjectGuid::LowType guid = scriptInfo->ToggleDoor.GOGuid; int32 nTimeToToggle = std::max(15, int32(scriptInfo->ToggleDoor.ResetDelay)); switch (scriptInfo->command) { @@ -266,7 +266,7 @@ inline void Map::_ScriptProcessDoor(Object* source, Object* target, const Script } } -inline GameObject* Map::_FindGameObject(WorldObject* searchObject, uint32 guid) const +inline GameObject* Map::_FindGameObject(WorldObject* searchObject, ObjectGuid::LowType guid) const { auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid); if (bounds.first == bounds.second) diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp index 7c4b11769b5..a6a8eca6004 100644 --- a/src/server/game/Scripting/ScriptLoader.cpp +++ b/src/server/game/Scripting/ScriptLoader.cpp @@ -92,6 +92,7 @@ void AddSC_npcs_special(); void AddSC_npc_taxi(); void AddSC_achievement_scripts(); void AddSC_action_ip_logger(); +void AddSC_duel_reset(); //eastern kingdoms void AddSC_alterac_valley(); //Alterac Valley @@ -789,6 +790,7 @@ void AddWorldScripts() // To avoid duplicate code, we check once /*ONLY*/ if logging is permitted or not. if (sWorld->getBoolConfig(CONFIG_IP_BASED_ACTION_LOGGING)) AddSC_action_ip_logger(); // location: scripts\World\action_ip_logger.cpp + AddSC_duel_reset(); #endif } diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 0ece05f1d93..c47df973692 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -33,6 +33,7 @@ #include "Player.h" #include "WorldPacket.h" #include "WorldSession.h" +#include "Chat.h" // namespace // { @@ -972,12 +973,15 @@ OutdoorPvP* ScriptMgr::CreateOutdoorPvP(OutdoorPvPData const* data) return tmpscript->GetOutdoorPvP(); } -std::vector<ChatCommand*> ScriptMgr::GetChatCommands() +std::vector<ChatCommand> ScriptMgr::GetChatCommands() { - std::vector<ChatCommand*> table; + std::vector<ChatCommand> table; FOR_SCRIPTS_RET(CommandScript, itr, end, table) - table.push_back(itr->second->GetCommands()); + { + std::vector<ChatCommand> cmds = itr->second->GetCommands(); + table.insert(table.end(), cmds.begin(), cmds.end()); + } return table; } @@ -1030,7 +1034,7 @@ void ScriptMgr::OnAuctionExpire(AuctionHouseObject* ah, AuctionEntry* entry) FOREACH_SCRIPT(AuctionHouseScript)->OnAuctionExpire(ah, entry); } -bool ScriptMgr::OnConditionCheck(Condition* condition, ConditionSourceInfo& sourceInfo) +bool ScriptMgr::OnConditionCheck(Condition const* condition, ConditionSourceInfo& sourceInfo) { ASSERT(condition); @@ -1392,12 +1396,12 @@ void ScriptMgr::OnGuildItemMove(Guild* guild, Player* player, Item* pItem, bool FOREACH_SCRIPT(GuildScript)->OnItemMove(guild, player, pItem, isSrcBank, srcContainer, srcSlotId, isDestBank, destContainer, destSlotId); } -void ScriptMgr::OnGuildEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) +void ScriptMgr::OnGuildEvent(Guild* guild, uint8 eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank) { FOREACH_SCRIPT(GuildScript)->OnEvent(guild, eventType, playerGuid1, playerGuid2, newRank); } -void ScriptMgr::OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) +void ScriptMgr::OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) { FOREACH_SCRIPT(GuildScript)->OnBankEvent(guild, eventType, tabId, playerGuid, itemOrMoney, itemStackCount, destTabId); } diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index a226f1b7ed2..025cedd84e0 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -554,7 +554,7 @@ class CommandScript : public ScriptObject public: // Should return a pointer to a valid command table (ChatCommand array) to be used by ChatHandler. - virtual ChatCommand* GetCommands() const = 0; + virtual std::vector<ChatCommand> GetCommands() const = 0; }; class WeatherScript : public ScriptObject, public UpdatableScript<Weather> @@ -603,7 +603,7 @@ class ConditionScript : public ScriptObject bool IsDatabaseBound() const final override { return true; } // Called when a single condition is checked for a player. - virtual bool OnConditionCheck(Condition* /*condition*/, ConditionSourceInfo& /*sourceInfo*/) { return true; } + virtual bool OnConditionCheck(Condition const* /*condition*/, ConditionSourceInfo& /*sourceInfo*/) { return true; } }; class VehicleScript : public ScriptObject @@ -839,9 +839,9 @@ class GuildScript : public ScriptObject virtual void OnItemMove(Guild* /*guild*/, Player* /*player*/, Item* /*pItem*/, bool /*isSrcBank*/, uint8 /*srcContainer*/, uint8 /*srcSlotId*/, bool /*isDestBank*/, uint8 /*destContainer*/, uint8 /*destSlotId*/) { } - virtual void OnEvent(Guild* /*guild*/, uint8 /*eventType*/, uint32 /*playerGuid1*/, uint32 /*playerGuid2*/, uint8 /*newRank*/) { } + virtual void OnEvent(Guild* /*guild*/, uint8 /*eventType*/, ObjectGuid::LowType /*playerGuid1*/, ObjectGuid::LowType /*playerGuid2*/, uint8 /*newRank*/) { } - virtual void OnBankEvent(Guild* /*guild*/, uint8 /*eventType*/, uint8 /*tabId*/, uint32 /*playerGuid*/, uint32 /*itemOrMoney*/, uint16 /*itemStackCount*/, uint8 /*destTabId*/) { } + virtual void OnBankEvent(Guild* /*guild*/, uint8 /*eventType*/, uint8 /*tabId*/, ObjectGuid::LowType /*playerGuid*/, uint32 /*itemOrMoney*/, uint16 /*itemStackCount*/, uint8 /*destTabId*/) { } }; class GroupScript : public ScriptObject @@ -1014,7 +1014,7 @@ class ScriptMgr public: /* CommandScript */ - std::vector<ChatCommand*> GetChatCommands(); + std::vector<ChatCommand> GetChatCommands(); public: /* WeatherScript */ @@ -1030,7 +1030,7 @@ class ScriptMgr public: /* ConditionScript */ - bool OnConditionCheck(Condition* condition, ConditionSourceInfo& sourceInfo); + bool OnConditionCheck(Condition const* condition, ConditionSourceInfo& sourceInfo); public: /* VehicleScript */ @@ -1111,8 +1111,8 @@ class ScriptMgr void OnGuildMemberDepositMoney(Guild* guild, Player* player, uint32 &amount); void OnGuildItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId, bool isDestBank, uint8 destContainer, uint8 destSlotId); - void OnGuildEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank); - void OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId); + void OnGuildEvent(Guild* guild, uint8 eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank); + void OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId); public: /* GroupScript */ diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index 45a816eda9b..b1a043c4b5b 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -95,7 +95,7 @@ bool WorldSessionFilter::Process(WorldPacket* packet) } /// WorldSession constructor -WorldSession::WorldSession(uint32 id, std::shared_ptr<WorldSocket> sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter): +WorldSession::WorldSession(uint32 id, std::string&& name, std::shared_ptr<WorldSocket> sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter): m_muteTime(mute_time), m_timeOutTime(0), AntiDOS(this), @@ -104,6 +104,7 @@ WorldSession::WorldSession(uint32 id, std::shared_ptr<WorldSocket> sock, Account m_Socket(sock), _security(sec), _accountId(id), + _accountName(std::move(name)), m_expansion(expansion), _warden(NULL), _logoutTime(0), @@ -170,17 +171,17 @@ std::string WorldSession::GetPlayerInfo() const { std::ostringstream ss; - ss << "[Player: " << GetPlayerName() << " ("; - if (_player != NULL) - ss << _player->GetGUID().ToString() << ", "; + ss << "[Player: "; + if (!m_playerLoading && _player) + ss << _player->GetName() << ' ' << _player->GetGUID().ToString() << ", "; - ss << "Account: " << GetAccountId() << ")]"; + ss << "Account: " << GetAccountId() << "]"; return ss.str(); } /// Get player guid if available. Use for logging purposes only -uint32 WorldSession::GetGUIDLow() const +ObjectGuid::LowType WorldSession::GetGUIDLow() const { return GetPlayer() ? GetPlayer()->GetGUID().GetCounter() : 0; } @@ -483,6 +484,15 @@ void WorldSession::LogoutPlayer(bool save) { if (BattlegroundQueueTypeId bgQueueTypeId = _player->GetBattlegroundQueueTypeId(i)) { + // track if player logs out after invited to join BG + if (_player->IsInvitedForBattlegroundQueueType(bgQueueTypeId) && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS)) + { + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK); + stmt->setUInt32(0, _player->GetGUID().GetCounter()); + stmt->setUInt8(1, BG_DESERTION_TYPE_INVITE_LOGOUT); + CharacterDatabase.Execute(stmt); + } + _player->RemoveBattlegroundQueueId(bgQueueTypeId); BattlegroundQueue& queue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId); queue.RemovePlayer(_player->GetGUID(), true); @@ -666,13 +676,6 @@ void WorldSession::SendAuthWaitQue(uint32 position) } } -void WorldSession::LoadGlobalAccountData() -{ - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_DATA); - stmt->setUInt32(0, GetAccountId()); - LoadAccountData(CharacterDatabase.Query(stmt), GLOBAL_CACHE_MASK); -} - void WorldSession::LoadAccountData(PreparedQueryResult result, uint32 mask) { for (uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i) @@ -748,13 +751,11 @@ void WorldSession::SendAccountDataTimes(uint32 mask) SendPacket(&data); } -void WorldSession::LoadTutorialsData() +void WorldSession::LoadTutorialsData(PreparedQueryResult result) { memset(m_Tutorials, 0, sizeof(uint32) * MAX_ACCOUNT_TUTORIAL_VALUES); - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_TUTORIALS); - stmt->setUInt32(0, GetAccountId()); - if (PreparedQueryResult result = CharacterDatabase.Query(stmt)) + if (result) for (uint8 i = 0; i < MAX_ACCOUNT_TUTORIAL_VALUES; ++i) m_Tutorials[i] = (*result)[i].GetUInt32(); @@ -957,7 +958,7 @@ void WorldSession::WriteMovementInfo(WorldPacket* data, MovementInfo* mi) *data << mi->splineElevation; } -void WorldSession::ReadAddonsInfo(WorldPacket &data) +void WorldSession::ReadAddonsInfo(ByteBuffer &data) { if (data.rpos() + 4 > data.size()) return; @@ -1116,6 +1117,9 @@ void WorldSession::ProcessQueryCallbacks() { PreparedQueryResult result; + if (_realmAccountLoginCallback.valid() && _realmAccountLoginCallback.wait_for(std::chrono::seconds(0)) == std::future_status::ready) + InitializeSessionCallback(_realmAccountLoginCallback.get()); + //! HandleCharEnumOpcode if (_charEnumCallback.valid() && _charEnumCallback.wait_for(std::chrono::seconds(0)) == std::future_status::ready) { @@ -1215,15 +1219,84 @@ void WorldSession::InitWarden(BigNumber* k, std::string const& os) void WorldSession::LoadPermissions() { uint32 id = GetAccountId(); - std::string name; - AccountMgr::GetName(id, name); uint8 secLevel = GetSecurity(); - _RBACData = new rbac::RBACData(id, name, realmID, secLevel); + _RBACData = new rbac::RBACData(id, _accountName, realmID, secLevel); _RBACData->LoadFromDB(); +} + +PreparedQueryResultFuture WorldSession::LoadPermissionsAsync() +{ + uint32 id = GetAccountId(); + uint8 secLevel = GetSecurity(); TC_LOG_DEBUG("rbac", "WorldSession::LoadPermissions [AccountId: %u, Name: %s, realmId: %d, secLevel: %u]", - id, name.c_str(), realmID, secLevel); + id, _accountName.c_str(), realmID, secLevel); + + _RBACData = new rbac::RBACData(id, _accountName, realmID, secLevel); + return _RBACData->LoadFromDBAsync(); +} + +class AccountInfoQueryHolderPerRealm : public SQLQueryHolder +{ +public: + enum + { + GLOBAL_ACCOUNT_DATA = 0, + TUTORIALS, + + MAX_QUERIES + }; + + AccountInfoQueryHolderPerRealm() { SetSize(MAX_QUERIES); } + + bool Initialize(uint32 accountId) + { + bool ok = true; + + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_DATA); + stmt->setUInt32(0, accountId); + ok = SetPreparedQuery(GLOBAL_ACCOUNT_DATA, stmt) && ok; + + stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_TUTORIALS); + stmt->setUInt32(0, accountId); + ok = SetPreparedQuery(TUTORIALS, stmt) && ok; + + return ok; + } +}; + +void WorldSession::InitializeSession() +{ + AccountInfoQueryHolderPerRealm* realmHolder = new AccountInfoQueryHolderPerRealm(); + if (!realmHolder->Initialize(GetAccountId())) + { + delete realmHolder; + SendAuthResponse(AUTH_SYSTEM_ERROR, false); + return; + } + + _realmAccountLoginCallback = CharacterDatabase.DelayQueryHolder(realmHolder); +} + +void WorldSession::InitializeSessionCallback(SQLQueryHolder* realmHolder) +{ + LoadAccountData(realmHolder->GetPreparedResult(AccountInfoQueryHolderPerRealm::GLOBAL_ACCOUNT_DATA), GLOBAL_CACHE_MASK); + LoadTutorialsData(realmHolder->GetPreparedResult(AccountInfoQueryHolderPerRealm::TUTORIALS)); + + if (!m_inQueue) + SendAuthResponse(AUTH_OK, true); + else + SendAuthWaitQue(0); + + SetInQueue(false); + ResetTimeOutTime(); + + SendAddonsInfo(); + SendClientCacheVersion(sWorld->getIntConfig(CONFIG_CLIENTCACHE_VERSION)); + SendTutorialsData(); + + delete realmHolder; } rbac::RBACData* WorldSession::GetRBACData() diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index e597cbff27b..af2d2d22c57 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -249,7 +249,7 @@ struct PacketCounter class WorldSession { public: - WorldSession(uint32 id, std::shared_ptr<WorldSocket> sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter); + WorldSession(uint32 id, std::string&& name, std::shared_ptr<WorldSocket> sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter); ~WorldSession(); bool PlayerLoading() const { return m_playerLoading; } @@ -258,7 +258,7 @@ class WorldSession bool PlayerRecentlyLoggedOut() const { return m_playerRecentlyLogout; } bool PlayerDisconnected() const { return !m_Socket; } - void ReadAddonsInfo(WorldPacket& data); + void ReadAddonsInfo(ByteBuffer& data); void SendAddonsInfo(); void ReadMovementInfo(WorldPacket& data, MovementInfo* mi); @@ -276,9 +276,13 @@ class WorldSession void SendAuthResponse(uint8 code, bool shortForm, uint32 queuePos = 0); void SendClientCacheVersion(uint32 version); + void InitializeSession(); + void InitializeSessionCallback(SQLQueryHolder* realmHolder); + rbac::RBACData* GetRBACData(); bool HasPermission(uint32 permissionId); void LoadPermissions(); + PreparedQueryResultFuture LoadPermissionsAsync(); void InvalidateRBACData(); // Used to force LoadPermissions at next HasPermission check AccountTypes GetSecurity() const { return _security; } @@ -287,7 +291,7 @@ class WorldSession std::string const& GetPlayerName() const; std::string GetPlayerInfo() const; - uint32 GetGUIDLow() const; + ObjectGuid::LowType GetGUIDLow() const; void SetSecurity(AccountTypes security) { _security = security; } std::string const& GetRemoteAddress() const { return m_Address; } void SetPlayer(Player* player); @@ -358,10 +362,9 @@ class WorldSession AccountData* GetAccountData(AccountDataType type) { return &m_accountData[type]; } void SetAccountData(AccountDataType type, time_t tm, std::string const& data); void SendAccountDataTimes(uint32 mask); - void LoadGlobalAccountData(); void LoadAccountData(PreparedQueryResult result, uint32 mask); - void LoadTutorialsData(); + void LoadTutorialsData(PreparedQueryResult result); void SendTutorialsData(); void SaveTutorialsData(SQLTransaction& trans); uint32 GetTutorialInt(uint8 index) const { return m_Tutorials[index]; } @@ -965,6 +968,7 @@ class WorldSession void InitializeQueryCallbackParameters(); void ProcessQueryCallbacks(); + QueryResultHolderFuture _realmAccountLoginCallback; PreparedQueryResultFuture _charEnumCallback; PreparedQueryResultFuture _addIgnoreCallback; PreparedQueryResultFuture _stablePetCallback; @@ -1026,7 +1030,7 @@ class WorldSession // characters who failed on Player::BuildEnumData shouldn't login GuidSet _legitCharacters; - uint32 m_GUIDLow; // set logined or recently logout player (while m_playerRecentlyLogout set) + ObjectGuid::LowType m_GUIDLow; // set logined or recently logout player (while m_playerRecentlyLogout set) Player* _player; std::shared_ptr<WorldSocket> m_Socket; std::string m_Address; // Current Remote Address @@ -1034,6 +1038,7 @@ class WorldSession AccountTypes _security; uint32 _accountId; + std::string _accountName; uint8 m_expansion; typedef std::list<AddonInfo> AddonsList; diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index 066a4e501be..1dc470744a1 100644 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -35,10 +35,65 @@ WorldSocket::WorldSocket(tcp::socket&& socket) void WorldSocket::Start() { + std::string ip_address = GetRemoteIpAddress().to_string(); + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_INFO); + stmt->setString(0, ip_address); + stmt->setUInt32(1, inet_addr(ip_address.c_str())); + + { + std::lock_guard<std::mutex> guard(_queryLock); + _queryCallback = io_service().wrap(std::bind(&WorldSocket::CheckIpCallback, this, std::placeholders::_1)); + _queryFuture = LoginDatabase.AsyncQuery(stmt); + } +} + +void WorldSocket::CheckIpCallback(PreparedQueryResult result) +{ + if (result) + { + bool banned = false; + do + { + Field* fields = result->Fetch(); + if (fields[0].GetUInt64() != 0) + banned = true; + + if (!fields[1].GetString().empty()) + _ipCountry = fields[1].GetString(); + + } while (result->NextRow()); + + if (banned) + { + SendAuthResponseError(AUTH_REJECT); + TC_LOG_ERROR("network", "WorldSocket::CheckIpCallback: Sent Auth Response (IP %s banned).", GetRemoteIpAddress().to_string().c_str()); + DelayedCloseSocket(); + return; + } + } + AsyncRead(); HandleSendAuthSession(); } +bool WorldSocket::Update() +{ + if (!BaseSocket::Update()) + return false; + + { + std::lock_guard<std::mutex> guard(_queryLock); + if (_queryFuture.valid() && _queryFuture.wait_for(std::chrono::seconds(0)) == std::future_status::ready) + { + auto callback = std::move(_queryCallback); + _queryCallback = nullptr; + callback(_queryFuture.get()); + } + } + + return true; +} + void WorldSocket::HandleSendAuthSession() { WorldPacket packet(SMSG_AUTH_CHALLENGE, 37); @@ -111,13 +166,15 @@ void WorldSocket::ReadHandler() } // just received fresh new payload - if (!ReadDataHandler()) + ReadDataHandlerResult result = ReadDataHandler(); + _headerBuffer.Reset(); + if (result != ReadDataHandlerResult::Ok) { - CloseSocket(); + if (result != ReadDataHandlerResult::WaitingForQuery) + CloseSocket(); + return; } - - _headerBuffer.Reset(); } AsyncRead(); @@ -145,7 +202,72 @@ bool WorldSocket::ReadHeaderHandler() return true; } -bool WorldSocket::ReadDataHandler() +struct AuthSession +{ + uint32 BattlegroupID = 0; + uint32 LoginServerType = 0; + uint32 RealmID = 0; + uint32 Build = 0; + uint32 LocalChallenge = 0; + uint32 LoginServerID = 0; + uint32 RegionID = 0; + uint64 DosResponse = 0; + uint8 Digest[SHA_DIGEST_LENGTH] = {}; + std::string Account; + ByteBuffer AddonInfo; +}; + +struct AccountInfo +{ + uint32 Id; + BigNumber SessionKey; + std::string LastIP; + bool IsLockedToIP; + std::string LockCountry; + uint8 Expansion; + int64 MuteTime; + LocaleConstant Locale; + uint32 Recruiter; + std::string OS; + bool IsRectuiter; + AccountTypes Security; + bool IsBanned; + + explicit AccountInfo(Field* fields) + { + // 0 1 2 3 4 5 6 7 8 9 10 + // SELECT a.id, a.sessionkey, a.last_ip, a.locked, a.lock_country, a.expansion, a.mutetime, a.locale, a.recruiter, a.os, aa.gmLevel, + // 11 12 + // ab.unbandate > UNIX_TIMESTAMP() OR ab.unbandate = ab.bandate, r.id + // FROM account a + // LEFT JOIN account_access aa ON a.id = aa.id AND aa.RealmID IN (-1, ?) + // LEFT JOIN account_banned ab ON a.id = ab.id + // LEFT JOIN account r ON a.id = r.recruiter + // WHERE a.username = ? ORDER BY aa.RealmID DESC LIMIT 1 + Id = fields[0].GetUInt32(); + SessionKey.SetHexStr(fields[1].GetCString()); + LastIP = fields[2].GetString(); + IsLockedToIP = fields[3].GetBool(); + LockCountry = fields[4].GetString(); + Expansion = fields[5].GetUInt8(); + MuteTime = fields[6].GetInt64(); + Locale = LocaleConstant(fields[7].GetUInt8()); + Recruiter = fields[8].GetUInt32(); + OS = fields[9].GetString(); + Security = AccountTypes(fields[10].GetUInt8()); + IsBanned = fields[11].GetUInt64() != 0; + IsRectuiter = fields[12].GetUInt32() != 0; + + uint32 world_expansion = sWorld->getIntConfig(CONFIG_EXPANSION); + if (Expansion > world_expansion) + Expansion = world_expansion; + + if (Locale >= TOTAL_LOCALES) + Locale = LOCALE_enUS; + } +}; + +WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler() { ClientPktHeader* header = reinterpret_cast<ClientPktHeader*>(_headerBuffer.GetReadPointer()); @@ -162,7 +284,7 @@ bool WorldSocket::ReadDataHandler() { case CMSG_PING: LogOpcodeText(opcode, sessionGuard); - return HandlePing(packet); + return HandlePing(packet) ? ReadDataHandlerResult::Ok : ReadDataHandlerResult::Error; case CMSG_AUTH_SESSION: LogOpcodeText(opcode, sessionGuard); if (_authed) @@ -170,11 +292,11 @@ bool WorldSocket::ReadDataHandler() // locking just to safely log offending user is probably overkill but we are disconnecting him anyway if (sessionGuard.try_lock()) TC_LOG_ERROR("network", "WorldSocket::ProcessIncoming: received duplicate CMSG_AUTH_SESSION from %s", _worldSession->GetPlayerInfo().c_str()); - return false; + return ReadDataHandlerResult::Error; } HandleAuthSession(packet); - break; + return ReadDataHandlerResult::WaitingForQuery; case CMSG_KEEP_ALIVE: LogOpcodeText(opcode, sessionGuard); break; @@ -186,7 +308,7 @@ bool WorldSocket::ReadDataHandler() { TC_LOG_ERROR("network.opcode", "ProcessIncoming: Client not authed opcode = %u", uint32(opcode)); CloseSocket(); - return false; + return ReadDataHandlerResult::Error; } // Our Idle timer will reset on any non PING opcodes. @@ -199,7 +321,7 @@ bool WorldSocket::ReadDataHandler() } } - return true; + return ReadDataHandlerResult::Ok; } void WorldSocket::LogOpcodeText(uint16 opcode, std::unique_lock<std::mutex> const& guard) const @@ -256,48 +378,35 @@ void WorldSocket::SendPacket(WorldPacket const& packet) void WorldSocket::HandleAuthSession(WorldPacket& recvPacket) { - uint8 digest[SHA_DIGEST_LENGTH]; - uint32 clientSeed; - uint8 security; - uint32 id; - LocaleConstant locale; - std::string account; - SHA1Hash sha; - uint32 clientBuild; - uint32 serverId, loginServerType, region, battlegroup, realmIndex; - uint64 unk4; - WorldPacket packet, SendAddonPacked; - BigNumber k; - bool wardenActive = sWorld->getBoolConfig(CONFIG_WARDEN_ENABLED); + std::shared_ptr<AuthSession> authSession = std::make_shared<AuthSession>(); // Read the content of the packet - recvPacket >> clientBuild; - recvPacket >> serverId; // Used for GRUNT only - recvPacket >> account; - recvPacket >> loginServerType; // 0 GRUNT, 1 Battle.net - recvPacket >> clientSeed; - recvPacket >> region >> battlegroup; // Used for Battle.net only - recvPacket >> realmIndex; // realmId from auth_database.realmlist table - recvPacket >> unk4; - recvPacket.read(digest, 20); - - TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: client %u, serverId %u, account %s, loginServerType %u, clientseed %u, realmIndex %u", - clientBuild, - serverId, - account.c_str(), - loginServerType, - clientSeed, - realmIndex); + recvPacket >> authSession->Build; + recvPacket >> authSession->LoginServerID; + recvPacket >> authSession->Account; + recvPacket >> authSession->LoginServerType; + recvPacket >> authSession->LocalChallenge; + recvPacket >> authSession->RegionID; + recvPacket >> authSession->BattlegroupID; + recvPacket >> authSession->RealmID; // realmId from auth_database.realmlist table + recvPacket >> authSession->DosResponse; + recvPacket.read(authSession->Digest, 20); + authSession->AddonInfo.append(recvPacket.contents() + recvPacket.rpos(), recvPacket.size() - recvPacket.rpos()); // Get the account information from the auth database - // 0 1 2 3 4 5 6 7 8 - // SELECT id, sessionkey, last_ip, locked, expansion, mutetime, locale, recruiter, os FROM account WHERE username = ? PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_INFO_BY_NAME); + stmt->setInt32(0, int32(realmID)); + stmt->setString(1, authSession->Account); - stmt->setString(0, account); - - PreparedQueryResult result = LoginDatabase.Query(stmt); + { + std::lock_guard<std::mutex> guard(_queryLock); + _queryCallback = io_service().wrap(std::bind(&WorldSocket::HandleAuthSessionCallback, this, authSession, std::placeholders::_1)); + _queryFuture = LoginDatabase.AsyncQuery(stmt); + } +} +void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSession, PreparedQueryResult result) +{ // Stop if the account is not found if (!result) { @@ -308,32 +417,20 @@ void WorldSocket::HandleAuthSession(WorldPacket& recvPacket) return; } - Field* fields = result->Fetch(); - - uint8 expansion = fields[4].GetUInt8(); - uint32 world_expansion = sWorld->getIntConfig(CONFIG_EXPANSION); - if (expansion > world_expansion) - expansion = world_expansion; + AccountInfo account(result->Fetch()); // For hook purposes, we get Remoteaddress at this point. std::string address = GetRemoteIpAddress().to_string(); // As we don't know if attempted login process by ip works, we update last_attempt_ip right away - stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_ATTEMPT_IP); - + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_ATTEMPT_IP); stmt->setString(0, address); - stmt->setString(1, account); - + stmt->setString(1, authSession->Account); LoginDatabase.Execute(stmt); // This also allows to check for possible "hack" attempts on account - // id has to be fetched at this point, so that first actual account response that fails can be logged - id = fields[0].GetUInt32(); - - k.SetHexStr(fields[1].GetCString()); - // even if auth credentials are bad, try using the session key we have - client cannot read auth response error without it - _authCrypt.Init(&k); + _authCrypt.Init(&account.SessionKey); // First reject the connection if packet contains invalid data or realm state doesn't allow logging in if (sWorld->IsClosed()) @@ -344,7 +441,7 @@ void WorldSocket::HandleAuthSession(WorldPacket& recvPacket) return; } - if (realmIndex != realmID) + if (authSession->RealmID != realmID) { SendAuthResponseError(REALM_LIST_REALM_NOT_FOUND); TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Sent Auth Response (bad realm)."); @@ -352,13 +449,12 @@ void WorldSocket::HandleAuthSession(WorldPacket& recvPacket) return; } - std::string os = fields[8].GetString(); - // Must be done before WorldSession is created - if (wardenActive && os != "Win" && os != "OSX") + bool wardenActive = sWorld->getBoolConfig(CONFIG_WARDEN_ENABLED); + if (wardenActive && account.OS != "Win" && account.OS != "OSX") { SendAuthResponseError(AUTH_REJECT); - TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Client %s attempted to log in using invalid client OS (%s).", address.c_str(), os.c_str()); + TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Client %s attempted to log in using invalid client OS (%s).", address.c_str(), account.OS.c_str()); DelayedCloseSocket(); return; } @@ -366,135 +462,112 @@ void WorldSocket::HandleAuthSession(WorldPacket& recvPacket) // Check that Key and account name are the same on client and server uint32 t = 0; - sha.UpdateData(account); + SHA1Hash sha; + sha.UpdateData(authSession->Account); sha.UpdateData((uint8*)&t, 4); - sha.UpdateData((uint8*)&clientSeed, 4); + sha.UpdateData((uint8*)&authSession->LocalChallenge, 4); sha.UpdateData((uint8*)&_authSeed, 4); - sha.UpdateBigNumbers(&k, NULL); + sha.UpdateBigNumbers(&account.SessionKey, NULL); sha.Finalize(); - if (memcmp(sha.GetDigest(), digest, SHA_DIGEST_LENGTH) != 0) + if (memcmp(sha.GetDigest(), authSession->Digest, SHA_DIGEST_LENGTH) != 0) { SendAuthResponseError(AUTH_FAILED); - TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Authentication failed for account: %u ('%s') address: %s", id, account.c_str(), address.c_str()); + TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Authentication failed for account: %u ('%s') address: %s", account.Id, authSession->Account.c_str(), address.c_str()); DelayedCloseSocket(); return; } ///- Re-check ip locking (same check as in auth). - if (fields[3].GetUInt8() == 1) // if ip is locked + if (account.IsLockedToIP) { - if (strcmp(fields[2].GetCString(), address.c_str()) != 0) + if (account.LastIP != address) { SendAuthResponseError(AUTH_FAILED); - TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Sent Auth Response (Account IP differs. Original IP: %s, new IP: %s).", fields[2].GetCString(), address.c_str()); + TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Sent Auth Response (Account IP differs. Original IP: %s, new IP: %s).", account.LastIP.c_str(), address.c_str()); // We could log on hook only instead of an additional db log, however action logger is config based. Better keep DB logging as well - sScriptMgr->OnFailedAccountLogin(id); + sScriptMgr->OnFailedAccountLogin(account.Id); + DelayedCloseSocket(); + return; + } + } + else if (!account.LockCountry.empty() && account.LockCountry != "00" && !_ipCountry.empty()) + { + if (account.LockCountry != _ipCountry) + { + SendAuthResponseError(AUTH_FAILED); + TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Sent Auth Response (Account country differs. Original country: %s, new country: %s).", account.LockCountry.c_str(), _ipCountry.c_str()); + // We could log on hook only instead of an additional db log, however action logger is config based. Better keep DB logging as well + sScriptMgr->OnFailedAccountLogin(account.Id); DelayedCloseSocket(); return; } } - int64 mutetime = fields[5].GetInt64(); + int64 mutetime = account.MuteTime; //! Negative mutetime indicates amount of seconds to be muted effective on next login - which is now. if (mutetime < 0) { mutetime = time(NULL) + llabs(mutetime); PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME_LOGIN); - stmt->setInt64(0, mutetime); - stmt->setUInt32(1, id); - + stmt->setUInt32(1, account.Id); LoginDatabase.Execute(stmt); } - locale = LocaleConstant(fields[6].GetUInt8()); - if (locale >= TOTAL_LOCALES) - locale = LOCALE_enUS; - - uint32 recruiter = fields[7].GetUInt32(); - // Checks gmlevel per Realm - stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_GMLEVEL_BY_REALMID); - - stmt->setUInt32(0, id); - stmt->setInt32(1, int32(realmID)); - - result = LoginDatabase.Query(stmt); - - if (!result) - security = 0; - else - { - fields = result->Fetch(); - security = fields[0].GetUInt8(); - } - - // Re-check account ban (same check as in auth) - stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BANS); - - stmt->setUInt32(0, id); - stmt->setString(1, address); - - PreparedQueryResult banresult = LoginDatabase.Query(stmt); - - if (banresult) // if account banned + if (account.IsBanned) { SendAuthResponseError(AUTH_BANNED); TC_LOG_ERROR("network", "WorldSocket::HandleAuthSession: Sent Auth Response (Account banned)."); - sScriptMgr->OnFailedAccountLogin(id); + sScriptMgr->OnFailedAccountLogin(account.Id); DelayedCloseSocket(); return; } // Check locked state for server AccountTypes allowedAccountType = sWorld->GetPlayerSecurityLimit(); - TC_LOG_DEBUG("network", "Allowed Level: %u Player Level %u", allowedAccountType, AccountTypes(security)); - if (allowedAccountType > SEC_PLAYER && AccountTypes(security) < allowedAccountType) + TC_LOG_DEBUG("network", "Allowed Level: %u Player Level %u", allowedAccountType, account.Security); + if (allowedAccountType > SEC_PLAYER && account.Security < allowedAccountType) { SendAuthResponseError(AUTH_UNAVAILABLE); TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: User tries to login but his security level is not enough"); - sScriptMgr->OnFailedAccountLogin(id); + sScriptMgr->OnFailedAccountLogin(account.Id); DelayedCloseSocket(); return; } - TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.", - account.c_str(), - address.c_str()); - - // Check if this user is by any chance a recruiter - stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_RECRUITER); - - stmt->setUInt32(0, id); - - result = LoginDatabase.Query(stmt); - - bool isRecruiter = false; - if (result) - isRecruiter = true; + TC_LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.", authSession->Account.c_str(), address.c_str()); // Update the last_ip in the database as it was successful for login stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_IP); stmt->setString(0, address); - stmt->setString(1, account); + stmt->setString(1, authSession->Account); LoginDatabase.Execute(stmt); // At this point, we can safely hook a successful login - sScriptMgr->OnAccountLogin(id); + sScriptMgr->OnAccountLogin(account.Id); _authed = true; - _worldSession = new WorldSession(id, shared_from_this(), AccountTypes(security), expansion, mutetime, locale, recruiter, isRecruiter); - _worldSession->LoadGlobalAccountData(); - _worldSession->LoadTutorialsData(); - _worldSession->ReadAddonsInfo(recvPacket); - _worldSession->LoadPermissions(); + _worldSession = new WorldSession(account.Id, std::move(authSession->Account), shared_from_this(), account.Security, + account.Expansion, mutetime, account.Locale, account.Recruiter, account.IsRectuiter); + _worldSession->ReadAddonsInfo(authSession->AddonInfo); // Initialize Warden system only if it is enabled by config if (wardenActive) - _worldSession->InitWarden(&k, os); + _worldSession->InitWarden(&account.SessionKey, account.OS); + + _queryCallback = io_service().wrap(std::bind(&WorldSocket::LoadSessionPermissionsCallback, this, std::placeholders::_1)); + _queryFuture = _worldSession->LoadPermissionsAsync(); + AsyncRead(); +} + +void WorldSocket::LoadSessionPermissionsCallback(PreparedQueryResult result) +{ + // RBAC must be loaded before adding session to check for skip queue permission + _worldSession->GetRBACData()->LoadFromDBCallback(result); sWorld->AddSession(_worldSession); } diff --git a/src/server/game/Server/WorldSocket.h b/src/server/game/Server/WorldSocket.h index 0f6acd0d72c..f0da520cf4c 100644 --- a/src/server/game/Server/WorldSocket.h +++ b/src/server/game/Server/WorldSocket.h @@ -45,8 +45,12 @@ struct ClientPktHeader #pragma pack(pop) +struct AuthSession; + class WorldSocket : public Socket<WorldSocket> { + typedef Socket<WorldSocket> BaseSocket; + public: WorldSocket(tcp::socket&& socket); @@ -54,6 +58,7 @@ public: WorldSocket& operator=(WorldSocket const& right) = delete; void Start() override; + bool Update() override; void SendPacket(WorldPacket const& packet); @@ -61,9 +66,19 @@ protected: void OnClose() override; void ReadHandler() override; bool ReadHeaderHandler(); - bool ReadDataHandler(); + + enum class ReadDataHandlerResult + { + Ok = 0, + Error = 1, + WaitingForQuery = 2 + }; + + ReadDataHandlerResult ReadDataHandler(); private: + void CheckIpCallback(PreparedQueryResult result); + /// writes network.opcode log /// accessing WorldSession is not threadsafe, only do it when holding _worldSessionLock void LogOpcodeText(uint16 opcode, std::unique_lock<std::mutex> const& guard) const; @@ -71,6 +86,8 @@ private: void SendPacketAndLogOpcode(WorldPacket const& packet); void HandleSendAuthSession(); void HandleAuthSession(WorldPacket& recvPacket); + void HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSession, PreparedQueryResult result); + void LoadSessionPermissionsCallback(PreparedQueryResult result); void SendAuthResponseError(uint8 code); bool HandlePing(WorldPacket& recvPacket); @@ -87,6 +104,11 @@ private: MessageBuffer _headerBuffer; MessageBuffer _packetBuffer; + + std::mutex _queryLock; + PreparedQueryResultFuture _queryFuture; + std::function<void(PreparedQueryResult&&)> _queryCallback; + std::string _ipCountry; }; #endif diff --git a/src/server/game/Skills/SkillExtraItems.cpp b/src/server/game/Skills/SkillExtraItems.cpp index 8df9ce86f9a..2c9a2a7bcfd 100644 --- a/src/server/game/Skills/SkillExtraItems.cpp +++ b/src/server/game/Skills/SkillExtraItems.cpp @@ -20,11 +20,98 @@ #include "DatabaseEnv.h" #include "Log.h" #include "Player.h" +#include "ObjectMgr.h" #include <map> // some type definitions // no use putting them in the header file, they're only used in this .cpp +// struct to store information about perfection procs +// one entry per spell +struct SkillPerfectItemEntry +{ + // the spell id of the spell required - it's named "specialization" to conform with SkillExtraItemEntry + uint32 requiredSpecialization; + // perfection proc chance + float perfectCreateChance; + // itemid of the resulting perfect item + uint32 perfectItemType; + + SkillPerfectItemEntry() + : requiredSpecialization(0), perfectCreateChance(0.0f), perfectItemType(0) { } + SkillPerfectItemEntry(uint32 rS, float pCC, uint32 pIT) + : requiredSpecialization(rS), perfectCreateChance(pCC), perfectItemType(pIT) { } +}; + +// map to store perfection info. key = spellId of the creation spell, value is the perfectitementry as specified above +typedef std::map<uint32, SkillPerfectItemEntry> SkillPerfectItemMap; + +SkillPerfectItemMap SkillPerfectItemStore; + +// loads the perfection proc info from DB +void LoadSkillPerfectItemTable() +{ + uint32 oldMSTime = getMSTime(); + + SkillPerfectItemStore.clear(); // reload capability + + // 0 1 2 3 + QueryResult result = WorldDatabase.Query("SELECT spellId, requiredSpecialization, perfectCreateChance, perfectItemType FROM skill_perfect_item_template"); + + if (!result) + { + TC_LOG_ERROR("server.loading", ">> Loaded 0 spell perfection definitions. DB table `skill_perfect_item_template` is empty."); + return; + } + + uint32 count = 0; + + do /* fetch data and run sanity checks */ + { + Field* fields = result->Fetch(); + + uint32 spellId = fields[0].GetUInt32(); + + if (!sSpellMgr->GetSpellInfo(spellId)) + { + TC_LOG_ERROR("sql.sql", "Skill perfection data for spell %u has non-existent spell id in `skill_perfect_item_template`!", spellId); + continue; + } + + uint32 requiredSpecialization = fields[1].GetUInt32(); + if (!sSpellMgr->GetSpellInfo(requiredSpecialization)) + { + TC_LOG_ERROR("sql.sql", "Skill perfection data for spell %u has non-existent required specialization spell id %u in `skill_perfect_item_template`!", spellId, requiredSpecialization); + continue; + } + + float perfectCreateChance = fields[2].GetFloat(); + if (perfectCreateChance <= 0.0f) + { + TC_LOG_ERROR("sql.sql", "Skill perfection data for spell %u has impossibly low proc chance in `skill_perfect_item_template`!", spellId); + continue; + } + + uint32 perfectItemType = fields[3].GetUInt32(); + if (!sObjectMgr->GetItemTemplate(perfectItemType)) + { + TC_LOG_ERROR("sql.sql", "Skill perfection data for spell %u references non-existent perfect item id %u in `skill_perfect_item_template`!", spellId, perfectItemType); + continue; + } + + SkillPerfectItemEntry& skillPerfectItemEntry = SkillPerfectItemStore[spellId]; + + skillPerfectItemEntry.requiredSpecialization = requiredSpecialization; + skillPerfectItemEntry.perfectCreateChance = perfectCreateChance; + skillPerfectItemEntry.perfectItemType = perfectItemType; + + ++count; + } + while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded %u spell perfection definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); +} + // struct to store information about extra item creation // one entry for every spell that is able to create an extra item struct SkillExtraItemEntry @@ -112,6 +199,30 @@ void LoadSkillExtraItemTable() TC_LOG_INFO("server.loading", ">> Loaded %u spell specialization definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } +bool CanCreatePerfectItem(Player* player, uint32 spellId, float &perfectCreateChance, uint32 &perfectItemType) +{ + SkillPerfectItemMap::const_iterator ret = SkillPerfectItemStore.find(spellId); + // no entry in DB means no perfection proc possible + if (ret == SkillPerfectItemStore.end()) + return false; + + SkillPerfectItemEntry const* thisEntry = &ret->second; + // lack of entry means no perfection proc possible + if (!thisEntry) + return false; + + // if you don't have the spell needed, then no procs for you + if (!player->HasSpell(thisEntry->requiredSpecialization)) + return false; + + // set values as appropriate + perfectCreateChance = thisEntry->perfectCreateChance; + perfectItemType = thisEntry->perfectItemType; + + // and tell the caller to start rolling the dice + return true; +} + bool CanCreateExtraItems(Player* player, uint32 spellId, float &additionalChance, uint8 &additionalMax) { // get the info for the specified spell diff --git a/src/server/game/Skills/SkillExtraItems.h b/src/server/game/Skills/SkillExtraItems.h index 0cdfff74ed2..118c49ed00f 100644 --- a/src/server/game/Skills/SkillExtraItems.h +++ b/src/server/game/Skills/SkillExtraItems.h @@ -23,6 +23,10 @@ // predef classes used in functions class Player; +// returns true and sets the appropriate info if the player can create a perfect item with the given spellId +bool CanCreatePerfectItem(Player* player, uint32 spellId, float &perfectCreateChance, uint32 &perfectItemType); +// load perfection proc info from DB +void LoadSkillPerfectItemTable(); // returns true and sets the appropriate info if the player can create extra items with the given spellId bool CanCreateExtraItems(Player* player, uint32 spellId, float &additionalChance, uint8 &additionalMax); // function to load the extra item creation info from DB diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 0cc075a3dde..5e70d953be9 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -1134,7 +1134,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const if (!spellInfo || !(spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE) || spellInfo->HasAttribute(SPELL_ATTR0_HIDDEN_CLIENTSIDE))) continue; - if (spellInfo->Stances & (1<<(GetMiscValue()-1))) + if (spellInfo->Stances & (UI64LIT(1) << (GetMiscValue() - 1))) target->CastSpell(target, itr->first, true, NULL, this); } @@ -1148,7 +1148,8 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(glyph->SpellId); if (!spellInfo || !(spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE) || spellInfo->HasAttribute(SPELL_ATTR0_HIDDEN_CLIENTSIDE))) continue; - if (spellInfo->Stances & (1<<(GetMiscValue()-1))) + + if (spellInfo->Stances & (UI64LIT(1) << (GetMiscValue() - 1))) target->CastSpell(target, glyph->SpellId, true, NULL, this); } } @@ -1158,7 +1159,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const if (target->ToPlayer()->HasSpell(17007)) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(24932); - if (spellInfo && spellInfo->Stances & (1<<(GetMiscValue()-1))) + if (spellInfo && spellInfo->Stances & (UI64LIT(1) << (GetMiscValue() - 1))) target->CastSpell(target, 24932, true, NULL, this); } // Improved Barkskin - apply/remove armor bonus due to shapeshift @@ -1278,14 +1279,8 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const for (Unit::AuraApplicationMap::iterator itr = tAuras.begin(); itr != tAuras.end();) { // Use the new aura to see on what stance the target will be - uint32 newStance = 0; - if (newAura) - { - if (newAura->GetMiscValue() > 0 && newAura->GetMiscValue() <= 32) //Not null and GetMiscValue is not == FORM_NONE - newStance = 1 << (newAura->GetMiscValue() - 1); - else - TC_LOG_ERROR("spell.aura", "newAura->GetMiscValue() returned value %i for SpellID: %u when it was expecting a value in range [0..31] for a bitshift", newAura->GetMiscValue(), newAura->GetId()); - } + uint64 newStance = newAura ? (UI64LIT(1) << (newAura->GetMiscValue() - 1)) : 0; + // If the stances are not compatible with the spell, remove it if (itr->second->GetBase()->IsRemovedOnShapeLost(target) && !(itr->second->GetBase()->GetSpellInfo()->Stances & newStance)) target->RemoveAura(itr); diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index e42f66c6ffb..93b8c3eb368 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -1487,7 +1487,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b { // This additional check is needed to add a minimal delay before cooldown in in effect // to allow all bubbles broken by a single damage source proc mana return - if (caster->GetSpellHistory()->GetRemainingCooldown(aura->GetId()) <= 11) + if (caster->GetSpellHistory()->GetRemainingCooldown(aura->GetSpellInfo()) <= 11) break; } else // and add if needed @@ -1920,9 +1920,7 @@ bool Aura::IsProcTriggeredOnEvent(AuraApplication* aurApp, ProcEventInfo& eventI return false; // do checks using conditions table - ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL_PROC, GetId()); - ConditionSourceInfo condInfo = ConditionSourceInfo(eventInfo.GetActor(), eventInfo.GetActionTarget()); - if (!sConditionMgr->IsObjectMeetToConditions(condInfo, conditions)) + if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPELL_PROC, GetId(), eventInfo.GetActor(), eventInfo.GetActionTarget())) return false; // AuraScript Hook diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index e1302d48d2f..76eefa0bb0e 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -1019,7 +1019,7 @@ void Spell::SelectImplicitNearbyTargets(SpellEffIndex effIndex, SpellImplicitTar break; } - ConditionList* condList = m_spellInfo->Effects[effIndex].ImplicitTargetConditions; + ConditionContainer* condList = m_spellInfo->Effects[effIndex].ImplicitTargetConditions; // handle emergency case - try to use other provided targets if no conditions provided if (targetType.GetCheckType() == TARGET_CHECK_ENTRY && (!condList || condList->empty())) @@ -1105,7 +1105,7 @@ void Spell::SelectImplicitConeTargets(SpellEffIndex effIndex, SpellImplicitTarge std::list<WorldObject*> targets; SpellTargetObjectTypes objectType = targetType.GetObjectType(); SpellTargetCheckTypes selectionType = targetType.GetCheckType(); - ConditionList* condList = m_spellInfo->Effects[effIndex].ImplicitTargetConditions; + ConditionContainer* condList = m_spellInfo->Effects[effIndex].ImplicitTargetConditions; float coneAngle = float(M_PI) / 2; float radius = m_spellInfo->Effects[effIndex].CalcRadius(m_caster) * m_spellValue->RadiusMod; @@ -1725,7 +1725,7 @@ void Spell::SelectEffectTypeImplicitTargets(uint8 effIndex) } } -uint32 Spell::GetSearcherTypeMask(SpellTargetObjectTypes objType, ConditionList* condList) +uint32 Spell::GetSearcherTypeMask(SpellTargetObjectTypes objType, ConditionContainer* condList) { // this function selects which containers need to be searched for spell target uint32 retMask = GRID_MAP_TYPE_MASK_ALL; @@ -1793,7 +1793,7 @@ void Spell::SearchTargets(SEARCHER& searcher, uint32 containerMask, Unit* refere } } -WorldObject* Spell::SearchNearbyTarget(float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionList* condList) +WorldObject* Spell::SearchNearbyTarget(float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer* condList) { WorldObject* target = NULL; uint32 containerTypeMask = GetSearcherTypeMask(objectType, condList); @@ -1805,7 +1805,7 @@ WorldObject* Spell::SearchNearbyTarget(float range, SpellTargetObjectTypes objec return target; } -void Spell::SearchAreaTargets(std::list<WorldObject*>& targets, float range, Position const* position, Unit* referer, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionList* condList) +void Spell::SearchAreaTargets(std::list<WorldObject*>& targets, float range, Position const* position, Unit* referer, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer* condList) { uint32 containerTypeMask = GetSearcherTypeMask(objectType, condList); if (!containerTypeMask) @@ -1815,7 +1815,7 @@ void Spell::SearchAreaTargets(std::list<WorldObject*>& targets, float range, Pos SearchTargets<Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellAreaTargetCheck> > (searcher, containerTypeMask, m_caster, position, range); } -void Spell::SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTargets, WorldObject* target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, ConditionList* condList, bool isChainHeal) +void Spell::SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTargets, WorldObject* target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, ConditionContainer* condList, bool isChainHeal) { // max dist for jump target selection float jumpRadius = 0.0f; @@ -4253,7 +4253,7 @@ void Spell::TakeCastItem() for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) { - if (proto->Spells[i].SpellId) + if (proto->Spells[i].SpellId > 0) { // item has limited charges if (proto->Spells[i].SpellCharges) @@ -4668,7 +4668,7 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_NOT_READY; } - if (!m_caster->GetSpellHistory()->IsReady(m_spellInfo)) + if (!m_caster->GetSpellHistory()->IsReady(m_spellInfo, m_castItemEntry)) { if (m_triggeredByAuraSpell) return SPELL_FAILED_DONT_REPORT; @@ -4789,10 +4789,8 @@ SpellCastResult Spell::CheckCast(bool strict) // check spell cast conditions from database { - ConditionSourceInfo condInfo = ConditionSourceInfo(m_caster); - condInfo.mConditionTargets[1] = m_targets.GetObjectTarget(); - ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL, m_spellInfo->Id); - if (!conditions.empty() && !sConditionMgr->IsObjectMeetToConditions(condInfo, conditions)) + ConditionSourceInfo condInfo = ConditionSourceInfo(m_caster, m_targets.GetObjectTarget()); + if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPELL, m_spellInfo->Id, condInfo)) { // mLastFailedCondition can be NULL if there was an error processing the condition in Condition::Meets (i.e. wrong data for ConditionTarget or others) if (condInfo.mLastFailedCondition && condInfo.mLastFailedCondition->ErrorType) @@ -6046,7 +6044,7 @@ SpellCastResult Spell::CheckItems() for (uint8 e = 0; e < MAX_ITEM_PROTO_SPELLS; ++e) { ItemTemplate const* proto = targetItem->GetTemplate(); - if (proto->Spells[e].SpellId && ( + if (proto->Spells[e].SpellId > 0 && ( proto->Spells[e].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE || proto->Spells[e].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE)) { @@ -7315,7 +7313,7 @@ namespace Trinity { WorldObjectSpellTargetCheck::WorldObjectSpellTargetCheck(Unit* caster, Unit* referer, SpellInfo const* spellInfo, - SpellTargetCheckTypes selectionType, ConditionList* condList) : _caster(caster), _referer(referer), _spellInfo(spellInfo), + SpellTargetCheckTypes selectionType, ConditionContainer* condList) : _caster(caster), _referer(referer), _spellInfo(spellInfo), _targetSelectionType(selectionType), _condList(condList) { if (condList) @@ -7389,7 +7387,7 @@ bool WorldObjectSpellTargetCheck::operator()(WorldObject* target) } WorldObjectSpellNearbyTargetCheck::WorldObjectSpellNearbyTargetCheck(float range, Unit* caster, SpellInfo const* spellInfo, - SpellTargetCheckTypes selectionType, ConditionList* condList) + SpellTargetCheckTypes selectionType, ConditionContainer* condList) : WorldObjectSpellTargetCheck(caster, caster, spellInfo, selectionType, condList), _range(range), _position(caster) { } bool WorldObjectSpellNearbyTargetCheck::operator()(WorldObject* target) @@ -7404,7 +7402,7 @@ bool WorldObjectSpellNearbyTargetCheck::operator()(WorldObject* target) } WorldObjectSpellAreaTargetCheck::WorldObjectSpellAreaTargetCheck(float range, Position const* position, Unit* caster, - Unit* referer, SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionList* condList) + Unit* referer, SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList) : WorldObjectSpellTargetCheck(caster, referer, spellInfo, selectionType, condList), _range(range), _position(position) { } bool WorldObjectSpellAreaTargetCheck::operator()(WorldObject* target) @@ -7415,7 +7413,7 @@ bool WorldObjectSpellAreaTargetCheck::operator()(WorldObject* target) } WorldObjectSpellConeTargetCheck::WorldObjectSpellConeTargetCheck(float coneAngle, float range, Unit* caster, - SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionList* condList) + SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList) : WorldObjectSpellAreaTargetCheck(range, caster, caster, caster, spellInfo, selectionType, condList), _coneAngle(coneAngle) { } bool WorldObjectSpellConeTargetCheck::operator()(WorldObject* target) diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 1aac88ac602..6b96f56c538 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -374,12 +374,12 @@ class Spell void SelectEffectTypeImplicitTargets(uint8 effIndex); - uint32 GetSearcherTypeMask(SpellTargetObjectTypes objType, ConditionList* condList); + uint32 GetSearcherTypeMask(SpellTargetObjectTypes objType, ConditionContainer* condList); template<class SEARCHER> void SearchTargets(SEARCHER& searcher, uint32 containerMask, Unit* referer, Position const* pos, float radius); - WorldObject* SearchNearbyTarget(float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionList* condList = NULL); - void SearchAreaTargets(std::list<WorldObject*>& targets, float range, Position const* position, Unit* referer, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionList* condList); - void SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTargets, WorldObject* target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, ConditionList* condList, bool isChainHeal); + WorldObject* SearchNearbyTarget(float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer* condList = NULL); + void SearchAreaTargets(std::list<WorldObject*>& targets, float range, Position const* position, Unit* referer, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer* condList); + void SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTargets, WorldObject* target, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectType, ConditionContainer* condList, bool isChainHeal); GameObject* SearchSpellFocus(); @@ -583,6 +583,8 @@ class Spell // Targets store structures and data struct TargetInfo { + // a bug in gcc-4.7 needs a destructor to call move operator instead of copy operator in std::vector remove + ~TargetInfo() { } ObjectGuid targetGUID; uint64 timeDelay; SpellMissInfo missCondition:8; @@ -712,10 +714,10 @@ namespace Trinity SpellInfo const* _spellInfo; SpellTargetCheckTypes _targetSelectionType; ConditionSourceInfo* _condSrcInfo; - ConditionList* _condList; + ConditionContainer* _condList; WorldObjectSpellTargetCheck(Unit* caster, Unit* referer, SpellInfo const* spellInfo, - SpellTargetCheckTypes selectionType, ConditionList* condList); + SpellTargetCheckTypes selectionType, ConditionContainer* condList); ~WorldObjectSpellTargetCheck(); bool operator()(WorldObject* target); }; @@ -725,7 +727,7 @@ namespace Trinity float _range; Position const* _position; WorldObjectSpellNearbyTargetCheck(float range, Unit* caster, SpellInfo const* spellInfo, - SpellTargetCheckTypes selectionType, ConditionList* condList); + SpellTargetCheckTypes selectionType, ConditionContainer* condList); bool operator()(WorldObject* target); }; @@ -734,7 +736,7 @@ namespace Trinity float _range; Position const* _position; WorldObjectSpellAreaTargetCheck(float range, Position const* position, Unit* caster, - Unit* referer, SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionList* condList); + Unit* referer, SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList); bool operator()(WorldObject* target); }; @@ -742,7 +744,7 @@ namespace Trinity { float _coneAngle; WorldObjectSpellConeTargetCheck(float coneAngle, float range, Unit* caster, - SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionList* condList); + SpellInfo const* spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer* condList); bool operator()(WorldObject* target); }; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 10dfbd511df..b345c5affea 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -1571,6 +1571,22 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype) if (num_to_add > pProto->GetMaxStackSize()) num_to_add = pProto->GetMaxStackSize(); + /* == gem perfection handling == */ + + // the chance of getting a perfect result + float perfectCreateChance = 0.0f; + // the resulting perfect item if successful + uint32 perfectItemType = itemtype; + // get perfection capability and chance + if (CanCreatePerfectItem(player, m_spellInfo->Id, perfectCreateChance, perfectItemType)) + if (roll_chance_f(perfectCreateChance)) // if the roll succeeds... + newitemid = perfectItemType; // the perfect item replaces the regular one + + /* == gem perfection handling over == */ + + + /* == profession specialization handling == */ + // init items_count to 1, since 1 item will be created regardless of specialization int items_count=1; // the chance to create additional items @@ -1579,15 +1595,16 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype) uint8 additionalMaxNum=0; // get the chance and maximum number for creating extra items if (CanCreateExtraItems(player, m_spellInfo->Id, additionalCreateChance, additionalMaxNum)) - { // roll with this chance till we roll not to create or we create the max num while (roll_chance_f(additionalCreateChance) && items_count <= additionalMaxNum) ++items_count; - } // really will be created more items num_to_add *= items_count; + /* == profession specialization handling over == */ + + // can the player store the new item? ItemPosCountVec dest; uint32 no_space = 0; @@ -4356,11 +4373,14 @@ void Spell::EffectEnchantHeldItem(SpellEffIndex effIndex) if (m_spellInfo->Effects[effIndex].MiscValue) { uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue; - int32 duration = m_spellInfo->GetDuration(); //Try duration index first .. + int32 duration = m_spellInfo->GetDuration(); // Try duration index first .. if (!duration) - duration = damage;//+1; //Base points after .. + duration = damage;//+1; // Base points after .. if (!duration) - duration = 10; //10 seconds for enchants which don't have listed duration + duration = 10 * IN_MILLISECONDS; // 10 seconds for enchants which don't have listed duration + + if (m_spellInfo->Id == 14792) // Venomhide Poison + duration = 5 * MINUTE * IN_MILLISECONDS; SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!pEnchant) @@ -4374,7 +4394,7 @@ void Spell::EffectEnchantHeldItem(SpellEffIndex effIndex) return; // Apply the temporary enchantment - item->SetEnchantment(slot, enchant_id, duration*IN_MILLISECONDS, 0, m_caster->GetGUID()); + item->SetEnchantment(slot, enchant_id, duration, 0, m_caster->GetGUID()); item_owner->ApplyEnchantment(item, slot, true); } } diff --git a/src/server/game/Spells/SpellHistory.cpp b/src/server/game/Spells/SpellHistory.cpp index 208b4cf7ed9..d2cf03dc936 100644 --- a/src/server/game/Spells/SpellHistory.cpp +++ b/src/server/game/Spells/SpellHistory.cpp @@ -43,6 +43,8 @@ struct SpellHistory::PersistenceHelper<Player> cooldownEntry->CooldownEnd = Clock::from_time_t(time_t(fields[2].GetUInt32())); cooldownEntry->ItemId = fields[1].GetUInt32(); + cooldownEntry->CategoryId = fields[3].GetUInt32(); + cooldownEntry->CategoryEnd = Clock::from_time_t(time_t(fields[4].GetUInt32())); return true; } @@ -51,6 +53,8 @@ struct SpellHistory::PersistenceHelper<Player> stmt->setUInt32(index++, cooldown.first); stmt->setUInt32(index++, cooldown.second.ItemId); stmt->setUInt32(index++, uint32(Clock::to_time_t(cooldown.second.CooldownEnd))); + stmt->setUInt32(index++, cooldown.second.CategoryId); + stmt->setUInt32(index++, uint32(Clock::to_time_t(cooldown.second.CategoryEnd))); } }; @@ -70,6 +74,8 @@ struct SpellHistory::PersistenceHelper<Pet> cooldownEntry->CooldownEnd = Clock::from_time_t(time_t(fields[1].GetUInt32())); cooldownEntry->ItemId = 0; + cooldownEntry->CategoryId = fields[2].GetUInt32(); + cooldownEntry->CategoryEnd = Clock::from_time_t(time_t(fields[3].GetUInt32())); return true; } @@ -77,6 +83,8 @@ struct SpellHistory::PersistenceHelper<Pet> { stmt->setUInt32(index++, cooldown.first); stmt->setUInt32(index++, uint32(Clock::to_time_t(cooldown.second.CooldownEnd))); + stmt->setUInt32(index++, cooldown.second.CategoryId); + stmt->setUInt32(index++, uint32(Clock::to_time_t(cooldown.second.CategoryEnd))); } }; @@ -92,7 +100,11 @@ void SpellHistory::LoadFromDB(PreparedQueryResult cooldownsResult) uint32 spellId; CooldownEntry cooldown; if (StatementInfo::ReadCooldown(cooldownsResult->Fetch(), &spellId, &cooldown)) + { _spellCooldowns[spellId] = cooldown; + if (cooldown.CategoryId) + _categoryCooldowns[cooldown.CategoryId] = &_spellCooldowns[spellId]; + } } while (cooldownsResult->NextRow()); } @@ -125,10 +137,18 @@ void SpellHistory::Update() { SQLTransaction t; Clock::time_point now = Clock::now(); + for (auto itr = _categoryCooldowns.begin(); itr != _categoryCooldowns.end();) + { + if (itr->second->CategoryEnd < now) + itr = _categoryCooldowns.erase(itr); + else + ++itr; + } + for (auto itr = _spellCooldowns.begin(); itr != _spellCooldowns.end();) { if (itr->second.CooldownEnd < now) - itr = _spellCooldowns.erase(itr); + itr = EraseCooldown(itr); else ++itr; } @@ -136,29 +156,37 @@ void SpellHistory::Update() void SpellHistory::HandleCooldowns(SpellInfo const* spellInfo, Item const* item, Spell* spell /*= nullptr*/) { + HandleCooldowns(spellInfo, item ? item->GetEntry() : 0, spell); +} + +void SpellHistory::HandleCooldowns(SpellInfo const* spellInfo, uint32 itemID, Spell* spell /*= nullptr*/) +{ if (Player* player = _owner->ToPlayer()) { // potions start cooldown until exiting combat - if (item && (item->IsPotion() || spellInfo->IsCooldownStartedOnEvent())) + if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemID)) { - player->SetLastPotionId(item->GetEntry()); - return; + if (itemTemplate->IsPotion() || spellInfo->IsCooldownStartedOnEvent()) + { + player->SetLastPotionId(itemID); + return; + } } } if (spellInfo->IsCooldownStartedOnEvent() || spellInfo->IsPassive() || (spell && spell->IsIgnoringCooldowns())) return; - StartCooldown(spellInfo, item ? item->GetEntry() : 0, spell); + StartCooldown(spellInfo, itemID, spell); } -bool SpellHistory::IsReady(SpellInfo const* spellInfo) const +bool SpellHistory::IsReady(SpellInfo const* spellInfo, uint32 itemId /*= 0*/) const { if (spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) if (IsSchoolLocked(spellInfo->GetSchoolMask())) return false; - if (HasCooldown(spellInfo->Id)) + if (HasCooldown(spellInfo->Id, itemId)) return false; return true; @@ -168,42 +196,33 @@ template<> void SpellHistory::WritePacket<Pet>(WorldPacket& packet) const { Clock::time_point now = Clock::now(); - + uint8 cooldownsCount = _spellCooldowns.size(); packet << uint8(cooldownsCount); for (auto const& spellCooldown : _spellCooldowns) { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellCooldown.first); - if (!spellInfo) - { - packet << uint32(0); - packet << uint16(0); - packet << uint32(0); - packet << uint32(0); - continue; - } - - packet << uint32(spellCooldown.first); // spell ID - packet << uint16(spellInfo->GetCategory()); // spell category + packet << uint32(spellCooldown.first); // spell ID + packet << uint16(spellCooldown.second.CategoryId); // spell category if (!spellCooldown.second.OnHold) { - uint32 cooldownDuration = spellCooldown.second.CooldownEnd > now ? std::chrono::duration_cast<std::chrono::milliseconds>(spellCooldown.second.CooldownEnd - now).count() : 0; - if (cooldownDuration <= 0) + std::chrono::milliseconds cooldownDuration = std::chrono::duration_cast<std::chrono::milliseconds>(spellCooldown.second.CooldownEnd - now); + if (cooldownDuration.count() <= 0) { packet << uint32(0); packet << uint32(0); continue; } - if (spellInfo->GetCategory()) + std::chrono::milliseconds categoryDuration = std::chrono::duration_cast<std::chrono::milliseconds>(spellCooldown.second.CategoryEnd - now); + if (categoryDuration.count() > 0) { packet << uint32(0); - packet << uint32(cooldownDuration); + packet << uint32(categoryDuration.count()); } else { - packet << uint32(cooldownDuration); + packet << uint32(cooldownDuration.count()); packet << uint32(0); } } @@ -216,23 +235,13 @@ void SpellHistory::WritePacket<Player>(WorldPacket& packet) const Clock::time_point now = Clock::now(); Clock::time_point infTime = now + InfinityCooldownDelayCheck; - uint16 cooldownsCount = _spellCooldowns.size(); - size_t dataPos = packet.wpos(); - packet << uint16(cooldownsCount); + packet << uint16(_spellCooldowns.size()); for (auto const& spellCooldown : _spellCooldowns) { - SpellInfo const* sEntry = sSpellMgr->GetSpellInfo(spellCooldown.first); - if (!sEntry) - { - --cooldownsCount; - continue; - } - packet << uint32(spellCooldown.first); - packet << uint16(spellCooldown.second.ItemId); // cast item id - packet << uint16(sEntry->GetCategory()); // spell category + packet << uint16(spellCooldown.second.CategoryId); // spell category // send infinity cooldown in special format if (spellCooldown.second.CooldownEnd >= infTime) @@ -242,21 +251,26 @@ void SpellHistory::WritePacket<Player>(WorldPacket& packet) const continue; } - uint32 cooldownDuration = spellCooldown.second.CooldownEnd > now ? std::chrono::duration_cast<std::chrono::milliseconds>(spellCooldown.second.CooldownEnd - now).count() : 0; + std::chrono::milliseconds cooldownDuration = std::chrono::duration_cast<std::chrono::milliseconds>(spellCooldown.second.CooldownEnd - now); + if (cooldownDuration.count() <= 0) + { + packet << uint32(0); + packet << uint32(0); + continue; + } - if (sEntry->GetCategory()) // may be wrong, but anyway better than nothing... + std::chrono::milliseconds categoryDuration = std::chrono::duration_cast<std::chrono::milliseconds>(spellCooldown.second.CategoryEnd - now); + if (categoryDuration.count() >= 0) { packet << uint32(0); // cooldown - packet << uint32(cooldownDuration); // category cooldown + packet << uint32(categoryDuration.count()); // category cooldown } else { - packet << uint32(cooldownDuration); // cooldown + packet << uint32(cooldownDuration.count()); // cooldown packet << uint32(0); // category cooldown } } - - packet.put<uint16>(dataPos, cooldownsCount); } void SpellHistory::StartCooldown(SpellInfo const* spellInfo, uint32 itemId, Spell* spell /*= nullptr*/, bool onHold /*= false*/) @@ -351,7 +365,7 @@ void SpellHistory::StartCooldown(SpellInfo const* spellInfo, uint32 itemId, Spel // self spell cooldown if (recTime != curTime) { - AddCooldown(spellInfo->Id, itemId, recTime, onHold); + AddCooldown(spellInfo->Id, itemId, recTime, categoryId, catrecTime, onHold); if (needsCooldownPacket) { @@ -363,22 +377,6 @@ void SpellHistory::StartCooldown(SpellInfo const* spellInfo, uint32 itemId, Spel } } } - - // category spells - if (categoryId && catrecTime != curTime) - { - SpellCategoryStore::const_iterator i_scstore = sSpellsByCategoryStore.find(categoryId); - if (i_scstore != sSpellsByCategoryStore.end()) - { - for (SpellCategorySet::const_iterator i_scset = i_scstore->second.begin(); i_scset != i_scstore->second.end(); ++i_scset) - { - if (*i_scset == spellInfo->Id) // skip main spell, already handled above - continue; - - AddCooldown(*i_scset, itemId, catrecTime, onHold); - } - } - } } void SpellHistory::SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId /*= 0*/, Spell* spell /*= nullptr*/, bool startCooldown /*= true*/) @@ -387,49 +385,27 @@ void SpellHistory::SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId / if (startCooldown) StartCooldown(spellInfo, itemId, spell); + // Send activate cooldown timer (possible 0) at client side if (Player* player = GetPlayerOwner()) { - // Send activate cooldown timer (possible 0) at client side WorldPacket data(SMSG_COOLDOWN_EVENT, 4 + 8); data << uint32(spellInfo->Id); data << uint64(_owner->GetGUID()); player->SendDirectMessage(&data); - - uint32 category = spellInfo->GetCategory(); - if (category && spellInfo->CategoryRecoveryTime) - { - SpellCategoryStore::const_iterator ct = sSpellsByCategoryStore.find(category); - if (ct != sSpellsByCategoryStore.end()) - { - for (auto const& cooldownPair : _spellCooldowns) - { - uint32 categorySpell = cooldownPair.first; - if (!ct->second.count(categorySpell)) - continue; - - if (categorySpell == spellInfo->Id) // skip main spell, already handled above - continue; - - SpellInfo const* spellInfo2 = sSpellMgr->EnsureSpellInfo(categorySpell); - if (!spellInfo2->IsCooldownStartedOnEvent()) - continue; - - data.Initialize(SMSG_COOLDOWN_EVENT, 4 + 8); - data << uint32(categorySpell); - data << uint64(_owner->GetGUID()); - player->SendDirectMessage(&data); - } - } - } } } -void SpellHistory::AddCooldown(uint32 spellId, uint32 itemId, Clock::time_point cooldownEnd, bool onHold /*= false*/) +void SpellHistory::AddCooldown(uint32 spellId, uint32 itemId, Clock::time_point cooldownEnd, uint32 categoryId, Clock::time_point categoryEnd, bool onHold /*= false*/) { CooldownEntry& cooldownEntry = _spellCooldowns[spellId]; cooldownEntry.CooldownEnd = cooldownEnd; cooldownEntry.ItemId = itemId; + cooldownEntry.CategoryId = categoryId; + cooldownEntry.CategoryEnd = categoryEnd; cooldownEntry.OnHold = onHold; + + if (categoryId) + _categoryCooldowns[categoryId] = &cooldownEntry; } void SpellHistory::ModifyCooldown(uint32 spellId, int32 cooldownModMs) @@ -443,7 +419,7 @@ void SpellHistory::ModifyCooldown(uint32 spellId, int32 cooldownModMs) if (itr->second.CooldownEnd + offset > now) itr->second.CooldownEnd += offset; else - _spellCooldowns.erase(itr); + EraseCooldown(itr); if (Player* playerOwner = GetPlayerOwner()) { @@ -477,7 +453,7 @@ void SpellHistory::ResetCooldown(CooldownStorageType::iterator& itr, bool update } } - itr = _spellCooldowns.erase(itr); + itr = EraseCooldown(itr); } void SpellHistory::ResetAllCooldowns() @@ -492,31 +468,69 @@ void SpellHistory::ResetAllCooldowns() SendClearCooldowns(cooldowns); } + _categoryCooldowns.clear(); _spellCooldowns.clear(); } -bool SpellHistory::HasCooldown(uint32 spellId) const +bool SpellHistory::HasCooldown(SpellInfo const* spellInfo, uint32 itemId /*= 0*/) const +{ + if (_spellCooldowns.count(spellInfo->Id) != 0) + return true; + + uint32 category = 0; + if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemId)) + { + for (uint32 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) + { + if (uint32(itemTemplate->Spells[i].SpellId) == spellInfo->Id) + { + category = itemTemplate->Spells[i].SpellCategory; + break; + } + } + } + + if (!category) + category = spellInfo->GetCategory(); + + if (!category) + return false; + + return _categoryCooldowns.count(category) != 0; +} + +bool SpellHistory::HasCooldown(uint32 spellId, uint32 itemId /*= 0*/) const { - return _spellCooldowns.count(spellId) != 0; + return HasCooldown(sSpellMgr->EnsureSpellInfo(spellId), itemId); } -uint32 SpellHistory::GetRemainingCooldown(uint32 spellId) const +uint32 SpellHistory::GetRemainingCooldown(SpellInfo const* spellInfo) const { - auto itr = _spellCooldowns.find(spellId); - if (itr == _spellCooldowns.end()) - return 0; + Clock::time_point end; + auto itr = _spellCooldowns.find(spellInfo->Id); + if (itr != _spellCooldowns.end()) + end = itr->second.CooldownEnd; + else + { + auto catItr = _categoryCooldowns.find(spellInfo->GetCategory()); + if (catItr == _categoryCooldowns.end()) + return 0; + + end = catItr->second->CategoryEnd; + } Clock::time_point now = Clock::now(); - if (itr->second.CooldownEnd < now) + if (end < now) return 0; - Clock::duration remaining = itr->second.CooldownEnd - now; + Clock::duration remaining = end - now; return uint32(std::chrono::duration_cast<std::chrono::milliseconds>(remaining).count()); } void SpellHistory::LockSpellSchool(SpellSchoolMask schoolMask, uint32 lockoutTime) { - Clock::time_point lockoutEnd = Clock::now() + std::chrono::duration_cast<Clock::duration>(std::chrono::milliseconds(lockoutTime)); + Clock::time_point now = Clock::now(); + Clock::time_point lockoutEnd = now + std::chrono::duration_cast<Clock::duration>(std::chrono::milliseconds(lockoutTime)); for (uint32 i = 0; i < MAX_SPELL_SCHOOL; ++i) if (SpellSchoolMask(1 << i) & schoolMask) _schoolLockouts[i] = lockoutEnd; @@ -553,10 +567,10 @@ void SpellHistory::LockSpellSchool(SpellSchoolMask schoolMask, uint32 lockoutTim if (spellInfo->PreventionType != SPELL_PREVENTION_TYPE_SILENCE) continue; - if ((schoolMask & spellInfo->GetSchoolMask()) && GetRemainingCooldown(spellId) < lockoutTime) + if ((schoolMask & spellInfo->GetSchoolMask()) && GetRemainingCooldown(spellInfo) < lockoutTime) { cooldowns[spellId] = lockoutTime; - AddCooldown(spellId, 0, lockoutEnd); + AddCooldown(spellId, 0, lockoutEnd, 0, now); } } @@ -637,21 +651,59 @@ void SpellHistory::BuildCooldownPacket(WorldPacket& data, uint8 flags, PacketCoo } } -uint16 SpellHistory::GetArenaCooldownsSize() +void SpellHistory::SaveCooldownStateBeforeDuel() { - uint16 count = 0; + _spellCooldownsBeforeDuel = _spellCooldowns; +} - for (auto itr = _spellCooldowns.begin(); itr != _spellCooldowns.end();) +void SpellHistory::RestoreCooldownStateAfterDuel() +{ + // category cooldows are not preserved. + if (Player* player = _owner->ToPlayer()) { - SpellInfo const* spellInfo = sSpellMgr->EnsureSpellInfo(itr->first); + // add all profession CDs created while in duel (if any) + for (auto itr = _spellCooldowns.begin(); itr != _spellCooldowns.end(); ++itr) + { + SpellInfo const* spellInfo = sSpellMgr->EnsureSpellInfo(itr->first); - if (spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS && - spellInfo->CategoryRecoveryTime < 10 * MINUTE * IN_MILLISECONDS) - ++count; - ++itr; - } + if (spellInfo->RecoveryTime > 10 * MINUTE * IN_MILLISECONDS || + spellInfo->CategoryRecoveryTime > 10 * MINUTE * IN_MILLISECONDS) + _spellCooldownsBeforeDuel[itr->first] = _spellCooldowns[itr->first]; + } + + _spellCooldowns = _spellCooldownsBeforeDuel; + + // update the client: clear all cooldowns + std::vector<int32> resetCooldowns; + resetCooldowns.reserve(_spellCooldowns.size()); + + for (auto itr = _spellCooldowns.begin(); itr != _spellCooldowns.end(); ++itr) + resetCooldowns.push_back(itr->first); - return count; + if (resetCooldowns.empty()) + return; + + SendClearCooldowns(resetCooldowns); + + // update the client: restore old cooldowns + PacketCooldowns cooldowns; + + for (auto itr = _spellCooldowns.begin(); itr != _spellCooldowns.end(); ++itr) + { + Clock::time_point now = Clock::now(); + uint32 cooldownDuration = itr->second.CooldownEnd > now ? std::chrono::duration_cast<std::chrono::milliseconds>(itr->second.CooldownEnd - now).count() : 0; + + // cooldownDuration must be between 0 and 10 minutes in order to avoid any visual bugs + if (cooldownDuration == 0 || cooldownDuration > 10 * MINUTE * IN_MILLISECONDS) + continue; + + cooldowns[itr->first] = cooldownDuration; + } + + WorldPacket data; + BuildCooldownPacket(data, SPELL_COOLDOWN_FLAG_NONE, cooldowns); + player->SendDirectMessage(&data); + } } template void SpellHistory::LoadFromDB<Player>(PreparedQueryResult cooldownsResult); diff --git a/src/server/game/Spells/SpellHistory.h b/src/server/game/Spells/SpellHistory.h index 4d0642d644e..572f407da96 100644 --- a/src/server/game/Spells/SpellHistory.h +++ b/src/server/game/Spells/SpellHistory.h @@ -38,15 +38,15 @@ public: struct CooldownEntry { - CooldownEntry() : ItemId(0), OnHold(false) { } - CooldownEntry(Clock::time_point endTime, uint32 itemId) : CooldownEnd(endTime), ItemId(itemId), OnHold(false) { } - Clock::time_point CooldownEnd; - uint32 ItemId; - bool OnHold; + uint32 ItemId = 0; + uint32 CategoryId = 0; + Clock::time_point CategoryEnd; + bool OnHold = false; }; typedef std::unordered_map<uint32 /*spellId*/, CooldownEntry> CooldownStorageType; + typedef std::unordered_map<uint32 /*categoryId*/, CooldownEntry*> CategoryCooldownStorageType; typedef std::unordered_map<uint32 /*categoryId*/, Clock::time_point> GlobalCooldownStorageType; explicit SpellHistory(Unit* owner) : _owner(owner), _schoolLockouts() { } @@ -60,7 +60,8 @@ public: void Update(); void HandleCooldowns(SpellInfo const* spellInfo, Item const* item, Spell* spell = nullptr); - bool IsReady(SpellInfo const* spellInfo) const; + void HandleCooldowns(SpellInfo const* spellInfo, uint32 itemID, Spell* spell = nullptr); + bool IsReady(SpellInfo const* spellInfo, uint32 itemId = 0) const; template<class OwnerType> void WritePacket(WorldPacket& packet) const; @@ -74,10 +75,11 @@ public: template<class Type, class Period> void AddCooldown(uint32 spellId, uint32 itemId, std::chrono::duration<Type, Period> cooldownDuration) { - AddCooldown(spellId, itemId, Clock::now() + std::chrono::duration_cast<Clock::duration>(cooldownDuration)); + Clock::time_point now = Clock::now(); + AddCooldown(spellId, itemId, now + std::chrono::duration_cast<Clock::duration>(cooldownDuration), 0, now); } - void AddCooldown(uint32 spellId, uint32 itemId, Clock::time_point cooldownEnd, bool onHold = false); + void AddCooldown(uint32 spellId, uint32 itemId, Clock::time_point cooldownEnd, uint32 categoryId, Clock::time_point categoryEnd, bool onHold = false); void ModifyCooldown(uint32 spellId, int32 cooldownModMs); void ResetCooldown(uint32 spellId, bool update = false); void ResetCooldown(CooldownStorageType::iterator& itr, bool update = false); @@ -102,8 +104,9 @@ public: } void ResetAllCooldowns(); - bool HasCooldown(uint32 spellId) const; - uint32 GetRemainingCooldown(uint32 spellId) const; + bool HasCooldown(SpellInfo const* spellInfo, uint32 itemId = 0) const; + bool HasCooldown(uint32 spellId, uint32 itemId = 0) const; + uint32 GetRemainingCooldown(SpellInfo const* spellInfo) const; // School lockouts void LockSpellSchool(SpellSchoolMask schoolMask, uint32 lockoutTime); @@ -117,17 +120,25 @@ public: void BuildCooldownPacket(WorldPacket& data, uint8 flags, uint32 spellId, uint32 cooldown) const; CooldownStorageType::size_type GetCooldownsSizeForPacket() const { return _spellCooldowns.size(); } - uint16 GetArenaCooldownsSize(); + void SaveCooldownStateBeforeDuel(); + void RestoreCooldownStateAfterDuel(); private: Player* GetPlayerOwner() const; void SendClearCooldowns(std::vector<int32> const& cooldowns) const; + CooldownStorageType::iterator EraseCooldown(CooldownStorageType::iterator itr) + { + _categoryCooldowns.erase(itr->second.CategoryId); + return _spellCooldowns.erase(itr); + } typedef std::unordered_map<uint32, uint32> PacketCooldowns; void BuildCooldownPacket(WorldPacket& data, uint8 flags, PacketCooldowns const& cooldowns) const; Unit* _owner; CooldownStorageType _spellCooldowns; + CooldownStorageType _spellCooldownsBeforeDuel; + CategoryCooldownStorageType _categoryCooldowns; Clock::time_point _schoolLockouts[MAX_SPELL_SCHOOL]; GlobalCooldownStorageType _globalCooldowns; diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index ea5e4c8df0b..6486a7eada7 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -776,8 +776,8 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry) AttributesEx6 = spellEntry->AttributesEx6; AttributesEx7 = spellEntry->AttributesEx7; AttributesCu = 0; - Stances = spellEntry->Stances; - StancesNot = spellEntry->StancesNot; + Stances = MAKE_PAIR64(spellEntry->Stances[0], spellEntry->Stances[1]); + StancesNot = MAKE_PAIR64(spellEntry->StancesNot[0], spellEntry->StancesNot[1]); Targets = spellEntry->Targets; TargetCreatureType = spellEntry->TargetCreatureType; RequiresSpellFocus = spellEntry->RequiresSpellFocus; @@ -1309,7 +1309,7 @@ SpellCastResult SpellInfo::CheckShapeshift(uint32 form) const (Effects[0].Effect == SPELL_EFFECT_LEARN_SPELL || Effects[1].Effect == SPELL_EFFECT_LEARN_SPELL || Effects[2].Effect == SPELL_EFFECT_LEARN_SPELL)) return SPELL_CAST_OK; - uint32 stanceMask = (form ? 1 << (form - 1) : 0); + uint64 stanceMask = (form ? UI64LIT(1) << (form - 1) : 0); if (stanceMask & StancesNot) // can explicitly not be cast in this stance return SPELL_FAILED_NOT_SHAPESHIFT; @@ -2658,7 +2658,7 @@ void SpellInfo::_UnloadImplicitTargetConditionLists() // find the same instances of ConditionList and delete them. for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { - ConditionList* cur = Effects[i].ImplicitTargetConditions; + ConditionContainer* cur = Effects[i].ImplicitTargetConditions; if (!cur) continue; for (uint8 j = i; j < MAX_SPELL_EFFECTS; ++j) diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index cfa9877405d..241e7df9544 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -249,7 +249,7 @@ public: uint32 ItemType; uint32 TriggerSpell; flag96 SpellClassMask; - std::list<Condition*>* ImplicitTargetConditions; + std::vector<Condition*>* ImplicitTargetConditions; SpellEffectInfo() : _spellInfo(NULL), _effIndex(0), Effect(0), ApplyAuraName(0), Amplitude(0), DieSides(0), RealPointsPerLevel(0), BasePoints(0), PointsPerComboPoint(0), ValueMultiplier(0), DamageMultiplier(0), @@ -306,8 +306,8 @@ public: uint32 AttributesEx6; uint32 AttributesEx7; uint32 AttributesCu; - uint32 Stances; - uint32 StancesNot; + uint64 Stances; + uint64 StancesNot; uint32 Targets; uint32 TargetCreatureType; uint32 RequiresSpellFocus; diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index f27f9220aaa..6305d0a456f 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -3105,11 +3105,13 @@ void SpellMgr::LoadSpellInfoCorrections() case 28796: // Poison Bolt Volly - Faerlina spellInfo->MaxAffectedTargets = 5; break; + case 54835: // Curse of the Plaguebringer - Noth (H) + spellInfo->MaxAffectedTargets = 8; + break; case 40827: // Sinful Beam case 40859: // Sinister Beam case 40860: // Vile Beam case 40861: // Wicked Beam - case 54835: // Curse of the Plaguebringer - Noth (H) case 54098: // Poison Bolt Volly - Faerlina (H) spellInfo->MaxAffectedTargets = 10; break; @@ -3180,13 +3182,13 @@ void SpellMgr::LoadSpellInfoCorrections() // Master Shapeshifter: missing stance data for forms other than bear - bear version has correct data // To prevent aura staying on target after talent unlearned case 48420: - spellInfo->Stances = 1 << (FORM_CAT - 1); + spellInfo->Stances = UI64LIT(1) << (FORM_CAT - 1); break; case 48421: - spellInfo->Stances = 1 << (FORM_MOONKIN - 1); + spellInfo->Stances = UI64LIT(1) << (FORM_MOONKIN - 1); break; case 48422: - spellInfo->Stances = 1 << (FORM_TREE - 1); + spellInfo->Stances = UI64LIT(1) << (FORM_TREE - 1); break; case 51466: // Elemental Oath (Rank 1) case 51470: // Elemental Oath (Rank 2) diff --git a/src/server/game/Tools/PlayerDump.cpp b/src/server/game/Tools/PlayerDump.cpp index 8710100d9b3..0a47da1c788 100644 --- a/src/server/game/Tools/PlayerDump.cpp +++ b/src/server/game/Tools/PlayerDump.cpp @@ -21,6 +21,7 @@ #include "DatabaseEnv.h" #include "UpdateFields.h" #include "ObjectMgr.h" +#include "Player.h" #include "AccountMgr.h" #include "World.h" @@ -63,11 +64,15 @@ static DumpTable dumpTables[DUMP_TABLE_COUNT] = }; // Low level functions -static bool findtoknth(std::string &str, int n, std::string::size_type &s, std::string::size_type &e) +static bool FindTokNth(std::string const& str, uint32 n, std::string::size_type& s, std::string::size_type& e) { - int i; s = e = 0; - std::string::size_type size = str.size(); - for (i = 1; s < size && i < n; s++) if (str[s] == ' ') ++i; + s = e = 0; + + uint32 i = 1; + for (; s < str.size() && i < n; ++s) + if (str[s] == ' ') + ++i; + if (i < n) return false; @@ -76,80 +81,86 @@ static bool findtoknth(std::string &str, int n, std::string::size_type &s, std:: return e != std::string::npos; } -std::string gettoknth(std::string &str, int n) +std::string GetTokNth(std::string const& str, uint32 n) { std::string::size_type s = 0, e = 0; - if (!findtoknth(str, n, s, e)) + if (!FindTokNth(str, n, s, e)) return ""; - return str.substr(s, e-s); + return str.substr(s, e - s); } -bool findnth(std::string &str, int n, std::string::size_type &s, std::string::size_type &e) +bool FindNth(std::string const& str, uint32 n, std::string::size_type& s, std::string::size_type& e) { - s = str.find("VALUES ('")+9; - if (s == std::string::npos) return false; + s = str.find("VALUES ('") + 9; + if (s == std::string::npos) + return false; do { e = str.find('\'', s); - if (e == std::string::npos) return false; - } while (str[e-1] == '\\'); + if (e == std::string::npos) + return false; + } while (str[e - 1] == '\\'); - for (int i = 1; i < n; ++i) + for (uint32 i = 1; i < n; ++i) { do { - s = e+4; + s = e + 4; e = str.find('\'', s); - if (e == std::string::npos) return false; - } while (str[e-1] == '\\'); + if (e == std::string::npos) + return false; + } while (str[e - 1] == '\\'); } return true; } -std::string gettablename(std::string &str) +std::string GetTableName(std::string const& str) { - std::string::size_type s = 13; + static std::string::size_type const s = 13; std::string::size_type e = str.find(_TABLE_SIM_, s); if (e == std::string::npos) return ""; - return str.substr(s, e-s); + return str.substr(s, e - s); } -bool changenth(std::string &str, int n, char const* with, bool insert = false, bool nonzero = false) +bool ChangeNth(std::string& str, uint32 n, char const* with, bool insert = false, bool allowZero = false) { std::string::size_type s, e; - if (!findnth(str, n, s, e)) + if (!FindNth(str, n, s, e)) return false; - if (nonzero && str.substr(s, e-s) == "0") + if (allowZero && str.substr(s, e - s) == "0") return true; // not an error + if (!insert) - str.replace(s, e-s, with); + str.replace(s, e - s, with); else str.insert(s, with); return true; } -std::string getnth(std::string &str, int n) +std::string GetNth(std::string& str, uint32 n) { std::string::size_type s, e; - if (!findnth(str, n, s, e)) + if (!FindNth(str, n, s, e)) return ""; return str.substr(s, e-s); } -bool changetoknth(std::string &str, int n, char const* with, bool insert = false, bool nonzero = false) +bool ChangeTokNth(std::string& str, uint32 n, char const* with, bool insert = false, bool allowZero = false) { std::string::size_type s = 0, e = 0; - if (!findtoknth(str, n, s, e)) + if (!FindTokNth(str, n, s, e)) return false; - if (nonzero && str.substr(s, e-s) == "0") + + if (allowZero && str.substr(s, e - s) == "0") return true; // not an error + if (!insert) str.replace(s, e-s, with); else @@ -158,41 +169,28 @@ bool changetoknth(std::string &str, int n, char const* with, bool insert = false return true; } -uint32 registerNewGuid(uint32 oldGuid, std::map<uint32, uint32> &guidMap, uint32 hiGuid) +ObjectGuid::LowType RegisterNewGuid(ObjectGuid::LowType oldGuid, PlayerDump::DumpGuidMap& guidMap, ObjectGuid::LowType guidOffset) { - std::map<uint32, uint32>::const_iterator itr = guidMap.find(oldGuid); + PlayerDumpWriter::DumpGuidMap::const_iterator itr = guidMap.find(oldGuid); if (itr != guidMap.end()) return itr->second; - uint32 newguid = hiGuid + guidMap.size(); + ObjectGuid::LowType newguid = guidOffset + guidMap.size(); guidMap[oldGuid] = newguid; return newguid; } -bool changeGuid(std::string &str, int n, std::map<uint32, uint32> &guidMap, uint32 hiGuid, bool nonzero = false) +bool ChangeGuid(std::string& str, uint32 n, PlayerDump::DumpGuidMap& guidMap, ObjectGuid::LowType guidOffset, bool allowZero = false) { - char chritem[20]; - uint32 oldGuid = atoi(getnth(str, n).c_str()); - if (nonzero && oldGuid == 0) + ObjectGuid::LowType oldGuid = strtoull(GetNth(str, n).c_str(), nullptr, 10); + if (allowZero && !oldGuid) return true; // not an error - uint32 newGuid = registerNewGuid(oldGuid, guidMap, hiGuid); - snprintf(chritem, 20, "%u", newGuid); - - return changenth(str, n, chritem, false, nonzero); -} - -bool changetokGuid(std::string &str, int n, std::map<uint32, uint32> &guidMap, uint32 hiGuid, bool nonzero = false) -{ char chritem[20]; - uint32 oldGuid = atoi(gettoknth(str, n).c_str()); - if (nonzero && oldGuid == 0) - return true; // not an error - - uint32 newGuid = registerNewGuid(oldGuid, guidMap, hiGuid); + ObjectGuid::LowType newGuid = RegisterNewGuid(oldGuid, guidMap, guidOffset); snprintf(chritem, 20, "%u", newGuid); - return changetoknth(str, n, chritem, false, nonzero); + return ChangeNth(str, n, chritem, false, allowZero); } std::string CreateDumpString(char const* tableName, QueryResult result) @@ -216,57 +214,54 @@ std::string CreateDumpString(char const* tableName, QueryResult result) return ss.str(); } -std::string PlayerDumpWriter::GenerateWhereStr(char const* field, uint32 guid) +std::string PlayerDumpWriter::GenerateWhereStr(char const* field, ObjectGuid::LowType guid) { std::ostringstream wherestr; wherestr << field << " = '" << guid << '\''; return wherestr.str(); } -std::string PlayerDumpWriter::GenerateWhereStr(char const* field, GUIDs const& guids, GUIDs::const_iterator& itr) +std::string PlayerDumpWriter::GenerateWhereStr(char const* field, DumpGuidSet const& guids, DumpGuidSet::const_iterator& itr) { std::ostringstream wherestr; wherestr << field << " IN ('"; - for (; itr != guids.end(); ++itr) + for (; itr != guids.end();) { wherestr << *itr; + ++itr; if (wherestr.str().size() > MAX_QUERY_LEN - 50) // near to max query - { - ++itr; break; - } - GUIDs::const_iterator itr2 = itr; - if (++itr2 != guids.end()) + if (itr != guids.end()) wherestr << "', '"; } wherestr << "')"; return wherestr.str(); } -void StoreGUID(QueryResult result, uint32 field, std::set<uint32>& guids) +void StoreGUID(QueryResult result, uint32 field, PlayerDump::DumpGuidSet &guids) { Field* fields = result->Fetch(); - uint32 guid = fields[field].GetUInt32(); + ObjectGuid::LowType guid = fields[field].GetUInt32(); if (guid) guids.insert(guid); } -void StoreGUID(QueryResult result, uint32 data, uint32 field, std::set<uint32>& guids) +void StoreGUID(QueryResult result, uint32 data, uint32 field, PlayerDump::DumpGuidSet& guids) { Field* fields = result->Fetch(); std::string dataStr = fields[data].GetString(); - uint32 guid = atoi(gettoknth(dataStr, field).c_str()); + ObjectGuid::LowType guid = strtoull(GetTokNth(dataStr, field).c_str(), nullptr, 10); if (guid) guids.insert(guid); } // Writing - High-level functions -bool PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type) +bool PlayerDumpWriter::DumpTable(std::string& dump, ObjectGuid::LowType guid, char const* tableFrom, char const* tableTo, DumpTableType type) { - GUIDs const* guids = NULL; - char const* fieldname = NULL; + DumpGuidSet const* guids = nullptr; + char const* fieldname = nullptr; switch (type) { @@ -281,20 +276,20 @@ bool PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tabl // for guid set stop if set is empty if (guids && guids->empty()) - return true; // nothing to do + return true; // nothing to do // setup for guids case start position - GUIDs::const_iterator guids_itr; + DumpGuidSet::const_iterator guidsItr; if (guids) - guids_itr = guids->begin(); + guidsItr = guids->begin(); do { std::string wherestr; - if (guids) // set case, get next guids string - wherestr = GenerateWhereStr(fieldname, *guids, guids_itr); - else // not set case, get single guid string + if (guids) // set case, get next guids string + wherestr = GenerateWhereStr(fieldname, *guids, guidsItr); + else // not set case, get single guid string wherestr = GenerateWhereStr(fieldname, guid); QueryResult result = CharacterDatabase.PQuery("SELECT * FROM %s WHERE %s", tableFrom, wherestr.c_str()); @@ -336,16 +331,16 @@ bool PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tabl } while (result->NextRow()); } - while (guids && guids_itr != guids->end()); // not set case iterate single time, set case iterate for all guids + while (guids && guidsItr != guids->end()); // not set case iterate single time, set case iterate for all guids return true; } -bool PlayerDumpWriter::GetDump(uint32 guid, std::string &dump) +bool PlayerDumpWriter::GetDump(ObjectGuid::LowType guid, std::string &dump) { dump = "IMPORTANT NOTE: THIS DUMPFILE IS MADE FOR USE WITH THE 'PDUMP' COMMAND ONLY - EITHER THROUGH INGAME CHAT OR ON CONSOLE!\n"; dump += "IMPORTANT NOTE: DO NOT apply it directly - it will irreversibly DAMAGE and CORRUPT your database! You have been warned!\n\n"; - for (int i = 0; i < DUMP_TABLE_COUNT; ++i) + for (uint8 i = 0; i < DUMP_TABLE_COUNT; ++i) if (!DumpTable(dump, guid, dumpTables[i].name, dumpTables[i].name, dumpTables[i].type)) return false; @@ -355,17 +350,19 @@ bool PlayerDumpWriter::GetDump(uint32 guid, std::string &dump) return true; } -DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, uint32 guid) +DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, ObjectGuid::LowType guid) { if (sWorld->getBoolConfig(CONFIG_PDUMP_NO_PATHS)) if (strstr(file.c_str(), "\\") || strstr(file.c_str(), "/")) return DUMP_FILE_OPEN_ERROR; + if (sWorld->getBoolConfig(CONFIG_PDUMP_NO_OVERWRITE)) if (FILE* f = fopen(file.c_str(), "r")) { fclose(f); return DUMP_FILE_OPEN_ERROR; } + FILE* fout = fopen(file.c_str(), "w"); if (!fout) return DUMP_FILE_OPEN_ERROR; @@ -383,9 +380,9 @@ DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, uint32 guid) // Reading - High-level functions #define ROLLBACK(DR) {fclose(fin); return (DR);} -void fixNULLfields(std::string &line) +void fixNULLfields(std::string& line) { - std::string nullString("'NULL'"); + static std::string const nullString("'NULL'"); size_t pos = line.find(nullString); while (pos != std::string::npos) { @@ -394,7 +391,7 @@ void fixNULLfields(std::string &line) } } -DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, std::string name, uint32 guid) +DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, std::string name, ObjectGuid::LowType guid) { uint32 charcount = AccountMgr::GetCharactersCount(account); if (charcount >= 10) @@ -404,7 +401,7 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s if (!fin) return DUMP_FILE_OPEN_ERROR; - char newguid[20], chraccount[20], newpetid[20], currpetid[20], lastpetid[20]; + char newguid[20], chraccount[20]; // make sure the same guid doesn't already exist and is safe to use bool incHighest = true; @@ -418,7 +415,8 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s if (result) guid = sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed(); // use first free if exists - else incHighest = false; + else + incHighest = false; } else guid = sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed(); @@ -428,7 +426,7 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s if (!normalizePlayerName(name)) name.clear(); - if (ObjectMgr::CheckPlayerName(name, true) == CHAR_NAME_SUCCESS) + if (ObjectMgr::CheckPlayerName(name, sWorld->GetDefaultDbcLocale(), true) == CHAR_NAME_SUCCESS) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHECK_NAME); stmt->setString(0, name); @@ -444,22 +442,22 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s snprintf(newguid, 20, "%u", guid); snprintf(chraccount, 20, "%u", account); - snprintf(newpetid, 20, "%u", sObjectMgr->GeneratePetNumber()); - snprintf(lastpetid, 20, "%s", ""); - std::map<uint32, uint32> items; - std::map<uint32, uint32> mails; - char buf[32000] = ""; + DumpGuidMap items; + DumpGuidMap mails; + char buf[32000]; + memset(buf, 0, sizeof(buf)); - typedef std::map<uint32, uint32> PetIds; // old->new petid relation - typedef PetIds::value_type PetIdsPair; - PetIds petids; + typedef std::map<uint32 /*old*/, uint32 /*new*/> PetIds; + PetIds petIds; uint8 gender = GENDER_NONE; uint8 race = RACE_NONE; uint8 playerClass = 0; uint8 level = 1; + ObjectGuid::LowType itemLowGuidOffset = sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed(); + SQLTransaction trans = CharacterDatabase.BeginTransaction(); while (!feof(fin)) { @@ -495,7 +493,7 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s */ // determine table name and load type - std::string tn = gettablename(line); + std::string tn = GetTableName(line); if (tn.empty()) { TC_LOG_ERROR("misc", "LoadPlayerDump: Can't extract table name from line: '%s'!", line.c_str()); @@ -524,142 +522,139 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s { case DTT_CHARACTER: { - if (!changenth(line, 1, newguid)) // characters.guid update + if (!ChangeNth(line, 1, newguid)) // characters.guid update ROLLBACK(DUMP_FILE_BROKEN); - if (!changenth(line, 2, chraccount)) // characters.account update + if (!ChangeNth(line, 2, chraccount)) // characters.account update ROLLBACK(DUMP_FILE_BROKEN); - race = uint8(atoul(getnth(line, 4).c_str())); - playerClass = uint8(atoul(getnth(line, 5).c_str())); - gender = uint8(atoul(getnth(line, 6).c_str())); - level = uint8(atoul(getnth(line, 7).c_str())); + race = uint8(atoul(GetNth(line, 4).c_str())); + playerClass = uint8(atoul(GetNth(line, 5).c_str())); + gender = uint8(atoul(GetNth(line, 6).c_str())); + level = uint8(atoul(GetNth(line, 7).c_str())); if (name.empty()) { // check if the original name already exists - name = getnth(line, 3); + name = GetNth(line, 3); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHECK_NAME); stmt->setString(0, name); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (result) - if (!changenth(line, 37, "1")) // characters.at_login set to "rename on login" + if (!ChangeNth(line, 37, "1")) // characters.at_login set to "rename on login" ROLLBACK(DUMP_FILE_BROKEN); } - else if (!changenth(line, 3, name.c_str())) // characters.name + else if (!ChangeNth(line, 3, name.c_str())) // characters.name ROLLBACK(DUMP_FILE_BROKEN); const char null[5] = "NULL"; - if (!changenth(line, 69, null)) // characters.deleteInfos_Account + if (!ChangeNth(line, 69, null)) // characters.deleteInfos_Account ROLLBACK(DUMP_FILE_BROKEN); - if (!changenth(line, 70, null)) // characters.deleteInfos_Name + if (!ChangeNth(line, 70, null)) // characters.deleteInfos_Name ROLLBACK(DUMP_FILE_BROKEN); - if (!changenth(line, 71, null)) // characters.deleteDate + if (!ChangeNth(line, 71, null)) // characters.deleteDate ROLLBACK(DUMP_FILE_BROKEN); break; } case DTT_CHAR_TABLE: { - if (!changenth(line, 1, newguid)) // character_*.guid update + if (!ChangeNth(line, 1, newguid)) // character_*.guid update ROLLBACK(DUMP_FILE_BROKEN); break; } case DTT_EQSET_TABLE: { - if (!changenth(line, 1, newguid)) + if (!ChangeNth(line, 1, newguid)) ROLLBACK(DUMP_FILE_BROKEN); // character_equipmentsets.guid char newSetGuid[24]; snprintf(newSetGuid, 24, UI64FMTD, sObjectMgr->GenerateEquipmentSetGuid()); - if (!changenth(line, 2, newSetGuid)) + if (!ChangeNth(line, 2, newSetGuid)) ROLLBACK(DUMP_FILE_BROKEN); // character_equipmentsets.setguid + + for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; ++slot) + if (!ChangeGuid(line, 7 + slot, items, itemLowGuidOffset, true)) + ROLLBACK(DUMP_FILE_BROKEN); // character_equipmentsets.item break; } case DTT_INVENTORY: { - if (!changenth(line, 1, newguid)) // character_inventory.guid update + if (!ChangeNth(line, 1, newguid)) // character_inventory.guid update ROLLBACK(DUMP_FILE_BROKEN); - if (!changeGuid(line, 2, items,sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed(), true)) + if (!ChangeGuid(line, 2, items, itemLowGuidOffset, true)) ROLLBACK(DUMP_FILE_BROKEN); // character_inventory.bag update - if (!changeGuid(line, 4, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed())) + if (!ChangeGuid(line, 4, items, itemLowGuidOffset)) ROLLBACK(DUMP_FILE_BROKEN); // character_inventory.item update break; } case DTT_MAIL: // mail { - if (!changeGuid(line, 1, mails, sObjectMgr->_mailId)) + if (!ChangeGuid(line, 1, mails, sObjectMgr->_mailId)) ROLLBACK(DUMP_FILE_BROKEN); // mail.id update - if (!changenth(line, 6, newguid)) // mail.receiver update + if (!ChangeNth(line, 6, newguid)) // mail.receiver update ROLLBACK(DUMP_FILE_BROKEN); break; } case DTT_MAIL_ITEM: // mail_items { - if (!changeGuid(line, 1, mails, sObjectMgr->_mailId)) + if (!ChangeGuid(line, 1, mails, sObjectMgr->_mailId)) ROLLBACK(DUMP_FILE_BROKEN); // mail_items.id - if (!changeGuid(line, 2, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed())) + if (!ChangeGuid(line, 2, items, itemLowGuidOffset)) ROLLBACK(DUMP_FILE_BROKEN); // mail_items.item_guid - if (!changenth(line, 3, newguid)) // mail_items.receiver + if (!ChangeNth(line, 3, newguid)) // mail_items.receiver ROLLBACK(DUMP_FILE_BROKEN); break; } case DTT_ITEM: { // item, owner, data field:item, owner guid - if (!changeGuid(line, 1, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed())) + if (!ChangeGuid(line, 1, items, itemLowGuidOffset)) ROLLBACK(DUMP_FILE_BROKEN); // item_instance.guid update - if (!changenth(line, 3, newguid)) // item_instance.owner_guid update + if (!ChangeNth(line, 3, newguid)) // item_instance.owner_guid update ROLLBACK(DUMP_FILE_BROKEN); break; } case DTT_ITEM_GIFT: { - if (!changenth(line, 1, newguid)) // character_gifts.guid update + if (!ChangeNth(line, 1, newguid)) // character_gifts.guid update ROLLBACK(DUMP_FILE_BROKEN); - if (!changeGuid(line, 2, items, sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed())) + if (!ChangeGuid(line, 2, items, itemLowGuidOffset)) ROLLBACK(DUMP_FILE_BROKEN); // character_gifts.item_guid update break; } case DTT_PET: { - //store a map of old pet id to new inserted pet id for use by type 5 tables - snprintf(currpetid, 20, "%s", getnth(line, 1).c_str()); - if (*lastpetid == '\0') - snprintf(lastpetid, 20, "%s", currpetid); - if (strcmp(lastpetid, currpetid) != 0) - { - snprintf(newpetid, 20, "%u", sObjectMgr->GeneratePetNumber()); - snprintf(lastpetid, 20, "%s", currpetid); - } + // store a map of old pet id to new inserted pet id for use by DTT_PET_TABLE tables + std::string petIdStr = GetNth(line, 1); - std::map<uint32, uint32> :: const_iterator petids_iter = petids.find(atoi(currpetid)); + uint32 currentPetId = atoul(petIdStr.c_str()); - if (petids_iter == petids.end()) - { - petids.insert(PetIdsPair(atoi(currpetid), atoi(newpetid))); - } + PetIds::const_iterator petIdsItr = petIds.find(currentPetId); + if (petIdsItr != petIds.end()) // duplicate pets + ROLLBACK(DUMP_FILE_BROKEN); + + uint32 newPetId = sObjectMgr->GeneratePetNumber(); + petIds[currentPetId] = newPetId; - if (!changenth(line, 1, newpetid)) // character_pet.id update + if (!ChangeNth(line, 1, std::to_string(newPetId).c_str())) // character_pet.id update ROLLBACK(DUMP_FILE_BROKEN); - if (!changenth(line, 3, newguid)) // character_pet.owner update + if (!ChangeNth(line, 3, newguid)) // character_pet.owner update ROLLBACK(DUMP_FILE_BROKEN); break; } case DTT_PET_TABLE: // pet_aura, pet_spell, pet_spell_cooldown { - snprintf(currpetid, 20, "%s", getnth(line, 1).c_str()); + std::string petIdStr = GetNth(line, 1); // lookup currpetid and match to new inserted pet id - std::map<uint32, uint32> :: const_iterator petids_iter = petids.find(atoi(currpetid)); - if (petids_iter == petids.end()) // couldn't find new inserted id + PetIds::const_iterator petIdsItr = petIds.find(atoul(petIdStr.c_str())); + if (petIdsItr == petIds.end()) // couldn't find new inserted id ROLLBACK(DUMP_FILE_BROKEN); - snprintf(newpetid, 20, "%d", petids_iter->second); - - if (!changenth(line, 1, newpetid)) + if (!ChangeNth(line, 1, std::to_string(petIdsItr->second).c_str())) ROLLBACK(DUMP_FILE_BROKEN); break; @@ -677,7 +672,7 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s CharacterDatabase.CommitTransaction(trans); // in case of name conflict player has to rename at login anyway - sWorld->AddCharacterNameData(ObjectGuid(HighGuid::Player, guid), name, gender, race, playerClass, level); + sWorld->AddCharacterInfo(ObjectGuid(HighGuid::Player, guid), account, name, gender, race, playerClass, level); sObjectMgr->GetGenerator<HighGuid::Item>().Set(sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed() + items.size()); diff --git a/src/server/game/Tools/PlayerDump.h b/src/server/game/Tools/PlayerDump.h index 5a26c10b7d8..5cdcc4b6bb8 100644 --- a/src/server/game/Tools/PlayerDump.h +++ b/src/server/game/Tools/PlayerDump.h @@ -22,6 +22,7 @@ #include <string> #include <map> #include <set> +#include "ObjectGuid.h" enum DumpTableType { @@ -63,6 +64,10 @@ enum DumpReturn class PlayerDump { + public: + typedef std::set<ObjectGuid::LowType> DumpGuidSet; + typedef std::map<ObjectGuid::LowType, ObjectGuid::LowType> DumpGuidMap; + protected: PlayerDump() { } }; @@ -72,18 +77,17 @@ class PlayerDumpWriter : public PlayerDump public: PlayerDumpWriter() { } - bool GetDump(uint32 guid, std::string& dump); - DumpReturn WriteDump(std::string const& file, uint32 guid); - private: - typedef std::set<uint32> GUIDs; + bool GetDump(ObjectGuid::LowType guid, std::string& dump); + DumpReturn WriteDump(std::string const& file, ObjectGuid::LowType guid); - bool DumpTable(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type); - std::string GenerateWhereStr(char const* field, GUIDs const& guids, GUIDs::const_iterator& itr); - std::string GenerateWhereStr(char const* field, uint32 guid); + private: + bool DumpTable(std::string& dump, ObjectGuid::LowType guid, char const* tableFrom, char const* tableTo, DumpTableType type); + std::string GenerateWhereStr(char const* field, DumpGuidSet const& guids, DumpGuidSet::const_iterator& itr); + std::string GenerateWhereStr(char const* field, ObjectGuid::LowType guid); - GUIDs pets; - GUIDs mails; - GUIDs items; + DumpGuidSet pets; + DumpGuidSet mails; + DumpGuidSet items; }; class PlayerDumpReader : public PlayerDump @@ -91,7 +95,7 @@ class PlayerDumpReader : public PlayerDump public: PlayerDumpReader() { } - DumpReturn LoadDump(std::string const& file, uint32 account, std::string name, uint32 guid); + DumpReturn LoadDump(std::string const& file, uint32 account, std::string name, ObjectGuid::LowType guid); }; #endif diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 85e79168b71..a0dd889876c 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -269,10 +269,7 @@ void World::AddSession_(WorldSession* s) return; } - s->SendAuthResponse(AUTH_OK, true); - s->SendAddonsInfo(); - s->SendClientCacheVersion(sWorld->getIntConfig(CONFIG_CLIENTCACHE_VERSION)); - s->SendTutorialsData(); + s->InitializeSession(); UpdateMaxSessionCounters(); @@ -362,15 +359,7 @@ bool World::RemoveQueuedPlayer(WorldSession* sess) if ((!m_playerLimit || sessions < m_playerLimit) && !m_QueuedPlayer.empty()) { WorldSession* pop_sess = m_QueuedPlayer.front(); - pop_sess->SetInQueue(false); - pop_sess->ResetTimeOutTime(); - pop_sess->SendAuthWaitQue(0); - pop_sess->SendAddonsInfo(); - - pop_sess->SendClientCacheVersion(sWorld->getIntConfig(CONFIG_CLIENTCACHE_VERSION)); - pop_sess->SendAccountDataTimes(GLOBAL_CACHE_MASK); - pop_sess->SendTutorialsData(); - + pop_sess->InitializeSession(); m_QueuedPlayer.pop_front(); // update iter to point first queued socket or end() if queue is empty now @@ -456,6 +445,7 @@ void World::LoadConfigSettings(bool reload) rate_values[RATE_DROP_ITEM_REFERENCED_AMOUNT] = sConfigMgr->GetFloatDefault("Rate.Drop.Item.ReferencedAmount", 1.0f); rate_values[RATE_DROP_MONEY] = sConfigMgr->GetFloatDefault("Rate.Drop.Money", 1.0f); rate_values[RATE_XP_KILL] = sConfigMgr->GetFloatDefault("Rate.XP.Kill", 1.0f); + rate_values[RATE_XP_BG_KILL] = sConfigMgr->GetFloatDefault("Rate.XP.BattlegroundKill", 1.0f); rate_values[RATE_XP_QUEST] = sConfigMgr->GetFloatDefault("Rate.XP.Quest", 1.0f); rate_values[RATE_XP_EXPLORE] = sConfigMgr->GetFloatDefault("Rate.XP.Explore", 1.0f); rate_values[RATE_REPAIRCOST] = sConfigMgr->GetFloatDefault("Rate.RepairCost", 1.0f); @@ -1037,6 +1027,7 @@ void World::LoadConfigSettings(bool reload) m_bool_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE] = sConfigMgr->GetBoolDefault("Battleground.QueueAnnouncer.Enable", false); m_bool_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY] = sConfigMgr->GetBoolDefault("Battleground.QueueAnnouncer.PlayerOnly", false); m_bool_configs[CONFIG_BATTLEGROUND_STORE_STATISTICS_ENABLE] = sConfigMgr->GetBoolDefault("Battleground.StoreStatistics.Enable", false); + m_bool_configs[CONFIG_BATTLEGROUND_TRACK_DESERTERS] = sConfigMgr->GetBoolDefault("Battleground.TrackDeserters.Enable", false); m_int_configs[CONFIG_BATTLEGROUND_INVITATION_TYPE] = sConfigMgr->GetIntDefault ("Battleground.InvitationType", 0); m_int_configs[CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER] = sConfigMgr->GetIntDefault ("Battleground.PrematureFinishTimer", 5 * MINUTE * IN_MILLISECONDS); m_int_configs[CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH] = sConfigMgr->GetIntDefault ("Battleground.PremadeGroupWaitForMatch", 30 * MINUTE * IN_MILLISECONDS); @@ -1190,7 +1181,7 @@ void World::LoadConfigSettings(bool reload) m_int_configs[CONFIG_MAX_WHO] = sConfigMgr->GetIntDefault("MaxWhoListReturns", 49); m_bool_configs[CONFIG_START_ALL_SPELLS] = sConfigMgr->GetBoolDefault("PlayerStart.AllSpells", false); m_int_configs[CONFIG_HONOR_AFTER_DUEL] = sConfigMgr->GetIntDefault("HonorPointsAfterDuel", 0); - m_bool_configs[CONFIG_RESET_COOLDOWN_AFTER_DUEL] = sConfigMgr->GetBoolDefault("ResetCoolDownAfterDuel", 0); + m_bool_configs[CONFIG_RESET_DUEL_COOLDOWNS] = sConfigMgr->GetBoolDefault("ResetDuelCooldowns", false); m_bool_configs[CONFIG_START_ALL_EXPLORED] = sConfigMgr->GetBoolDefault("PlayerStart.MapsExplored", false); m_bool_configs[CONFIG_START_ALL_REP] = sConfigMgr->GetBoolDefault("PlayerStart.AllReputation", false); m_bool_configs[CONFIG_ALWAYS_MAXSKILL] = sConfigMgr->GetBoolDefault("AlwaysMaxWeaponSkill", false); @@ -1644,6 +1635,9 @@ void World::SetInitialWorldSettings() TC_LOG_INFO("server.loading", "Loading Skill Extra Item Table..."); LoadSkillExtraItemTable(); + TC_LOG_INFO("server.loading", "Loading Skill Perfection Data Table..."); + LoadSkillPerfectItemTable(); + TC_LOG_INFO("server.loading", "Loading Skill Fishing base level requirements..."); sObjectMgr->LoadFishingBaseSkillLevel(); @@ -1877,7 +1871,7 @@ void World::SetInitialWorldSettings() TC_LOG_INFO("server.loading", "Calculate guild limitation(s) reset time..."); InitGuildResetTime(); - LoadCharacterNameData(); + LoadCharacterInfoStore(); uint32 startupDuration = GetMSTimeDiffToNow(startupBegin); @@ -2505,7 +2499,7 @@ bool World::RemoveBanAccount(BanMode mode, std::string const& nameOrIP) BanReturn World::BanCharacter(std::string const& name, std::string const& duration, std::string const& reason, std::string const& author) { Player* pBanned = ObjectAccessor::FindConnectedPlayerByName(name); - uint32 guid = 0; + ObjectGuid::LowType guid = 0; uint32 duration_secs = TimeStringToSecs(duration); @@ -2546,7 +2540,7 @@ BanReturn World::BanCharacter(std::string const& name, std::string const& durati bool World::RemoveBanCharacter(std::string const& name) { Player* pBanned = ObjectAccessor::FindConnectedPlayerByName(name); - uint32 guid = 0; + ObjectGuid::LowType guid = 0; /// Pick a player to ban if not online if (!pBanned) @@ -3168,6 +3162,15 @@ void World::ProcessQueryCallbacks() } } +CharacterInfo const* World::GetCharacterInfo(ObjectGuid const& guid) const +{ + CharacterInfoContainer::const_iterator itr = _characterInfoStore.find(guid); + if (itr != _characterInfoStore.end()) + return &itr->second; + + return nullptr; +} + /** * @brief Loads several pieces of information on server startup with the GUID * There is no further database query necessary. @@ -3177,87 +3180,78 @@ void World::ProcessQueryCallbacks() * @return Name, Gender, Race, Class and Level of player character * Example Usage: * @code -* CharacterNameData const* nameData = sWorld->GetCharacterNameData(GUID); -* if (!nameData) +* CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(GUID); +* if (!characterInfo) * return; * -* std::string playerName = nameData->m_name; -* uint8 playerGender = nameData->m_gender; -* uint8 playerRace = nameData->m_race; -* uint8 playerClass = nameData->m_class; -* uint8 playerLevel = nameData->m_level; +* std::string playerName = characterInfo->Name; +* uint8 playerGender = characterInfo->Sex; +* uint8 playerRace = characterInfo->Race; +* uint8 playerClass = characterInfo->Class; +* uint8 playerLevel = characterInfo->Level; * @endcode **/ -void World::LoadCharacterNameData() +void World::LoadCharacterInfoStore() { - TC_LOG_INFO("server.loading", "Loading character name data"); + TC_LOG_INFO("server.loading", "Loading character info store"); + + _characterInfoStore.clear(); - QueryResult result = CharacterDatabase.Query("SELECT guid, name, race, gender, class, level FROM characters WHERE deleteDate IS NULL"); + QueryResult result = CharacterDatabase.Query("SELECT guid, name, account, race, gender, class, level FROM characters"); if (!result) { TC_LOG_INFO("server.loading", "No character name data loaded, empty query"); return; } - uint32 count = 0; - do { Field* fields = result->Fetch(); - AddCharacterNameData(ObjectGuid(HighGuid::Player, fields[0].GetUInt32()), fields[1].GetString(), - fields[3].GetUInt8() /*gender*/, fields[2].GetUInt8() /*race*/, fields[4].GetUInt8() /*class*/, fields[5].GetUInt8() /*level*/); - ++count; + AddCharacterInfo(ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32()), fields[2].GetUInt32(), fields[1].GetString(), + fields[4].GetUInt8() /*gender*/, fields[3].GetUInt8() /*race*/, fields[5].GetUInt8() /*class*/, fields[6].GetUInt8() /*level*/); } while (result->NextRow()); - TC_LOG_INFO("server.loading", "Loaded name data for %u characters", count); + TC_LOG_INFO("server.loading", "Loaded character infos for " SZFMTD " characters", _characterInfoStore.size()); } -void World::AddCharacterNameData(ObjectGuid guid, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level) +void World::AddCharacterInfo(ObjectGuid const& guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level) { - CharacterNameData& data = _characterNameDataMap[guid]; - data.m_name = name; - data.m_race = race; - data.m_gender = gender; - data.m_class = playerClass; - data.m_level = level; + CharacterInfo& data = _characterInfoStore[guid]; + data.Name = name; + data.AccountId = accountId; + data.Race = race; + data.Sex = gender; + data.Class = playerClass; + data.Level = level; } -void World::UpdateCharacterNameData(ObjectGuid guid, std::string const& name, uint8 gender /*= GENDER_NONE*/, uint8 race /*= RACE_NONE*/) +void World::UpdateCharacterInfo(ObjectGuid const& guid, std::string const& name, uint8 gender /*= GENDER_NONE*/, uint8 race /*= RACE_NONE*/) { - std::map<ObjectGuid, CharacterNameData>::iterator itr = _characterNameDataMap.find(guid); - if (itr == _characterNameDataMap.end()) + CharacterInfoContainer::iterator itr = _characterInfoStore.find(guid); + if (itr == _characterInfoStore.end()) return; - itr->second.m_name = name; + itr->second.Name = name; if (gender != GENDER_NONE) - itr->second.m_gender = gender; + itr->second.Sex = gender; if (race != RACE_NONE) - itr->second.m_race = race; + itr->second.Race = race; WorldPacket data(SMSG_INVALIDATE_PLAYER, 8); data << guid; SendGlobalMessage(&data); } -void World::UpdateCharacterNameDataLevel(ObjectGuid guid, uint8 level) +void World::UpdateCharacterInfoLevel(ObjectGuid const& guid, uint8 level) { - std::map<ObjectGuid, CharacterNameData>::iterator itr = _characterNameDataMap.find(guid); - if (itr == _characterNameDataMap.end()) + CharacterInfoContainer::iterator itr = _characterInfoStore.find(guid); + if (itr == _characterInfoStore.end()) return; - itr->second.m_level = level; -} - -CharacterNameData const* World::GetCharacterNameData(ObjectGuid guid) const -{ - std::map<ObjectGuid, CharacterNameData>::const_iterator itr = _characterNameDataMap.find(guid); - if (itr != _characterNameDataMap.end()) - return &itr->second; - else - return NULL; + itr->second.Level = level; } void World::ReloadRBAC() diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 1f71975cde2..b8ffc946615 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -124,6 +124,7 @@ enum WorldBoolConfigs CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE, CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY, CONFIG_BATTLEGROUND_STORE_STATISTICS_ENABLE, + CONFIG_BATTLEGROUND_TRACK_DESERTERS, CONFIG_BG_XP_FOR_KILL, CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS, CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE, @@ -161,7 +162,7 @@ enum WorldBoolConfigs CONFIG_ALLOW_TRACK_BOTH_RESOURCES, CONFIG_CALCULATE_CREATURE_ZONE_AREA_DATA, CONFIG_CALCULATE_GAMEOBJECT_ZONE_AREA_DATA, - CONFIG_RESET_COOLDOWN_AFTER_DUEL, + CONFIG_RESET_DUEL_COOLDOWNS, BOOL_CONFIG_VALUE_COUNT }; @@ -374,6 +375,7 @@ enum Rates RATE_DROP_ITEM_REFERENCED_AMOUNT, RATE_DROP_MONEY, RATE_XP_KILL, + RATE_XP_BG_KILL, RATE_XP_QUEST, RATE_XP_EXPLORE, RATE_REPAIRCOST, @@ -523,13 +525,14 @@ private: typedef std::unordered_map<uint32, WorldSession*> SessionMap; -struct CharacterNameData +struct CharacterInfo { - std::string m_name; - uint8 m_class; - uint8 m_race; - uint8 m_gender; - uint8 m_level; + std::string Name; + uint32 AccountId; + uint8 Class; + uint8 Race; + uint8 Sex; + uint8 Level; }; /// The World @@ -749,12 +752,12 @@ class World void UpdateAreaDependentAuras(); - CharacterNameData const* GetCharacterNameData(ObjectGuid guid) const; - void AddCharacterNameData(ObjectGuid guid, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level); - void UpdateCharacterNameData(ObjectGuid guid, std::string const& name, uint8 gender = GENDER_NONE, uint8 race = RACE_NONE); - void UpdateCharacterNameDataLevel(ObjectGuid guid, uint8 level); - void DeleteCharacterNameData(ObjectGuid guid) { _characterNameDataMap.erase(guid); } - bool HasCharacterNameData(ObjectGuid guid) { return _characterNameDataMap.find(guid) != _characterNameDataMap.end(); } + CharacterInfo const* GetCharacterInfo(ObjectGuid const& guid) const; + void AddCharacterInfo(ObjectGuid const& guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level); + void DeleteCharacterInfo(ObjectGuid const& guid) { _characterInfoStore.erase(guid); } + bool HasCharacterInfo(ObjectGuid const& guid) { return _characterInfoStore.find(guid) != _characterInfoStore.end(); } + void UpdateCharacterInfo(ObjectGuid const& guid, std::string const& name, uint8 gender = GENDER_NONE, uint8 race = RACE_NONE); + void UpdateCharacterInfoLevel(ObjectGuid const& guid, uint8 level); uint32 GetCleaningFlags() const { return m_CleaningFlags; } void SetCleaningFlags(uint32 flags) { m_CleaningFlags = flags; } @@ -861,8 +864,9 @@ class World typedef std::map<uint8, uint8> AutobroadcastsWeightMap; AutobroadcastsWeightMap m_AutobroadcastsWeights; - std::map<ObjectGuid, CharacterNameData> _characterNameDataMap; - void LoadCharacterNameData(); + typedef std::unordered_map<ObjectGuid, CharacterInfo> CharacterInfoContainer; + CharacterInfoContainer _characterInfoStore; + void LoadCharacterInfoStore(); void ProcessQueryCallbacks(); std::deque<std::future<PreparedQueryResult>> m_realmCharCallbacks; diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index 04520101d15..8d9a40d9d1f 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -33,45 +33,40 @@ class account_commandscript : public CommandScript public: account_commandscript() : CommandScript("account_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand accountSetSecTable[] = + static std::vector<ChatCommand> accountSetSecTable = { - { "regmail", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC_REGMAIL, true, &HandleAccountSetRegEmailCommand, "", NULL }, - { "email", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC_EMAIL, true, &HandleAccountSetEmailCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "regmail", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC_REGMAIL, true, &HandleAccountSetRegEmailCommand, "" }, + { "email", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC_EMAIL, true, &HandleAccountSetEmailCommand, "" }, }; - static ChatCommand accountSetCommandTable[] = + static std::vector<ChatCommand> accountSetCommandTable = { - { "addon", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_ADDON, true, &HandleAccountSetAddonCommand, "", NULL }, + { "addon", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_ADDON, true, &HandleAccountSetAddonCommand, "" }, { "sec", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC, true, NULL, "", accountSetSecTable }, - { "gmlevel", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_GMLEVEL, true, &HandleAccountSetGmLevelCommand, "", NULL }, - { "password", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_PASSWORD, true, &HandleAccountSetPasswordCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "gmlevel", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_GMLEVEL, true, &HandleAccountSetGmLevelCommand, "" }, + { "password", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_PASSWORD, true, &HandleAccountSetPasswordCommand, "" }, }; - static ChatCommand accountLockCommandTable[] = + static std::vector<ChatCommand> accountLockCommandTable = { - { "country", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK_COUNTRY, false, &HandleAccountLockCountryCommand, "", NULL }, - { "ip", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK_IP, false, &HandleAccountLockIpCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "country", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK_COUNTRY, false, &HandleAccountLockCountryCommand, "" }, + { "ip", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK_IP, false, &HandleAccountLockIpCommand, "" }, }; - static ChatCommand accountCommandTable[] = + static std::vector<ChatCommand> accountCommandTable = { - { "addon", rbac::RBAC_PERM_COMMAND_ACCOUNT_ADDON, false, &HandleAccountAddonCommand, "", NULL }, - { "create", rbac::RBAC_PERM_COMMAND_ACCOUNT_CREATE, true, &HandleAccountCreateCommand, "", NULL }, - { "delete", rbac::RBAC_PERM_COMMAND_ACCOUNT_DELETE, true, &HandleAccountDeleteCommand, "", NULL }, - { "email", rbac::RBAC_PERM_COMMAND_ACCOUNT_EMAIL, false, &HandleAccountEmailCommand, "", NULL }, - { "onlinelist", rbac::RBAC_PERM_COMMAND_ACCOUNT_ONLINE_LIST, true, &HandleAccountOnlineListCommand, "", NULL }, + { "addon", rbac::RBAC_PERM_COMMAND_ACCOUNT_ADDON, false, &HandleAccountAddonCommand, "" }, + { "create", rbac::RBAC_PERM_COMMAND_ACCOUNT_CREATE, true, &HandleAccountCreateCommand, "" }, + { "delete", rbac::RBAC_PERM_COMMAND_ACCOUNT_DELETE, true, &HandleAccountDeleteCommand, "" }, + { "email", rbac::RBAC_PERM_COMMAND_ACCOUNT_EMAIL, false, &HandleAccountEmailCommand, "" }, + { "onlinelist", rbac::RBAC_PERM_COMMAND_ACCOUNT_ONLINE_LIST, true, &HandleAccountOnlineListCommand, "" }, { "lock", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK, false, NULL, "", accountLockCommandTable }, { "set", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET, true, NULL, "", accountSetCommandTable }, - { "password", rbac::RBAC_PERM_COMMAND_ACCOUNT_PASSWORD, false, &HandleAccountPasswordCommand, "", NULL }, - { "", rbac::RBAC_PERM_COMMAND_ACCOUNT, false, &HandleAccountCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "password", rbac::RBAC_PERM_COMMAND_ACCOUNT_PASSWORD, false, &HandleAccountPasswordCommand, "" }, + { "", rbac::RBAC_PERM_COMMAND_ACCOUNT, false, &HandleAccountCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "account", rbac::RBAC_PERM_COMMAND_ACCOUNT, true, NULL, "", accountCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_achievement.cpp b/src/server/scripts/Commands/cs_achievement.cpp index 8a038844ec1..ea77bc1f189 100644 --- a/src/server/scripts/Commands/cs_achievement.cpp +++ b/src/server/scripts/Commands/cs_achievement.cpp @@ -33,17 +33,15 @@ class achievement_commandscript : public CommandScript public: achievement_commandscript() : CommandScript("achievement_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand achievementCommandTable[] = + static std::vector<ChatCommand> achievementCommandTable = { - { "add", rbac::RBAC_PERM_COMMAND_ACHIEVEMENT_ADD, false, &HandleAchievementAddCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "add", rbac::RBAC_PERM_COMMAND_ACHIEVEMENT_ADD, false, &HandleAchievementAddCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "achievement", rbac::RBAC_PERM_COMMAND_ACHIEVEMENT, false, NULL, "", achievementCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_ahbot.cpp b/src/server/scripts/Commands/cs_ahbot.cpp index 559a775da31..44889fccd37 100644 --- a/src/server/scripts/Commands/cs_ahbot.cpp +++ b/src/server/scripts/Commands/cs_ahbot.cpp @@ -33,44 +33,40 @@ class ahbot_commandscript : public CommandScript public: ahbot_commandscript(): CommandScript("ahbot_commandscript") {} - ChatCommand* GetCommands() const + std::vector<ChatCommand> GetCommands() const { - static ChatCommand ahbotItemsAmountCommandTable[] = + static std::vector<ChatCommand> ahbotItemsAmountCommandTable = { - { "gray", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_GRAY, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_GRAY>, "", NULL }, - { "white", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_WHITE, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_WHITE>, "", NULL }, - { "green", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_GREEN, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_GREEN>, "", NULL }, - { "blue", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_BLUE, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_BLUE>, "", NULL }, - { "purple", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_PURPLE, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_PURPLE>, "", NULL }, - { "orange", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_ORANGE, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_ORANGE>, "", NULL }, - { "yellow", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_YELLOW, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_YELLOW>, "", NULL }, - { "", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS, true, &HandleAHBotItemsAmountCommand, "", NULL }, - { NULL, 0, true, NULL, "", NULL } + { "gray", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_GRAY, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_GRAY>, "" }, + { "white", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_WHITE, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_WHITE>, "" }, + { "green", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_GREEN, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_GREEN>, "" }, + { "blue", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_BLUE, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_BLUE>, "" }, + { "purple", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_PURPLE, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_PURPLE>, "" }, + { "orange", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_ORANGE, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_ORANGE>, "" }, + { "yellow", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS_YELLOW, true, &HandleAHBotItemsAmountQualityCommand<AUCTION_QUALITY_YELLOW>, "" }, + { "", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS, true, &HandleAHBotItemsAmountCommand, "" }, }; - static ChatCommand ahbotItemsRatioCommandTable[] = + static std::vector<ChatCommand> ahbotItemsRatioCommandTable = { - { "alliance", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO_ALLIANCE, true, &HandleAHBotItemsRatioHouseCommand<AUCTION_HOUSE_ALLIANCE>, "", NULL }, - { "horde", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO_HORDE, true, &HandleAHBotItemsRatioHouseCommand<AUCTION_HOUSE_HORDE>, "", NULL }, - { "neutral", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO_NEUTRAL, true, &HandleAHBotItemsRatioHouseCommand<AUCTION_HOUSE_NEUTRAL>, "", NULL }, - { "", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO, true, &HandleAHBotItemsRatioCommand, "", NULL }, - { NULL, 0, true, NULL, "", NULL } + { "alliance", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO_ALLIANCE, true, &HandleAHBotItemsRatioHouseCommand<AUCTION_HOUSE_ALLIANCE>, "" }, + { "horde", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO_HORDE, true, &HandleAHBotItemsRatioHouseCommand<AUCTION_HOUSE_HORDE>, "" }, + { "neutral", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO_NEUTRAL, true, &HandleAHBotItemsRatioHouseCommand<AUCTION_HOUSE_NEUTRAL>, "" }, + { "", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO, true, &HandleAHBotItemsRatioCommand, "" }, }; - static ChatCommand ahbotCommandTable[] = + static std::vector<ChatCommand> ahbotCommandTable = { { "items", rbac::RBAC_PERM_COMMAND_AHBOT_ITEMS, true, NULL, "", ahbotItemsAmountCommandTable }, { "ratio", rbac::RBAC_PERM_COMMAND_AHBOT_RATIO, true, NULL, "", ahbotItemsRatioCommandTable }, - { "rebuild", rbac::RBAC_PERM_COMMAND_AHBOT_REBUILD, true, &HandleAHBotRebuildCommand, "", NULL }, - { "reload", rbac::RBAC_PERM_COMMAND_AHBOT_RELOAD, true, &HandleAHBotReloadCommand, "", NULL }, - { "status", rbac::RBAC_PERM_COMMAND_AHBOT_STATUS, true, &HandleAHBotStatusCommand, "", NULL }, - { NULL, 0, true, NULL, "", NULL } + { "rebuild", rbac::RBAC_PERM_COMMAND_AHBOT_REBUILD, true, &HandleAHBotRebuildCommand, "" }, + { "reload", rbac::RBAC_PERM_COMMAND_AHBOT_RELOAD, true, &HandleAHBotReloadCommand, "" }, + { "status", rbac::RBAC_PERM_COMMAND_AHBOT_STATUS, true, &HandleAHBotStatusCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "ahbot", rbac::RBAC_PERM_COMMAND_AHBOT, false, NULL, "", ahbotCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; diff --git a/src/server/scripts/Commands/cs_arena.cpp b/src/server/scripts/Commands/cs_arena.cpp index 4cafb651add..71657d51e7b 100644 --- a/src/server/scripts/Commands/cs_arena.cpp +++ b/src/server/scripts/Commands/cs_arena.cpp @@ -34,22 +34,20 @@ class arena_commandscript : public CommandScript public: arena_commandscript() : CommandScript("arena_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand arenaCommandTable[] = + static std::vector<ChatCommand> arenaCommandTable = { - { "create", rbac::RBAC_PERM_COMMAND_ARENA_CREATE, true, &HandleArenaCreateCommand, "", NULL }, - { "disband", rbac::RBAC_PERM_COMMAND_ARENA_DISBAND, true, &HandleArenaDisbandCommand, "", NULL }, - { "rename", rbac::RBAC_PERM_COMMAND_ARENA_RENAME, true, &HandleArenaRenameCommand, "", NULL }, - { "captain", rbac::RBAC_PERM_COMMAND_ARENA_CAPTAIN, false, &HandleArenaCaptainCommand, "", NULL }, - { "info", rbac::RBAC_PERM_COMMAND_ARENA_INFO, true, &HandleArenaInfoCommand, "", NULL }, - { "lookup", rbac::RBAC_PERM_COMMAND_ARENA_LOOKUP, false, &HandleArenaLookupCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "create", rbac::RBAC_PERM_COMMAND_ARENA_CREATE, true, &HandleArenaCreateCommand, "" }, + { "disband", rbac::RBAC_PERM_COMMAND_ARENA_DISBAND, true, &HandleArenaDisbandCommand, "" }, + { "rename", rbac::RBAC_PERM_COMMAND_ARENA_RENAME, true, &HandleArenaRenameCommand, "" }, + { "captain", rbac::RBAC_PERM_COMMAND_ARENA_CAPTAIN, false, &HandleArenaCaptainCommand, "" }, + { "info", rbac::RBAC_PERM_COMMAND_ARENA_INFO, true, &HandleArenaInfoCommand, "" }, + { "lookup", rbac::RBAC_PERM_COMMAND_ARENA_LOOKUP, false, &HandleArenaLookupCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "arena", rbac::RBAC_PERM_COMMAND_ARENA, false, NULL, "", arenaCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } @@ -275,14 +273,14 @@ public: arena->SetCaptain(targetGuid); - CharacterNameData const* oldCaptainNameData = sWorld->GetCharacterNameData(arena->GetCaptain()); + CharacterInfo const* oldCaptainNameData = sWorld->GetCharacterInfo(arena->GetCaptain()); if (!oldCaptainNameData) { handler->SetSentErrorMessage(true); return false; } - handler->PSendSysMessage(LANG_ARENA_CAPTAIN, arena->GetName().c_str(), arena->GetId(), oldCaptainNameData->m_name.c_str(), target->GetName().c_str()); + handler->PSendSysMessage(LANG_ARENA_CAPTAIN, arena->GetName().c_str(), arena->GetId(), oldCaptainNameData->Name.c_str(), target->GetName().c_str()); if (handler->GetSession()) TC_LOG_DEBUG("bg.arena", "GameMaster: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team \"%s\"[Id: %u]", handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().GetCounter(), target->GetName().c_str(), target->GetGUID().GetCounter(), arena->GetName().c_str(), arena->GetId()); diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp index fc246898186..67015cd7d9c 100644 --- a/src/server/scripts/Commands/cs_ban.cpp +++ b/src/server/scripts/Commands/cs_ban.cpp @@ -35,45 +35,40 @@ class ban_commandscript : public CommandScript public: ban_commandscript() : CommandScript("ban_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand unbanCommandTable[] = + static std::vector<ChatCommand> unbanCommandTable = { - { "account", rbac::RBAC_PERM_COMMAND_UNBAN_ACCOUNT, true, &HandleUnBanAccountCommand, "", NULL }, - { "character", rbac::RBAC_PERM_COMMAND_UNBAN_CHARACTER, true, &HandleUnBanCharacterCommand, "", NULL }, - { "playeraccount", rbac::RBAC_PERM_COMMAND_UNBAN_PLAYERACCOUNT, true, &HandleUnBanAccountByCharCommand, "", NULL }, - { "ip", rbac::RBAC_PERM_COMMAND_UNBAN_IP, true, &HandleUnBanIPCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "account", rbac::RBAC_PERM_COMMAND_UNBAN_ACCOUNT, true, &HandleUnBanAccountCommand, "" }, + { "character", rbac::RBAC_PERM_COMMAND_UNBAN_CHARACTER, true, &HandleUnBanCharacterCommand, "" }, + { "playeraccount", rbac::RBAC_PERM_COMMAND_UNBAN_PLAYERACCOUNT, true, &HandleUnBanAccountByCharCommand, "" }, + { "ip", rbac::RBAC_PERM_COMMAND_UNBAN_IP, true, &HandleUnBanIPCommand, "" }, }; - static ChatCommand banlistCommandTable[] = + static std::vector<ChatCommand> banlistCommandTable = { - { "account", rbac::RBAC_PERM_COMMAND_BANLIST_ACCOUNT, true, &HandleBanListAccountCommand, "", NULL }, - { "character", rbac::RBAC_PERM_COMMAND_BANLIST_CHARACTER, true, &HandleBanListCharacterCommand, "", NULL }, - { "ip", rbac::RBAC_PERM_COMMAND_BANLIST_IP, true, &HandleBanListIPCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "account", rbac::RBAC_PERM_COMMAND_BANLIST_ACCOUNT, true, &HandleBanListAccountCommand, "" }, + { "character", rbac::RBAC_PERM_COMMAND_BANLIST_CHARACTER, true, &HandleBanListCharacterCommand, "" }, + { "ip", rbac::RBAC_PERM_COMMAND_BANLIST_IP, true, &HandleBanListIPCommand, "" }, }; - static ChatCommand baninfoCommandTable[] = + static std::vector<ChatCommand> baninfoCommandTable = { - { "account", rbac::RBAC_PERM_COMMAND_BANINFO_ACCOUNT, true, &HandleBanInfoAccountCommand, "", NULL }, - { "character", rbac::RBAC_PERM_COMMAND_BANINFO_CHARACTER, true, &HandleBanInfoCharacterCommand, "", NULL }, - { "ip", rbac::RBAC_PERM_COMMAND_BANINFO_IP, true, &HandleBanInfoIPCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "account", rbac::RBAC_PERM_COMMAND_BANINFO_ACCOUNT, true, &HandleBanInfoAccountCommand, "" }, + { "character", rbac::RBAC_PERM_COMMAND_BANINFO_CHARACTER, true, &HandleBanInfoCharacterCommand, "" }, + { "ip", rbac::RBAC_PERM_COMMAND_BANINFO_IP, true, &HandleBanInfoIPCommand, "" }, }; - static ChatCommand banCommandTable[] = + static std::vector<ChatCommand> banCommandTable = { - { "account", rbac::RBAC_PERM_COMMAND_BAN_ACCOUNT, true, &HandleBanAccountCommand, "", NULL }, - { "character", rbac::RBAC_PERM_COMMAND_BAN_CHARACTER, true, &HandleBanCharacterCommand, "", NULL }, - { "playeraccount", rbac::RBAC_PERM_COMMAND_BAN_PLAYERACCOUNT, true, &HandleBanAccountByCharCommand, "", NULL }, - { "ip", rbac::RBAC_PERM_COMMAND_BAN_IP, true, &HandleBanIPCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "account", rbac::RBAC_PERM_COMMAND_BAN_ACCOUNT, true, &HandleBanAccountCommand, "" }, + { "character", rbac::RBAC_PERM_COMMAND_BAN_CHARACTER, true, &HandleBanCharacterCommand, "" }, + { "playeraccount", rbac::RBAC_PERM_COMMAND_BAN_PLAYERACCOUNT, true, &HandleBanAccountByCharCommand, "" }, + { "ip", rbac::RBAC_PERM_COMMAND_BAN_IP, true, &HandleBanIPCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "ban", rbac::RBAC_PERM_COMMAND_BAN, true, NULL, "", banCommandTable }, { "baninfo", rbac::RBAC_PERM_COMMAND_BANINFO, true, NULL, "", baninfoCommandTable }, { "banlist", rbac::RBAC_PERM_COMMAND_BANLIST, true, NULL, "", banlistCommandTable }, { "unban", rbac::RBAC_PERM_COMMAND_UNBAN, true, NULL, "", unbanCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } @@ -300,7 +295,7 @@ public: return false; Player* target = ObjectAccessor::FindPlayerByName(args); - uint32 targetGuid = 0; + ObjectGuid::LowType targetGuid = 0; std::string name(args); if (!target) diff --git a/src/server/scripts/Commands/cs_bf.cpp b/src/server/scripts/Commands/cs_bf.cpp index 830e801bcef..7101b89b5fa 100644 --- a/src/server/scripts/Commands/cs_bf.cpp +++ b/src/server/scripts/Commands/cs_bf.cpp @@ -31,21 +31,19 @@ class bf_commandscript : public CommandScript public: bf_commandscript() : CommandScript("bf_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand battlefieldcommandTable[] = + static std::vector<ChatCommand> battlefieldcommandTable = { - { "start", rbac::RBAC_PERM_COMMAND_BF_START, false, &HandleBattlefieldStart, "", NULL }, - { "stop", rbac::RBAC_PERM_COMMAND_BF_STOP, false, &HandleBattlefieldEnd, "", NULL }, - { "switch", rbac::RBAC_PERM_COMMAND_BF_SWITCH, false, &HandleBattlefieldSwitch, "", NULL }, - { "timer", rbac::RBAC_PERM_COMMAND_BF_TIMER, false, &HandleBattlefieldTimer, "", NULL }, - { "enable", rbac::RBAC_PERM_COMMAND_BF_ENABLE, false, &HandleBattlefieldEnable, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "start", rbac::RBAC_PERM_COMMAND_BF_START, false, &HandleBattlefieldStart, "" }, + { "stop", rbac::RBAC_PERM_COMMAND_BF_STOP, false, &HandleBattlefieldEnd, "" }, + { "switch", rbac::RBAC_PERM_COMMAND_BF_SWITCH, false, &HandleBattlefieldSwitch, "" }, + { "timer", rbac::RBAC_PERM_COMMAND_BF_TIMER, false, &HandleBattlefieldTimer, "" }, + { "enable", rbac::RBAC_PERM_COMMAND_BF_ENABLE, false, &HandleBattlefieldEnable, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "bf", rbac::RBAC_PERM_COMMAND_BF, false, NULL, "", battlefieldcommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_cast.cpp b/src/server/scripts/Commands/cs_cast.cpp index dfd0bb36755..f45e73b7c58 100644 --- a/src/server/scripts/Commands/cs_cast.cpp +++ b/src/server/scripts/Commands/cs_cast.cpp @@ -33,26 +33,43 @@ class cast_commandscript : public CommandScript public: cast_commandscript() : CommandScript("cast_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand castCommandTable[] = + static std::vector<ChatCommand> castCommandTable = { - { "back", rbac::RBAC_PERM_COMMAND_CAST_BACK, false, &HandleCastBackCommand, "", NULL }, - { "dist", rbac::RBAC_PERM_COMMAND_CAST_DIST, false, &HandleCastDistCommand, "", NULL }, - { "self", rbac::RBAC_PERM_COMMAND_CAST_SELF, false, &HandleCastSelfCommand, "", NULL }, - { "target", rbac::RBAC_PERM_COMMAND_CAST_TARGET, false, &HandleCastTargetCommad, "", NULL }, - { "dest", rbac::RBAC_PERM_COMMAND_CAST_DEST, false, &HandleCastDestCommand, "", NULL }, - { "", rbac::RBAC_PERM_COMMAND_CAST, false, &HandleCastCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "back", rbac::RBAC_PERM_COMMAND_CAST_BACK, false, &HandleCastBackCommand, "" }, + { "dist", rbac::RBAC_PERM_COMMAND_CAST_DIST, false, &HandleCastDistCommand, "" }, + { "self", rbac::RBAC_PERM_COMMAND_CAST_SELF, false, &HandleCastSelfCommand, "" }, + { "target", rbac::RBAC_PERM_COMMAND_CAST_TARGET, false, &HandleCastTargetCommad, "" }, + { "dest", rbac::RBAC_PERM_COMMAND_CAST_DEST, false, &HandleCastDestCommand, "" }, + { "", rbac::RBAC_PERM_COMMAND_CAST, false, &HandleCastCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "cast", rbac::RBAC_PERM_COMMAND_CAST, false, NULL, "", castCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } + static bool CheckSpellExistsAndIsValid(ChatHandler* handler, uint32 spellId) + { + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); + if (!spellInfo) + { + handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND); + handler->SetSentErrorMessage(true); + return false; + } + + if (!SpellMgr::IsSpellValid(spellInfo, handler->GetSession()->GetPlayer())) + { + handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spellId); + handler->SetSentErrorMessage(true); + return false; + } + return true; + } + static bool HandleCastCommand(ChatHandler* handler, char const* args) { if (!*args) @@ -71,20 +88,8 @@ public: if (!spellId) return false; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); - if (!spellInfo) - { - handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND); - handler->SetSentErrorMessage(true); + if (!CheckSpellExistsAndIsValid(handler, spellId)) return false; - } - - if (!SpellMgr::IsSpellValid(spellInfo, handler->GetSession()->GetPlayer())) - { - handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spellId); - handler->SetSentErrorMessage(true); - return false; - } char* triggeredStr = strtok(NULL, " "); if (triggeredStr) @@ -111,15 +116,13 @@ public: return false; } - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spellId = handler->extractSpellIdFromLink((char*)args); - if (!spellId || !sSpellMgr->GetSpellInfo(spellId)) - { - handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND); - handler->SetSentErrorMessage(true); + if (!spellId) + return false; + + if (!CheckSpellExistsAndIsValid(handler, spellId)) return false; - } char* triggeredStr = strtok(NULL, " "); if (triggeredStr) @@ -146,20 +149,8 @@ public: if (!spellId) return false; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); - if (!spellInfo) - { - handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND); - handler->SetSentErrorMessage(true); + if (!CheckSpellExistsAndIsValid(handler, spellId)) return false; - } - - if (!SpellMgr::IsSpellValid(spellInfo, handler->GetSession()->GetPlayer())) - { - handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spellId); - handler->SetSentErrorMessage(true); - return false; - } char* distStr = strtok(NULL, " "); @@ -192,28 +183,14 @@ public: return false; Unit* target = handler->getSelectedUnit(); - if (!target) - { - handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - handler->SetSentErrorMessage(true); - return false; - } // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spellId = handler->extractSpellIdFromLink((char*)args); if (!spellId) return false; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); - if (!spellInfo) - return false; - - if (!SpellMgr::IsSpellValid(spellInfo, handler->GetSession()->GetPlayer())) - { - handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spellId); - handler->SetSentErrorMessage(true); + if (!CheckSpellExistsAndIsValid(handler, spellId)) return false; - } target->CastSpell(target, spellId, false); @@ -239,12 +216,11 @@ public: // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spellId = handler->extractSpellIdFromLink((char*)args); - if (!spellId || !sSpellMgr->GetSpellInfo(spellId)) - { - handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND); - handler->SetSentErrorMessage(true); + if (!spellId) + return false; + + if (!CheckSpellExistsAndIsValid(handler, spellId)) return false; - } char* triggeredStr = strtok(NULL, " "); if (triggeredStr) @@ -273,12 +249,11 @@ public: // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spellId = handler->extractSpellIdFromLink((char*)args); - if (!spellId || !sSpellMgr->GetSpellInfo(spellId)) - { - handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND); - handler->SetSentErrorMessage(true); + if (!spellId) + return false; + + if (!CheckSpellExistsAndIsValid(handler, spellId)) return false; - } char* posX = strtok(NULL, " "); char* posY = strtok(NULL, " "); diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp index 405f6fde624..65dd44f8563 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -35,43 +35,39 @@ class character_commandscript : public CommandScript public: character_commandscript() : CommandScript("character_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand pdumpCommandTable[] = + static std::vector<ChatCommand> pdumpCommandTable = { - { "load", rbac::RBAC_PERM_COMMAND_PDUMP_LOAD, true, &HandlePDumpLoadCommand, "", NULL }, - { "write", rbac::RBAC_PERM_COMMAND_PDUMP_WRITE, true, &HandlePDumpWriteCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "load", rbac::RBAC_PERM_COMMAND_PDUMP_LOAD, true, &HandlePDumpLoadCommand, "" }, + { "write", rbac::RBAC_PERM_COMMAND_PDUMP_WRITE, true, &HandlePDumpWriteCommand, "" }, }; - static ChatCommand characterDeletedCommandTable[] = + static std::vector<ChatCommand> characterDeletedCommandTable = { - { "delete", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_DELETE, true, &HandleCharacterDeletedDeleteCommand, "", NULL }, - { "list", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_LIST, true, &HandleCharacterDeletedListCommand, "", NULL }, - { "restore", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_RESTORE, true, &HandleCharacterDeletedRestoreCommand, "", NULL }, - { "old", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_OLD, true, &HandleCharacterDeletedOldCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "delete", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_DELETE, true, &HandleCharacterDeletedDeleteCommand, "" }, + { "list", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_LIST, true, &HandleCharacterDeletedListCommand, "" }, + { "restore", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_RESTORE, true, &HandleCharacterDeletedRestoreCommand, "" }, + { "old", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED_OLD, true, &HandleCharacterDeletedOldCommand, "" }, }; - static ChatCommand characterCommandTable[] = + static std::vector<ChatCommand> characterCommandTable = { - { "customize", rbac::RBAC_PERM_COMMAND_CHARACTER_CUSTOMIZE, true, &HandleCharacterCustomizeCommand, "", NULL }, - { "changefaction", rbac::RBAC_PERM_COMMAND_CHARACTER_CHANGEFACTION, true, &HandleCharacterChangeFactionCommand, "", NULL }, - { "changerace", rbac::RBAC_PERM_COMMAND_CHARACTER_CHANGERACE, true, &HandleCharacterChangeRaceCommand, "", NULL }, + { "customize", rbac::RBAC_PERM_COMMAND_CHARACTER_CUSTOMIZE, true, &HandleCharacterCustomizeCommand, "", }, + { "changefaction", rbac::RBAC_PERM_COMMAND_CHARACTER_CHANGEFACTION, true, &HandleCharacterChangeFactionCommand, "", }, + { "changerace", rbac::RBAC_PERM_COMMAND_CHARACTER_CHANGERACE, true, &HandleCharacterChangeRaceCommand, "", }, { "deleted", rbac::RBAC_PERM_COMMAND_CHARACTER_DELETED, true, NULL, "", characterDeletedCommandTable }, - { "erase", rbac::RBAC_PERM_COMMAND_CHARACTER_ERASE, true, &HandleCharacterEraseCommand, "", NULL }, - { "level", rbac::RBAC_PERM_COMMAND_CHARACTER_LEVEL, true, &HandleCharacterLevelCommand, "", NULL }, - { "rename", rbac::RBAC_PERM_COMMAND_CHARACTER_RENAME, true, &HandleCharacterRenameCommand, "", NULL }, - { "reputation", rbac::RBAC_PERM_COMMAND_CHARACTER_REPUTATION, true, &HandleCharacterReputationCommand, "", NULL }, - { "titles", rbac::RBAC_PERM_COMMAND_CHARACTER_TITLES, true, &HandleCharacterTitlesCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "erase", rbac::RBAC_PERM_COMMAND_CHARACTER_ERASE, true, &HandleCharacterEraseCommand, "", }, + { "level", rbac::RBAC_PERM_COMMAND_CHARACTER_LEVEL, true, &HandleCharacterLevelCommand, "", }, + { "rename", rbac::RBAC_PERM_COMMAND_CHARACTER_RENAME, true, &HandleCharacterRenameCommand, "", }, + { "reputation", rbac::RBAC_PERM_COMMAND_CHARACTER_REPUTATION, true, &HandleCharacterReputationCommand, "", }, + { "titles", rbac::RBAC_PERM_COMMAND_CHARACTER_TITLES, true, &HandleCharacterTitlesCommand, "", }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "character", rbac::RBAC_PERM_COMMAND_CHARACTER, true, NULL, "", characterCommandTable }, - { "levelup", rbac::RBAC_PERM_COMMAND_LEVELUP, false, &HandleLevelUpCommand, "", NULL }, + { "levelup", rbac::RBAC_PERM_COMMAND_LEVELUP, false, &HandleLevelUpCommand, "" }, { "pdump", rbac::RBAC_PERM_COMMAND_PDUMP, true, NULL, "", pdumpCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } @@ -226,7 +222,7 @@ public: stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_NAME_DATA); stmt->setUInt32(0, delInfo.guid.GetCounter()); if (PreparedQueryResult result = CharacterDatabase.Query(stmt)) - sWorld->AddCharacterNameData(delInfo.guid, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8(), (*result)[3].GetUInt8()); + sWorld->AddCharacterInfo(delInfo.guid, delInfo.accountId, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8(), (*result)[3].GetUInt8()); } static void HandleCharacterLevel(Player* player, ObjectGuid playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler* handler) @@ -339,7 +335,7 @@ public: return false; } - if (ObjectMgr::CheckPlayerName(newName, true) != CHAR_NAME_SUCCESS) + if (ObjectMgr::CheckPlayerName(newName, target ? target->GetSession()->GetSessionDbcLocale() : sWorld->GetDefaultDbcLocale(), true) != CHAR_NAME_SUCCESS) { handler->SendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); @@ -386,7 +382,7 @@ public: CharacterDatabase.Execute(stmt); } - sWorld->UpdateCharacterNameData(targetGuid, newName); + sWorld->UpdateCharacterInfo(targetGuid, newName); handler->PSendSysMessage(LANG_RENAME_PLAYER_WITH_NEW_NAME, playerOldName.c_str(), newName.c_str()); @@ -899,7 +895,7 @@ public: return false; } - if (ObjectMgr::CheckPlayerName(name, true) != CHAR_NAME_SUCCESS) + if (ObjectMgr::CheckPlayerName(name, sWorld->GetDefaultDbcLocale(), true) != CHAR_NAME_SUCCESS) { handler->PSendSysMessage(LANG_INVALID_CHARACTER_NAME); handler->SetSentErrorMessage(true); @@ -909,7 +905,7 @@ public: guidStr = strtok(NULL, " "); } - uint32 guid = 0; + ObjectGuid::LowType guid = 0; if (guidStr) { diff --git a/src/server/scripts/Commands/cs_cheat.cpp b/src/server/scripts/Commands/cs_cheat.cpp index 78ba5a4dc74..2dc2c17bdc2 100644 --- a/src/server/scripts/Commands/cs_cheat.cpp +++ b/src/server/scripts/Commands/cs_cheat.cpp @@ -32,27 +32,24 @@ class cheat_commandscript : public CommandScript public: cheat_commandscript() : CommandScript("cheat_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - - static ChatCommand cheatCommandTable[] = + static std::vector<ChatCommand> cheatCommandTable = { - { "god", rbac::RBAC_PERM_COMMAND_CHEAT_GOD, false, &HandleGodModeCheatCommand, "", NULL }, - { "casttime", rbac::RBAC_PERM_COMMAND_CHEAT_CASTTIME, false, &HandleCasttimeCheatCommand, "", NULL }, - { "cooldown", rbac::RBAC_PERM_COMMAND_CHEAT_COOLDOWN, false, &HandleCoolDownCheatCommand, "", NULL }, - { "power", rbac::RBAC_PERM_COMMAND_CHEAT_POWER, false, &HandlePowerCheatCommand, "", NULL }, - { "waterwalk", rbac::RBAC_PERM_COMMAND_CHEAT_WATERWALK, false, &HandleWaterWalkCheatCommand, "", NULL }, - { "status", rbac::RBAC_PERM_COMMAND_CHEAT_STATUS, false, &HandleCheatStatusCommand, "", NULL }, - { "taxi", rbac::RBAC_PERM_COMMAND_CHEAT_TAXI, false, &HandleTaxiCheatCommand, "", NULL }, - { "explore", rbac::RBAC_PERM_COMMAND_CHEAT_EXPLORE, false, &HandleExploreCheatCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "god", rbac::RBAC_PERM_COMMAND_CHEAT_GOD, false, &HandleGodModeCheatCommand, "" }, + { "casttime", rbac::RBAC_PERM_COMMAND_CHEAT_CASTTIME, false, &HandleCasttimeCheatCommand, "" }, + { "cooldown", rbac::RBAC_PERM_COMMAND_CHEAT_COOLDOWN, false, &HandleCoolDownCheatCommand, "" }, + { "power", rbac::RBAC_PERM_COMMAND_CHEAT_POWER, false, &HandlePowerCheatCommand, "" }, + { "waterwalk", rbac::RBAC_PERM_COMMAND_CHEAT_WATERWALK, false, &HandleWaterWalkCheatCommand, "" }, + { "status", rbac::RBAC_PERM_COMMAND_CHEAT_STATUS, false, &HandleCheatStatusCommand, "" }, + { "taxi", rbac::RBAC_PERM_COMMAND_CHEAT_TAXI, false, &HandleTaxiCheatCommand, "" }, + { "explore", rbac::RBAC_PERM_COMMAND_CHEAT_EXPLORE, false, &HandleExploreCheatCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "cheat", rbac::RBAC_PERM_COMMAND_CHEAT, false, NULL, "", cheatCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 422104fedd5..7f517d09e90 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -42,66 +42,62 @@ class debug_commandscript : public CommandScript public: debug_commandscript() : CommandScript("debug_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand debugPlayCommandTable[] = + static std::vector<ChatCommand> debugPlayCommandTable = { - { "cinematic", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY_CINEMATIC, false, &HandleDebugPlayCinematicCommand, "", NULL }, - { "movie", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY_MOVIE, false, &HandleDebugPlayMovieCommand, "", NULL }, - { "sound", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY_SOUND, false, &HandleDebugPlaySoundCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "cinematic", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY_CINEMATIC, false, &HandleDebugPlayCinematicCommand, "" }, + { "movie", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY_MOVIE, false, &HandleDebugPlayMovieCommand, "" }, + { "sound", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY_SOUND, false, &HandleDebugPlaySoundCommand, "" }, }; - static ChatCommand debugSendCommandTable[] = + static std::vector<ChatCommand> debugSendCommandTable = { - { "buyerror", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_BUYERROR, false, &HandleDebugSendBuyErrorCommand, "", NULL }, - { "channelnotify", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_CHANNELNOTIFY, false, &HandleDebugSendChannelNotifyCommand, "", NULL }, - { "chatmessage", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_CHATMESSAGE, false, &HandleDebugSendChatMsgCommand, "", NULL }, - { "equiperror", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_EQUIPERROR, false, &HandleDebugSendEquipErrorCommand, "", NULL }, - { "largepacket", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_LARGEPACKET, false, &HandleDebugSendLargePacketCommand, "", NULL }, - { "opcode", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_OPCODE, false, &HandleDebugSendOpcodeCommand, "", NULL }, - { "qpartymsg", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_QPARTYMSG, false, &HandleDebugSendQuestPartyMsgCommand, "", NULL }, - { "qinvalidmsg", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_QINVALIDMSG, false, &HandleDebugSendQuestInvalidMsgCommand, "", NULL }, - { "sellerror", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_SELLERROR, false, &HandleDebugSendSellErrorCommand, "", NULL }, - { "setphaseshift", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_SETPHASESHIFT, false, &HandleDebugSendSetPhaseShiftCommand, "", NULL }, - { "spellfail", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_SPELLFAIL, false, &HandleDebugSendSpellFailCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "buyerror", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_BUYERROR, false, &HandleDebugSendBuyErrorCommand, "" }, + { "channelnotify", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_CHANNELNOTIFY, false, &HandleDebugSendChannelNotifyCommand, "" }, + { "chatmessage", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_CHATMESSAGE, false, &HandleDebugSendChatMsgCommand, "" }, + { "equiperror", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_EQUIPERROR, false, &HandleDebugSendEquipErrorCommand, "" }, + { "largepacket", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_LARGEPACKET, false, &HandleDebugSendLargePacketCommand, "" }, + { "opcode", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_OPCODE, false, &HandleDebugSendOpcodeCommand, "" }, + { "qpartymsg", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_QPARTYMSG, false, &HandleDebugSendQuestPartyMsgCommand, "" }, + { "qinvalidmsg", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_QINVALIDMSG, false, &HandleDebugSendQuestInvalidMsgCommand, "" }, + { "sellerror", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_SELLERROR, false, &HandleDebugSendSellErrorCommand, "" }, + { "setphaseshift", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_SETPHASESHIFT, false, &HandleDebugSendSetPhaseShiftCommand, "" }, + { "spellfail", rbac::RBAC_PERM_COMMAND_DEBUG_SEND_SPELLFAIL, false, &HandleDebugSendSpellFailCommand, "" }, }; - static ChatCommand debugCommandTable[] = + static std::vector<ChatCommand> debugCommandTable = { - { "setbit", rbac::RBAC_PERM_COMMAND_DEBUG_SETBIT, false, &HandleDebugSet32BitCommand, "", NULL }, - { "threat", rbac::RBAC_PERM_COMMAND_DEBUG_THREAT, false, &HandleDebugThreatListCommand, "", NULL }, - { "hostil", rbac::RBAC_PERM_COMMAND_DEBUG_HOSTIL, false, &HandleDebugHostileRefListCommand, "", NULL }, - { "anim", rbac::RBAC_PERM_COMMAND_DEBUG_ANIM, false, &HandleDebugAnimCommand, "", NULL }, - { "arena", rbac::RBAC_PERM_COMMAND_DEBUG_ARENA, false, &HandleDebugArenaCommand, "", NULL }, - { "bg", rbac::RBAC_PERM_COMMAND_DEBUG_BG, false, &HandleDebugBattlegroundCommand, "", NULL }, - { "getitemstate", rbac::RBAC_PERM_COMMAND_DEBUG_GETITEMSTATE, false, &HandleDebugGetItemStateCommand, "", NULL }, - { "lootrecipient", rbac::RBAC_PERM_COMMAND_DEBUG_LOOTRECIPIENT, false, &HandleDebugGetLootRecipientCommand, "", NULL }, - { "getvalue", rbac::RBAC_PERM_COMMAND_DEBUG_GETVALUE, false, &HandleDebugGetValueCommand, "", NULL }, - { "getitemvalue", rbac::RBAC_PERM_COMMAND_DEBUG_GETITEMVALUE, false, &HandleDebugGetItemValueCommand, "", NULL }, - { "Mod32Value", rbac::RBAC_PERM_COMMAND_DEBUG_MOD32VALUE, false, &HandleDebugMod32ValueCommand, "", NULL }, + { "setbit", rbac::RBAC_PERM_COMMAND_DEBUG_SETBIT, false, &HandleDebugSet32BitCommand, "" }, + { "threat", rbac::RBAC_PERM_COMMAND_DEBUG_THREAT, false, &HandleDebugThreatListCommand, "" }, + { "hostil", rbac::RBAC_PERM_COMMAND_DEBUG_HOSTIL, false, &HandleDebugHostileRefListCommand, "" }, + { "anim", rbac::RBAC_PERM_COMMAND_DEBUG_ANIM, false, &HandleDebugAnimCommand, "" }, + { "arena", rbac::RBAC_PERM_COMMAND_DEBUG_ARENA, false, &HandleDebugArenaCommand, "" }, + { "bg", rbac::RBAC_PERM_COMMAND_DEBUG_BG, false, &HandleDebugBattlegroundCommand, "" }, + { "getitemstate", rbac::RBAC_PERM_COMMAND_DEBUG_GETITEMSTATE, false, &HandleDebugGetItemStateCommand, "" }, + { "lootrecipient", rbac::RBAC_PERM_COMMAND_DEBUG_LOOTRECIPIENT, false, &HandleDebugGetLootRecipientCommand, "" }, + { "getvalue", rbac::RBAC_PERM_COMMAND_DEBUG_GETVALUE, false, &HandleDebugGetValueCommand, "" }, + { "getitemvalue", rbac::RBAC_PERM_COMMAND_DEBUG_GETITEMVALUE, false, &HandleDebugGetItemValueCommand, "" }, + { "Mod32Value", rbac::RBAC_PERM_COMMAND_DEBUG_MOD32VALUE, false, &HandleDebugMod32ValueCommand, "" }, { "play", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY, false, NULL, "", debugPlayCommandTable }, { "send", rbac::RBAC_PERM_COMMAND_DEBUG_SEND, false, NULL, "", debugSendCommandTable }, - { "setaurastate", rbac::RBAC_PERM_COMMAND_DEBUG_SETAURASTATE, false, &HandleDebugSetAuraStateCommand, "", NULL }, - { "setitemvalue", rbac::RBAC_PERM_COMMAND_DEBUG_SETITEMVALUE, false, &HandleDebugSetItemValueCommand, "", NULL }, - { "setvalue", rbac::RBAC_PERM_COMMAND_DEBUG_SETVALUE, false, &HandleDebugSetValueCommand, "", NULL }, - { "spawnvehicle", rbac::RBAC_PERM_COMMAND_DEBUG_SPAWNVEHICLE, false, &HandleDebugSpawnVehicleCommand, "", NULL }, - { "setvid", rbac::RBAC_PERM_COMMAND_DEBUG_SETVID, false, &HandleDebugSetVehicleIdCommand, "", NULL }, - { "entervehicle", rbac::RBAC_PERM_COMMAND_DEBUG_ENTERVEHICLE, false, &HandleDebugEnterVehicleCommand, "", NULL }, - { "uws", rbac::RBAC_PERM_COMMAND_DEBUG_UWS, false, &HandleDebugUpdateWorldStateCommand, "", NULL }, - { "update", rbac::RBAC_PERM_COMMAND_DEBUG_UPDATE, false, &HandleDebugUpdateCommand, "", NULL }, - { "itemexpire", rbac::RBAC_PERM_COMMAND_DEBUG_ITEMEXPIRE, false, &HandleDebugItemExpireCommand, "", NULL }, - { "areatriggers", rbac::RBAC_PERM_COMMAND_DEBUG_AREATRIGGERS, false, &HandleDebugAreaTriggersCommand, "", NULL }, - { "los", rbac::RBAC_PERM_COMMAND_DEBUG_LOS, false, &HandleDebugLoSCommand, "", NULL }, - { "moveflags", rbac::RBAC_PERM_COMMAND_DEBUG_MOVEFLAGS, false, &HandleDebugMoveflagsCommand, "", NULL }, - { "transport", rbac::RBAC_PERM_COMMAND_DEBUG_TRANSPORT, false, &HandleDebugTransportCommand, "", NULL }, - { "loadcells", rbac::RBAC_PERM_COMMAND_DEBUG_LOADCELLS, false, &HandleDebugLoadCellsCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "setaurastate", rbac::RBAC_PERM_COMMAND_DEBUG_SETAURASTATE, false, &HandleDebugSetAuraStateCommand, "" }, + { "setitemvalue", rbac::RBAC_PERM_COMMAND_DEBUG_SETITEMVALUE, false, &HandleDebugSetItemValueCommand, "" }, + { "setvalue", rbac::RBAC_PERM_COMMAND_DEBUG_SETVALUE, false, &HandleDebugSetValueCommand, "" }, + { "spawnvehicle", rbac::RBAC_PERM_COMMAND_DEBUG_SPAWNVEHICLE, false, &HandleDebugSpawnVehicleCommand, "" }, + { "setvid", rbac::RBAC_PERM_COMMAND_DEBUG_SETVID, false, &HandleDebugSetVehicleIdCommand, "" }, + { "entervehicle", rbac::RBAC_PERM_COMMAND_DEBUG_ENTERVEHICLE, false, &HandleDebugEnterVehicleCommand, "" }, + { "uws", rbac::RBAC_PERM_COMMAND_DEBUG_UWS, false, &HandleDebugUpdateWorldStateCommand, "" }, + { "update", rbac::RBAC_PERM_COMMAND_DEBUG_UPDATE, false, &HandleDebugUpdateCommand, "" }, + { "itemexpire", rbac::RBAC_PERM_COMMAND_DEBUG_ITEMEXPIRE, false, &HandleDebugItemExpireCommand, "" }, + { "areatriggers", rbac::RBAC_PERM_COMMAND_DEBUG_AREATRIGGERS, false, &HandleDebugAreaTriggersCommand, "" }, + { "los", rbac::RBAC_PERM_COMMAND_DEBUG_LOS, false, &HandleDebugLoSCommand, "" }, + { "moveflags", rbac::RBAC_PERM_COMMAND_DEBUG_MOVEFLAGS, false, &HandleDebugMoveflagsCommand, "" }, + { "transport", rbac::RBAC_PERM_COMMAND_DEBUG_TRANSPORT, false, &HandleDebugTransportCommand, "" }, + { "loadcells", rbac::RBAC_PERM_COMMAND_DEBUG_LOADCELLS, false, &HandleDebugLoadCellsCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "debug", rbac::RBAC_PERM_COMMAND_DEBUG, true, NULL, "", debugCommandTable }, - { "wpgps", rbac::RBAC_PERM_COMMAND_WPGPS, false, &HandleWPGPSCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "wpgps", rbac::RBAC_PERM_COMMAND_WPGPS, false, &HandleWPGPSCommand, "" }, }; return commandTable; } @@ -971,7 +967,7 @@ public: if (!e || !f) return false; - uint32 guid = (uint32)atoi(e); + ObjectGuid::LowType guid = (uint32)atoi(e); uint32 index = (uint32)atoi(f); Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid(HighGuid::Item, 0, guid)); @@ -1001,7 +997,7 @@ public: if (!e || !f || !g) return false; - uint32 guid = (uint32)atoi(e); + ObjectGuid::LowType guid = (uint32)atoi(e); uint32 index = (uint32)atoi(f); uint32 value = (uint32)atoi(g); @@ -1027,7 +1023,7 @@ public: if (!e) return false; - uint32 guid = (uint32)atoi(e); + ObjectGuid::LowType guid = (uint32)atoi(e); Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid(HighGuid::Item, guid)); diff --git a/src/server/scripts/Commands/cs_deserter.cpp b/src/server/scripts/Commands/cs_deserter.cpp index 2887ac8c134..9f461207707 100644 --- a/src/server/scripts/Commands/cs_deserter.cpp +++ b/src/server/scripts/Commands/cs_deserter.cpp @@ -43,31 +43,27 @@ public: * @brief Returns the command structure for the system. */ - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand deserterInstanceCommandTable[] = + static std::vector<ChatCommand> deserterInstanceCommandTable = { - { "add", rbac::RBAC_PERM_COMMAND_DESERTER_INSTANCE_ADD, false, &HandleDeserterInstanceAdd, "", NULL }, - { "remove", rbac::RBAC_PERM_COMMAND_DESERTER_INSTANCE_REMOVE, false, &HandleDeserterInstanceRemove, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "add", rbac::RBAC_PERM_COMMAND_DESERTER_INSTANCE_ADD, false, &HandleDeserterInstanceAdd, "" }, + { "remove", rbac::RBAC_PERM_COMMAND_DESERTER_INSTANCE_REMOVE, false, &HandleDeserterInstanceRemove, "" }, }; - static ChatCommand deserterBGCommandTable[] = + static std::vector<ChatCommand> deserterBGCommandTable = { - { "add", rbac::RBAC_PERM_COMMAND_DESERTER_BG_ADD, false, &HandleDeserterBGAdd, "", NULL }, - { "remove", rbac::RBAC_PERM_COMMAND_DESERTER_BG_REMOVE, false, &HandleDeserterBGRemove, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "add", rbac::RBAC_PERM_COMMAND_DESERTER_BG_ADD, false, &HandleDeserterBGAdd, "" }, + { "remove", rbac::RBAC_PERM_COMMAND_DESERTER_BG_REMOVE, false, &HandleDeserterBGRemove, "" }, }; - static ChatCommand deserterCommandTable[] = + static std::vector<ChatCommand> deserterCommandTable = { { "instance", rbac::RBAC_PERM_COMMAND_DESERTER_INSTANCE, false, NULL, "", deserterInstanceCommandTable }, { "bg", rbac::RBAC_PERM_COMMAND_DESERTER_BG, false, NULL, "", deserterBGCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "deserter", rbac::RBAC_PERM_COMMAND_DESERTER, false, NULL, "", deserterCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_disable.cpp b/src/server/scripts/Commands/cs_disable.cpp index 14f76945a80..8c73f3f41de 100644 --- a/src/server/scripts/Commands/cs_disable.cpp +++ b/src/server/scripts/Commands/cs_disable.cpp @@ -37,42 +37,38 @@ class disable_commandscript : public CommandScript public: disable_commandscript() : CommandScript("disable_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand removeDisableCommandTable[] = + static std::vector<ChatCommand> removeDisableCommandTable = { - { "spell", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_SPELL, true, &HandleRemoveDisableSpellCommand, "", NULL }, - { "quest", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_QUEST, true, &HandleRemoveDisableQuestCommand, "", NULL }, - { "map", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_MAP, true, &HandleRemoveDisableMapCommand, "", NULL }, - { "battleground", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_BATTLEGROUND, true, &HandleRemoveDisableBattlegroundCommand, "", NULL }, - { "achievement_criteria", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_ACHIEVEMENT_CRITERIA, true, &HandleRemoveDisableAchievementCriteriaCommand, "", NULL }, - { "outdoorpvp", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_OUTDOORPVP, true, &HandleRemoveDisableOutdoorPvPCommand, "", NULL }, - { "vmap", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_VMAP, true, &HandleRemoveDisableVmapCommand, "", NULL }, - { "mmap", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_MMAP, true, &HandleRemoveDisableMMapCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "spell", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_SPELL, true, &HandleRemoveDisableSpellCommand, "" }, + { "quest", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_QUEST, true, &HandleRemoveDisableQuestCommand, "" }, + { "map", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_MAP, true, &HandleRemoveDisableMapCommand, "" }, + { "battleground", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_BATTLEGROUND, true, &HandleRemoveDisableBattlegroundCommand, "" }, + { "achievement_criteria", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_ACHIEVEMENT_CRITERIA, true, &HandleRemoveDisableAchievementCriteriaCommand, "" }, + { "outdoorpvp", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_OUTDOORPVP, true, &HandleRemoveDisableOutdoorPvPCommand, "" }, + { "vmap", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_VMAP, true, &HandleRemoveDisableVmapCommand, "" }, + { "mmap", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE_MMAP, true, &HandleRemoveDisableMMapCommand, "" }, }; - static ChatCommand addDisableCommandTable[] = + static std::vector<ChatCommand> addDisableCommandTable = { - { "spell", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_SPELL, true, &HandleAddDisableSpellCommand, "", NULL }, - { "quest", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_QUEST, true, &HandleAddDisableQuestCommand, "", NULL }, - { "map", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_MAP, true, &HandleAddDisableMapCommand, "", NULL }, - { "battleground", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_BATTLEGROUND, true, &HandleAddDisableBattlegroundCommand, "", NULL }, - { "achievement_criteria", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_ACHIEVEMENT_CRITERIA, true, &HandleAddDisableAchievementCriteriaCommand, "", NULL }, - { "outdoorpvp", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_OUTDOORPVP, true, &HandleAddDisableOutdoorPvPCommand, "", NULL }, - { "vmap", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_VMAP, true, &HandleAddDisableVmapCommand, "", NULL }, - { "mmap", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_MMAP, true, &HandleAddDisableMMapCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "spell", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_SPELL, true, &HandleAddDisableSpellCommand, "" }, + { "quest", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_QUEST, true, &HandleAddDisableQuestCommand, "" }, + { "map", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_MAP, true, &HandleAddDisableMapCommand, "" }, + { "battleground", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_BATTLEGROUND, true, &HandleAddDisableBattlegroundCommand, "" }, + { "achievement_criteria", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_ACHIEVEMENT_CRITERIA, true, &HandleAddDisableAchievementCriteriaCommand, "" }, + { "outdoorpvp", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_OUTDOORPVP, true, &HandleAddDisableOutdoorPvPCommand, "" }, + { "vmap", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_VMAP, true, &HandleAddDisableVmapCommand, "" }, + { "mmap", rbac::RBAC_PERM_COMMAND_DISABLE_ADD_MMAP, true, &HandleAddDisableMMapCommand, "" }, }; - static ChatCommand disableCommandTable[] = + static std::vector<ChatCommand> disableCommandTable = { { "add", rbac::RBAC_PERM_COMMAND_DISABLE_ADD, true, NULL, "", addDisableCommandTable }, { "remove", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE, true, NULL, "", removeDisableCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "disable", rbac::RBAC_PERM_COMMAND_DISABLE, false, NULL, "", disableCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_event.cpp b/src/server/scripts/Commands/cs_event.cpp index 37495289149..352bce4e7f0 100644 --- a/src/server/scripts/Commands/cs_event.cpp +++ b/src/server/scripts/Commands/cs_event.cpp @@ -33,20 +33,18 @@ class event_commandscript : public CommandScript public: event_commandscript() : CommandScript("event_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand eventCommandTable[] = + static std::vector<ChatCommand> eventCommandTable = { - { "activelist", rbac::RBAC_PERM_COMMAND_EVENT_ACTIVELIST, true, &HandleEventActiveListCommand, "", NULL }, - { "start", rbac::RBAC_PERM_COMMAND_EVENT_START, true, &HandleEventStartCommand, "", NULL }, - { "stop", rbac::RBAC_PERM_COMMAND_EVENT_STOP, true, &HandleEventStopCommand, "", NULL }, - { "", rbac::RBAC_PERM_COMMAND_EVENT, true, &HandleEventInfoCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "activelist", rbac::RBAC_PERM_COMMAND_EVENT_ACTIVELIST, true, &HandleEventActiveListCommand, "" }, + { "start", rbac::RBAC_PERM_COMMAND_EVENT_START, true, &HandleEventStartCommand, "" }, + { "stop", rbac::RBAC_PERM_COMMAND_EVENT_STOP, true, &HandleEventStopCommand, "" }, + { "", rbac::RBAC_PERM_COMMAND_EVENT, true, &HandleEventInfoCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "event", rbac::RBAC_PERM_COMMAND_EVENT, false, NULL, "", eventCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp index 94e974bea0b..81b70603680 100644 --- a/src/server/scripts/Commands/cs_gm.cpp +++ b/src/server/scripts/Commands/cs_gm.cpp @@ -36,22 +36,20 @@ class gm_commandscript : public CommandScript public: gm_commandscript() : CommandScript("gm_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand gmCommandTable[] = + static std::vector<ChatCommand> gmCommandTable = { - { "chat", rbac::RBAC_PERM_COMMAND_GM_CHAT, false, &HandleGMChatCommand, "", NULL }, - { "fly", rbac::RBAC_PERM_COMMAND_GM_FLY, false, &HandleGMFlyCommand, "", NULL }, - { "ingame", rbac::RBAC_PERM_COMMAND_GM_INGAME, true, &HandleGMListIngameCommand, "", NULL }, - { "list", rbac::RBAC_PERM_COMMAND_GM_LIST, true, &HandleGMListFullCommand, "", NULL }, - { "visible", rbac::RBAC_PERM_COMMAND_GM_VISIBLE, false, &HandleGMVisibleCommand, "", NULL }, - { "", rbac::RBAC_PERM_COMMAND_GM, false, &HandleGMCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "chat", rbac::RBAC_PERM_COMMAND_GM_CHAT, false, &HandleGMChatCommand, "" }, + { "fly", rbac::RBAC_PERM_COMMAND_GM_FLY, false, &HandleGMFlyCommand, "" }, + { "ingame", rbac::RBAC_PERM_COMMAND_GM_INGAME, true, &HandleGMListIngameCommand, "" }, + { "list", rbac::RBAC_PERM_COMMAND_GM_LIST, true, &HandleGMListFullCommand, "" }, + { "visible", rbac::RBAC_PERM_COMMAND_GM_VISIBLE, false, &HandleGMVisibleCommand, "" }, + { "", rbac::RBAC_PERM_COMMAND_GM, false, &HandleGMCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "gm", rbac::RBAC_PERM_COMMAND_GM, false, NULL, "", gmCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp index ce1a42e6e78..a810106269e 100644 --- a/src/server/scripts/Commands/cs_go.cpp +++ b/src/server/scripts/Commands/cs_go.cpp @@ -36,27 +36,25 @@ class go_commandscript : public CommandScript public: go_commandscript() : CommandScript("go_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand goCommandTable[] = - { - { "creature", rbac::RBAC_PERM_COMMAND_GO_CREATURE, false, &HandleGoCreatureCommand, "", NULL }, - { "graveyard", rbac::RBAC_PERM_COMMAND_GO_GRAVEYARD, false, &HandleGoGraveyardCommand, "", NULL }, - { "grid", rbac::RBAC_PERM_COMMAND_GO_GRID, false, &HandleGoGridCommand, "", NULL }, - { "object", rbac::RBAC_PERM_COMMAND_GO_OBJECT, false, &HandleGoObjectCommand, "", NULL }, - { "taxinode", rbac::RBAC_PERM_COMMAND_GO_TAXINODE, false, &HandleGoTaxinodeCommand, "", NULL }, - { "trigger", rbac::RBAC_PERM_COMMAND_GO_TRIGGER, false, &HandleGoTriggerCommand, "", NULL }, - { "zonexy", rbac::RBAC_PERM_COMMAND_GO_ZONEXY, false, &HandleGoZoneXYCommand, "", NULL }, - { "xyz", rbac::RBAC_PERM_COMMAND_GO_XYZ, false, &HandleGoXYZCommand, "", NULL }, - { "ticket", rbac::RBAC_PERM_COMMAND_GO_TICKET, false, &HandleGoTicketCommand, "", NULL }, - { "", rbac::RBAC_PERM_COMMAND_GO, false, &HandleGoXYZCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + static std::vector<ChatCommand> goCommandTable = + { + { "creature", rbac::RBAC_PERM_COMMAND_GO_CREATURE, false, &HandleGoCreatureCommand, "" }, + { "graveyard", rbac::RBAC_PERM_COMMAND_GO_GRAVEYARD, false, &HandleGoGraveyardCommand, "" }, + { "grid", rbac::RBAC_PERM_COMMAND_GO_GRID, false, &HandleGoGridCommand, "" }, + { "object", rbac::RBAC_PERM_COMMAND_GO_OBJECT, false, &HandleGoObjectCommand, "" }, + { "taxinode", rbac::RBAC_PERM_COMMAND_GO_TAXINODE, false, &HandleGoTaxinodeCommand, "" }, + { "trigger", rbac::RBAC_PERM_COMMAND_GO_TRIGGER, false, &HandleGoTriggerCommand, "" }, + { "zonexy", rbac::RBAC_PERM_COMMAND_GO_ZONEXY, false, &HandleGoZoneXYCommand, "" }, + { "xyz", rbac::RBAC_PERM_COMMAND_GO_XYZ, false, &HandleGoXYZCommand, "" }, + { "ticket", rbac::RBAC_PERM_COMMAND_GO_TICKET, false, &HandleGoTicketCommand, "" }, + { "", rbac::RBAC_PERM_COMMAND_GO, false, &HandleGoXYZCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "go", rbac::RBAC_PERM_COMMAND_GO, false, NULL, "", goCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index 0a45506c736..fda9101fc3f 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -37,37 +37,33 @@ class gobject_commandscript : public CommandScript public: gobject_commandscript() : CommandScript("gobject_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand gobjectAddCommandTable[] = + static std::vector<ChatCommand> gobjectAddCommandTable = { - { "temp", rbac::RBAC_PERM_COMMAND_GOBJECT_ADD_TEMP, false, &HandleGameObjectAddTempCommand, "", NULL }, - { "", rbac::RBAC_PERM_COMMAND_GOBJECT_ADD, false, &HandleGameObjectAddCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "temp", rbac::RBAC_PERM_COMMAND_GOBJECT_ADD_TEMP, false, &HandleGameObjectAddTempCommand, "" }, + { "", rbac::RBAC_PERM_COMMAND_GOBJECT_ADD, false, &HandleGameObjectAddCommand, "" }, }; - static ChatCommand gobjectSetCommandTable[] = + static std::vector<ChatCommand> gobjectSetCommandTable = { - { "phase", rbac::RBAC_PERM_COMMAND_GOBJECT_SET_PHASE, false, &HandleGameObjectSetPhaseCommand, "", NULL }, - { "state", rbac::RBAC_PERM_COMMAND_GOBJECT_SET_STATE, false, &HandleGameObjectSetStateCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "phase", rbac::RBAC_PERM_COMMAND_GOBJECT_SET_PHASE, false, &HandleGameObjectSetPhaseCommand, "" }, + { "state", rbac::RBAC_PERM_COMMAND_GOBJECT_SET_STATE, false, &HandleGameObjectSetStateCommand, "" }, }; - static ChatCommand gobjectCommandTable[] = - { - { "activate", rbac::RBAC_PERM_COMMAND_GOBJECT_ACTIVATE, false, &HandleGameObjectActivateCommand, "", NULL }, - { "delete", rbac::RBAC_PERM_COMMAND_GOBJECT_DELETE, false, &HandleGameObjectDeleteCommand, "", NULL }, - { "info", rbac::RBAC_PERM_COMMAND_GOBJECT_INFO, false, &HandleGameObjectInfoCommand, "", NULL }, - { "move", rbac::RBAC_PERM_COMMAND_GOBJECT_MOVE, false, &HandleGameObjectMoveCommand, "", NULL }, - { "near", rbac::RBAC_PERM_COMMAND_GOBJECT_NEAR, false, &HandleGameObjectNearCommand, "", NULL }, - { "target", rbac::RBAC_PERM_COMMAND_GOBJECT_TARGET, false, &HandleGameObjectTargetCommand, "", NULL }, - { "turn", rbac::RBAC_PERM_COMMAND_GOBJECT_TURN, false, &HandleGameObjectTurnCommand, "", NULL }, + static std::vector<ChatCommand> gobjectCommandTable = + { + { "activate", rbac::RBAC_PERM_COMMAND_GOBJECT_ACTIVATE, false, &HandleGameObjectActivateCommand, "" }, + { "delete", rbac::RBAC_PERM_COMMAND_GOBJECT_DELETE, false, &HandleGameObjectDeleteCommand, "" }, + { "info", rbac::RBAC_PERM_COMMAND_GOBJECT_INFO, false, &HandleGameObjectInfoCommand, "" }, + { "move", rbac::RBAC_PERM_COMMAND_GOBJECT_MOVE, false, &HandleGameObjectMoveCommand, "" }, + { "near", rbac::RBAC_PERM_COMMAND_GOBJECT_NEAR, false, &HandleGameObjectNearCommand, "" }, + { "target", rbac::RBAC_PERM_COMMAND_GOBJECT_TARGET, false, &HandleGameObjectTargetCommand, "" }, + { "turn", rbac::RBAC_PERM_COMMAND_GOBJECT_TURN, false, &HandleGameObjectTurnCommand, "" }, { "add", rbac::RBAC_PERM_COMMAND_GOBJECT_ADD, false, NULL, "", gobjectAddCommandTable }, { "set", rbac::RBAC_PERM_COMMAND_GOBJECT_SET, false, NULL, "", gobjectSetCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "gobject", rbac::RBAC_PERM_COMMAND_GOBJECT, false, NULL, "", gobjectCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } @@ -81,7 +77,7 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; @@ -150,7 +146,7 @@ public: Map* map = player->GetMap(); GameObject* object = new GameObject; - uint32 guidLow = map->GenerateLowGuid<HighGuid::GameObject>(); + ObjectGuid::LowType guidLow = map->GenerateLowGuid<HighGuid::GameObject>(); if (!object->Create(guidLow, objectInfo->entry, map, player->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY)) { @@ -292,7 +288,8 @@ public: bool found = false; float x, y, z, o; - uint32 guidLow, id, phase; + ObjectGuid::LowType guidLow; + uint32 id, phase; uint16 mapId; uint32 poolId; @@ -352,7 +349,7 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; @@ -400,7 +397,7 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; @@ -459,7 +456,7 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; @@ -533,7 +530,7 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; @@ -587,7 +584,7 @@ public: do { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); float x = fields[2].GetFloat(); float y = fields[3].GetFloat(); @@ -656,7 +653,7 @@ public: if (!id) return false; - uint32 guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoi(id); if (!guidLow) return false; diff --git a/src/server/scripts/Commands/cs_group.cpp b/src/server/scripts/Commands/cs_group.cpp index 8152508c5df..054cff996f9 100644 --- a/src/server/scripts/Commands/cs_group.cpp +++ b/src/server/scripts/Commands/cs_group.cpp @@ -28,23 +28,21 @@ class group_commandscript : public CommandScript public: group_commandscript() : CommandScript("group_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand groupCommandTable[] = + static std::vector<ChatCommand> groupCommandTable = { - { "leader", rbac::RBAC_PERM_COMMAND_GROUP_LEADER, false, &HandleGroupLeaderCommand, "", NULL }, - { "disband", rbac::RBAC_PERM_COMMAND_GROUP_DISBAND, false, &HandleGroupDisbandCommand, "", NULL }, - { "remove", rbac::RBAC_PERM_COMMAND_GROUP_REMOVE, false, &HandleGroupRemoveCommand, "", NULL }, - { "join", rbac::RBAC_PERM_COMMAND_GROUP_JOIN, false, &HandleGroupJoinCommand, "", NULL }, - { "list", rbac::RBAC_PERM_COMMAND_GROUP_LIST, false, &HandleGroupListCommand, "", NULL }, - { "summon", rbac::RBAC_PERM_COMMAND_GROUP_SUMMON, false, &HandleGroupSummonCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "leader", rbac::RBAC_PERM_COMMAND_GROUP_LEADER, false, &HandleGroupLeaderCommand, "" }, + { "disband", rbac::RBAC_PERM_COMMAND_GROUP_DISBAND, false, &HandleGroupDisbandCommand, "" }, + { "remove", rbac::RBAC_PERM_COMMAND_GROUP_REMOVE, false, &HandleGroupRemoveCommand, "" }, + { "join", rbac::RBAC_PERM_COMMAND_GROUP_JOIN, false, &HandleGroupJoinCommand, "" }, + { "list", rbac::RBAC_PERM_COMMAND_GROUP_LIST, false, &HandleGroupListCommand, "" }, + { "summon", rbac::RBAC_PERM_COMMAND_GROUP_SUMMON, false, &HandleGroupSummonCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "group", rbac::RBAC_PERM_COMMAND_GROUP, false, NULL, "", groupCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_guild.cpp b/src/server/scripts/Commands/cs_guild.cpp index a735e296f59..04b633f6f40 100644 --- a/src/server/scripts/Commands/cs_guild.cpp +++ b/src/server/scripts/Commands/cs_guild.cpp @@ -34,23 +34,21 @@ class guild_commandscript : public CommandScript public: guild_commandscript() : CommandScript("guild_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand guildCommandTable[] = + static std::vector<ChatCommand> guildCommandTable = { - { "create", rbac::RBAC_PERM_COMMAND_GUILD_CREATE, true, &HandleGuildCreateCommand, "", NULL }, - { "delete", rbac::RBAC_PERM_COMMAND_GUILD_DELETE, true, &HandleGuildDeleteCommand, "", NULL }, - { "invite", rbac::RBAC_PERM_COMMAND_GUILD_INVITE, true, &HandleGuildInviteCommand, "", NULL }, - { "uninvite", rbac::RBAC_PERM_COMMAND_GUILD_UNINVITE, true, &HandleGuildUninviteCommand, "", NULL }, - { "rank", rbac::RBAC_PERM_COMMAND_GUILD_RANK, true, &HandleGuildRankCommand, "", NULL }, - { "rename", rbac::RBAC_PERM_COMMAND_GUILD_RENAME, true, &HandleGuildRenameCommand, "", NULL }, - { "info", rbac::RBAC_PERM_COMMAND_GUILD_INFO, true, &HandleGuildInfoCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "create", rbac::RBAC_PERM_COMMAND_GUILD_CREATE, true, &HandleGuildCreateCommand, "" }, + { "delete", rbac::RBAC_PERM_COMMAND_GUILD_DELETE, true, &HandleGuildDeleteCommand, "" }, + { "invite", rbac::RBAC_PERM_COMMAND_GUILD_INVITE, true, &HandleGuildInviteCommand, "" }, + { "uninvite", rbac::RBAC_PERM_COMMAND_GUILD_UNINVITE, true, &HandleGuildUninviteCommand, "" }, + { "rank", rbac::RBAC_PERM_COMMAND_GUILD_RANK, true, &HandleGuildRankCommand, "" }, + { "rename", rbac::RBAC_PERM_COMMAND_GUILD_RENAME, true, &HandleGuildRenameCommand, "" }, + { "info", rbac::RBAC_PERM_COMMAND_GUILD_INFO, true, &HandleGuildInfoCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "guild", rbac::RBAC_PERM_COMMAND_GUILD, true, NULL, "", guildCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } @@ -158,7 +156,7 @@ public: if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid)) return false; - uint32 guildId = target ? target->GetGuildId() : Player::GetGuildIdFromDB(targetGuid); + ObjectGuid::LowType guildId = target ? target->GetGuildId() : Player::GetGuildIdFromDB(targetGuid); if (!guildId) return false; @@ -184,7 +182,7 @@ public: if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &target_name)) return false; - uint32 guildId = target ? target->GetGuildId() : Player::GetGuildIdFromDB(targetGuid); + ObjectGuid::LowType guildId = target ? target->GetGuildId() : Player::GetGuildIdFromDB(targetGuid); if (!guildId) return false; diff --git a/src/server/scripts/Commands/cs_honor.cpp b/src/server/scripts/Commands/cs_honor.cpp index ad2c53415bb..e8b41309d47 100644 --- a/src/server/scripts/Commands/cs_honor.cpp +++ b/src/server/scripts/Commands/cs_honor.cpp @@ -33,26 +33,23 @@ class honor_commandscript : public CommandScript public: honor_commandscript() : CommandScript("honor_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand honorAddCommandTable[] = + static std::vector<ChatCommand> honorAddCommandTable = { - { "kill", rbac::RBAC_PERM_COMMAND_HONOR_ADD_KILL, false, &HandleHonorAddKillCommand, "", NULL }, - { "", rbac::RBAC_PERM_COMMAND_HONOR_ADD, false, &HandleHonorAddCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "kill", rbac::RBAC_PERM_COMMAND_HONOR_ADD_KILL, false, &HandleHonorAddKillCommand, "" }, + { "", rbac::RBAC_PERM_COMMAND_HONOR_ADD, false, &HandleHonorAddCommand, "" }, }; - static ChatCommand honorCommandTable[] = + static std::vector<ChatCommand> honorCommandTable = { { "add", rbac::RBAC_PERM_COMMAND_HONOR_ADD, false, NULL, "", honorAddCommandTable }, - { "update", rbac::RBAC_PERM_COMMAND_HONOR_UPDATE, false, &HandleHonorUpdateCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "update", rbac::RBAC_PERM_COMMAND_HONOR_UPDATE, false, &HandleHonorUpdateCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "honor", rbac::RBAC_PERM_COMMAND_HONOR, false, NULL, "", honorCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_instance.cpp b/src/server/scripts/Commands/cs_instance.cpp index c960d3f3753..5651aaa12ee 100644 --- a/src/server/scripts/Commands/cs_instance.cpp +++ b/src/server/scripts/Commands/cs_instance.cpp @@ -36,23 +36,21 @@ class instance_commandscript : public CommandScript public: instance_commandscript() : CommandScript("instance_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand instanceCommandTable[] = + static std::vector<ChatCommand> instanceCommandTable = { - { "listbinds", rbac::RBAC_PERM_COMMAND_INSTANCE_LISTBINDS, false, &HandleInstanceListBindsCommand, "", NULL }, - { "unbind", rbac::RBAC_PERM_COMMAND_INSTANCE_UNBIND, false, &HandleInstanceUnbindCommand, "", NULL }, - { "stats", rbac::RBAC_PERM_COMMAND_INSTANCE_STATS, true, &HandleInstanceStatsCommand, "", NULL }, - { "savedata", rbac::RBAC_PERM_COMMAND_INSTANCE_SAVEDATA, false, &HandleInstanceSaveDataCommand, "", NULL }, - { "setbossstate", rbac::RBAC_PERM_COMMAND_INSTANCE_SET_BOSS_STATE, true, &HandleInstanceSetBossStateCommand, "", NULL }, - { "getbossstate", rbac::RBAC_PERM_COMMAND_INSTANCE_GET_BOSS_STATE, true, &HandleInstanceGetBossStateCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "listbinds", rbac::RBAC_PERM_COMMAND_INSTANCE_LISTBINDS, false, &HandleInstanceListBindsCommand, "" }, + { "unbind", rbac::RBAC_PERM_COMMAND_INSTANCE_UNBIND, false, &HandleInstanceUnbindCommand, "" }, + { "stats", rbac::RBAC_PERM_COMMAND_INSTANCE_STATS, true, &HandleInstanceStatsCommand, "" }, + { "savedata", rbac::RBAC_PERM_COMMAND_INSTANCE_SAVEDATA, false, &HandleInstanceSaveDataCommand, "" }, + { "setbossstate", rbac::RBAC_PERM_COMMAND_INSTANCE_SET_BOSS_STATE, true, &HandleInstanceSetBossStateCommand, "" }, + { "getbossstate", rbac::RBAC_PERM_COMMAND_INSTANCE_GET_BOSS_STATE, true, &HandleInstanceGetBossStateCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "instance", rbac::RBAC_PERM_COMMAND_INSTANCE, true, NULL, "", instanceCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; @@ -170,22 +168,22 @@ public: static bool HandleInstanceSaveDataCommand(ChatHandler* handler, char const* /*args*/) { Player* player = handler->GetSession()->GetPlayer(); - Map* map = player->GetMap(); - if (!map->IsDungeon()) + InstanceMap* map = player->GetMap()->ToInstanceMap(); + if (!map) { handler->PSendSysMessage(LANG_NOT_DUNGEON); handler->SetSentErrorMessage(true); return false; } - if (!((InstanceMap*)map)->GetInstanceScript()) + if (!map->GetInstanceScript()) { handler->PSendSysMessage(LANG_NO_INSTANCE_DATA); handler->SetSentErrorMessage(true); return false; } - ((InstanceMap*)map)->GetInstanceScript()->SaveToDB(); + map->GetInstanceScript()->SaveToDB(); return true; } @@ -227,15 +225,15 @@ public: return false; } - Map* map = player->GetMap(); - if (!map->IsDungeon()) + InstanceMap* map = player->GetMap()->ToInstanceMap(); + if (!map) { handler->PSendSysMessage(LANG_NOT_DUNGEON); handler->SetSentErrorMessage(true); return false; } - if (!map->ToInstanceMap()->GetInstanceScript()) + if (!map->GetInstanceScript()) { handler->PSendSysMessage(LANG_NO_INSTANCE_DATA); handler->SetSentErrorMessage(true); @@ -246,15 +244,16 @@ public: state = atoi(param2); // Reject improper values. - if (state > TO_BE_DECIDED || encounterId > map->ToInstanceMap()->GetInstanceScript()->GetEncounterCount()) + if (state > TO_BE_DECIDED || encounterId > map->GetInstanceScript()->GetEncounterCount()) { handler->PSendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); return false; } - map->ToInstanceMap()->GetInstanceScript()->SetBossState(encounterId, (EncounterState)state); - handler->PSendSysMessage(LANG_COMMAND_INST_SET_BOSS_STATE, encounterId, state); + map->GetInstanceScript()->SetBossState(encounterId, EncounterState(state)); + std::string stateName = InstanceScript::GetBossStateName(state); + handler->PSendSysMessage(LANG_COMMAND_INST_SET_BOSS_STATE, encounterId, state, stateName); return true; } @@ -293,15 +292,15 @@ public: return false; } - Map* map = player->GetMap(); - if (!map->IsDungeon()) + InstanceMap* map = player->GetMap()->ToInstanceMap(); + if (!map) { handler->PSendSysMessage(LANG_NOT_DUNGEON); handler->SetSentErrorMessage(true); return false; } - if (!map->ToInstanceMap()->GetInstanceScript()) + if (!map->GetInstanceScript()) { handler->PSendSysMessage(LANG_NO_INSTANCE_DATA); handler->SetSentErrorMessage(true); @@ -310,15 +309,16 @@ public: encounterId = atoi(param1); - if (encounterId > map->ToInstanceMap()->GetInstanceScript()->GetEncounterCount()) + if (encounterId > map->GetInstanceScript()->GetEncounterCount()) { handler->PSendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); return false; } - uint8 state = map->ToInstanceMap()->GetInstanceScript()->GetBossState(encounterId); - handler->PSendSysMessage(LANG_COMMAND_INST_GET_BOSS_STATE, encounterId, state); + uint32 state = map->GetInstanceScript()->GetBossState(encounterId); + std::string stateName = InstanceScript::GetBossStateName(state); + handler->PSendSysMessage(LANG_COMMAND_INST_GET_BOSS_STATE, encounterId, state, stateName); return true; } }; diff --git a/src/server/scripts/Commands/cs_learn.cpp b/src/server/scripts/Commands/cs_learn.cpp index 21211afad50..d7fd4e6664c 100644 --- a/src/server/scripts/Commands/cs_learn.cpp +++ b/src/server/scripts/Commands/cs_learn.cpp @@ -36,40 +36,36 @@ class learn_commandscript : public CommandScript public: learn_commandscript() : CommandScript("learn_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand learnAllMyCommandTable[] = + static std::vector<ChatCommand> learnAllMyCommandTable = { - { "class", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_CLASS, false, &HandleLearnAllMyClassCommand, "", NULL }, - { "pettalents", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_PETTALENTS, false, &HandleLearnAllMyPetTalentsCommand, "", NULL }, - { "spells", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_SPELLS, false, &HandleLearnAllMySpellsCommand, "", NULL }, - { "talents", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_TALENTS, false, &HandleLearnAllMyTalentsCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "class", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_CLASS, false, &HandleLearnAllMyClassCommand, "" }, + { "pettalents", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_PETTALENTS, false, &HandleLearnAllMyPetTalentsCommand, "" }, + { "spells", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_SPELLS, false, &HandleLearnAllMySpellsCommand, "" }, + { "talents", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY_TALENTS, false, &HandleLearnAllMyTalentsCommand, "" }, }; - static ChatCommand learnAllCommandTable[] = + static std::vector<ChatCommand> learnAllCommandTable = { { "my", rbac::RBAC_PERM_COMMAND_LEARN_ALL_MY, false, NULL, "", learnAllMyCommandTable }, - { "gm", rbac::RBAC_PERM_COMMAND_LEARN_ALL_GM, false, &HandleLearnAllGMCommand, "", NULL }, - { "crafts", rbac::RBAC_PERM_COMMAND_LEARN_ALL_CRAFTS, false, &HandleLearnAllCraftsCommand, "", NULL }, - { "default", rbac::RBAC_PERM_COMMAND_LEARN_ALL_DEFAULT, false, &HandleLearnAllDefaultCommand, "", NULL }, - { "lang", rbac::RBAC_PERM_COMMAND_LEARN_ALL_LANG, false, &HandleLearnAllLangCommand, "", NULL }, - { "recipes", rbac::RBAC_PERM_COMMAND_LEARN_ALL_RECIPES, false, &HandleLearnAllRecipesCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "gm", rbac::RBAC_PERM_COMMAND_LEARN_ALL_GM, false, &HandleLearnAllGMCommand, "" }, + { "crafts", rbac::RBAC_PERM_COMMAND_LEARN_ALL_CRAFTS, false, &HandleLearnAllCraftsCommand, "" }, + { "default", rbac::RBAC_PERM_COMMAND_LEARN_ALL_DEFAULT, false, &HandleLearnAllDefaultCommand, "" }, + { "lang", rbac::RBAC_PERM_COMMAND_LEARN_ALL_LANG, false, &HandleLearnAllLangCommand, "" }, + { "recipes", rbac::RBAC_PERM_COMMAND_LEARN_ALL_RECIPES, false, &HandleLearnAllRecipesCommand, "" }, }; - static ChatCommand learnCommandTable[] = + static std::vector<ChatCommand> learnCommandTable = { { "all", rbac::RBAC_PERM_COMMAND_LEARN_ALL, false, NULL, "", learnAllCommandTable }, - { "", rbac::RBAC_PERM_COMMAND_LEARN, false, &HandleLearnCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "", rbac::RBAC_PERM_COMMAND_LEARN, false, &HandleLearnCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "learn", rbac::RBAC_PERM_COMMAND_LEARN, false, NULL, "", learnCommandTable }, - { "unlearn", rbac::RBAC_PERM_COMMAND_UNLEARN, false, &HandleUnLearnCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "unlearn", rbac::RBAC_PERM_COMMAND_UNLEARN, false, &HandleUnLearnCommand, "" }, }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_lfg.cpp b/src/server/scripts/Commands/cs_lfg.cpp index 2de22714a15..9287d5553e3 100644 --- a/src/server/scripts/Commands/cs_lfg.cpp +++ b/src/server/scripts/Commands/cs_lfg.cpp @@ -43,22 +43,20 @@ class lfg_commandscript : public CommandScript public: lfg_commandscript() : CommandScript("lfg_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand lfgCommandTable[] = + static std::vector<ChatCommand> lfgCommandTable = { - { "player", rbac::RBAC_PERM_COMMAND_LFG_PLAYER, false, &HandleLfgPlayerInfoCommand, "", NULL }, - { "group", rbac::RBAC_PERM_COMMAND_LFG_GROUP, false, &HandleLfgGroupInfoCommand, "", NULL }, - { "queue", rbac::RBAC_PERM_COMMAND_LFG_QUEUE, true, &HandleLfgQueueInfoCommand, "", NULL }, - { "clean", rbac::RBAC_PERM_COMMAND_LFG_CLEAN, true, &HandleLfgCleanCommand, "", NULL }, - { "options", rbac::RBAC_PERM_COMMAND_LFG_OPTIONS, true, &HandleLfgOptionsCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "player", rbac::RBAC_PERM_COMMAND_LFG_PLAYER, false, &HandleLfgPlayerInfoCommand, "" }, + { "group", rbac::RBAC_PERM_COMMAND_LFG_GROUP, false, &HandleLfgGroupInfoCommand, "" }, + { "queue", rbac::RBAC_PERM_COMMAND_LFG_QUEUE, true, &HandleLfgQueueInfoCommand, "" }, + { "clean", rbac::RBAC_PERM_COMMAND_LFG_CLEAN, true, &HandleLfgCleanCommand, "" }, + { "options", rbac::RBAC_PERM_COMMAND_LFG_OPTIONS, true, &HandleLfgOptionsCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "lfg", rbac::RBAC_PERM_COMMAND_LFG, true, NULL, "", lfgCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_list.cpp b/src/server/scripts/Commands/cs_list.cpp index fb051832d7b..a1b79a69605 100644 --- a/src/server/scripts/Commands/cs_list.cpp +++ b/src/server/scripts/Commands/cs_list.cpp @@ -36,21 +36,19 @@ class list_commandscript : public CommandScript public: list_commandscript() : CommandScript("list_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand listCommandTable[] = + static std::vector<ChatCommand> listCommandTable = { - { "creature", rbac::RBAC_PERM_COMMAND_LIST_CREATURE, true, &HandleListCreatureCommand, "", NULL }, - { "item", rbac::RBAC_PERM_COMMAND_LIST_ITEM, true, &HandleListItemCommand, "", NULL }, - { "object", rbac::RBAC_PERM_COMMAND_LIST_OBJECT, true, &HandleListObjectCommand, "", NULL }, - { "auras", rbac::RBAC_PERM_COMMAND_LIST_AURAS, false, &HandleListAurasCommand, "", NULL }, - { "mail", rbac::RBAC_PERM_COMMAND_LIST_MAIL, true, &HandleListMailCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "creature", rbac::RBAC_PERM_COMMAND_LIST_CREATURE, true, &HandleListCreatureCommand, "" }, + { "item", rbac::RBAC_PERM_COMMAND_LIST_ITEM, true, &HandleListItemCommand, "" }, + { "object", rbac::RBAC_PERM_COMMAND_LIST_OBJECT, true, &HandleListObjectCommand, "" }, + { "auras", rbac::RBAC_PERM_COMMAND_LIST_AURAS, false, &HandleListAurasCommand, "" }, + { "mail", rbac::RBAC_PERM_COMMAND_LIST_MAIL, true, &HandleListMailCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "list", rbac::RBAC_PERM_COMMAND_LIST,true, NULL, "", listCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } @@ -109,7 +107,7 @@ public: do { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); float x = fields[1].GetFloat(); float y = fields[2].GetFloat(); float z = fields[3].GetFloat(); @@ -235,8 +233,8 @@ public: do { Field* fields = result->Fetch(); - uint32 itemGuid = fields[0].GetUInt32(); - uint32 itemSender = fields[1].GetUInt32(); + ObjectGuid::LowType itemGuid = fields[0].GetUInt32(); + ObjectGuid::LowType itemSender = fields[1].GetUInt32(); uint32 itemReceiver = fields[2].GetUInt32(); uint32 itemSenderAccountId = fields[3].GetUInt32(); std::string itemSenderName = fields[4].GetString(); @@ -398,7 +396,7 @@ public: do { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); float x = fields[1].GetFloat(); float y = fields[2].GetFloat(); float z = fields[3].GetFloat(); @@ -534,7 +532,7 @@ public: { do { - uint32 item_guid = (*result2)[0].GetUInt32(); + ObjectGuid::LowType item_guid = (*result2)[0].GetUInt32(); stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_LIST_ITEMS); stmt->setUInt32(0, item_guid); PreparedQueryResult result3 = CharacterDatabase.Query(stmt); diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp index 56aa6d0bf92..ec35c5a7b62 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -37,47 +37,43 @@ class lookup_commandscript : public CommandScript public: lookup_commandscript() : CommandScript("lookup_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand lookupPlayerCommandTable[] = + static std::vector<ChatCommand> lookupPlayerCommandTable = { - { "ip", rbac::RBAC_PERM_COMMAND_LOOKUP_PLAYER_IP, true, &HandleLookupPlayerIpCommand, "", NULL }, - { "account", rbac::RBAC_PERM_COMMAND_LOOKUP_PLAYER_ACCOUNT, true, &HandleLookupPlayerAccountCommand, "", NULL }, - { "email", rbac::RBAC_PERM_COMMAND_LOOKUP_PLAYER_EMAIL, true, &HandleLookupPlayerEmailCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "ip", rbac::RBAC_PERM_COMMAND_LOOKUP_PLAYER_IP, true, &HandleLookupPlayerIpCommand, "" }, + { "account", rbac::RBAC_PERM_COMMAND_LOOKUP_PLAYER_ACCOUNT, true, &HandleLookupPlayerAccountCommand, "" }, + { "email", rbac::RBAC_PERM_COMMAND_LOOKUP_PLAYER_EMAIL, true, &HandleLookupPlayerEmailCommand, "" }, }; - static ChatCommand lookupSpellCommandTable[] = + static std::vector<ChatCommand> lookupSpellCommandTable = { - { "id", rbac::RBAC_PERM_COMMAND_LOOKUP_SPELL_ID, true, &HandleLookupSpellIdCommand, "", NULL }, - { "", rbac::RBAC_PERM_COMMAND_LOOKUP_SPELL, true, &HandleLookupSpellCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "id", rbac::RBAC_PERM_COMMAND_LOOKUP_SPELL_ID, true, &HandleLookupSpellIdCommand, "" }, + { "", rbac::RBAC_PERM_COMMAND_LOOKUP_SPELL, true, &HandleLookupSpellCommand, "" }, }; - static ChatCommand lookupCommandTable[] = + static std::vector<ChatCommand> lookupCommandTable = { - { "area", rbac::RBAC_PERM_COMMAND_LOOKUP_AREA, true, &HandleLookupAreaCommand, "", NULL }, - { "creature", rbac::RBAC_PERM_COMMAND_LOOKUP_CREATURE, true, &HandleLookupCreatureCommand, "", NULL }, - { "event", rbac::RBAC_PERM_COMMAND_LOOKUP_EVENT, true, &HandleLookupEventCommand, "", NULL }, - { "faction", rbac::RBAC_PERM_COMMAND_LOOKUP_FACTION, true, &HandleLookupFactionCommand, "", NULL }, - { "item", rbac::RBAC_PERM_COMMAND_LOOKUP_ITEM, true, &HandleLookupItemCommand, "", NULL }, - { "itemset", rbac::RBAC_PERM_COMMAND_LOOKUP_ITEMSET, true, &HandleLookupItemSetCommand, "", NULL }, - { "object", rbac::RBAC_PERM_COMMAND_LOOKUP_OBJECT, true, &HandleLookupObjectCommand, "", NULL }, - { "quest", rbac::RBAC_PERM_COMMAND_LOOKUP_QUEST, true, &HandleLookupQuestCommand, "", NULL }, + { "area", rbac::RBAC_PERM_COMMAND_LOOKUP_AREA, true, &HandleLookupAreaCommand, "" }, + { "creature", rbac::RBAC_PERM_COMMAND_LOOKUP_CREATURE, true, &HandleLookupCreatureCommand, "" }, + { "event", rbac::RBAC_PERM_COMMAND_LOOKUP_EVENT, true, &HandleLookupEventCommand, "" }, + { "faction", rbac::RBAC_PERM_COMMAND_LOOKUP_FACTION, true, &HandleLookupFactionCommand, "" }, + { "item", rbac::RBAC_PERM_COMMAND_LOOKUP_ITEM, true, &HandleLookupItemCommand, "" }, + { "itemset", rbac::RBAC_PERM_COMMAND_LOOKUP_ITEMSET, true, &HandleLookupItemSetCommand, "" }, + { "object", rbac::RBAC_PERM_COMMAND_LOOKUP_OBJECT, true, &HandleLookupObjectCommand, "" }, + { "quest", rbac::RBAC_PERM_COMMAND_LOOKUP_QUEST, true, &HandleLookupQuestCommand, "" }, { "player", rbac::RBAC_PERM_COMMAND_LOOKUP_PLAYER, true, NULL, "", lookupPlayerCommandTable }, - { "skill", rbac::RBAC_PERM_COMMAND_LOOKUP_SKILL, true, &HandleLookupSkillCommand, "", NULL }, + { "skill", rbac::RBAC_PERM_COMMAND_LOOKUP_SKILL, true, &HandleLookupSkillCommand, "" }, { "spell", rbac::RBAC_PERM_COMMAND_LOOKUP_SPELL, true, NULL, "", lookupSpellCommandTable }, - { "taxinode", rbac::RBAC_PERM_COMMAND_LOOKUP_TAXINODE, true, &HandleLookupTaxiNodeCommand, "", NULL }, - { "tele", rbac::RBAC_PERM_COMMAND_LOOKUP_TELE, true, &HandleLookupTeleCommand, "", NULL }, - { "title", rbac::RBAC_PERM_COMMAND_LOOKUP_TITLE, true, &HandleLookupTitleCommand, "", NULL }, - { "map", rbac::RBAC_PERM_COMMAND_LOOKUP_MAP, true, &HandleLookupMapCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "taxinode", rbac::RBAC_PERM_COMMAND_LOOKUP_TAXINODE, true, &HandleLookupTaxiNodeCommand, "" }, + { "tele", rbac::RBAC_PERM_COMMAND_LOOKUP_TELE, true, &HandleLookupTeleCommand, "" }, + { "title", rbac::RBAC_PERM_COMMAND_LOOKUP_TITLE, true, &HandleLookupTitleCommand, "" }, + { "map", rbac::RBAC_PERM_COMMAND_LOOKUP_MAP, true, &HandleLookupMapCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "lookup", rbac::RBAC_PERM_COMMAND_LOOKUP, true, NULL, "", lookupCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } @@ -1410,7 +1406,7 @@ public: do { Field* characterFields = result2->Fetch(); - uint32 guid = characterFields[0].GetUInt32(); + ObjectGuid::LowType guid = characterFields[0].GetUInt32(); std::string name = characterFields[1].GetString(); handler->PSendSysMessage(LANG_LOOKUP_PLAYER_CHARACTER, name.c_str(), guid); diff --git a/src/server/scripts/Commands/cs_message.cpp b/src/server/scripts/Commands/cs_message.cpp index 922958f7222..f3c1f4d7df8 100644 --- a/src/server/scripts/Commands/cs_message.cpp +++ b/src/server/scripts/Commands/cs_message.cpp @@ -34,29 +34,26 @@ class message_commandscript : public CommandScript public: message_commandscript() : CommandScript("message_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand channelSetCommandTable[] = + static std::vector<ChatCommand> channelSetCommandTable = { - { "ownership", rbac::RBAC_PERM_COMMAND_CHANNEL_SET_OWNERSHIP, false, &HandleChannelSetOwnership, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "ownership", rbac::RBAC_PERM_COMMAND_CHANNEL_SET_OWNERSHIP, false, &HandleChannelSetOwnership, "" }, }; - static ChatCommand channelCommandTable[] = + static std::vector<ChatCommand> channelCommandTable = { { "set", rbac::RBAC_PERM_COMMAND_CHANNEL_SET, true, NULL, "", channelSetCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "channel", rbac::RBAC_PERM_COMMAND_CHANNEL, true, NULL, "", channelCommandTable }, - { "nameannounce", rbac::RBAC_PERM_COMMAND_NAMEANNOUNCE, true, &HandleNameAnnounceCommand, "", NULL }, - { "gmnameannounce", rbac::RBAC_PERM_COMMAND_GMNAMEANNOUNCE, true, &HandleGMNameAnnounceCommand, "", NULL }, - { "announce", rbac::RBAC_PERM_COMMAND_ANNOUNCE, true, &HandleAnnounceCommand, "", NULL }, - { "gmannounce", rbac::RBAC_PERM_COMMAND_GMANNOUNCE, true, &HandleGMAnnounceCommand, "", NULL }, - { "notify", rbac::RBAC_PERM_COMMAND_NOTIFY, true, &HandleNotifyCommand, "", NULL }, - { "gmnotify", rbac::RBAC_PERM_COMMAND_GMNOTIFY, true, &HandleGMNotifyCommand, "", NULL }, - { "whispers", rbac::RBAC_PERM_COMMAND_WHISPERS, false, &HandleWhispersCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "nameannounce", rbac::RBAC_PERM_COMMAND_NAMEANNOUNCE, true, &HandleNameAnnounceCommand, "" }, + { "gmnameannounce", rbac::RBAC_PERM_COMMAND_GMNAMEANNOUNCE, true, &HandleGMNameAnnounceCommand, "" }, + { "announce", rbac::RBAC_PERM_COMMAND_ANNOUNCE, true, &HandleAnnounceCommand, "" }, + { "gmannounce", rbac::RBAC_PERM_COMMAND_GMANNOUNCE, true, &HandleGMAnnounceCommand, "" }, + { "notify", rbac::RBAC_PERM_COMMAND_NOTIFY, true, &HandleNotifyCommand, "" }, + { "gmnotify", rbac::RBAC_PERM_COMMAND_GMNOTIFY, true, &HandleGMNotifyCommand, "" }, + { "whispers", rbac::RBAC_PERM_COMMAND_WHISPERS, false, &HandleWhispersCommand, "" }, }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 21a55b1558a..b81d6152c03 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -42,62 +42,61 @@ class misc_commandscript : public CommandScript public: misc_commandscript() : CommandScript("misc_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand commandTable[] = - { - { "additem", rbac::RBAC_PERM_COMMAND_ADDITEM, false, &HandleAddItemCommand, "", NULL }, - { "additemset", rbac::RBAC_PERM_COMMAND_ADDITEMSET, false, &HandleAddItemSetCommand, "", NULL }, - { "appear", rbac::RBAC_PERM_COMMAND_APPEAR, false, &HandleAppearCommand, "", NULL }, - { "aura", rbac::RBAC_PERM_COMMAND_AURA, false, &HandleAuraCommand, "", NULL }, - { "bank", rbac::RBAC_PERM_COMMAND_BANK, false, &HandleBankCommand, "", NULL }, - { "bindsight", rbac::RBAC_PERM_COMMAND_BINDSIGHT, false, &HandleBindSightCommand, "", NULL }, - { "combatstop", rbac::RBAC_PERM_COMMAND_COMBATSTOP, true, &HandleCombatStopCommand, "", NULL }, - { "cometome", rbac::RBAC_PERM_COMMAND_COMETOME, false, &HandleComeToMeCommand, "", NULL }, - { "commands", rbac::RBAC_PERM_COMMAND_COMMANDS, true, &HandleCommandsCommand, "", NULL }, - { "cooldown", rbac::RBAC_PERM_COMMAND_COOLDOWN, false, &HandleCooldownCommand, "", NULL }, - { "damage", rbac::RBAC_PERM_COMMAND_DAMAGE, false, &HandleDamageCommand, "", NULL }, - { "dev", rbac::RBAC_PERM_COMMAND_DEV, false, &HandleDevCommand, "", NULL }, - { "die", rbac::RBAC_PERM_COMMAND_DIE, false, &HandleDieCommand, "", NULL }, - { "dismount", rbac::RBAC_PERM_COMMAND_DISMOUNT, false, &HandleDismountCommand, "", NULL }, - { "distance", rbac::RBAC_PERM_COMMAND_DISTANCE, false, &HandleGetDistanceCommand, "", NULL }, - { "flusharenapoints", rbac::RBAC_PERM_COMMAND_FLUSHARENAPOINTS, false, &HandleFlushArenaPointsCommand, "", NULL }, - { "freeze", rbac::RBAC_PERM_COMMAND_FREEZE, false, &HandleFreezeCommand, "", NULL }, - { "gps", rbac::RBAC_PERM_COMMAND_GPS, false, &HandleGPSCommand, "", NULL }, - { "guid", rbac::RBAC_PERM_COMMAND_GUID, false, &HandleGUIDCommand, "", NULL }, - { "help", rbac::RBAC_PERM_COMMAND_HELP, true, &HandleHelpCommand, "", NULL }, - { "hidearea", rbac::RBAC_PERM_COMMAND_HIDEAREA, false, &HandleHideAreaCommand, "", NULL }, - { "itemmove", rbac::RBAC_PERM_COMMAND_ITEMMOVE, false, &HandleItemMoveCommand, "", NULL }, - { "kick", rbac::RBAC_PERM_COMMAND_KICK, true, &HandleKickPlayerCommand, "", NULL }, - { "linkgrave", rbac::RBAC_PERM_COMMAND_LINKGRAVE, false, &HandleLinkGraveCommand, "", NULL }, - { "listfreeze", rbac::RBAC_PERM_COMMAND_LISTFREEZE, false, &HandleListFreezeCommand, "", NULL }, - { "maxskill", rbac::RBAC_PERM_COMMAND_MAXSKILL, false, &HandleMaxSkillCommand, "", NULL }, - { "movegens", rbac::RBAC_PERM_COMMAND_MOVEGENS, false, &HandleMovegensCommand, "", NULL }, - { "mute", rbac::RBAC_PERM_COMMAND_MUTE, true, &HandleMuteCommand, "", NULL }, - { "mutehistory", rbac::RBAC_PERM_COMMAND_MUTEHISTORY, true, &HandleMuteInfoCommand, "", NULL }, - { "neargrave", rbac::RBAC_PERM_COMMAND_NEARGRAVE, false, &HandleNearGraveCommand, "", NULL }, - { "pinfo", rbac::RBAC_PERM_COMMAND_PINFO, true, &HandlePInfoCommand, "", NULL }, - { "playall", rbac::RBAC_PERM_COMMAND_PLAYALL, false, &HandlePlayAllCommand, "", NULL }, - { "possess", rbac::RBAC_PERM_COMMAND_POSSESS, false, &HandlePossessCommand, "", NULL }, - { "pvpstats", rbac::RBAC_PERM_COMMAND_PVPSTATS, true, &HandlePvPstatsCommand, "", NULL }, - { "recall", rbac::RBAC_PERM_COMMAND_RECALL, false, &HandleRecallCommand, "", NULL }, - { "repairitems", rbac::RBAC_PERM_COMMAND_REPAIRITEMS, true, &HandleRepairitemsCommand, "", NULL }, - { "respawn", rbac::RBAC_PERM_COMMAND_RESPAWN, false, &HandleRespawnCommand, "", NULL }, - { "revive", rbac::RBAC_PERM_COMMAND_REVIVE, true, &HandleReviveCommand, "", NULL }, - { "saveall", rbac::RBAC_PERM_COMMAND_SAVEALL, true, &HandleSaveAllCommand, "", NULL }, - { "save", rbac::RBAC_PERM_COMMAND_SAVE, false, &HandleSaveCommand, "", NULL }, - { "setskill", rbac::RBAC_PERM_COMMAND_SETSKILL, false, &HandleSetSkillCommand, "", NULL }, - { "showarea", rbac::RBAC_PERM_COMMAND_SHOWAREA, false, &HandleShowAreaCommand, "", NULL }, - { "summon", rbac::RBAC_PERM_COMMAND_SUMMON, false, &HandleSummonCommand, "", NULL }, - { "unaura", rbac::RBAC_PERM_COMMAND_UNAURA, false, &HandleUnAuraCommand, "", NULL }, - { "unbindsight", rbac::RBAC_PERM_COMMAND_UNBINDSIGHT, false, HandleUnbindSightCommand, "", NULL }, - { "unfreeze", rbac::RBAC_PERM_COMMAND_UNFREEZE, false, &HandleUnFreezeCommand, "", NULL }, - { "unmute", rbac::RBAC_PERM_COMMAND_UNMUTE, true, &HandleUnmuteCommand, "", NULL }, - { "unpossess", rbac::RBAC_PERM_COMMAND_UNPOSSESS, false, &HandleUnPossessCommand, "", NULL }, - { "unstuck", rbac::RBAC_PERM_COMMAND_UNSTUCK, true, &HandleUnstuckCommand, "", NULL }, - { "wchange", rbac::RBAC_PERM_COMMAND_WCHANGE, false, &HandleChangeWeather, "", NULL }, - { "mailbox", rbac::RBAC_PERM_COMMAND_MAILBOX, false, &HandleMailBoxCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + static std::vector<ChatCommand> commandTable = + { + { "additem", rbac::RBAC_PERM_COMMAND_ADDITEM, false, &HandleAddItemCommand, "" }, + { "additemset", rbac::RBAC_PERM_COMMAND_ADDITEMSET, false, &HandleAddItemSetCommand, "" }, + { "appear", rbac::RBAC_PERM_COMMAND_APPEAR, false, &HandleAppearCommand, "" }, + { "aura", rbac::RBAC_PERM_COMMAND_AURA, false, &HandleAuraCommand, "" }, + { "bank", rbac::RBAC_PERM_COMMAND_BANK, false, &HandleBankCommand, "" }, + { "bindsight", rbac::RBAC_PERM_COMMAND_BINDSIGHT, false, &HandleBindSightCommand, "" }, + { "combatstop", rbac::RBAC_PERM_COMMAND_COMBATSTOP, true, &HandleCombatStopCommand, "" }, + { "cometome", rbac::RBAC_PERM_COMMAND_COMETOME, false, &HandleComeToMeCommand, "" }, + { "commands", rbac::RBAC_PERM_COMMAND_COMMANDS, true, &HandleCommandsCommand, "" }, + { "cooldown", rbac::RBAC_PERM_COMMAND_COOLDOWN, false, &HandleCooldownCommand, "" }, + { "damage", rbac::RBAC_PERM_COMMAND_DAMAGE, false, &HandleDamageCommand, "" }, + { "dev", rbac::RBAC_PERM_COMMAND_DEV, false, &HandleDevCommand, "" }, + { "die", rbac::RBAC_PERM_COMMAND_DIE, false, &HandleDieCommand, "" }, + { "dismount", rbac::RBAC_PERM_COMMAND_DISMOUNT, false, &HandleDismountCommand, "" }, + { "distance", rbac::RBAC_PERM_COMMAND_DISTANCE, false, &HandleGetDistanceCommand, "" }, + { "flusharenapoints", rbac::RBAC_PERM_COMMAND_FLUSHARENAPOINTS, false, &HandleFlushArenaPointsCommand, "" }, + { "freeze", rbac::RBAC_PERM_COMMAND_FREEZE, false, &HandleFreezeCommand, "" }, + { "gps", rbac::RBAC_PERM_COMMAND_GPS, false, &HandleGPSCommand, "" }, + { "guid", rbac::RBAC_PERM_COMMAND_GUID, false, &HandleGUIDCommand, "" }, + { "help", rbac::RBAC_PERM_COMMAND_HELP, true, &HandleHelpCommand, "" }, + { "hidearea", rbac::RBAC_PERM_COMMAND_HIDEAREA, false, &HandleHideAreaCommand, "" }, + { "itemmove", rbac::RBAC_PERM_COMMAND_ITEMMOVE, false, &HandleItemMoveCommand, "" }, + { "kick", rbac::RBAC_PERM_COMMAND_KICK, true, &HandleKickPlayerCommand, "" }, + { "linkgrave", rbac::RBAC_PERM_COMMAND_LINKGRAVE, false, &HandleLinkGraveCommand, "" }, + { "listfreeze", rbac::RBAC_PERM_COMMAND_LISTFREEZE, false, &HandleListFreezeCommand, "" }, + { "maxskill", rbac::RBAC_PERM_COMMAND_MAXSKILL, false, &HandleMaxSkillCommand, "" }, + { "movegens", rbac::RBAC_PERM_COMMAND_MOVEGENS, false, &HandleMovegensCommand, "" }, + { "mute", rbac::RBAC_PERM_COMMAND_MUTE, true, &HandleMuteCommand, "" }, + { "mutehistory", rbac::RBAC_PERM_COMMAND_MUTEHISTORY, true, &HandleMuteInfoCommand, "" }, + { "neargrave", rbac::RBAC_PERM_COMMAND_NEARGRAVE, false, &HandleNearGraveCommand, "" }, + { "pinfo", rbac::RBAC_PERM_COMMAND_PINFO, true, &HandlePInfoCommand, "" }, + { "playall", rbac::RBAC_PERM_COMMAND_PLAYALL, false, &HandlePlayAllCommand, "" }, + { "possess", rbac::RBAC_PERM_COMMAND_POSSESS, false, &HandlePossessCommand, "" }, + { "pvpstats", rbac::RBAC_PERM_COMMAND_PVPSTATS, true, &HandlePvPstatsCommand, "" }, + { "recall", rbac::RBAC_PERM_COMMAND_RECALL, false, &HandleRecallCommand, "" }, + { "repairitems", rbac::RBAC_PERM_COMMAND_REPAIRITEMS, true, &HandleRepairitemsCommand, "" }, + { "respawn", rbac::RBAC_PERM_COMMAND_RESPAWN, false, &HandleRespawnCommand, "" }, + { "revive", rbac::RBAC_PERM_COMMAND_REVIVE, true, &HandleReviveCommand, "" }, + { "saveall", rbac::RBAC_PERM_COMMAND_SAVEALL, true, &HandleSaveAllCommand, "" }, + { "save", rbac::RBAC_PERM_COMMAND_SAVE, false, &HandleSaveCommand, "" }, + { "setskill", rbac::RBAC_PERM_COMMAND_SETSKILL, false, &HandleSetSkillCommand, "" }, + { "showarea", rbac::RBAC_PERM_COMMAND_SHOWAREA, false, &HandleShowAreaCommand, "" }, + { "summon", rbac::RBAC_PERM_COMMAND_SUMMON, false, &HandleSummonCommand, "" }, + { "unaura", rbac::RBAC_PERM_COMMAND_UNAURA, false, &HandleUnAuraCommand, "" }, + { "unbindsight", rbac::RBAC_PERM_COMMAND_UNBINDSIGHT, false, HandleUnbindSightCommand, "" }, + { "unfreeze", rbac::RBAC_PERM_COMMAND_UNFREEZE, false, &HandleUnFreezeCommand, "" }, + { "unmute", rbac::RBAC_PERM_COMMAND_UNMUTE, true, &HandleUnmuteCommand, "" }, + { "unpossess", rbac::RBAC_PERM_COMMAND_UNPOSSESS, false, &HandleUnPossessCommand, "" }, + { "unstuck", rbac::RBAC_PERM_COMMAND_UNSTUCK, true, &HandleUnstuckCommand, "" }, + { "wchange", rbac::RBAC_PERM_COMMAND_WCHANGE, false, &HandleChangeWeather, "" }, + { "mailbox", rbac::RBAC_PERM_COMMAND_MAILBOX, false, &HandleMailBoxCommand, "" }, }; return commandTable; } @@ -1470,7 +1469,7 @@ public: // Account data print variables std::string userName = handler->GetTrinityString(LANG_ERROR); uint32 accId = 0; - uint32 lowguid = targetGuid.GetCounter(); + ObjectGuid::LowType lowguid = targetGuid.GetCounter(); std::string eMail = handler->GetTrinityString(LANG_ERROR); std::string regMail = handler->GetTrinityString(LANG_ERROR); uint32 security = 0; @@ -1659,7 +1658,7 @@ public: { Field* fields = result4->Fetch(); xp = fields[0].GetUInt32(); // Used for "current xp" output and "%u XP Left" calculation - uint32 gguid = fields[1].GetUInt32(); // We check if have a guild for the person, so we might not require to query it at all + ObjectGuid::LowType gguid = fields[1].GetUInt32(); // We check if have a guild for the person, so we might not require to query it at all xptotal = sObjectMgr->GetXPForLevel(level); if (gguid != 0) @@ -1774,21 +1773,13 @@ public: PreparedQueryResult result6 = CharacterDatabase.Query(stmt4); if (result6) { - // Define the variables, so the compiler knows they exist - uint32 rmailint = 0; - - // Fetch the fields - readmail is a SUM(x) and given out as char! Thus... - // ... while totalmail is a COUNT(x), which is given out as INt64, which we just convert on fetch... Field* fields = result6->Fetch(); - std::string readmail = fields[0].GetString(); + uint32 readmail = uint32(fields[0].GetDouble()); uint32 totalmail = uint32(fields[1].GetUInt64()); - // ... we have to convert it from Char to int. We can use totalmail as it is - rmailint = atoul(readmail.c_str()); - // Output XXI. LANG_INFO_CHR_MAILS if at least one mail is given if (totalmail >= 1) - handler->PSendSysMessage(LANG_PINFO_CHR_MAILS, rmailint, totalmail); + handler->PSendSysMessage(LANG_PINFO_CHR_MAILS, readmail, totalmail); } return true; @@ -2487,7 +2478,7 @@ public: // If player found: delete his freeze aura Field* fields = result->Fetch(); - uint32 lowGuid = fields[0].GetUInt32(); + ObjectGuid::LowType lowGuid = fields[0].GetUInt32(); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_AURA_FROZEN); stmt->setUInt32(0, lowGuid); diff --git a/src/server/scripts/Commands/cs_mmaps.cpp b/src/server/scripts/Commands/cs_mmaps.cpp index e06159a6748..479c34dd90c 100644 --- a/src/server/scripts/Commands/cs_mmaps.cpp +++ b/src/server/scripts/Commands/cs_mmaps.cpp @@ -42,22 +42,20 @@ class mmaps_commandscript : public CommandScript public: mmaps_commandscript() : CommandScript("mmaps_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand mmapCommandTable[] = + static std::vector<ChatCommand> mmapCommandTable = { - { "loadedtiles", rbac::RBAC_PERM_COMMAND_MMAP_LOADEDTILES, false, &HandleMmapLoadedTilesCommand, "", NULL }, - { "loc", rbac::RBAC_PERM_COMMAND_MMAP_LOC, false, &HandleMmapLocCommand, "", NULL }, - { "path", rbac::RBAC_PERM_COMMAND_MMAP_PATH, false, &HandleMmapPathCommand, "", NULL }, - { "stats", rbac::RBAC_PERM_COMMAND_MMAP_STATS, false, &HandleMmapStatsCommand, "", NULL }, - { "testarea", rbac::RBAC_PERM_COMMAND_MMAP_TESTAREA, false, &HandleMmapTestArea, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "loadedtiles", rbac::RBAC_PERM_COMMAND_MMAP_LOADEDTILES, false, &HandleMmapLoadedTilesCommand, "" }, + { "loc", rbac::RBAC_PERM_COMMAND_MMAP_LOC, false, &HandleMmapLocCommand, "" }, + { "path", rbac::RBAC_PERM_COMMAND_MMAP_PATH, false, &HandleMmapPathCommand, "" }, + { "stats", rbac::RBAC_PERM_COMMAND_MMAP_STATS, false, &HandleMmapStatsCommand, "" }, + { "testarea", rbac::RBAC_PERM_COMMAND_MMAP_TESTAREA, false, &HandleMmapTestArea, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { - { "mmap", rbac::RBAC_PERM_COMMAND_MMAP, true, NULL, "", mmapCommandTable }, - { NULL, 0, false, NULL, "", NULL } + { "mmap", rbac::RBAC_PERM_COMMAND_MMAP, true, NULL, "", mmapCommandTable }, }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index bf82b81a8b7..a3eed4dfd5d 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -36,49 +36,46 @@ class modify_commandscript : public CommandScript public: modify_commandscript() : CommandScript("modify_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand modifyspeedCommandTable[] = + static std::vector<ChatCommand> modifyspeedCommandTable = { - { "all", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_ALL, false, &HandleModifyASpeedCommand, "", NULL }, - { "backwalk", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_BACKWALK, false, &HandleModifyBWalkCommand, "", NULL }, - { "fly", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_FLY, false, &HandleModifyFlyCommand, "", NULL }, - { "walk", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_WALK, false, &HandleModifySpeedCommand, "", NULL }, - { "swim", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_SWIM, false, &HandleModifySwimCommand, "", NULL }, - { "", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED, false, &HandleModifyASpeedCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "all", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_ALL, false, &HandleModifyASpeedCommand, "" }, + { "backwalk", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_BACKWALK, false, &HandleModifyBWalkCommand, "" }, + { "fly", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_FLY, false, &HandleModifyFlyCommand, "" }, + { "walk", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_WALK, false, &HandleModifySpeedCommand, "" }, + { "swim", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED_SWIM, false, &HandleModifySwimCommand, "" }, + { "", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED, false, &HandleModifyASpeedCommand, "" }, }; - static ChatCommand modifyCommandTable[] = + static std::vector<ChatCommand> modifyCommandTable = { - { "arenapoints", rbac::RBAC_PERM_COMMAND_MODIFY_ARENAPOINTS, false, &HandleModifyArenaCommand, "", NULL }, - { "bit", rbac::RBAC_PERM_COMMAND_MODIFY_BIT, false, &HandleModifyBitCommand, "", NULL }, - { "drunk", rbac::RBAC_PERM_COMMAND_MODIFY_DRUNK, false, &HandleModifyDrunkCommand, "", NULL }, - { "energy", rbac::RBAC_PERM_COMMAND_MODIFY_ENERGY, false, &HandleModifyEnergyCommand, "", NULL }, - { "faction", rbac::RBAC_PERM_COMMAND_MODIFY_FACTION, false, &HandleModifyFactionCommand, "", NULL }, - { "gender", rbac::RBAC_PERM_COMMAND_MODIFY_GENDER, false, &HandleModifyGenderCommand, "", NULL }, - { "honor", rbac::RBAC_PERM_COMMAND_MODIFY_HONOR, false, &HandleModifyHonorCommand, "", NULL }, - { "hp", rbac::RBAC_PERM_COMMAND_MODIFY_HP, false, &HandleModifyHPCommand, "", NULL }, - { "mana", rbac::RBAC_PERM_COMMAND_MODIFY_MANA, false, &HandleModifyManaCommand, "", NULL }, - { "money", rbac::RBAC_PERM_COMMAND_MODIFY_MONEY, false, &HandleModifyMoneyCommand, "", NULL }, - { "mount", rbac::RBAC_PERM_COMMAND_MODIFY_MOUNT, false, &HandleModifyMountCommand, "", NULL }, - { "phase", rbac::RBAC_PERM_COMMAND_MODIFY_PHASE, false, &HandleModifyPhaseCommand, "", NULL }, - { "rage", rbac::RBAC_PERM_COMMAND_MODIFY_RAGE, false, &HandleModifyRageCommand, "", NULL }, - { "reputation", rbac::RBAC_PERM_COMMAND_MODIFY_REPUTATION, false, &HandleModifyRepCommand, "", NULL }, - { "runicpower", rbac::RBAC_PERM_COMMAND_MODIFY_RUNICPOWER, false, &HandleModifyRunicPowerCommand, "", NULL }, - { "scale", rbac::RBAC_PERM_COMMAND_MODIFY_SCALE, false, &HandleModifyScaleCommand, "", NULL }, + { "arenapoints", rbac::RBAC_PERM_COMMAND_MODIFY_ARENAPOINTS, false, &HandleModifyArenaCommand, "" }, + { "bit", rbac::RBAC_PERM_COMMAND_MODIFY_BIT, false, &HandleModifyBitCommand, "" }, + { "drunk", rbac::RBAC_PERM_COMMAND_MODIFY_DRUNK, false, &HandleModifyDrunkCommand, "" }, + { "energy", rbac::RBAC_PERM_COMMAND_MODIFY_ENERGY, false, &HandleModifyEnergyCommand, "" }, + { "faction", rbac::RBAC_PERM_COMMAND_MODIFY_FACTION, false, &HandleModifyFactionCommand, "" }, + { "gender", rbac::RBAC_PERM_COMMAND_MODIFY_GENDER, false, &HandleModifyGenderCommand, "" }, + { "honor", rbac::RBAC_PERM_COMMAND_MODIFY_HONOR, false, &HandleModifyHonorCommand, "" }, + { "hp", rbac::RBAC_PERM_COMMAND_MODIFY_HP, false, &HandleModifyHPCommand, "" }, + { "mana", rbac::RBAC_PERM_COMMAND_MODIFY_MANA, false, &HandleModifyManaCommand, "" }, + { "money", rbac::RBAC_PERM_COMMAND_MODIFY_MONEY, false, &HandleModifyMoneyCommand, "" }, + { "mount", rbac::RBAC_PERM_COMMAND_MODIFY_MOUNT, false, &HandleModifyMountCommand, "" }, + { "phase", rbac::RBAC_PERM_COMMAND_MODIFY_PHASE, false, &HandleModifyPhaseCommand, "" }, + { "rage", rbac::RBAC_PERM_COMMAND_MODIFY_RAGE, false, &HandleModifyRageCommand, "" }, + { "reputation", rbac::RBAC_PERM_COMMAND_MODIFY_REPUTATION, false, &HandleModifyRepCommand, "" }, + { "runicpower", rbac::RBAC_PERM_COMMAND_MODIFY_RUNICPOWER, false, &HandleModifyRunicPowerCommand, "" }, + { "scale", rbac::RBAC_PERM_COMMAND_MODIFY_SCALE, false, &HandleModifyScaleCommand, "" }, { "speed", rbac::RBAC_PERM_COMMAND_MODIFY_SPEED, false, NULL, "", modifyspeedCommandTable }, - { "spell", rbac::RBAC_PERM_COMMAND_MODIFY_SPELL, false, &HandleModifySpellCommand, "", NULL }, - { "standstate", rbac::RBAC_PERM_COMMAND_MODIFY_STANDSTATE, false, &HandleModifyStandStateCommand, "", NULL }, - { "talentpoints", rbac::RBAC_PERM_COMMAND_MODIFY_TALENTPOINTS, false, &HandleModifyTalentCommand, "", NULL }, - { "xp", rbac::RBAC_PERM_COMMAND_MODIFY_XP, false, &HandleModifyXPCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "spell", rbac::RBAC_PERM_COMMAND_MODIFY_SPELL, false, &HandleModifySpellCommand, "" }, + { "standstate", rbac::RBAC_PERM_COMMAND_MODIFY_STANDSTATE, false, &HandleModifyStandStateCommand, "" }, + { "talentpoints", rbac::RBAC_PERM_COMMAND_MODIFY_TALENTPOINTS, false, &HandleModifyTalentCommand, "" }, + { "xp", rbac::RBAC_PERM_COMMAND_MODIFY_XP, false, &HandleModifyXPCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { - { "morph", rbac::RBAC_PERM_COMMAND_MORPH, false, &HandleModifyMorphCommand, "", NULL }, - { "demorph", rbac::RBAC_PERM_COMMAND_DEMORPH, false, &HandleDeMorphCommand, "", NULL }, + { "morph", rbac::RBAC_PERM_COMMAND_MORPH, false, &HandleModifyMorphCommand, "" }, + { "demorph", rbac::RBAC_PERM_COMMAND_DEMORPH, false, &HandleDeMorphCommand, "" }, { "modify", rbac::RBAC_PERM_COMMAND_MODIFY, false, NULL, "", modifyCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index dcf75d0c5db..99c10b074a0 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -170,69 +170,61 @@ class npc_commandscript : public CommandScript public: npc_commandscript() : CommandScript("npc_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand npcAddCommandTable[] = - { - { "formation", rbac::RBAC_PERM_COMMAND_NPC_ADD_FORMATION, false, &HandleNpcAddFormationCommand, "", NULL }, - { "item", rbac::RBAC_PERM_COMMAND_NPC_ADD_ITEM, false, &HandleNpcAddVendorItemCommand, "", NULL }, - { "move", rbac::RBAC_PERM_COMMAND_NPC_ADD_MOVE, false, &HandleNpcAddMoveCommand, "", NULL }, - { "temp", rbac::RBAC_PERM_COMMAND_NPC_ADD_TEMP, false, &HandleNpcAddTempSpawnCommand, "", NULL }, - //{ "weapon", rbac::RBAC_PERM_COMMAND_NPC_ADD_WEAPON, false, &HandleNpcAddWeaponCommand, "", NULL }, - { "", rbac::RBAC_PERM_COMMAND_NPC_ADD, false, &HandleNpcAddCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + static std::vector<ChatCommand> npcAddCommandTable = + { + { "formation", rbac::RBAC_PERM_COMMAND_NPC_ADD_FORMATION, false, &HandleNpcAddFormationCommand, "" }, + { "item", rbac::RBAC_PERM_COMMAND_NPC_ADD_ITEM, false, &HandleNpcAddVendorItemCommand, "" }, + { "move", rbac::RBAC_PERM_COMMAND_NPC_ADD_MOVE, false, &HandleNpcAddMoveCommand, "" }, + { "temp", rbac::RBAC_PERM_COMMAND_NPC_ADD_TEMP, false, &HandleNpcAddTempSpawnCommand, "" }, + //{ "weapon", rbac::RBAC_PERM_COMMAND_NPC_ADD_WEAPON, false, &HandleNpcAddWeaponCommand, "" }, + { "", rbac::RBAC_PERM_COMMAND_NPC_ADD, false, &HandleNpcAddCommand, "" }, }; - static ChatCommand npcDeleteCommandTable[] = + static std::vector<ChatCommand> npcDeleteCommandTable = { - { "item", rbac::RBAC_PERM_COMMAND_NPC_DELETE_ITEM, false, &HandleNpcDeleteVendorItemCommand, "", NULL }, - { "", rbac::RBAC_PERM_COMMAND_NPC_DELETE, false, &HandleNpcDeleteCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "item", rbac::RBAC_PERM_COMMAND_NPC_DELETE_ITEM, false, &HandleNpcDeleteVendorItemCommand, "" }, + { "", rbac::RBAC_PERM_COMMAND_NPC_DELETE, false, &HandleNpcDeleteCommand, "" }, }; - static ChatCommand npcFollowCommandTable[] = + static std::vector<ChatCommand> npcFollowCommandTable = { - { "stop", rbac::RBAC_PERM_COMMAND_NPC_FOLLOW_STOP, false, &HandleNpcUnFollowCommand, "", NULL }, - { "", rbac::RBAC_PERM_COMMAND_NPC_FOLLOW, false, &HandleNpcFollowCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "stop", rbac::RBAC_PERM_COMMAND_NPC_FOLLOW_STOP, false, &HandleNpcUnFollowCommand, "" }, + { "", rbac::RBAC_PERM_COMMAND_NPC_FOLLOW, false, &HandleNpcFollowCommand, "" }, }; - static ChatCommand npcSetCommandTable[] = - { - { "allowmove", rbac::RBAC_PERM_COMMAND_NPC_SET_ALLOWMOVE, false, &HandleNpcSetAllowMovementCommand, "", NULL }, - { "entry", rbac::RBAC_PERM_COMMAND_NPC_SET_ENTRY, false, &HandleNpcSetEntryCommand, "", NULL }, - { "factionid", rbac::RBAC_PERM_COMMAND_NPC_SET_FACTIONID, false, &HandleNpcSetFactionIdCommand, "", NULL }, - { "flag", rbac::RBAC_PERM_COMMAND_NPC_SET_FLAG, false, &HandleNpcSetFlagCommand, "", NULL }, - { "level", rbac::RBAC_PERM_COMMAND_NPC_SET_LEVEL, false, &HandleNpcSetLevelCommand, "", NULL }, - { "link", rbac::RBAC_PERM_COMMAND_NPC_SET_LINK, false, &HandleNpcSetLinkCommand, "", NULL }, - { "model", rbac::RBAC_PERM_COMMAND_NPC_SET_MODEL, false, &HandleNpcSetModelCommand, "", NULL }, - { "movetype", rbac::RBAC_PERM_COMMAND_NPC_SET_MOVETYPE, false, &HandleNpcSetMoveTypeCommand, "", NULL }, - { "phase", rbac::RBAC_PERM_COMMAND_NPC_SET_PHASE, false, &HandleNpcSetPhaseCommand, "", NULL }, - { "spawndist", rbac::RBAC_PERM_COMMAND_NPC_SET_SPAWNDIST, false, &HandleNpcSetSpawnDistCommand, "", NULL }, - { "spawntime", rbac::RBAC_PERM_COMMAND_NPC_SET_SPAWNTIME, false, &HandleNpcSetSpawnTimeCommand, "", NULL }, - { "data", rbac::RBAC_PERM_COMMAND_NPC_SET_DATA, false, &HandleNpcSetDataCommand, "", NULL }, - //{ "name", rbac::RBAC_PERM_COMMAND_NPC_SET_NAME, false, &HandleNpcSetNameCommand, "", NULL }, - //{ "subname", rbac::RBAC_PERM_COMMAND_NPC_SET_SUBNAME, false, &HandleNpcSetSubNameCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + static std::vector<ChatCommand> npcSetCommandTable = + { + { "allowmove", rbac::RBAC_PERM_COMMAND_NPC_SET_ALLOWMOVE, false, &HandleNpcSetAllowMovementCommand, "" }, + { "entry", rbac::RBAC_PERM_COMMAND_NPC_SET_ENTRY, false, &HandleNpcSetEntryCommand, "" }, + { "factionid", rbac::RBAC_PERM_COMMAND_NPC_SET_FACTIONID, false, &HandleNpcSetFactionIdCommand, "" }, + { "flag", rbac::RBAC_PERM_COMMAND_NPC_SET_FLAG, false, &HandleNpcSetFlagCommand, "" }, + { "level", rbac::RBAC_PERM_COMMAND_NPC_SET_LEVEL, false, &HandleNpcSetLevelCommand, "" }, + { "link", rbac::RBAC_PERM_COMMAND_NPC_SET_LINK, false, &HandleNpcSetLinkCommand, "" }, + { "model", rbac::RBAC_PERM_COMMAND_NPC_SET_MODEL, false, &HandleNpcSetModelCommand, "" }, + { "movetype", rbac::RBAC_PERM_COMMAND_NPC_SET_MOVETYPE, false, &HandleNpcSetMoveTypeCommand, "" }, + { "phase", rbac::RBAC_PERM_COMMAND_NPC_SET_PHASE, false, &HandleNpcSetPhaseCommand, "" }, + { "spawndist", rbac::RBAC_PERM_COMMAND_NPC_SET_SPAWNDIST, false, &HandleNpcSetSpawnDistCommand, "" }, + { "spawntime", rbac::RBAC_PERM_COMMAND_NPC_SET_SPAWNTIME, false, &HandleNpcSetSpawnTimeCommand, "" }, + { "data", rbac::RBAC_PERM_COMMAND_NPC_SET_DATA, false, &HandleNpcSetDataCommand, "" }, }; - static ChatCommand npcCommandTable[] = - { - { "info", rbac::RBAC_PERM_COMMAND_NPC_INFO, false, &HandleNpcInfoCommand, "", NULL }, - { "near", rbac::RBAC_PERM_COMMAND_NPC_NEAR, false, &HandleNpcNearCommand, "", NULL }, - { "move", rbac::RBAC_PERM_COMMAND_NPC_MOVE, false, &HandleNpcMoveCommand, "", NULL }, - { "playemote", rbac::RBAC_PERM_COMMAND_NPC_PLAYEMOTE, false, &HandleNpcPlayEmoteCommand, "", NULL }, - { "say", rbac::RBAC_PERM_COMMAND_NPC_SAY, false, &HandleNpcSayCommand, "", NULL }, - { "textemote", rbac::RBAC_PERM_COMMAND_NPC_TEXTEMOTE, false, &HandleNpcTextEmoteCommand, "", NULL }, - { "whisper", rbac::RBAC_PERM_COMMAND_NPC_WHISPER, false, &HandleNpcWhisperCommand, "", NULL }, - { "yell", rbac::RBAC_PERM_COMMAND_NPC_YELL, false, &HandleNpcYellCommand, "", NULL }, - { "tame", rbac::RBAC_PERM_COMMAND_NPC_TAME, false, &HandleNpcTameCommand, "", NULL }, + static std::vector<ChatCommand> npcCommandTable = + { + { "info", rbac::RBAC_PERM_COMMAND_NPC_INFO, false, &HandleNpcInfoCommand, "" }, + { "near", rbac::RBAC_PERM_COMMAND_NPC_NEAR, false, &HandleNpcNearCommand, "" }, + { "move", rbac::RBAC_PERM_COMMAND_NPC_MOVE, false, &HandleNpcMoveCommand, "" }, + { "playemote", rbac::RBAC_PERM_COMMAND_NPC_PLAYEMOTE, false, &HandleNpcPlayEmoteCommand, "" }, + { "say", rbac::RBAC_PERM_COMMAND_NPC_SAY, false, &HandleNpcSayCommand, "" }, + { "textemote", rbac::RBAC_PERM_COMMAND_NPC_TEXTEMOTE, false, &HandleNpcTextEmoteCommand, "" }, + { "whisper", rbac::RBAC_PERM_COMMAND_NPC_WHISPER, false, &HandleNpcWhisperCommand, "" }, + { "yell", rbac::RBAC_PERM_COMMAND_NPC_YELL, false, &HandleNpcYellCommand, "" }, + { "tame", rbac::RBAC_PERM_COMMAND_NPC_TAME, false, &HandleNpcTameCommand, "" }, { "add", rbac::RBAC_PERM_COMMAND_NPC_ADD, false, NULL, "", npcAddCommandTable }, { "delete", rbac::RBAC_PERM_COMMAND_NPC_DELETE, false, NULL, "", npcDeleteCommandTable }, { "follow", rbac::RBAC_PERM_COMMAND_NPC_FOLLOW, false, NULL, "", npcFollowCommandTable }, { "set", rbac::RBAC_PERM_COMMAND_NPC_SET, false, NULL, "", npcSetCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "npc", rbac::RBAC_PERM_COMMAND_NPC, false, NULL, "", npcCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } @@ -260,7 +252,7 @@ public: if (Transport* trans = chr->GetTransport()) { - uint32 guid = map->GenerateLowGuid<HighGuid::Unit>(); + ObjectGuid::LowType guid = map->GenerateLowGuid<HighGuid::Unit>(); CreatureData& data = sObjectMgr->NewOrExistCreatureData(guid); data.id = id; data.phaseMask = chr->GetPhaseMaskForSpawn(); @@ -286,7 +278,7 @@ public: creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - uint32 db_guid = creature->GetSpawnId(); + ObjectGuid::LowType db_guid = creature->GetSpawnId(); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells() // current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior @@ -368,7 +360,7 @@ public: char* guidStr = strtok((char*)args, " "); char* waitStr = strtok((char*)NULL, " "); - uint32 lowGuid = atoi((char*)guidStr); + ObjectGuid::LowType lowGuid = atoi((char*)guidStr); // attempt check creature existence by DB data CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid); @@ -489,7 +481,7 @@ public: if (!cId) return false; - uint32 lowguid = atoi(cId); + ObjectGuid::LowType lowguid = atoi(cId); if (!lowguid) return false; @@ -764,7 +756,7 @@ public: do { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); float x = fields[2].GetFloat(); float y = fields[3].GetFloat(); @@ -790,7 +782,7 @@ public: //move selected creature static bool HandleNpcMoveCommand(ChatHandler* handler, char const* args) { - uint32 lowguid = 0; + ObjectGuid::LowType lowguid = 0; Creature* creature = handler->getSelectedCreature(); @@ -939,7 +931,7 @@ public: if (!guid_str) return false; - uint32 lowguid = 0; + ObjectGuid::LowType lowguid = 0; Creature* creature = NULL; if (dontdel_str) @@ -1101,7 +1093,7 @@ public: mtype = RANDOM_MOTION_TYPE; Creature* creature = handler->getSelectedCreature(); - uint32 guidLow = 0; + ObjectGuid::LowType guidLow = 0; if (creature) guidLow = creature->GetSpawnId(); @@ -1150,7 +1142,7 @@ public: } Creature* creature = handler->getSelectedCreature(); - uint32 guidLow = 0; + ObjectGuid::LowType guidLow = 0; if (creature) guidLow = creature->GetSpawnId(); @@ -1414,7 +1406,7 @@ public: if (!*args) return false; - uint32 leaderGUID = (uint32) atoi((char*)args); + ObjectGuid::LowType leaderGUID = (uint32) atoi((char*)args); Creature* creature = handler->getSelectedCreature(); if (!creature || !creature->GetSpawnId()) @@ -1424,7 +1416,7 @@ public: return false; } - uint32 lowguid = creature->GetSpawnId(); + ObjectGuid::LowType lowguid = creature->GetSpawnId(); if (creature->GetFormation()) { handler->PSendSysMessage("Selected creature is already member of group %u", creature->GetFormation()->GetId()); @@ -1466,7 +1458,7 @@ public: if (!*args) return false; - uint32 linkguid = (uint32) atoi((char*)args); + ObjectGuid::LowType linkguid = (uint32) atoi((char*)args); Creature* creature = handler->getSelectedCreature(); @@ -1563,98 +1555,6 @@ public: */ return true; } - - static bool HandleNpcSetNameCommand(ChatHandler* /*handler*/, char const* /*args*/) - { - /* Temp. disabled - if (!*args) - return false; - - if (strlen((char*)args)>75) - { - handler->PSendSysMessage(LANG_TOO_LONG_NAME, strlen((char*)args)-75); - return true; - } - - for (uint8 i = 0; i < strlen(args); ++i) - { - if (!isalpha(args[i]) && args[i] != ' ') - { - handler->SendSysMessage(LANG_CHARS_ONLY); - return false; - } - } - - uint64 guid; - guid = handler->GetSession()->GetPlayer()->GetSelection(); - if (guid == 0) - { - handler->SendSysMessage(LANG_NO_SELECTION); - return true; - } - - Creature* creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), guid); - - if (!creature) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - return true; - } - - creature->SetName(args); - uint32 idname = sObjectMgr->AddCreatureTemplate(creature->GetName()); - creature->SetUInt32Value(OBJECT_FIELD_ENTRY, idname); - - creature->SaveToDB(); - */ - - return true; - } - - static bool HandleNpcSetSubNameCommand(ChatHandler* /*handler*/, char const* /*args*/) - { - /* Temp. disabled - - if (!*args) - args = ""; - - if (strlen((char*)args)>75) - { - handler->PSendSysMessage(LANG_TOO_LONG_SUBNAME, strlen((char*)args)-75); - return true; - } - - for (uint8 i = 0; i < strlen(args); i++) - { - if (!isalpha(args[i]) && args[i] != ' ') - { - handler->SendSysMessage(LANG_CHARS_ONLY); - return false; - } - } - uint64 guid; - guid = handler->GetSession()->GetPlayer()->GetSelection(); - if (guid == 0) - { - handler->SendSysMessage(LANG_NO_SELECTION); - return true; - } - - Creature* creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), guid); - - if (!creature) - { - handler->SendSysMessage(LANG_SELECT_CREATURE); - return true; - } - - uint32 idname = sObjectMgr->AddCreatureSubName(creature->GetName(), args, creature->GetUInt32Value(UNIT_FIELD_DISPLAYID)); - creature->SetUInt32Value(OBJECT_FIELD_ENTRY, idname); - - creature->SaveToDB(); - */ - return true; - } }; void AddSC_npc_commandscript() diff --git a/src/server/scripts/Commands/cs_pet.cpp b/src/server/scripts/Commands/cs_pet.cpp index fdac9d1a35f..e3046817821 100644 --- a/src/server/scripts/Commands/cs_pet.cpp +++ b/src/server/scripts/Commands/cs_pet.cpp @@ -27,20 +27,18 @@ class pet_commandscript : public CommandScript public: pet_commandscript() : CommandScript("pet_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand petCommandTable[] = + static std::vector<ChatCommand> petCommandTable = { - { "create", rbac::RBAC_PERM_COMMAND_PET_CREATE, false, &HandlePetCreateCommand, "", NULL }, - { "learn", rbac::RBAC_PERM_COMMAND_PET_LEARN, false, &HandlePetLearnCommand, "", NULL }, - { "unlearn", rbac::RBAC_PERM_COMMAND_PET_UNLEARN, false, &HandlePetUnlearnCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "create", rbac::RBAC_PERM_COMMAND_PET_CREATE, false, &HandlePetCreateCommand, "" }, + { "learn", rbac::RBAC_PERM_COMMAND_PET_LEARN, false, &HandlePetLearnCommand, "" }, + { "unlearn", rbac::RBAC_PERM_COMMAND_PET_UNLEARN, false, &HandlePetUnlearnCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "pet", rbac::RBAC_PERM_COMMAND_PET, false, NULL, "", petCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp index 82904efc949..442950bca96 100644 --- a/src/server/scripts/Commands/cs_quest.cpp +++ b/src/server/scripts/Commands/cs_quest.cpp @@ -33,20 +33,18 @@ class quest_commandscript : public CommandScript public: quest_commandscript() : CommandScript("quest_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand questCommandTable[] = + static std::vector<ChatCommand> questCommandTable = { - { "add", rbac::RBAC_PERM_COMMAND_QUEST_ADD, false, &HandleQuestAdd, "", NULL }, - { "complete", rbac::RBAC_PERM_COMMAND_QUEST_COMPLETE, false, &HandleQuestComplete, "", NULL }, - { "remove", rbac::RBAC_PERM_COMMAND_QUEST_REMOVE, false, &HandleQuestRemove, "", NULL }, - { "reward", rbac::RBAC_PERM_COMMAND_QUEST_REWARD, false, &HandleQuestReward, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "add", rbac::RBAC_PERM_COMMAND_QUEST_ADD, false, &HandleQuestAdd, "" }, + { "complete", rbac::RBAC_PERM_COMMAND_QUEST_COMPLETE, false, &HandleQuestComplete, "" }, + { "remove", rbac::RBAC_PERM_COMMAND_QUEST_REMOVE, false, &HandleQuestRemove, "" }, + { "reward", rbac::RBAC_PERM_COMMAND_QUEST_REWARD, false, &HandleQuestReward, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "quest", rbac::RBAC_PERM_COMMAND_QUEST, false, NULL, "", questCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_rbac.cpp b/src/server/scripts/Commands/cs_rbac.cpp index 03f35e6ba65..c28aa04175f 100644 --- a/src/server/scripts/Commands/cs_rbac.cpp +++ b/src/server/scripts/Commands/cs_rbac.cpp @@ -49,28 +49,25 @@ class rbac_commandscript : public CommandScript public: rbac_commandscript() : CommandScript("rbac_commandscript") { } - ChatCommand* GetCommands() const + std::vector<ChatCommand> GetCommands() const { - static ChatCommand rbacAccountCommandTable[] = + static std::vector<ChatCommand> rbacAccountCommandTable = { - { "list", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_LIST, true, &HandleRBACPermListCommand, "", NULL }, - { "grant", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_GRANT, true, &HandleRBACPermGrantCommand, "", NULL }, - { "deny", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_DENY, true, &HandleRBACPermDenyCommand, "", NULL }, - { "revoke", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_REVOKE, true, &HandleRBACPermRevokeCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "list", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_LIST, true, &HandleRBACPermListCommand, "" }, + { "grant", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_GRANT, true, &HandleRBACPermGrantCommand, "" }, + { "deny", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_DENY, true, &HandleRBACPermDenyCommand, "" }, + { "revoke", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_REVOKE, true, &HandleRBACPermRevokeCommand, "" }, }; - static ChatCommand rbacCommandTable[] = + static std::vector<ChatCommand> rbacCommandTable = { { "account", rbac::RBAC_PERM_COMMAND_RBAC_ACC, true, NULL, "", rbacAccountCommandTable }, - { "list", rbac::RBAC_PERM_COMMAND_RBAC_LIST, true, &HandleRBACListPermissionsCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "list", rbac::RBAC_PERM_COMMAND_RBAC_LIST, true, &HandleRBACListPermissionsCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "rbac", rbac::RBAC_PERM_COMMAND_RBAC, true, NULL, "", rbacCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index f4b442de92a..44e34b8e2a9 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -47,122 +47,119 @@ class reload_commandscript : public CommandScript public: reload_commandscript() : CommandScript("reload_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand reloadAllCommandTable[] = + static std::vector<ChatCommand> reloadAllCommandTable = { - { "achievement", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_ACHIEVEMENT, true, &HandleReloadAllAchievementCommand, "", NULL }, - { "area", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_AREA, true, &HandleReloadAllAreaCommand, "", NULL }, - { "gossips", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_GOSSIP, true, &HandleReloadAllGossipsCommand, "", NULL }, - { "item", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_ITEM, true, &HandleReloadAllItemCommand, "", NULL }, - { "locales", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_LOCALES, true, &HandleReloadAllLocalesCommand, "", NULL }, - { "loot", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_LOOT, true, &HandleReloadAllLootCommand, "", NULL }, - { "npc", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_NPC, true, &HandleReloadAllNpcCommand, "", NULL }, - { "quest", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_QUEST, true, &HandleReloadAllQuestCommand, "", NULL }, - { "scripts", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_SCRIPTS, true, &HandleReloadAllScriptsCommand, "", NULL }, - { "spell", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_SPELL, true, &HandleReloadAllSpellCommand, "", NULL }, - { "", rbac::RBAC_PERM_COMMAND_RELOAD_ALL, true, &HandleReloadAllCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "achievement", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_ACHIEVEMENT, true, &HandleReloadAllAchievementCommand, "" }, + { "area", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_AREA, true, &HandleReloadAllAreaCommand, "" }, + { "gossips", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_GOSSIP, true, &HandleReloadAllGossipsCommand, "" }, + { "item", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_ITEM, true, &HandleReloadAllItemCommand, "" }, + { "locales", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_LOCALES, true, &HandleReloadAllLocalesCommand, "" }, + { "loot", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_LOOT, true, &HandleReloadAllLootCommand, "" }, + { "npc", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_NPC, true, &HandleReloadAllNpcCommand, "" }, + { "quest", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_QUEST, true, &HandleReloadAllQuestCommand, "" }, + { "scripts", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_SCRIPTS, true, &HandleReloadAllScriptsCommand, "" }, + { "spell", rbac::RBAC_PERM_COMMAND_RELOAD_ALL_SPELL, true, &HandleReloadAllSpellCommand, "" }, + { "", rbac::RBAC_PERM_COMMAND_RELOAD_ALL, true, &HandleReloadAllCommand, "" }, }; - static ChatCommand reloadCommandTable[] = + static std::vector<ChatCommand> reloadCommandTable = { - { "auctions", rbac::RBAC_PERM_COMMAND_RELOAD_AUCTIONS, true, &HandleReloadAuctionsCommand, "", NULL }, - { "access_requirement", rbac::RBAC_PERM_COMMAND_RELOAD_ACCESS_REQUIREMENT, true, &HandleReloadAccessRequirementCommand, "", NULL }, - { "achievement_criteria_data", rbac::RBAC_PERM_COMMAND_RELOAD_ACHIEVEMENT_CRITERIA_DATA, true, &HandleReloadAchievementCriteriaDataCommand, "", NULL }, - { "achievement_reward", rbac::RBAC_PERM_COMMAND_RELOAD_ACHIEVEMENT_REWARD, true, &HandleReloadAchievementRewardCommand, "", NULL }, + { "auctions", rbac::RBAC_PERM_COMMAND_RELOAD_AUCTIONS, true, &HandleReloadAuctionsCommand, "" }, + { "access_requirement", rbac::RBAC_PERM_COMMAND_RELOAD_ACCESS_REQUIREMENT, true, &HandleReloadAccessRequirementCommand, "" }, + { "achievement_criteria_data", rbac::RBAC_PERM_COMMAND_RELOAD_ACHIEVEMENT_CRITERIA_DATA, true, &HandleReloadAchievementCriteriaDataCommand, "" }, + { "achievement_reward", rbac::RBAC_PERM_COMMAND_RELOAD_ACHIEVEMENT_REWARD, true, &HandleReloadAchievementRewardCommand, "" }, { "all", rbac::RBAC_PERM_COMMAND_RELOAD_ALL, true, NULL, "", reloadAllCommandTable }, - { "areatrigger_involvedrelation", rbac::RBAC_PERM_COMMAND_RELOAD_AREATRIGGER_INVOLVEDRELATION, true, &HandleReloadQuestAreaTriggersCommand, "", NULL }, - { "areatrigger_tavern", rbac::RBAC_PERM_COMMAND_RELOAD_AREATRIGGER_TAVERN, true, &HandleReloadAreaTriggerTavernCommand, "", NULL }, - { "areatrigger_teleport", rbac::RBAC_PERM_COMMAND_RELOAD_AREATRIGGER_TELEPORT, true, &HandleReloadAreaTriggerTeleportCommand, "", NULL }, - { "autobroadcast", rbac::RBAC_PERM_COMMAND_RELOAD_AUTOBROADCAST, true, &HandleReloadAutobroadcastCommand, "", NULL }, - { "battleground_template", rbac::RBAC_PERM_COMMAND_RELOAD_BATTLEGROUND_TEMPLATE, true, &HandleReloadBattlegroundTemplate, "", NULL }, - { "broadcast_text", rbac::RBAC_PERM_COMMAND_RELOAD_BROADCAST_TEXT, true, &HandleReloadBroadcastTextCommand, "", NULL }, - { "command", rbac::RBAC_PERM_COMMAND_RELOAD_COMMAND, true, &HandleReloadCommandCommand, "", NULL }, - { "conditions", rbac::RBAC_PERM_COMMAND_RELOAD_CONDITIONS, true, &HandleReloadConditions, "", NULL }, - { "config", rbac::RBAC_PERM_COMMAND_RELOAD_CONFIG, true, &HandleReloadConfigCommand, "", NULL }, - { "creature_text", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_TEXT, true, &HandleReloadCreatureText, "", NULL }, - { "creature_questender", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_QUESTENDER, true, &HandleReloadCreatureQuestEnderCommand, "", NULL }, - { "creature_linked_respawn", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_LINKED_RESPAWN, true, &HandleReloadLinkedRespawnCommand, "", NULL }, - { "creature_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesCreatureCommand, "", NULL }, - { "creature_onkill_reputation", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_ONKILL_REPUTATION, true, &HandleReloadOnKillReputationCommand, "", NULL }, - { "creature_queststarter", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_QUESTSTARTER, true, &HandleReloadCreatureQuestStarterCommand, "", NULL }, - { "creature_summon_groups", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_SUMMON_GROUPS, true, &HandleReloadCreatureSummonGroupsCommand, "", NULL }, - { "creature_template", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_TEMPLATE, true, &HandleReloadCreatureTemplateCommand, "", NULL }, - { "disables", rbac::RBAC_PERM_COMMAND_RELOAD_DISABLES, true, &HandleReloadDisablesCommand, "", NULL }, - { "disenchant_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_DISENCHANT_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesDisenchantCommand, "", NULL }, - { "event_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_EVENT_SCRIPTS, true, &HandleReloadEventScriptsCommand, "", NULL }, - { "fishing_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_FISHING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesFishingCommand, "", NULL }, - { "game_graveyard_zone", rbac::RBAC_PERM_COMMAND_RELOAD_GAME_GRAVEYARD_ZONE, true, &HandleReloadGameGraveyardZoneCommand, "", NULL }, - { "game_tele", rbac::RBAC_PERM_COMMAND_RELOAD_GAME_TELE, true, &HandleReloadGameTeleCommand, "", NULL }, - { "gameobject_questender", rbac::RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUESTENDER, true, &HandleReloadGOQuestEnderCommand, "", NULL }, - { "gameobject_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUEST_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesGameobjectCommand, "", NULL }, - { "gameobject_queststarter", rbac::RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUESTSTARTER, true, &HandleReloadGOQuestStarterCommand, "", NULL }, - { "gm_tickets", rbac::RBAC_PERM_COMMAND_RELOAD_GM_TICKETS, true, &HandleReloadGMTicketsCommand, "", NULL }, - { "gossip_menu", rbac::RBAC_PERM_COMMAND_RELOAD_GOSSIP_MENU, true, &HandleReloadGossipMenuCommand, "", NULL }, - { "gossip_menu_option", rbac::RBAC_PERM_COMMAND_RELOAD_GOSSIP_MENU_OPTION, true, &HandleReloadGossipMenuOptionCommand, "", NULL }, - { "item_enchantment_template", rbac::RBAC_PERM_COMMAND_RELOAD_ITEM_ENCHANTMENT_TEMPLATE, true, &HandleReloadItemEnchantementsCommand, "", NULL }, - { "item_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_ITEM_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesItemCommand, "", NULL }, - { "item_set_names", rbac::RBAC_PERM_COMMAND_RELOAD_ITEM_SET_NAMES, true, &HandleReloadItemSetNamesCommand, "", NULL }, - { "lfg_dungeon_rewards", rbac::RBAC_PERM_COMMAND_RELOAD_LFG_DUNGEON_REWARDS, true, &HandleReloadLfgRewardsCommand, "", NULL }, - { "locales_achievement_reward", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_ACHIEVEMENT_REWARD, true, &HandleReloadLocalesAchievementRewardCommand, "", NULL }, - { "locales_creature", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_CRETURE, true, &HandleReloadLocalesCreatureCommand, "", NULL }, - { "locales_creature_text", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_CRETURE_TEXT, true, &HandleReloadLocalesCreatureTextCommand, "", NULL }, - { "locales_gameobject", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_GAMEOBJECT, true, &HandleReloadLocalesGameobjectCommand, "", NULL }, - { "locales_gossip_menu_option", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_GOSSIP_MENU_OPTION, true, &HandleReloadLocalesGossipMenuOptionCommand, "", NULL }, - { "locales_item", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_ITEM, true, &HandleReloadLocalesItemCommand, "", NULL }, - { "locales_item_set_name", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_ITEM_SET_NAME, true, &HandleReloadLocalesItemSetNameCommand, "", NULL }, - { "locales_npc_text", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_NPC_TEXT, true, &HandleReloadLocalesNpcTextCommand, "", NULL }, - { "locales_page_text", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_PAGE_TEXT, true, &HandleReloadLocalesPageTextCommand, "", NULL }, - { "locales_points_of_interest", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_POINTS_OF_INTEREST, true, &HandleReloadLocalesPointsOfInterestCommand, "", NULL }, - { "locales_quest", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_QUEST, true, &HandleReloadLocalesQuestCommand, "", NULL }, - { "mail_level_reward", rbac::RBAC_PERM_COMMAND_RELOAD_MAIL_LEVEL_REWARD, true, &HandleReloadMailLevelRewardCommand, "", NULL }, - { "mail_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_MAIL_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesMailCommand, "", NULL }, - { "milling_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_MILLING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesMillingCommand, "", NULL }, - { "npc_spellclick_spells", rbac::RBAC_PERM_COMMAND_RELOAD_NPC_SPELLCLICK_SPELLS, true, &HandleReloadSpellClickSpellsCommand, "", NULL }, - { "npc_trainer", rbac::RBAC_PERM_COMMAND_RELOAD_NPC_TRAINER, true, &HandleReloadNpcTrainerCommand, "", NULL }, - { "npc_vendor", rbac::RBAC_PERM_COMMAND_RELOAD_NPC_VENDOR, true, &HandleReloadNpcVendorCommand, "", NULL }, - { "page_text", rbac::RBAC_PERM_COMMAND_RELOAD_PAGE_TEXT, true, &HandleReloadPageTextsCommand, "", NULL }, - { "pickpocketing_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_PICKPOCKETING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesPickpocketingCommand, "", NULL }, - { "points_of_interest", rbac::RBAC_PERM_COMMAND_RELOAD_POINTS_OF_INTEREST, true, &HandleReloadPointsOfInterestCommand, "", NULL }, - { "prospecting_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_PROSPECTING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesProspectingCommand, "", NULL }, - { "quest_poi", rbac::RBAC_PERM_COMMAND_RELOAD_QUEST_POI, true, &HandleReloadQuestPOICommand, "", NULL }, - { "quest_template", rbac::RBAC_PERM_COMMAND_RELOAD_QUEST_TEMPLATE, true, &HandleReloadQuestTemplateCommand, "", NULL }, - { "rbac", rbac::RBAC_PERM_COMMAND_RELOAD_RBAC, true, &HandleReloadRBACCommand, "", NULL }, - { "reference_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_REFERENCE_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesReferenceCommand, "", NULL }, - { "reserved_name", rbac::RBAC_PERM_COMMAND_RELOAD_RESERVED_NAME, true, &HandleReloadReservedNameCommand, "", NULL }, - { "reputation_reward_rate", rbac::RBAC_PERM_COMMAND_RELOAD_REPUTATION_REWARD_RATE, true, &HandleReloadReputationRewardRateCommand, "", NULL }, - { "reputation_spillover_template", rbac::RBAC_PERM_COMMAND_RELOAD_SPILLOVER_TEMPLATE, true, &HandleReloadReputationRewardRateCommand, "", NULL }, - { "skill_discovery_template", rbac::RBAC_PERM_COMMAND_RELOAD_SKILL_DISCOVERY_TEMPLATE, true, &HandleReloadSkillDiscoveryTemplateCommand, "", NULL }, - { "skill_extra_item_template", rbac::RBAC_PERM_COMMAND_RELOAD_SKILL_EXTRA_ITEM_TEMPLATE, true, &HandleReloadSkillExtraItemTemplateCommand, "", NULL }, - { "skill_fishing_base_level", rbac::RBAC_PERM_COMMAND_RELOAD_SKILL_FISHING_BASE_LEVEL, true, &HandleReloadSkillFishingBaseLevelCommand, "", NULL }, - { "skinning_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_SKINNING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesSkinningCommand, "", NULL }, - { "smart_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_SMART_SCRIPTS, true, &HandleReloadSmartScripts, "", NULL }, - { "spell_required", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_REQUIRED, true, &HandleReloadSpellRequiredCommand, "", NULL }, - { "spell_area", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_AREA, true, &HandleReloadSpellAreaCommand, "", NULL }, - { "spell_bonus_data", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_BONUS_DATA, true, &HandleReloadSpellBonusesCommand, "", NULL }, - { "spell_group", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_GROUP, true, &HandleReloadSpellGroupsCommand, "", NULL }, - { "spell_learn_spell", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_LEARN_SPELL, true, &HandleReloadSpellLearnSpellCommand, "", NULL }, - { "spell_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesSpellCommand, "", NULL }, - { "spell_linked_spell", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_LINKED_SPELL, true, &HandleReloadSpellLinkedSpellCommand, "", NULL }, - { "spell_pet_auras", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PET_AURAS, true, &HandleReloadSpellPetAurasCommand, "", NULL }, - { "spell_proc_event", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PROC_EVENT, true, &HandleReloadSpellProcEventCommand, "", NULL }, - { "spell_proc", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PROC, true, &HandleReloadSpellProcsCommand, "", NULL }, - { "spell_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_SCRIPTS, true, &HandleReloadSpellScriptsCommand, "", NULL }, - { "spell_target_position", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_TARGET_POSITION, true, &HandleReloadSpellTargetPositionCommand, "", NULL }, - { "spell_threats", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_THREATS, true, &HandleReloadSpellThreatsCommand, "", NULL }, - { "spell_group_stack_rules", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_GROUP_STACK_RULES, true, &HandleReloadSpellGroupStackRulesCommand, "", NULL }, - { "trinity_string", rbac::RBAC_PERM_COMMAND_RELOAD_TRINITY_STRING, true, &HandleReloadTrinityStringCommand, "", NULL }, - { "warden_action", rbac::RBAC_PERM_COMMAND_RELOAD_WARDEN_ACTION, true, &HandleReloadWardenactionCommand, "", NULL }, - { "waypoint_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_WAYPOINT_SCRIPTS, true, &HandleReloadWpScriptsCommand, "", NULL }, - { "waypoint_data", rbac::RBAC_PERM_COMMAND_RELOAD_WAYPOINT_DATA, true, &HandleReloadWpCommand, "", NULL }, - { "vehicle_accessory", rbac::RBAC_PERM_COMMAND_RELOAD_VEHICLE_ACCESORY, true, &HandleReloadVehicleAccessoryCommand, "", NULL }, - { "vehicle_template_accessory", rbac::RBAC_PERM_COMMAND_RELOAD_VEHICLE_TEMPLATE_ACCESSORY, true, &HandleReloadVehicleTemplateAccessoryCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "areatrigger_involvedrelation", rbac::RBAC_PERM_COMMAND_RELOAD_AREATRIGGER_INVOLVEDRELATION, true, &HandleReloadQuestAreaTriggersCommand, "" }, + { "areatrigger_tavern", rbac::RBAC_PERM_COMMAND_RELOAD_AREATRIGGER_TAVERN, true, &HandleReloadAreaTriggerTavernCommand, "" }, + { "areatrigger_teleport", rbac::RBAC_PERM_COMMAND_RELOAD_AREATRIGGER_TELEPORT, true, &HandleReloadAreaTriggerTeleportCommand, "" }, + { "autobroadcast", rbac::RBAC_PERM_COMMAND_RELOAD_AUTOBROADCAST, true, &HandleReloadAutobroadcastCommand, "" }, + { "battleground_template", rbac::RBAC_PERM_COMMAND_RELOAD_BATTLEGROUND_TEMPLATE, true, &HandleReloadBattlegroundTemplate, "" }, + { "broadcast_text", rbac::RBAC_PERM_COMMAND_RELOAD_BROADCAST_TEXT, true, &HandleReloadBroadcastTextCommand, "" }, + { "command", rbac::RBAC_PERM_COMMAND_RELOAD_COMMAND, true, &HandleReloadCommandCommand, "" }, + { "conditions", rbac::RBAC_PERM_COMMAND_RELOAD_CONDITIONS, true, &HandleReloadConditions, "" }, + { "config", rbac::RBAC_PERM_COMMAND_RELOAD_CONFIG, true, &HandleReloadConfigCommand, "" }, + { "creature_text", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_TEXT, true, &HandleReloadCreatureText, "" }, + { "creature_questender", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_QUESTENDER, true, &HandleReloadCreatureQuestEnderCommand, "" }, + { "creature_linked_respawn", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_LINKED_RESPAWN, true, &HandleReloadLinkedRespawnCommand, "" }, + { "creature_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesCreatureCommand, "" }, + { "creature_onkill_reputation", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_ONKILL_REPUTATION, true, &HandleReloadOnKillReputationCommand, "" }, + { "creature_queststarter", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_QUESTSTARTER, true, &HandleReloadCreatureQuestStarterCommand, "" }, + { "creature_summon_groups", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_SUMMON_GROUPS, true, &HandleReloadCreatureSummonGroupsCommand, "" }, + { "creature_template", rbac::RBAC_PERM_COMMAND_RELOAD_CREATURE_TEMPLATE, true, &HandleReloadCreatureTemplateCommand, "" }, + { "disables", rbac::RBAC_PERM_COMMAND_RELOAD_DISABLES, true, &HandleReloadDisablesCommand, "" }, + { "disenchant_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_DISENCHANT_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesDisenchantCommand, "" }, + { "event_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_EVENT_SCRIPTS, true, &HandleReloadEventScriptsCommand, "" }, + { "fishing_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_FISHING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesFishingCommand, "" }, + { "game_graveyard_zone", rbac::RBAC_PERM_COMMAND_RELOAD_GAME_GRAVEYARD_ZONE, true, &HandleReloadGameGraveyardZoneCommand, "" }, + { "game_tele", rbac::RBAC_PERM_COMMAND_RELOAD_GAME_TELE, true, &HandleReloadGameTeleCommand, "" }, + { "gameobject_questender", rbac::RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUESTENDER, true, &HandleReloadGOQuestEnderCommand, "" }, + { "gameobject_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUEST_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesGameobjectCommand, "" }, + { "gameobject_queststarter", rbac::RBAC_PERM_COMMAND_RELOAD_GAMEOBJECT_QUESTSTARTER, true, &HandleReloadGOQuestStarterCommand, "" }, + { "gm_tickets", rbac::RBAC_PERM_COMMAND_RELOAD_GM_TICKETS, true, &HandleReloadGMTicketsCommand, "" }, + { "gossip_menu", rbac::RBAC_PERM_COMMAND_RELOAD_GOSSIP_MENU, true, &HandleReloadGossipMenuCommand, "" }, + { "gossip_menu_option", rbac::RBAC_PERM_COMMAND_RELOAD_GOSSIP_MENU_OPTION, true, &HandleReloadGossipMenuOptionCommand, "" }, + { "item_enchantment_template", rbac::RBAC_PERM_COMMAND_RELOAD_ITEM_ENCHANTMENT_TEMPLATE, true, &HandleReloadItemEnchantementsCommand, "" }, + { "item_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_ITEM_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesItemCommand, "" }, + { "item_set_names", rbac::RBAC_PERM_COMMAND_RELOAD_ITEM_SET_NAMES, true, &HandleReloadItemSetNamesCommand, "" }, + { "lfg_dungeon_rewards", rbac::RBAC_PERM_COMMAND_RELOAD_LFG_DUNGEON_REWARDS, true, &HandleReloadLfgRewardsCommand, "" }, + { "locales_achievement_reward", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_ACHIEVEMENT_REWARD, true, &HandleReloadLocalesAchievementRewardCommand, "" }, + { "locales_creature", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_CRETURE, true, &HandleReloadLocalesCreatureCommand, "" }, + { "locales_creature_text", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_CRETURE_TEXT, true, &HandleReloadLocalesCreatureTextCommand, "" }, + { "locales_gameobject", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_GAMEOBJECT, true, &HandleReloadLocalesGameobjectCommand, "" }, + { "locales_gossip_menu_option", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_GOSSIP_MENU_OPTION, true, &HandleReloadLocalesGossipMenuOptionCommand, "" }, + { "locales_item", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_ITEM, true, &HandleReloadLocalesItemCommand, "" }, + { "locales_item_set_name", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_ITEM_SET_NAME, true, &HandleReloadLocalesItemSetNameCommand, "" }, + { "locales_npc_text", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_NPC_TEXT, true, &HandleReloadLocalesNpcTextCommand, "" }, + { "locales_page_text", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_PAGE_TEXT, true, &HandleReloadLocalesPageTextCommand, "" }, + { "locales_points_of_interest", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_POINTS_OF_INTEREST, true, &HandleReloadLocalesPointsOfInterestCommand, "" }, + { "locales_quest", rbac::RBAC_PERM_COMMAND_RELOAD_LOCALES_QUEST, true, &HandleReloadLocalesQuestCommand, "" }, + { "mail_level_reward", rbac::RBAC_PERM_COMMAND_RELOAD_MAIL_LEVEL_REWARD, true, &HandleReloadMailLevelRewardCommand, "" }, + { "mail_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_MAIL_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesMailCommand, "" }, + { "milling_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_MILLING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesMillingCommand, "" }, + { "npc_spellclick_spells", rbac::RBAC_PERM_COMMAND_RELOAD_NPC_SPELLCLICK_SPELLS, true, &HandleReloadSpellClickSpellsCommand, "" }, + { "npc_trainer", rbac::RBAC_PERM_COMMAND_RELOAD_NPC_TRAINER, true, &HandleReloadNpcTrainerCommand, "" }, + { "npc_vendor", rbac::RBAC_PERM_COMMAND_RELOAD_NPC_VENDOR, true, &HandleReloadNpcVendorCommand, "" }, + { "page_text", rbac::RBAC_PERM_COMMAND_RELOAD_PAGE_TEXT, true, &HandleReloadPageTextsCommand, "" }, + { "pickpocketing_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_PICKPOCKETING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesPickpocketingCommand, "" }, + { "points_of_interest", rbac::RBAC_PERM_COMMAND_RELOAD_POINTS_OF_INTEREST, true, &HandleReloadPointsOfInterestCommand, "" }, + { "prospecting_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_PROSPECTING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesProspectingCommand, "" }, + { "quest_poi", rbac::RBAC_PERM_COMMAND_RELOAD_QUEST_POI, true, &HandleReloadQuestPOICommand, "" }, + { "quest_template", rbac::RBAC_PERM_COMMAND_RELOAD_QUEST_TEMPLATE, true, &HandleReloadQuestTemplateCommand, "" }, + { "rbac", rbac::RBAC_PERM_COMMAND_RELOAD_RBAC, true, &HandleReloadRBACCommand, "" }, + { "reference_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_REFERENCE_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesReferenceCommand, "" }, + { "reserved_name", rbac::RBAC_PERM_COMMAND_RELOAD_RESERVED_NAME, true, &HandleReloadReservedNameCommand, "" }, + { "reputation_reward_rate", rbac::RBAC_PERM_COMMAND_RELOAD_REPUTATION_REWARD_RATE, true, &HandleReloadReputationRewardRateCommand, "" }, + { "reputation_spillover_template", rbac::RBAC_PERM_COMMAND_RELOAD_SPILLOVER_TEMPLATE, true, &HandleReloadReputationRewardRateCommand, "" }, + { "skill_discovery_template", rbac::RBAC_PERM_COMMAND_RELOAD_SKILL_DISCOVERY_TEMPLATE, true, &HandleReloadSkillDiscoveryTemplateCommand, "" }, + { "skill_extra_item_template", rbac::RBAC_PERM_COMMAND_RELOAD_SKILL_EXTRA_ITEM_TEMPLATE, true, &HandleReloadSkillExtraItemTemplateCommand, "" }, + { "skill_fishing_base_level", rbac::RBAC_PERM_COMMAND_RELOAD_SKILL_FISHING_BASE_LEVEL, true, &HandleReloadSkillFishingBaseLevelCommand, "" }, + { "skinning_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_SKINNING_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesSkinningCommand, "" }, + { "smart_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_SMART_SCRIPTS, true, &HandleReloadSmartScripts, "" }, + { "spell_required", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_REQUIRED, true, &HandleReloadSpellRequiredCommand, "" }, + { "spell_area", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_AREA, true, &HandleReloadSpellAreaCommand, "" }, + { "spell_bonus_data", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_BONUS_DATA, true, &HandleReloadSpellBonusesCommand, "" }, + { "spell_group", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_GROUP, true, &HandleReloadSpellGroupsCommand, "" }, + { "spell_learn_spell", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_LEARN_SPELL, true, &HandleReloadSpellLearnSpellCommand, "" }, + { "spell_loot_template", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_LOOT_TEMPLATE, true, &HandleReloadLootTemplatesSpellCommand, "" }, + { "spell_linked_spell", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_LINKED_SPELL, true, &HandleReloadSpellLinkedSpellCommand, "" }, + { "spell_pet_auras", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PET_AURAS, true, &HandleReloadSpellPetAurasCommand, "" }, + { "spell_proc_event", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PROC_EVENT, true, &HandleReloadSpellProcEventCommand, "" }, + { "spell_proc", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_PROC, true, &HandleReloadSpellProcsCommand, "" }, + { "spell_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_SCRIPTS, true, &HandleReloadSpellScriptsCommand, "" }, + { "spell_target_position", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_TARGET_POSITION, true, &HandleReloadSpellTargetPositionCommand, "" }, + { "spell_threats", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_THREATS, true, &HandleReloadSpellThreatsCommand, "" }, + { "spell_group_stack_rules", rbac::RBAC_PERM_COMMAND_RELOAD_SPELL_GROUP_STACK_RULES, true, &HandleReloadSpellGroupStackRulesCommand, "" }, + { "trinity_string", rbac::RBAC_PERM_COMMAND_RELOAD_TRINITY_STRING, true, &HandleReloadTrinityStringCommand, "" }, + { "warden_action", rbac::RBAC_PERM_COMMAND_RELOAD_WARDEN_ACTION, true, &HandleReloadWardenactionCommand, "" }, + { "waypoint_scripts", rbac::RBAC_PERM_COMMAND_RELOAD_WAYPOINT_SCRIPTS, true, &HandleReloadWpScriptsCommand, "" }, + { "waypoint_data", rbac::RBAC_PERM_COMMAND_RELOAD_WAYPOINT_DATA, true, &HandleReloadWpCommand, "" }, + { "vehicle_accessory", rbac::RBAC_PERM_COMMAND_RELOAD_VEHICLE_ACCESORY, true, &HandleReloadVehicleAccessoryCommand, "" }, + { "vehicle_template_accessory", rbac::RBAC_PERM_COMMAND_RELOAD_VEHICLE_TEMPLATE_ACCESSORY, true, &HandleReloadVehicleTemplateAccessoryCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "reload", rbac::RBAC_PERM_COMMAND_RELOAD, true, NULL, "", reloadCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } @@ -749,12 +746,21 @@ public: return true; } - static bool HandleReloadSkillExtraItemTemplateCommand(ChatHandler* handler, const char* /*args*/) + static bool HandleReloadSkillPerfectItemTemplateCommand(ChatHandler* handler, const char* /*args*/) + { // latched onto HandleReloadSkillExtraItemTemplateCommand as it's part of that table group (and i don't want to chance all the command IDs) + TC_LOG_INFO("misc", "Re-Loading Skill Perfection Data Table..."); + LoadSkillPerfectItemTable(); + handler->SendGlobalGMSysMessage("DB table `skill_perfect_item_template` (perfect item procs when crafting) reloaded."); + return true; + } + + static bool HandleReloadSkillExtraItemTemplateCommand(ChatHandler* handler, const char* args) { TC_LOG_INFO("misc", "Re-Loading Skill Extra Item Table..."); LoadSkillExtraItemTable(); handler->SendGlobalGMSysMessage("DB table `skill_extra_item_template` (extra item creation when crafting) reloaded."); - return true; + + return HandleReloadSkillPerfectItemTemplateCommand(handler, args); } static bool HandleReloadSkillFishingBaseLevelCommand(ChatHandler* handler, const char* /*args*/) diff --git a/src/server/scripts/Commands/cs_reset.cpp b/src/server/scripts/Commands/cs_reset.cpp index b2bccfd884a..d1c7421b761 100644 --- a/src/server/scripts/Commands/cs_reset.cpp +++ b/src/server/scripts/Commands/cs_reset.cpp @@ -35,23 +35,21 @@ class reset_commandscript : public CommandScript public: reset_commandscript() : CommandScript("reset_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand resetCommandTable[] = + static std::vector<ChatCommand> resetCommandTable = { - { "achievements", rbac::RBAC_PERM_COMMAND_RESET_ACHIEVEMENTS, true, &HandleResetAchievementsCommand, "", NULL }, - { "honor", rbac::RBAC_PERM_COMMAND_RESET_HONOR, true, &HandleResetHonorCommand, "", NULL }, - { "level", rbac::RBAC_PERM_COMMAND_RESET_LEVEL, true, &HandleResetLevelCommand, "", NULL }, - { "spells", rbac::RBAC_PERM_COMMAND_RESET_SPELLS, true, &HandleResetSpellsCommand, "", NULL }, - { "stats", rbac::RBAC_PERM_COMMAND_RESET_STATS, true, &HandleResetStatsCommand, "", NULL }, - { "talents", rbac::RBAC_PERM_COMMAND_RESET_TALENTS, true, &HandleResetTalentsCommand, "", NULL }, - { "all", rbac::RBAC_PERM_COMMAND_RESET_ALL, true, &HandleResetAllCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "achievements", rbac::RBAC_PERM_COMMAND_RESET_ACHIEVEMENTS, true, &HandleResetAchievementsCommand, "" }, + { "honor", rbac::RBAC_PERM_COMMAND_RESET_HONOR, true, &HandleResetHonorCommand, "" }, + { "level", rbac::RBAC_PERM_COMMAND_RESET_LEVEL, true, &HandleResetLevelCommand, "" }, + { "spells", rbac::RBAC_PERM_COMMAND_RESET_SPELLS, true, &HandleResetSpellsCommand, "" }, + { "stats", rbac::RBAC_PERM_COMMAND_RESET_STATS, true, &HandleResetStatsCommand, "" }, + { "talents", rbac::RBAC_PERM_COMMAND_RESET_TALENTS, true, &HandleResetTalentsCommand, "" }, + { "all", rbac::RBAC_PERM_COMMAND_RESET_ALL, true, &HandleResetAllCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "reset", rbac::RBAC_PERM_COMMAND_RESET, true, NULL, "", resetCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_send.cpp b/src/server/scripts/Commands/cs_send.cpp index 57ea44a67bf..b7165ed339c 100644 --- a/src/server/scripts/Commands/cs_send.cpp +++ b/src/server/scripts/Commands/cs_send.cpp @@ -27,21 +27,19 @@ class send_commandscript : public CommandScript public: send_commandscript() : CommandScript("send_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand sendCommandTable[] = + static std::vector<ChatCommand> sendCommandTable = { - { "items", rbac::RBAC_PERM_COMMAND_SEND_ITEMS, true, &HandleSendItemsCommand, "", NULL }, - { "mail", rbac::RBAC_PERM_COMMAND_SEND_MAIL, true, &HandleSendMailCommand, "", NULL }, - { "message", rbac::RBAC_PERM_COMMAND_SEND_MESSAGE, true, &HandleSendMessageCommand, "", NULL }, - { "money", rbac::RBAC_PERM_COMMAND_SEND_MONEY, true, &HandleSendMoneyCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "items", rbac::RBAC_PERM_COMMAND_SEND_ITEMS, true, &HandleSendItemsCommand, "" }, + { "mail", rbac::RBAC_PERM_COMMAND_SEND_MAIL, true, &HandleSendMailCommand, "" }, + { "message", rbac::RBAC_PERM_COMMAND_SEND_MESSAGE, true, &HandleSendMessageCommand, "" }, + { "money", rbac::RBAC_PERM_COMMAND_SEND_MONEY, true, &HandleSendMoneyCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "send", rbac::RBAC_PERM_COMMAND_SEND, false, NULL, "", sendCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp index fe5ae940f88..e41a7d161d2 100644 --- a/src/server/scripts/Commands/cs_server.cpp +++ b/src/server/scripts/Commands/cs_server.cpp @@ -35,64 +35,57 @@ class server_commandscript : public CommandScript public: server_commandscript() : CommandScript("server_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand serverIdleRestartCommandTable[] = + static std::vector<ChatCommand> serverIdleRestartCommandTable = { - { "cancel", rbac::RBAC_PERM_COMMAND_SERVER_IDLERESTART_CANCEL, true, &HandleServerShutDownCancelCommand, "", NULL }, - { "" , rbac::RBAC_PERM_COMMAND_SERVER_IDLERESTART, true, &HandleServerIdleRestartCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "cancel", rbac::RBAC_PERM_COMMAND_SERVER_IDLERESTART_CANCEL, true, &HandleServerShutDownCancelCommand, "" }, + { "" , rbac::RBAC_PERM_COMMAND_SERVER_IDLERESTART, true, &HandleServerIdleRestartCommand, "" }, }; - static ChatCommand serverIdleShutdownCommandTable[] = + static std::vector<ChatCommand> serverIdleShutdownCommandTable = { - { "cancel", rbac::RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN_CANCEL, true, &HandleServerShutDownCancelCommand, "", NULL }, - { "" , rbac::RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN, true, &HandleServerIdleShutDownCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "cancel", rbac::RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN_CANCEL, true, &HandleServerShutDownCancelCommand, "" }, + { "" , rbac::RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN, true, &HandleServerIdleShutDownCommand, "" }, }; - static ChatCommand serverRestartCommandTable[] = + static std::vector<ChatCommand> serverRestartCommandTable = { - { "cancel", rbac::RBAC_PERM_COMMAND_SERVER_RESTART_CANCEL, true, &HandleServerShutDownCancelCommand, "", NULL }, - { "" , rbac::RBAC_PERM_COMMAND_SERVER_RESTART, true, &HandleServerRestartCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "cancel", rbac::RBAC_PERM_COMMAND_SERVER_RESTART_CANCEL, true, &HandleServerShutDownCancelCommand, "" }, + { "" , rbac::RBAC_PERM_COMMAND_SERVER_RESTART, true, &HandleServerRestartCommand, "" }, }; - static ChatCommand serverShutdownCommandTable[] = + static std::vector<ChatCommand> serverShutdownCommandTable = { - { "cancel", rbac::RBAC_PERM_COMMAND_SERVER_SHUTDOWN_CANCEL, true, &HandleServerShutDownCancelCommand, "", NULL }, - { "" , rbac::RBAC_PERM_COMMAND_SERVER_SHUTDOWN, true, &HandleServerShutDownCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "cancel", rbac::RBAC_PERM_COMMAND_SERVER_SHUTDOWN_CANCEL, true, &HandleServerShutDownCancelCommand, "" }, + { "" , rbac::RBAC_PERM_COMMAND_SERVER_SHUTDOWN, true, &HandleServerShutDownCommand, "" }, }; - static ChatCommand serverSetCommandTable[] = + static std::vector<ChatCommand> serverSetCommandTable = { - { "difftime", rbac::RBAC_PERM_COMMAND_SERVER_SET_DIFFTIME, true, &HandleServerSetDiffTimeCommand, "", NULL }, - { "loglevel", rbac::RBAC_PERM_COMMAND_SERVER_SET_LOGLEVEL, true, &HandleServerSetLogLevelCommand, "", NULL }, - { "motd", rbac::RBAC_PERM_COMMAND_SERVER_SET_MOTD, true, &HandleServerSetMotdCommand, "", NULL }, - { "closed", rbac::RBAC_PERM_COMMAND_SERVER_SET_CLOSED, true, &HandleServerSetClosedCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "difftime", rbac::RBAC_PERM_COMMAND_SERVER_SET_DIFFTIME, true, &HandleServerSetDiffTimeCommand, "" }, + { "loglevel", rbac::RBAC_PERM_COMMAND_SERVER_SET_LOGLEVEL, true, &HandleServerSetLogLevelCommand, "" }, + { "motd", rbac::RBAC_PERM_COMMAND_SERVER_SET_MOTD, true, &HandleServerSetMotdCommand, "" }, + { "closed", rbac::RBAC_PERM_COMMAND_SERVER_SET_CLOSED, true, &HandleServerSetClosedCommand, "" }, }; - static ChatCommand serverCommandTable[] = + static std::vector<ChatCommand> serverCommandTable = { - { "corpses", rbac::RBAC_PERM_COMMAND_SERVER_CORPSES, true, &HandleServerCorpsesCommand, "", NULL }, - { "exit", rbac::RBAC_PERM_COMMAND_SERVER_EXIT, true, &HandleServerExitCommand, "", NULL }, + { "corpses", rbac::RBAC_PERM_COMMAND_SERVER_CORPSES, true, &HandleServerCorpsesCommand, "" }, + { "exit", rbac::RBAC_PERM_COMMAND_SERVER_EXIT, true, &HandleServerExitCommand, "" }, { "idlerestart", rbac::RBAC_PERM_COMMAND_SERVER_IDLERESTART, true, NULL, "", serverIdleRestartCommandTable }, { "idleshutdown", rbac::RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN, true, NULL, "", serverIdleShutdownCommandTable }, - { "info", rbac::RBAC_PERM_COMMAND_SERVER_INFO, true, &HandleServerInfoCommand, "", NULL }, - { "motd", rbac::RBAC_PERM_COMMAND_SERVER_MOTD, true, &HandleServerMotdCommand, "", NULL }, - { "plimit", rbac::RBAC_PERM_COMMAND_SERVER_PLIMIT, true, &HandleServerPLimitCommand, "", NULL }, + { "info", rbac::RBAC_PERM_COMMAND_SERVER_INFO, true, &HandleServerInfoCommand, "" }, + { "motd", rbac::RBAC_PERM_COMMAND_SERVER_MOTD, true, &HandleServerMotdCommand, "" }, + { "plimit", rbac::RBAC_PERM_COMMAND_SERVER_PLIMIT, true, &HandleServerPLimitCommand, "" }, { "restart", rbac::RBAC_PERM_COMMAND_SERVER_RESTART, true, NULL, "", serverRestartCommandTable }, { "shutdown", rbac::RBAC_PERM_COMMAND_SERVER_SHUTDOWN, true, NULL, "", serverShutdownCommandTable }, { "set", rbac::RBAC_PERM_COMMAND_SERVER_SET, true, NULL, "", serverSetCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "server", rbac::RBAC_PERM_COMMAND_SERVER, true, NULL, "", serverCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp index 8e82f9980d3..9ea516f0972 100644 --- a/src/server/scripts/Commands/cs_tele.cpp +++ b/src/server/scripts/Commands/cs_tele.cpp @@ -35,21 +35,19 @@ class tele_commandscript : public CommandScript public: tele_commandscript() : CommandScript("tele_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand teleCommandTable[] = + static std::vector<ChatCommand> teleCommandTable = { - { "add", rbac::RBAC_PERM_COMMAND_TELE_ADD, false, &HandleTeleAddCommand, "", NULL }, - { "del", rbac::RBAC_PERM_COMMAND_TELE_DEL, true, &HandleTeleDelCommand, "", NULL }, - { "name", rbac::RBAC_PERM_COMMAND_TELE_NAME, true, &HandleTeleNameCommand, "", NULL }, - { "group", rbac::RBAC_PERM_COMMAND_TELE_GROUP, false, &HandleTeleGroupCommand, "", NULL }, - { "", rbac::RBAC_PERM_COMMAND_TELE, false, &HandleTeleCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "add", rbac::RBAC_PERM_COMMAND_TELE_ADD, false, &HandleTeleAddCommand, "" }, + { "del", rbac::RBAC_PERM_COMMAND_TELE_DEL, true, &HandleTeleDelCommand, "" }, + { "name", rbac::RBAC_PERM_COMMAND_TELE_NAME, true, &HandleTeleNameCommand, "" }, + { "group", rbac::RBAC_PERM_COMMAND_TELE_GROUP, false, &HandleTeleGroupCommand, "" }, + { "", rbac::RBAC_PERM_COMMAND_TELE, false, &HandleTeleCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "tele", rbac::RBAC_PERM_COMMAND_TELE, false, NULL, "", teleCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_ticket.cpp b/src/server/scripts/Commands/cs_ticket.cpp index f7634381fc9..9b771f734be 100644 --- a/src/server/scripts/Commands/cs_ticket.cpp +++ b/src/server/scripts/Commands/cs_ticket.cpp @@ -36,38 +36,35 @@ class ticket_commandscript : public CommandScript public: ticket_commandscript() : CommandScript("ticket_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand ticketResponseCommandTable[] = + static std::vector<ChatCommand> ticketResponseCommandTable = { - { "append", rbac::RBAC_PERM_COMMAND_TICKET_RESPONSE_APPEND, true, &HandleGMTicketResponseAppendCommand, "", NULL }, - { "appendln", rbac::RBAC_PERM_COMMAND_TICKET_RESPONSE_APPENDLN, true, &HandleGMTicketResponseAppendLnCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "append", rbac::RBAC_PERM_COMMAND_TICKET_RESPONSE_APPEND, true, &HandleGMTicketResponseAppendCommand, "" }, + { "appendln", rbac::RBAC_PERM_COMMAND_TICKET_RESPONSE_APPENDLN, true, &HandleGMTicketResponseAppendLnCommand, "" }, }; - static ChatCommand ticketCommandTable[] = + static std::vector<ChatCommand> ticketCommandTable = { - { "assign", rbac::RBAC_PERM_COMMAND_TICKET_ASSIGN, true, &HandleGMTicketAssignToCommand, "", NULL }, - { "close", rbac::RBAC_PERM_COMMAND_TICKET_CLOSE, true, &HandleGMTicketCloseByIdCommand, "", NULL }, - { "closedlist", rbac::RBAC_PERM_COMMAND_TICKET_CLOSEDLIST, true, &HandleGMTicketListClosedCommand, "", NULL }, - { "comment", rbac::RBAC_PERM_COMMAND_TICKET_COMMENT, true, &HandleGMTicketCommentCommand, "", NULL }, - { "complete", rbac::RBAC_PERM_COMMAND_TICKET_COMPLETE, true, &HandleGMTicketCompleteCommand, "", NULL }, - { "delete", rbac::RBAC_PERM_COMMAND_TICKET_DELETE, true, &HandleGMTicketDeleteByIdCommand, "", NULL }, - { "escalate", rbac::RBAC_PERM_COMMAND_TICKET_ESCALATE, true, &HandleGMTicketEscalateCommand, "", NULL }, - { "escalatedlist", rbac::RBAC_PERM_COMMAND_TICKET_ESCALATEDLIST, true, &HandleGMTicketListEscalatedCommand, "", NULL }, - { "list", rbac::RBAC_PERM_COMMAND_TICKET_LIST, true, &HandleGMTicketListCommand, "", NULL }, - { "onlinelist", rbac::RBAC_PERM_COMMAND_TICKET_ONLINELIST, true, &HandleGMTicketListOnlineCommand, "", NULL }, - { "reset", rbac::RBAC_PERM_COMMAND_TICKET_RESET, true, &HandleGMTicketResetCommand, "", NULL }, + { "assign", rbac::RBAC_PERM_COMMAND_TICKET_ASSIGN, true, &HandleGMTicketAssignToCommand, "" }, + { "close", rbac::RBAC_PERM_COMMAND_TICKET_CLOSE, true, &HandleGMTicketCloseByIdCommand, "" }, + { "closedlist", rbac::RBAC_PERM_COMMAND_TICKET_CLOSEDLIST, true, &HandleGMTicketListClosedCommand, "" }, + { "comment", rbac::RBAC_PERM_COMMAND_TICKET_COMMENT, true, &HandleGMTicketCommentCommand, "" }, + { "complete", rbac::RBAC_PERM_COMMAND_TICKET_COMPLETE, true, &HandleGMTicketCompleteCommand, "" }, + { "delete", rbac::RBAC_PERM_COMMAND_TICKET_DELETE, true, &HandleGMTicketDeleteByIdCommand, "" }, + { "escalate", rbac::RBAC_PERM_COMMAND_TICKET_ESCALATE, true, &HandleGMTicketEscalateCommand, "" }, + { "escalatedlist", rbac::RBAC_PERM_COMMAND_TICKET_ESCALATEDLIST, true, &HandleGMTicketListEscalatedCommand, "" }, + { "list", rbac::RBAC_PERM_COMMAND_TICKET_LIST, true, &HandleGMTicketListCommand, "" }, + { "onlinelist", rbac::RBAC_PERM_COMMAND_TICKET_ONLINELIST, true, &HandleGMTicketListOnlineCommand, "" }, + { "reset", rbac::RBAC_PERM_COMMAND_TICKET_RESET, true, &HandleGMTicketResetCommand, "" }, { "response", rbac::RBAC_PERM_COMMAND_TICKET_RESPONSE, true, NULL, "", ticketResponseCommandTable }, - { "togglesystem", rbac::RBAC_PERM_COMMAND_TICKET_TOGGLESYSTEM, true, &HandleToggleGMTicketSystem, "", NULL }, - { "unassign", rbac::RBAC_PERM_COMMAND_TICKET_UNASSIGN, true, &HandleGMTicketUnAssignCommand, "", NULL }, - { "viewid", rbac::RBAC_PERM_COMMAND_TICKET_VIEWID, true, &HandleGMTicketGetByIdCommand, "", NULL }, - { "viewname", rbac::RBAC_PERM_COMMAND_TICKET_VIEWNAME, true, &HandleGMTicketGetByNameCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "togglesystem", rbac::RBAC_PERM_COMMAND_TICKET_TOGGLESYSTEM, true, &HandleToggleGMTicketSystem, "" }, + { "unassign", rbac::RBAC_PERM_COMMAND_TICKET_UNASSIGN, true, &HandleGMTicketUnAssignCommand, "" }, + { "viewid", rbac::RBAC_PERM_COMMAND_TICKET_VIEWID, true, &HandleGMTicketGetByIdCommand, "" }, + { "viewname", rbac::RBAC_PERM_COMMAND_TICKET_VIEWNAME, true, &HandleGMTicketGetByNameCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "ticket", rbac::RBAC_PERM_COMMAND_TICKET, false, NULL, "", ticketCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_titles.cpp b/src/server/scripts/Commands/cs_titles.cpp index 74a2f9f5aaf..bc6027ce3c3 100644 --- a/src/server/scripts/Commands/cs_titles.cpp +++ b/src/server/scripts/Commands/cs_titles.cpp @@ -33,25 +33,22 @@ class titles_commandscript : public CommandScript public: titles_commandscript() : CommandScript("titles_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand titlesSetCommandTable[] = + static std::vector<ChatCommand> titlesSetCommandTable = { - { "mask", rbac::RBAC_PERM_COMMAND_TITLES_SET_MASK, false, &HandleTitlesSetMaskCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "mask", rbac::RBAC_PERM_COMMAND_TITLES_SET_MASK, false, &HandleTitlesSetMaskCommand, "" }, }; - static ChatCommand titlesCommandTable[] = + static std::vector<ChatCommand> titlesCommandTable = { - { "add", rbac::RBAC_PERM_COMMAND_TITLES_ADD, false, &HandleTitlesAddCommand, "", NULL }, - { "current", rbac::RBAC_PERM_COMMAND_TITLES_CURRENT, false, &HandleTitlesCurrentCommand, "", NULL }, - { "remove", rbac::RBAC_PERM_COMMAND_TITLES_REMOVE, false, &HandleTitlesRemoveCommand, "", NULL }, + { "add", rbac::RBAC_PERM_COMMAND_TITLES_ADD, false, &HandleTitlesAddCommand, "" }, + { "current", rbac::RBAC_PERM_COMMAND_TITLES_CURRENT, false, &HandleTitlesCurrentCommand, "" }, + { "remove", rbac::RBAC_PERM_COMMAND_TITLES_REMOVE, false, &HandleTitlesRemoveCommand, "" }, { "set", rbac::RBAC_PERM_COMMAND_TITLES_SET, false, NULL, "", titlesSetCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "titles", rbac::RBAC_PERM_COMMAND_TITLES, false, NULL, "", titlesCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index 00b8bec51c8..b35e71dbd50 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -34,23 +34,21 @@ class wp_commandscript : public CommandScript public: wp_commandscript() : CommandScript("wp_commandscript") { } - ChatCommand* GetCommands() const override + std::vector<ChatCommand> GetCommands() const override { - static ChatCommand wpCommandTable[] = + static std::vector<ChatCommand> wpCommandTable = { - { "add", rbac::RBAC_PERM_COMMAND_WP_ADD, false, &HandleWpAddCommand, "", NULL }, - { "event", rbac::RBAC_PERM_COMMAND_WP_EVENT, false, &HandleWpEventCommand, "", NULL }, - { "load", rbac::RBAC_PERM_COMMAND_WP_LOAD, false, &HandleWpLoadCommand, "", NULL }, - { "modify", rbac::RBAC_PERM_COMMAND_WP_MODIFY, false, &HandleWpModifyCommand, "", NULL }, - { "unload", rbac::RBAC_PERM_COMMAND_WP_UNLOAD, false, &HandleWpUnLoadCommand, "", NULL }, - { "reload", rbac::RBAC_PERM_COMMAND_WP_RELOAD, false, &HandleWpReloadCommand, "", NULL }, - { "show", rbac::RBAC_PERM_COMMAND_WP_SHOW, false, &HandleWpShowCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "add", rbac::RBAC_PERM_COMMAND_WP_ADD, false, &HandleWpAddCommand, "" }, + { "event", rbac::RBAC_PERM_COMMAND_WP_EVENT, false, &HandleWpEventCommand, "" }, + { "load", rbac::RBAC_PERM_COMMAND_WP_LOAD, false, &HandleWpLoadCommand, "" }, + { "modify", rbac::RBAC_PERM_COMMAND_WP_MODIFY, false, &HandleWpModifyCommand, "" }, + { "unload", rbac::RBAC_PERM_COMMAND_WP_UNLOAD, false, &HandleWpUnLoadCommand, "" }, + { "reload", rbac::RBAC_PERM_COMMAND_WP_RELOAD, false, &HandleWpReloadCommand, "" }, + { "show", rbac::RBAC_PERM_COMMAND_WP_SHOW, false, &HandleWpShowCommand, "" }, }; - static ChatCommand commandTable[] = + static std::vector<ChatCommand> commandTable = { { "wp", rbac::RBAC_PERM_COMMAND_WP, false, NULL, "", wpCommandTable }, - { NULL, 0, false, NULL, "", NULL } }; return commandTable; } @@ -150,7 +148,7 @@ public: path_number = strtok((char*)args, " "); uint32 pathid = 0; - uint32 guidLow = 0; + ObjectGuid::LowType guidLow = 0; Creature* target = handler->getSelectedCreature(); // Did player provide a path_id? @@ -1037,7 +1035,7 @@ public: do { Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].GetUInt32(); Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HighGuid::Unit, VISUAL_WAYPOINT, guid)); if (!creature) { diff --git a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp index 64513fece8b..c1470d3bc47 100644 --- a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp +++ b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp @@ -203,10 +203,6 @@ public: void AggroAllPlayers(Creature* temp) { Map::PlayerList const &PlList = me->GetMap()->GetPlayers(); - - if (PlList.isEmpty()) - return; - for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i) { if (Player* player = i->GetSource()) diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp index 8965b64767a..0a287173ada 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp @@ -181,23 +181,21 @@ public: // temporary store for the best suitable beam reciever Unit* target = me; - if (Map* map = me->GetMap()) - { - Map::PlayerList const& players = map->GetPlayers(); + Map::PlayerList const& players = me->GetMap()->GetPlayers(); - // get the best suitable target - for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i) - { - Player* p = i->GetSource(); - if (p && p->IsAlive() // alive - && (!target || target->GetDistance2d(portal)>p->GetDistance2d(portal)) // closer than current best - && !p->HasAura(PlayerDebuff[j]) // not exhausted - && !p->HasAura(PlayerBuff[(j + 1) % 3]) // not on another beam - && !p->HasAura(PlayerBuff[(j + 2) % 3]) - && IsBetween(me, p, portal)) // on the beam - target = p; - } + // get the best suitable target + for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i) + { + Player* p = i->GetSource(); + if (p && p->IsAlive() // alive + && (!target || target->GetDistance2d(portal)>p->GetDistance2d(portal)) // closer than current best + && !p->HasAura(PlayerDebuff[j]) // not exhausted + && !p->HasAura(PlayerBuff[(j + 1) % 3]) // not on another beam + && !p->HasAura(PlayerBuff[(j + 2) % 3]) + && IsBetween(me, p, portal)) // on the beam + target = p; } + // buff the target if (target->GetTypeId() == TYPEID_PLAYER) target->AddAura(PlayerBuff[j], target); diff --git a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp index 87945ccf916..8aba0a15462 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/karazhan.cpp @@ -309,11 +309,7 @@ public: { if (WipeTimer <= diff) { - Map* map = me->GetMap(); - if (!map->IsDungeon()) - return; - - Map::PlayerList const &PlayerList = map->GetPlayers(); + Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers(); if (PlayerList.isEmpty()) return; @@ -518,8 +514,6 @@ public: uint32 NextStep(uint32 step) { - Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID); - Map* map = me->GetMap(); switch (step) { case 0: return 9999999; @@ -527,21 +521,21 @@ public: me->Yell(SAY_DIALOG_MEDIVH_1, LANG_UNIVERSAL); return 10000; case 2: - if (arca) + if (Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID)) arca->Yell(SAY_DIALOG_ARCANAGOS_2, LANG_UNIVERSAL); return 20000; case 3: me->Yell(SAY_DIALOG_MEDIVH_3, LANG_UNIVERSAL); return 10000; case 4: - if (arca) + if (Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID)) arca->Yell(SAY_DIALOG_ARCANAGOS_4, LANG_UNIVERSAL); return 20000; case 5: me->Yell(SAY_DIALOG_MEDIVH_5, LANG_UNIVERSAL); return 20000; case 6: - if (arca) + if (Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID)) arca->Yell(SAY_DIALOG_ARCANAGOS_6, LANG_UNIVERSAL); return 10000; case 7: @@ -555,15 +549,15 @@ public: me->TextEmote(EMOTE_DIALOG_MEDIVH_7); return 10000; case 10: - if (arca) + if (Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID)) DoCast(arca, SPELL_CONFLAGRATION_BLAST, false); return 1000; case 11: - if (arca) + if (Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID)) arca->Yell(SAY_DIALOG_ARCANAGOS_8, LANG_UNIVERSAL); return 5000; case 12: - if (arca) + if (Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID)) { arca->GetMotionMaster()->MovePoint(0, -11010.82f, -1761.18f, 156.47f); arca->setActive(true); @@ -575,27 +569,27 @@ public: me->Yell(SAY_DIALOG_MEDIVH_9, LANG_UNIVERSAL); return 10000; case 14: + { me->SetVisible(false); me->ClearInCombat(); - if (map->IsDungeon()) + InstanceMap::PlayerList const &PlayerList = me->GetMap()->GetPlayers(); + for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) { - InstanceMap::PlayerList const &PlayerList = map->GetPlayers(); - for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + if (i->GetSource()->IsAlive()) { - if (i->GetSource()->IsAlive()) - { - if (i->GetSource()->GetQuestStatus(9645) == QUEST_STATUS_INCOMPLETE) - i->GetSource()->CompleteQuest(9645); - } + if (i->GetSource()->GetQuestStatus(9645) == QUEST_STATUS_INCOMPLETE) + i->GetSource()->CompleteQuest(9645); } } return 50000; + } case 15: - if (arca) + if (Creature* arca = ObjectAccessor::GetCreature(*me, ArcanagosGUID)) arca->DealDamage(arca, arca->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); return 5000; - default : return 9999999; + default: + return 9999999; } } diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp index 9b303fce89d..9c904dcada9 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/magisters_terrace.cpp @@ -145,39 +145,13 @@ public: m_uiTransformTimer = MINUTE*IN_MILLISECONDS; } - // some targeting issues with the spell, so use this workaround as temporary solution - void DoWorkaroundForQuestCredit() - { - Map* map = me->GetMap(); - - if (!map || map->IsHeroic()) - return; - - Map::PlayerList const &lList = map->GetPlayers(); - - if (lList.isEmpty()) - return; - - SpellInfo const* spell = sSpellMgr->GetSpellInfo(SPELL_ORB_KILL_CREDIT); - - for (Map::PlayerList::const_iterator i = lList.begin(); i != lList.end(); ++i) - { - if (Player* player = i->GetSource()) - { - if (spell && spell->Effects[0].MiscValue) - player->KilledMonsterCredit(spell->Effects[0].MiscValue); - } - } - } - void UpdateAI(uint32 uiDiff) override { if (m_uiTransformTimer) { if (m_uiTransformTimer <= uiDiff) { - DoCast(me, SPELL_ORB_KILL_CREDIT, false); - DoWorkaroundForQuestCredit(); + DoCast(me, SPELL_ORB_KILL_CREDIT, true); // Transform and update entry, now ready for quest/read gossip DoCast(me, SPELL_TRANSFORM_TO_KAEL, false); diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp index 9747d31952b..f2d7f23bdc7 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp @@ -93,11 +93,6 @@ class npc_unworthy_initiate : public CreatureScript public: npc_unworthy_initiate() : CreatureScript("npc_unworthy_initiate") { } - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_unworthy_initiateAI(creature); - } - struct npc_unworthy_initiateAI : public ScriptedAI { npc_unworthy_initiateAI(Creature* creature) : ScriptedAI(creature) @@ -156,7 +151,7 @@ public: me->CastSpell(me, SPELL_DK_INITIATE_VISUAL, true); if (Player* starter = ObjectAccessor::GetPlayer(*me, playerGUID)) - sCreatureTextMgr->SendChat(me, SAY_EVENT_ATTACK, NULL, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, starter); + Talk(SAY_EVENT_ATTACK, starter); phase = PHASE_TO_ATTACK; } @@ -286,6 +281,11 @@ public: } } }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_unworthy_initiateAI(creature); + } }; class npc_unworthy_initiate_anchor : public CreatureScript @@ -457,6 +457,7 @@ enum Spells_DKI //SPELL_DUEL_TRIGGERED = 52990, SPELL_DUEL_VICTORY = 52994, SPELL_DUEL_FLAG = 52991, + SPELL_GROVEL = 7267, }; enum Says_VBM @@ -494,8 +495,6 @@ public: creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_15); - sCreatureTextMgr->SendChat(creature, SAY_DUEL, NULL, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_OTHER, false, player); - player->CastSpell(creature, SPELL_DUEL, false); player->CastSpell(player, SPELL_DUEL_FLAG, true); } @@ -518,11 +517,6 @@ public: return true; } - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_death_knight_initiateAI(creature); - } - struct npc_death_knight_initiateAI : public CombatAI { npc_death_knight_initiateAI(Creature* creature) : CombatAI(creature) @@ -557,6 +551,7 @@ public: if (!m_bIsDuelInProgress && pSpell->Id == SPELL_DUEL) { m_uiDuelerGUID = pCaster->GetGUID(); + Talk(SAY_DUEL, pCaster); m_bIsDuelInProgress = true; } } @@ -577,7 +572,7 @@ public: pDoneBy->AttackStop(); me->CastSpell(pDoneBy, SPELL_DUEL_VICTORY, true); lose = true; - me->CastSpell(me, 7267, true); + me->CastSpell(me, SPELL_GROVEL, true); me->RestoreFaction(); } } @@ -607,13 +602,13 @@ public: { if (lose) { - if (!me->HasAura(7267)) + if (!me->HasAura(SPELL_GROVEL)) EnterEvadeMode(); return; } else if (me->GetVictim() && me->EnsureVictim()->GetTypeId() == TYPEID_PLAYER && me->EnsureVictim()->HealthBelowPct(10)) { - me->EnsureVictim()->CastSpell(me->GetVictim(), 7267, true); // beg + me->EnsureVictim()->CastSpell(me->GetVictim(), SPELL_GROVEL, true); // beg me->EnsureVictim()->RemoveGameObject(SPELL_DUEL_FLAG, true); EnterEvadeMode(); return; @@ -626,6 +621,10 @@ public: } }; + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_death_knight_initiateAI(creature); + } }; /*###### diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp index 3df07562d50..2714d65774f 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp @@ -1293,8 +1293,8 @@ public: //if (GameObject* go = me->GetMap()->GetGameObject(uiDawnofLightGUID)) // Turn off dawn of light // go->SetPhaseMask(0, true); { - Map* map = me->GetMap(); // search players with in 50 yards for quest credit - Map::PlayerList const &PlayerList = map->GetPlayers(); + // search players with in 50 yards for quest credit + Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers(); if (!PlayerList.isEmpty()) { for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp index 14be8c51bc2..a78ad740c97 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp @@ -538,11 +538,7 @@ public: Player* SelectRandomPlayer(float range = 0.0f, bool checkLoS = true) { - Map* map = me->GetMap(); - if (!map->IsDungeon()) - return NULL; - - Map::PlayerList const &PlayerList = map->GetPlayers(); + Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers(); if (PlayerList.isEmpty()) return NULL; diff --git a/src/server/scripts/EasternKingdoms/Stratholme/boss_baron_rivendare.cpp b/src/server/scripts/EasternKingdoms/Stratholme/boss_baron_rivendare.cpp index 8d7d43048b4..f6f6dab866d 100644 --- a/src/server/scripts/EasternKingdoms/Stratholme/boss_baron_rivendare.cpp +++ b/src/server/scripts/EasternKingdoms/Stratholme/boss_baron_rivendare.cpp @@ -106,7 +106,8 @@ public: void AttackStart(Unit* who) override { //can't use entercombat(), boss' dmg aura sets near players in combat, before entering the room's door - instance->SetData(TYPE_BARON, IN_PROGRESS); + if (instance->GetData(TYPE_BARON) == NOT_STARTED) + instance->SetData(TYPE_BARON, IN_PROGRESS); ScriptedAI::AttackStart(who); } diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index ae327dbb874..c8964b2ff31 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -551,13 +551,9 @@ public: bool OnGossipHello(Player* player, GameObject* go) override { - Map* map = go->GetMap(); - if (!map->IsDungeon()) - return true; - #if MAX_PLAYERS_IN_SPECTRAL_REALM > 0 uint8 SpectralPlayers = 0; - Map::PlayerList const &PlayerList = map->GetPlayers(); + Map::PlayerList const &PlayerList = go->GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) { if (i->GetSource() && i->GetSource()->GetPositionZ() < DEMON_REALM_Z + 5) @@ -569,6 +565,8 @@ public: player->GetSession()->SendNotification(GO_FAILED); return true; } +#else + (void)go; #endif player->CastSpell(player, SPELL_TELEPORT_SPECTRAL, true); @@ -688,12 +686,8 @@ public: void TeleportAllPlayersBack() { - Map* map = me->GetMap(); - if (!map->IsDungeon()) - return; - - Map::PlayerList const &playerList = map->GetPlayers(); - Position homePos = me->GetHomePosition(); + Map::PlayerList const &playerList = me->GetMap()->GetPlayers(); + Position const& homePos = me->GetHomePosition(); for (Map::PlayerList::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr) { Player* player = itr->GetSource(); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp index 780cf6646a3..33b8516657a 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp @@ -433,15 +433,11 @@ public: } //kill credit Creature for quest - Map* map = me->GetMap(); - Map::PlayerList const& players = map->GetPlayers(); - if (!players.isEmpty() && map->IsDungeon()) + Map::PlayerList const& players = me->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) { - for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) - { - if (Player* player = itr->GetSource()) - player->KilledMonsterCredit(20156); - } + if (Player* player = itr->GetSource()) + player->KilledMonsterCredit(20156); } //alot will happen here, thrall and taretha talk, erozion appear at spot to explain diff --git a/src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp b/src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp index d8966ec76c1..b57d1b78de0 100644 --- a/src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp +++ b/src/server/scripts/Kalimdor/RazorfenKraul/instance_razorfen_kraul.cpp @@ -54,14 +54,10 @@ public: Player* GetPlayerInMap() { Map::PlayerList const& players = instance->GetPlayers(); - - if (!players.isEmpty()) + for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) { - for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) - { - if (Player* player = itr->GetSource()) - return player; - } + if (Player* player = itr->GetSource()) + return player; } TC_LOG_DEBUG("scripts", "Instance Razorfen Kraul: GetPlayerInMap, but PlayerList is empty!"); return NULL; diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp index 463d1ee7e0b..8ccc5f0b4ce 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp @@ -143,8 +143,6 @@ class boss_ossirian : public CreatureScript Talk(SAY_AGGRO); Map* map = me->GetMap(); - if (!map->IsDungeon()) - return; WorldPacket data(SMSG_WEATHER, (4+4+4)); data << uint32(WEATHER_STATE_HEAVY_SANDSTORM) << float(1) << uint8(0); @@ -153,7 +151,7 @@ class boss_ossirian : public CreatureScript for (uint8 i = 0; i < NUM_TORNADOS; ++i) { Position Point = me->GetRandomPoint(RoomCenter, RoomRadius); - if (Creature* Tornado = me->GetMap()->SummonCreature(NPC_SAND_VORTEX, Point)) + if (Creature* Tornado = map->SummonCreature(NPC_SAND_VORTEX, Point)) Tornado->CastSpell(Tornado, SPELL_SAND_STORM, true); } diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp index f967bd6a217..8e84f1b4265 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp @@ -586,21 +586,10 @@ public: //WisperTimer if (WisperTimer <= diff) { - Map* map = me->GetMap(); - if (!map->IsDungeon()) - return; - //Play random sound to the zone - Map::PlayerList const &PlayerList = map->GetPlayers(); - - if (!PlayerList.isEmpty()) - { - for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr) - { - if (Player* pPlr = itr->GetSource()) - pPlr->PlayDirectSound(RANDOM_SOUND_WHISPER, pPlr); - } - } + Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr) + me->PlayDirectSound(RANDOM_SOUND_WHISPER, itr->GetSource()); //One random wisper every 90 - 300 seconds WisperTimer = urand(90000, 300000); diff --git a/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp b/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp index c4ab8f76487..0ae870b27ee 100644 --- a/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp +++ b/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp @@ -808,7 +808,7 @@ public: private: int8 _phase; uint32 _moveTimer; - uint32 _eventStarterGuidLow; + ObjectGuid::LowType _eventStarterGuidLow; GuidList _explosivesGuids; EventMap _events; }; diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp index cfed13a8f38..d8ebfbbd743 100644 --- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_herald_volazj.cpp @@ -230,11 +230,7 @@ public: // Roll Insanity uint32 spell = GetSpellForPhaseMask(phase); uint32 spell2 = GetSpellForPhaseMask(nextPhase); - Map* map = me->GetMap(); - if (!map) - return; - - Map::PlayerList const &PlayerList = map->GetPlayers(); + Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers(); if (!PlayerList.isEmpty()) { for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp index 7cb2c0e5178..5890b9cbec7 100644 --- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/boss_jedoga_shadowseeker.cpp @@ -185,7 +185,7 @@ public: who->RemoveAurasByType(SPELL_AURA_MOD_STEALTH); AttackStart(who); } - else if (me->GetMap()->IsDungeon()) + else { who->SetInCombatWith(me); me->AddThreat(who, 0.0f); diff --git a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp index b4627d7f941..eac84d1f6c9 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/obsidian_sanctum.cpp @@ -652,23 +652,19 @@ class npc_acolyte_of_shadron : public CreatureScript if (ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SHADRON))) instance->SetBossState(DATA_PORTAL_OPEN, NOT_STARTED); - Map* map = me->GetMap(); - if (map->IsDungeon()) - { - Map::PlayerList const& PlayerList = map->GetPlayers(); + Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers(); - if (PlayerList.isEmpty()) - return; + if (PlayerList.isEmpty()) + return; - for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + { + if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_SHIFT) && !i->GetSource()->GetVictim()) { - if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_SHIFT) && !i->GetSource()->GetVictim()) - { - i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_SHIFT_REMOVAL_ALL, true); - i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_RESIDUE, true); - i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT); - i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT_ENTER); - } + i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_SHIFT_REMOVAL_ALL, true); + i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_RESIDUE, true); + i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT); + i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT_ENTER); } } @@ -740,26 +736,22 @@ class npc_acolyte_of_vesperon : public CreatureScript vesperon->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP); } - Map* map = me->GetMap(); - if (map->IsDungeon()) - { - Map::PlayerList const &PlayerList = map->GetPlayers(); + Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers(); - if (PlayerList.isEmpty()) - return; + if (PlayerList.isEmpty()) + return; - for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + { + if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_SHIFT) && !i->GetSource()->GetVictim()) { - if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_SHIFT) && !i->GetSource()->GetVictim()) - { - i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_SHIFT_REMOVAL_ALL, true); - i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_RESIDUE, true); - i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT); - i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT_ENTER); - } - if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_TORMENT_VESP) && !i->GetSource()->GetVictim()) - i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP); + i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_SHIFT_REMOVAL_ALL, true); + i->GetSource()->CastSpell(i->GetSource(), SPELL_TWILIGHT_RESIDUE, true); + i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT); + i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_SHIFT_ENTER); } + if (i->GetSource()->IsAlive() && i->GetSource()->HasAura(SPELL_TWILIGHT_TORMENT_VESP) && !i->GetSource()->GetVictim()) + i->GetSource()->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP); } instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_TWILIGHT_TORMENT_VESP_ACO); diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp index c375e5c1b95..512016c6eeb 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp @@ -254,7 +254,7 @@ public: if (uiChargeTimer <= uiDiff) { Map::PlayerList const& players = me->GetMap()->GetPlayers(); - if (me->GetMap()->IsDungeon() && !players.isEmpty()) + if (!players.isEmpty()) { for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) { @@ -281,7 +281,7 @@ public: if (Unit* pPassenger = pVehicle->GetPassenger(SEAT_ID_0)) { Map::PlayerList const& players = me->GetMap()->GetPlayers(); - if (me->GetMap()->IsDungeon() && !players.isEmpty()) + if (!players.isEmpty()) { for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) { @@ -400,7 +400,7 @@ public: if (uiInterceptTimer <= uiDiff) { Map::PlayerList const& players = me->GetMap()->GetPlayers(); - if (me->GetMap()->IsDungeon() && !players.isEmpty()) + if (!players.isEmpty()) { for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) { @@ -867,7 +867,7 @@ public: else { Map::PlayerList const& players = me->GetMap()->GetPlayers(); - if (me->GetMap()->IsDungeon() && !players.isEmpty()) + if (!players.isEmpty()) { for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) { diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp index efc24b94cdb..a7ac5d1227e 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp @@ -203,7 +203,7 @@ class boss_blood_queen_lana_thel : public CreatureScript { instance->SetData(DATA_BLOOD_QUICKENING_STATE, DONE); if (Player* player = killer->ToPlayer()) - player->RewardPlayerAndGroupAtEvent(NPC_INFILTRATOR_MINCHAR_BQ, player); + player->RewardPlayerAndGroupAtEvent(Is25ManRaid() ? NPC_INFILTRATOR_MINCHAR_BQ_25 : NPC_INFILTRATOR_MINCHAR_BQ, player); if (Creature* minchar = me->FindNearestCreature(NPC_INFILTRATOR_MINCHAR_BQ, 200.0f)) { minchar->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp index db0fcee22fa..e3e89d865ff 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp @@ -470,21 +470,11 @@ class spell_festergut_blighted_spores : public SpellScriptLoader if (target->HasAura(SPELL_ORANGE_BLIGHT_RESIDUE)) return; - if (target->GetMap() && !target->GetMap()->Is25ManRaid()) - { - if (target->GetQuestStatus(QUEST_RESIDUE_RENDEZVOUS_10) != QUEST_STATUS_INCOMPLETE) - return; - - target->CastSpell(target, SPELL_ORANGE_BLIGHT_RESIDUE, TRIGGERED_FULL_MASK); - } - - if (target->GetMap() && target->GetMap()->Is25ManRaid()) - { - if (target->GetQuestStatus(QUEST_RESIDUE_RENDEZVOUS_25) != QUEST_STATUS_INCOMPLETE) - return; + uint32 questId = target->GetMap()->Is25ManRaid() ? QUEST_RESIDUE_RENDEZVOUS_25 : QUEST_RESIDUE_RENDEZVOUS_10; + if (target->GetQuestStatus(questId) != QUEST_STATUS_INCOMPLETE) + return; - target->CastSpell(target, SPELL_ORANGE_BLIGHT_RESIDUE, TRIGGERED_FULL_MASK); - } + target->CastSpell(target, SPELL_ORANGE_BLIGHT_RESIDUE, TRIGGERED_FULL_MASK); } void Register() override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp index c1d930cb62c..1a2ebd179fe 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp @@ -892,21 +892,11 @@ class spell_rotface_slime_spray : public SpellScriptLoader if (target->HasAura(SPELL_GREEN_BLIGHT_RESIDUE)) return; - if (target->GetMap() && !target->GetMap()->Is25ManRaid()) - { - if (target->GetQuestStatus(QUEST_RESIDUE_RENDEZVOUS_10) != QUEST_STATUS_INCOMPLETE) - return; - - target->CastSpell(target, SPELL_GREEN_BLIGHT_RESIDUE, TRIGGERED_FULL_MASK); - } - - if (target->GetMap() && target->GetMap()->Is25ManRaid()) - { - if (target->GetQuestStatus(QUEST_RESIDUE_RENDEZVOUS_25) != QUEST_STATUS_INCOMPLETE) - return; + uint32 questId = target->GetMap()->Is25ManRaid() ? QUEST_RESIDUE_RENDEZVOUS_25 : QUEST_RESIDUE_RENDEZVOUS_10; + if (target->GetQuestStatus(questId) != QUEST_STATUS_INCOMPLETE) + return; - target->CastSpell(target, SPELL_GREEN_BLIGHT_RESIDUE, TRIGGERED_FULL_MASK); - } + target->CastSpell(target, SPELL_GREEN_BLIGHT_RESIDUE, TRIGGERED_FULL_MASK); } void Register() override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp index f0835135890..f9d5a310526 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp @@ -1336,7 +1336,7 @@ class spell_dreamwalker_summon_dream_portal : public SpellScriptLoader if (!GetHitUnit()) return; - uint32 spellId = RAND<uint32>(71301, 72220, 72223, 72225); + uint32 spellId = RAND(71301, 72220, 72223, 72225); GetHitUnit()->CastSpell(GetHitUnit(), spellId, true); } @@ -1367,7 +1367,7 @@ class spell_dreamwalker_summon_nightmare_portal : public SpellScriptLoader if (!GetHitUnit()) return; - uint32 spellId = RAND<uint32>(71977, 72481, 72482, 72483); + uint32 spellId = RAND(71977, 72481, 72482, 72483); GetHitUnit()->CastSpell(GetHitUnit(), spellId, true); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h index 091190b6b4e..e739f5a5036 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.h @@ -155,6 +155,7 @@ enum CreaturesIds NPC_ALCHEMIST_ADRIANNA = 38501, NPC_ALRIN_THE_AGILE = 38551, NPC_INFILTRATOR_MINCHAR_BQ = 38558, + NPC_INFILTRATOR_MINCHAR_BQ_25 = 39123, NPC_MINCHAR_BEAM_STALKER = 38557, NPC_VALITHRIA_DREAMWALKER_QUEST = 38589, diff --git a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp index dd67f2b1ac0..3778d8d25a0 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp @@ -317,37 +317,30 @@ class boss_gothik : public CreatureScript bool CheckGroupSplitted() { - Map* map = me->GetMap(); - if (map && map->IsDungeon()) + bool checklife = false; + bool checkdead = false; + Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) { - Map::PlayerList const &PlayerList = map->GetPlayers(); - if (!PlayerList.isEmpty()) + if (i->GetSource() && i->GetSource()->IsAlive() && + i->GetSource()->GetPositionX() <= POS_X_NORTH && + i->GetSource()->GetPositionX() >= POS_X_SOUTH && + i->GetSource()->GetPositionY() <= POS_Y_GATE && + i->GetSource()->GetPositionY() >= POS_Y_EAST) { - bool checklife = false; - bool checkdead = false; - for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - { - if (i->GetSource() && i->GetSource()->IsAlive() && - i->GetSource()->GetPositionX() <= POS_X_NORTH && - i->GetSource()->GetPositionX() >= POS_X_SOUTH && - i->GetSource()->GetPositionY() <= POS_Y_GATE && - i->GetSource()->GetPositionY() >= POS_Y_EAST) - { - checklife = true; - } - else if (i->GetSource() && i->GetSource()->IsAlive() && - i->GetSource()->GetPositionX() <= POS_X_NORTH && - i->GetSource()->GetPositionX() >= POS_X_SOUTH && - i->GetSource()->GetPositionY() >= POS_Y_GATE && - i->GetSource()->GetPositionY() <= POS_Y_WEST) - { - checkdead = true; - } - - if (checklife && checkdead) - return true; - } + checklife = true; } + else if (i->GetSource() && i->GetSource()->IsAlive() && + i->GetSource()->GetPositionX() <= POS_X_NORTH && + i->GetSource()->GetPositionX() >= POS_X_SOUTH && + i->GetSource()->GetPositionY() >= POS_Y_GATE && + i->GetSource()->GetPositionY() <= POS_Y_WEST) + { + checkdead = true; + } + + if (checklife && checkdead) + return true; } return false; @@ -555,20 +548,13 @@ class npc_gothik_minion : public CreatureScript if (!_EnterEvadeMode()) return; - Map* map = me->GetMap(); - if (map->IsDungeon()) + Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) { - Map::PlayerList const &PlayerList = map->GetPlayers(); - if (!PlayerList.isEmpty()) + if (i->GetSource() && i->GetSource()->IsAlive() && isOnSameSide(i->GetSource())) { - for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - { - if (i->GetSource() && i->GetSource()->IsAlive() && isOnSameSide(i->GetSource())) - { - AttackStart(i->GetSource()); - return; - } - } + AttackStart(i->GetSource()); + return; } } diff --git a/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp b/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp index 3d7c128c8dd..5248c48029c 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp @@ -21,36 +21,42 @@ #include "naxxramas.h" #include "Player.h" -enum Heigan +enum Spells { - SPELL_DECREPIT_FEVER = 29998, // 25-man: 55011 - SPELL_SPELL_DISRUPTION = 29310, - SPELL_PLAGUE_CLOUD = 29350, - - SAY_AGGRO = 0, - SAY_SLAY = 1, - SAY_TAUNT = 2, - SAY_DEATH = 3 + SPELL_DECREPIT_FEVER = 29998, // 25-man: 55011 + SPELL_SPELL_DISRUPTION = 29310, + SPELL_PLAGUE_CLOUD = 29350, + SPELL_TELEPORT_SELF = 30211, +}; + +enum Yells +{ + SAY_AGGRO = 0, + SAY_SLAY = 1, + SAY_TAUNT = 2, + SAY_DEATH = 3, + + EMOTE_DANCE = 4, + EMOTE_DANCE_END = 5, }; enum Events { - EVENT_NONE, - EVENT_DISRUPT, + EVENT_DISRUPT = 1, EVENT_FEVER, EVENT_ERUPT, - EVENT_PHASE, + EVENT_DANCE, + EVENT_DANCE_END }; enum Phases { PHASE_FIGHT = 1, - PHASE_DANCE, + PHASE_DANCE }; enum Misc { - ACTION_SAFETY_DANCE_FAIL = 1, DATA_SAFETY_DANCE = 19962139 }; @@ -66,39 +72,25 @@ public: struct boss_heiganAI : public BossAI { - boss_heiganAI(Creature* creature) : BossAI(creature, BOSS_HEIGAN) + boss_heiganAI(Creature* creature) : BossAI(creature, BOSS_HEIGAN), eruptSection(0), eruptDirection(false), safetyDance(false) { } + + void Reset() override { - eruptSection = 0; - eruptDirection = false; - safetyDance = false; - phase = PHASE_FIGHT; + me->SetReactState(REACT_AGGRESSIVE); + _Reset(); } - uint32 eruptSection; - bool eruptDirection; - bool safetyDance; - Phases phase; - void KilledUnit(Unit* who) override { - if (!(rand32() % 5)) - Talk(SAY_SLAY); + Talk(SAY_SLAY); + if (who->GetTypeId() == TYPEID_PLAYER) safetyDance = false; } - void SetData(uint32 id, uint32 data) override - { - if (id == DATA_SAFETY_DANCE) - safetyDance = data ? true : false; - } - uint32 GetData(uint32 type) const override { - if (type == DATA_SAFETY_DANCE) - return safetyDance ? 1 : 0; - - return 0; + return (type == DATA_SAFETY_DANCE && safetyDance) ? 1u : 0u; } void JustDied(Unit* /*killer*/) override @@ -111,35 +103,14 @@ public: { _EnterCombat(); Talk(SAY_AGGRO); - EnterPhase(PHASE_FIGHT); - safetyDance = true; - } - - void EnterPhase(Phases newPhase) - { - phase = newPhase; - events.Reset(); + eruptSection = 3; - if (phase == PHASE_FIGHT) - { - events.ScheduleEvent(EVENT_DISRUPT, urand(10000, 25000)); - events.ScheduleEvent(EVENT_FEVER, urand(15000, 20000)); - events.ScheduleEvent(EVENT_PHASE, 90000); - events.ScheduleEvent(EVENT_ERUPT, 15000); - me->GetMotionMaster()->MoveChase(me->GetVictim()); - } - else - { - float x, y, z, o; - me->GetHomePosition(x, y, z, o); - me->NearTeleportTo(x, y, z, o - (float(M_PI) / 2)); - me->GetMotionMaster()->Clear(); - me->GetMotionMaster()->MoveIdle(); - me->SetTarget(ObjectGuid::Empty); - DoCastAOE(SPELL_PLAGUE_CLOUD); - events.ScheduleEvent(EVENT_PHASE, 45000); - events.ScheduleEvent(EVENT_ERUPT, 8000); - } + events.ScheduleEvent(EVENT_DISRUPT, urand(15 * IN_MILLISECONDS, 20 * IN_MILLISECONDS), 0, PHASE_FIGHT); + events.ScheduleEvent(EVENT_FEVER, urand(10 * IN_MILLISECONDS, 20 * IN_MILLISECONDS), 0, PHASE_FIGHT); + events.ScheduleEvent(EVENT_DANCE, 90 * IN_MILLISECONDS, 0, PHASE_FIGHT); + events.ScheduleEvent(EVENT_ERUPT, 15 * IN_MILLISECONDS, 0, PHASE_FIGHT); + + safetyDance = true; } void UpdateAI(uint32 diff) override @@ -155,15 +126,36 @@ public: { case EVENT_DISRUPT: DoCastAOE(SPELL_SPELL_DISRUPTION); - events.ScheduleEvent(EVENT_DISRUPT, urand(5000, 10000)); + events.ScheduleEvent(EVENT_DISRUPT, 11 * IN_MILLISECONDS); break; case EVENT_FEVER: DoCastAOE(SPELL_DECREPIT_FEVER); - events.ScheduleEvent(EVENT_FEVER, urand(20000, 25000)); + events.ScheduleEvent(EVENT_FEVER, urand(20 * IN_MILLISECONDS, 25 * IN_MILLISECONDS)); + break; + case EVENT_DANCE: + events.SetPhase(PHASE_DANCE); + Talk(SAY_TAUNT); + Talk(EMOTE_DANCE); + eruptSection = 3; + me->SetReactState(REACT_PASSIVE); + me->AttackStop(); + me->StopMoving(); + DoCast(SPELL_TELEPORT_SELF); + DoCastAOE(SPELL_PLAGUE_CLOUD); + events.ScheduleEvent(EVENT_DANCE_END, 45 * IN_MILLISECONDS, 0, PHASE_DANCE); + events.ScheduleEvent(EVENT_ERUPT, 10 * IN_MILLISECONDS); break; - case EVENT_PHASE: - /// @todo Add missing texts for both phase switches - EnterPhase(phase == PHASE_FIGHT ? PHASE_DANCE : PHASE_FIGHT); + case EVENT_DANCE_END: + events.SetPhase(PHASE_FIGHT); + Talk(EMOTE_DANCE_END); + eruptSection = 3; + events.ScheduleEvent(EVENT_DISRUPT, urand(10, 25) * IN_MILLISECONDS, 0, PHASE_FIGHT); + events.ScheduleEvent(EVENT_FEVER, urand(15, 20) * IN_MILLISECONDS, 0, PHASE_FIGHT); + events.ScheduleEvent(EVENT_DANCE, 90 * IN_MILLISECONDS, 0, PHASE_FIGHT); + events.ScheduleEvent(EVENT_ERUPT, 15 * IN_MILLISECONDS, 0, PHASE_FIGHT); + me->CastStop(); + me->SetReactState(REACT_AGGRESSIVE); + DoZoneInCombat(); break; case EVENT_ERUPT: instance->SetData(DATA_HEIGAN_ERUPT, eruptSection); @@ -176,13 +168,22 @@ public: eruptDirection ? ++eruptSection : --eruptSection; - events.ScheduleEvent(EVENT_ERUPT, phase == PHASE_FIGHT ? 10000 : 3000); + if (events.IsInPhase(PHASE_DANCE)) + events.ScheduleEvent(EVENT_ERUPT, 3 * IN_MILLISECONDS, 0, PHASE_DANCE); + else + events.ScheduleEvent(EVENT_ERUPT, 10 * IN_MILLISECONDS, 0, PHASE_FIGHT); break; } } DoMeleeAttackIfReady(); } + + private: + uint32 eruptSection; + bool eruptDirection; + + bool safetyDance; // is achievement still possible? (= no player deaths yet) }; }; @@ -205,7 +206,7 @@ class spell_heigan_eruption : public SpellScriptLoader if (GetHitDamage() >= int32(GetHitPlayer()->GetHealth())) if (InstanceScript* instance = caster->GetInstanceScript()) if (Creature* Heigan = ObjectAccessor::GetCreature(*caster, instance->GetGuidData(DATA_HEIGAN))) - Heigan->AI()->SetData(DATA_SAFETY_DANCE, 0); + Heigan->AI()->KilledUnit(GetHitPlayer()); } void Register() override @@ -223,9 +224,7 @@ class spell_heigan_eruption : public SpellScriptLoader class achievement_safety_dance : public AchievementCriteriaScript { public: - achievement_safety_dance() : AchievementCriteriaScript("achievement_safety_dance") - { - } + achievement_safety_dance() : AchievementCriteriaScript("achievement_safety_dance") { } bool OnCheck(Player* /*player*/, Unit* target) override { diff --git a/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp b/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp index 33fb43b6bbc..494c173f5fc 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_loatheb.cpp @@ -27,7 +27,10 @@ enum Spells SPELL_WARN_NECROTIC_AURA = 59481, SPELL_SUMMON_SPORE = 29234, SPELL_DEATHBLOOM = 29865, - SPELL_INEVITABLE_DOOM = 29204 + SPELL_INEVITABLE_DOOM = 29204, + SPELL_FUNGAL_CREEP = 29232, + + SPELL_DEATHBLOOM_FINAL_DAMAGE = 55594, }; enum Texts @@ -72,29 +75,35 @@ class boss_loatheb : public CreatureScript void Reset() override { _Reset(); + instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_FUNGAL_CREEP); Initialize(); } void EnterCombat(Unit* /*who*/) override { _EnterCombat(); - events.ScheduleEvent(EVENT_NECROTIC_AURA, 17000); - events.ScheduleEvent(EVENT_DEATHBLOOM, 5000); - events.ScheduleEvent(EVENT_SPORE, IsHeroic() ? 18000 : 36000); - events.ScheduleEvent(EVENT_INEVITABLE_DOOM, 120000); + events.ScheduleEvent(EVENT_NECROTIC_AURA, 17 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_DEATHBLOOM, 5 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_SPORE, RAID_MODE(36,18) * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_INEVITABLE_DOOM, 2 * MINUTE * IN_MILLISECONDS); } - void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) override + void SummonedCreatureDies(Creature* summon, Unit* /*killer*/) override { _sporeLoserData = false; + summon->CastSpell(summon,SPELL_FUNGAL_CREEP,true); } - uint32 GetData(uint32 id) const override + void SummonedCreatureDespawn(Creature* summon) override { - if (id != DATA_ACHIEVEMENT_SPORE_LOSER) - return 0; + summons.Despawn(summon); + if (summon->IsAlive()) + summon->CastSpell(summon,SPELL_FUNGAL_CREEP,true); + } - return uint32(_sporeLoserData); + uint32 GetData(uint32 id) const override + { + return (_sporeLoserData && id == DATA_ACHIEVEMENT_SPORE_LOSER) ? 1u : 0u; } void UpdateAI(uint32 diff) override @@ -111,21 +120,29 @@ class boss_loatheb : public CreatureScript case EVENT_NECROTIC_AURA: DoCastAOE(SPELL_NECROTIC_AURA); DoCast(me, SPELL_WARN_NECROTIC_AURA); - events.ScheduleEvent(EVENT_NECROTIC_AURA, 20000); - events.ScheduleEvent(EVENT_NECROTIC_AURA_FADING, 14000); + events.ScheduleEvent(EVENT_NECROTIC_AURA, 20 * IN_MILLISECONDS); + events.ScheduleEvent(EVENT_NECROTIC_AURA_FADING, 14 * IN_MILLISECONDS); break; case EVENT_DEATHBLOOM: DoCastAOE(SPELL_DEATHBLOOM); - events.ScheduleEvent(EVENT_DEATHBLOOM, 30000); + events.ScheduleEvent(EVENT_DEATHBLOOM, 30 * IN_MILLISECONDS); break; case EVENT_INEVITABLE_DOOM: _doomCounter++; DoCastAOE(SPELL_INEVITABLE_DOOM); - events.ScheduleEvent(EVENT_INEVITABLE_DOOM, std::max(120000 - _doomCounter * 15000, 15000)); // needs to be confirmed + if (_doomCounter > 6) + { + if (_doomCounter & 1) // odd + events.ScheduleEvent(EVENT_INEVITABLE_DOOM, 14 * IN_MILLISECONDS); + else + events.ScheduleEvent(EVENT_INEVITABLE_DOOM, 17 * IN_MILLISECONDS); + } + else + events.ScheduleEvent(EVENT_INEVITABLE_DOOM, 30 * IN_MILLISECONDS); break; case EVENT_SPORE: DoCast(me, SPELL_SUMMON_SPORE, false); - events.ScheduleEvent(EVENT_SPORE, IsHeroic() ? 18000 : 36000); + events.ScheduleEvent(EVENT_SPORE, RAID_MODE(36,18) * IN_MILLISECONDS); break; case EVENT_NECROTIC_AURA_FADING: Talk(SAY_NECROTIC_AURA_FADING); @@ -203,9 +220,46 @@ class spell_loatheb_necrotic_aura_warning : public SpellScriptLoader } }; +class spell_loatheb_deathbloom : public SpellScriptLoader +{ + public: + spell_loatheb_deathbloom() : SpellScriptLoader("spell_loatheb_deathbloom") { } + + class spell_loatheb_deathbloom_AuraScript : public AuraScript + { + PrepareAuraScript(spell_loatheb_deathbloom_AuraScript); + + bool Validate(SpellInfo const* /*spell*/) override + { + if (!sSpellMgr->GetSpellInfo(SPELL_DEATHBLOOM_FINAL_DAMAGE)) + return false; + return true; + } + + void AfterRemove(AuraEffect const* eff, AuraEffectHandleModes /*mode*/) + { + if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE) + return; + + GetTarget()->CastSpell(nullptr, SPELL_DEATHBLOOM_FINAL_DAMAGE, true, nullptr, eff, GetCasterGUID()); + } + + void Register() override + { + AfterEffectRemove += AuraEffectRemoveFn(spell_loatheb_deathbloom_AuraScript::AfterRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL); + } + }; + + AuraScript* GetAuraScript() const override + { + return new spell_loatheb_deathbloom_AuraScript(); + } +}; + void AddSC_boss_loatheb() { new boss_loatheb(); new achievement_spore_loser(); new spell_loatheb_necrotic_aura_warning(); + new spell_loatheb_deathbloom(); } diff --git a/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp b/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp index f5e5b287571..f6dc75c7b3b 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp @@ -19,51 +19,58 @@ #include "ScriptedCreature.h" #include "naxxramas.h" -enum Noth +enum Phases { - SAY_AGGRO = 0, - SAY_SUMMON = 1, - SAY_SLAY = 2, - SAY_DEATH = 3, - - SOUND_DEATH = 8848, - - SPELL_CURSE_PLAGUEBRINGER = 29213, // 25-man: 54835 - SPELL_CRIPPLE = 29212, // 25-man: 54814 - SPELL_TELEPORT = 29216, - - NPC_WARRIOR = 16984, - NPC_CHAMPION = 16983, - NPC_GUARDIAN = 16981 + PHASE_NONE, + PHASE_GROUND, + PHASE_BALCONY }; -#define SPELL_BLINK RAND(29208, 29209, 29210, 29211) +enum Events +{ + EVENT_CURSE = 1, // curse of the plaguebringer + EVENT_BLINK, // blink (25m only) + EVENT_WARRIOR, // summon warriors during ground phase + EVENT_BALCONY, // become untargetable and begin balcony phase + EVENT_BALCONY_TELEPORT, // actually teleport to balcony, this is slightly delayed + EVENT_WAVE, // spawn wave during balcony phase + EVENT_GROUND, // end balcony phase and teleport to ground + EVENT_GROUND_ATTACKABLE // become attackable and aggressive again at start of ground phase, once again slightly delayed to prevent motionmaster weirdness +}; -// Teleport position of Noth on his balcony -Position const Teleport = { 2631.370f, -3529.680f, 274.040f, 6.277f }; +enum Talk +{ + SAY_AGGRO = 0, + SAY_SUMMON = 1, + SAY_SLAY = 2, + SAY_DEATH = 3, -#define MAX_SUMMON_POS 5 + EMOTE_SUMMON = 4, // ground phase + EMOTE_SUMMON_WAVE = 5, // balcony phase + EMOTE_TELEPORT_1 = 6, // ground to balcony + EMOTE_TELEPORT_2 = 7 // balcony to ground +}; -Position const SummonPos[MAX_SUMMON_POS] = +enum Spells { - { 2728.12f, -3544.43f, 261.91f, 6.04f }, - { 2729.05f, -3544.47f, 261.91f, 5.58f }, - { 2728.24f, -3465.08f, 264.20f, 3.56f }, - { 2704.11f, -3456.81f, 265.53f, 4.51f }, - { 2663.56f, -3464.43f, 262.66f, 5.20f } + SPELL_CURSE = 29213, // 25-man: 54835 + SPELL_CRIPPLE = 29212, // 25-man: 54814 + + SPELL_TELEPORT = 29216, // ground to balcony + SPELL_TELEPORT_BACK = 29231 // balcony to ground }; -enum Events +enum Adds { - EVENT_NONE, - EVENT_BERSERK, - EVENT_CURSE, - EVENT_BLINK, - EVENT_WARRIOR, - EVENT_BALCONY, - EVENT_WAVE, - EVENT_GROUND + N_WARRIOR_SPELLS = 3, + N_CHAMPION_SPELLS = 6, + N_GUARDIAN_SPELLS = 3 }; +const uint32 SummonWarriorSpells[N_WARRIOR_SPELLS] = { 29247, 29248, 29249 }; +const uint32 SummonChampionSpells[N_CHAMPION_SPELLS] = { 29238, 29255, 29257, 29258, 29262, 29267 }; +const uint32 SummonGuardianSpells[N_GUARDIAN_SPELLS] = { 29239, 29256, 29268 }; + +#define SPELL_BLINK RAND(29208, 29209, 29210, 29211) class boss_noth : public CreatureScript { @@ -72,16 +79,38 @@ public: struct boss_nothAI : public BossAI { - boss_nothAI(Creature* creature) : BossAI(creature, BOSS_NOTH) + boss_nothAI(Creature* creature) : BossAI(creature, BOSS_NOTH), balconyCount(0), justBlinked(false) { - balconyCount = 0; - waveCount = 0; + std::copy(SummonWarriorSpells, SummonWarriorSpells + N_WARRIOR_SPELLS, _SummonWarriorSpells); + std::copy(SummonChampionSpells, SummonChampionSpells + N_CHAMPION_SPELLS, _SummonChampionSpells); + std::copy(SummonGuardianSpells, SummonGuardianSpells + N_GUARDIAN_SPELLS, _SummonGuardianSpells); + + events.SetPhase(PHASE_NONE); + } + + void EnterEvadeMode() override + { + Reset(); // teleport back first + _EnterEvadeMode(); } void Reset() override { - me->SetReactState(REACT_AGGRESSIVE); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + if (!me->IsAlive()) + return; + + // in case we reset during balcony phase + if (events.IsInPhase(PHASE_BALCONY)) + { + DoCastAOE(SPELL_TELEPORT_BACK); + me->SetReactState(REACT_AGGRESSIVE); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE); + } + + balconyCount = 0; + events.SetPhase(PHASE_NONE); + justBlinked = false; + _Reset(); } @@ -89,31 +118,44 @@ public: { _EnterCombat(); Talk(SAY_AGGRO); - balconyCount = 0; EnterPhaseGround(); } void EnterPhaseGround() { - me->SetReactState(REACT_AGGRESSIVE); - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + events.SetPhase(PHASE_GROUND); + DoZoneInCombat(); if (me->getThreatManager().isThreatListEmpty()) - EnterEvadeMode(); + Reset(); else { - events.ScheduleEvent(EVENT_BALCONY, 110000); - events.ScheduleEvent(EVENT_CURSE, 10000 + rand32() % 15000); - events.ScheduleEvent(EVENT_WARRIOR, 30000); + uint8 secondsGround; + switch (balconyCount) + { + case 0: + secondsGround = 90; + break; + case 1: + secondsGround = 110; + break; + case 2: + default: + secondsGround = 180; + } + events.ScheduleEvent(EVENT_GROUND_ATTACKABLE, 2 * IN_MILLISECONDS, 0, PHASE_GROUND); + events.ScheduleEvent(EVENT_BALCONY, secondsGround * IN_MILLISECONDS, 0, PHASE_GROUND); + events.ScheduleEvent(EVENT_CURSE, urand(10,25) * IN_MILLISECONDS, 0, PHASE_GROUND); + events.ScheduleEvent(EVENT_WARRIOR, urand(20,30) * IN_MILLISECONDS, 0, PHASE_GROUND); if (GetDifficulty() == RAID_DIFFICULTY_25MAN_NORMAL) - events.ScheduleEvent(EVENT_BLINK, urand(20000, 40000)); + events.ScheduleEvent(EVENT_BLINK, urand(20,30) * IN_MILLISECONDS, 0, PHASE_GROUND); } } - void KilledUnit(Unit* /*victim*/) override + void KilledUnit(Unit* victim) override { - if (!(rand32() % 5)) + if(victim->GetTypeId() == TYPEID_PLAYER) Talk(SAY_SLAY); } @@ -121,7 +163,7 @@ public: { summons.Summon(summon); summon->setActive(true); - summon->AI()->DoZoneInCombat(); + summon->AI()->DoZoneInCombat(nullptr, 250.0f); // specify range to cover entire room - default 50yd is not enough } void JustDied(Unit* /*killer*/) override @@ -130,10 +172,35 @@ public: Talk(SAY_DEATH); } - void SummonUndead(uint32 entry, uint32 num) + void DamageTaken(Unit* /*who*/, uint32& damage) override // prevent noth from somehow dying in the balcony phase { - for (uint32 i = 0; i < num; ++i) - me->SummonCreature(entry, SummonPos[rand32() % MAX_SUMMON_POS], TEMPSUMMON_CORPSE_DESPAWN, 60000); + if (!events.IsInPhase(PHASE_BALCONY)) + return; + if (damage < me->GetHealth()) + return; + + me->SetHealth(1u); + damage = 0u; + } + + void HandleSummon(uint32* spellsList, const uint8 nSpells, uint8 num) + { // this ensures we do not spawn two mobs using the same spell (<=> in the same position) if we can help it + while (num) + for (uint8 it = 0; it < nSpells && num; ++it) + { + num--; + uint8 selected = urand(it, nSpells - 1); + DoCastAOE(spellsList[selected]); + if (selected != it) // shuffle the selected into the part of the array that is no longer being searched + std::swap(spellsList[selected], spellsList[it]); + } + } + + void CastSummon(uint8 nWarrior, uint8 nChampion, uint8 nGuardian) + { + HandleSummon(_SummonWarriorSpells, N_WARRIOR_SPELLS, nWarrior); + HandleSummon(_SummonChampionSpells, N_CHAMPION_SPELLS, nChampion); + HandleSummon(_SummonGuardianSpells, N_GUARDIAN_SPELLS, nGuardian); } void UpdateAI(uint32 diff) override @@ -151,72 +218,115 @@ public: switch (eventId) { case EVENT_CURSE: - DoCastAOE(SPELL_CURSE_PLAGUEBRINGER); - events.ScheduleEvent(EVENT_CURSE, urand(50000, 60000)); - return; + { + DoCastAOE(SPELL_CURSE); + events.ScheduleEvent(EVENT_CURSE, urand(50, 70) * IN_MILLISECONDS, 0, PHASE_GROUND); + break; + } case EVENT_WARRIOR: Talk(SAY_SUMMON); - SummonUndead(NPC_WARRIOR, RAID_MODE(2, 3)); - events.ScheduleEvent(EVENT_WARRIOR, 30000); - return; + Talk(EMOTE_SUMMON); + + CastSummon(RAID_MODE(2, 3), 0, 0); + + events.ScheduleEvent(EVENT_WARRIOR, 40 * IN_MILLISECONDS, 0, PHASE_GROUND); + break; case EVENT_BLINK: DoCastAOE(SPELL_CRIPPLE, true); DoCastAOE(SPELL_BLINK); DoResetThreat(); - events.ScheduleEvent(EVENT_BLINK, 40000); - return; + justBlinked = true; + + events.ScheduleEvent(EVENT_BLINK, 40000, 0, PHASE_GROUND); + break; case EVENT_BALCONY: + events.SetPhase(PHASE_BALCONY); me->SetReactState(REACT_PASSIVE); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE); me->AttackStop(); + me->StopMoving(); me->RemoveAllAuras(); - me->NearTeleportTo(Teleport.GetPositionX(), Teleport.GetPositionY(), Teleport.GetPositionZ(), Teleport.GetOrientation()); - events.Reset(); - events.ScheduleEvent(EVENT_WAVE, urand(2000, 5000)); - waveCount = 0; - return; + + events.ScheduleEvent(EVENT_BALCONY_TELEPORT, 3 * IN_MILLISECONDS, 0, PHASE_BALCONY); + events.ScheduleEvent(EVENT_WAVE, urand(5 * IN_MILLISECONDS, 8 * IN_MILLISECONDS), 0, PHASE_BALCONY); + + uint8 secondsBalcony; + switch (balconyCount) + { + case 0: + secondsBalcony = 70; + break; + case 1: + secondsBalcony = 97; + break; + case 2: + default: + secondsBalcony = 120; + break; + } + events.ScheduleEvent(EVENT_GROUND, secondsBalcony * IN_MILLISECONDS, 0, PHASE_BALCONY); + break; + case EVENT_BALCONY_TELEPORT: + Talk(EMOTE_TELEPORT_1); + DoCastAOE(SPELL_TELEPORT); + break; case EVENT_WAVE: - Talk(SAY_SUMMON); + Talk(EMOTE_SUMMON_WAVE); switch (balconyCount) { case 0: - SummonUndead(NPC_CHAMPION, RAID_MODE(2, 4)); + CastSummon(0, RAID_MODE(2, 4), 0); break; case 1: - SummonUndead(NPC_CHAMPION, RAID_MODE(1, 2)); - SummonUndead(NPC_GUARDIAN, RAID_MODE(1, 2)); + CastSummon(0, RAID_MODE(1, 2), RAID_MODE(1, 2)); break; case 2: - SummonUndead(NPC_GUARDIAN, RAID_MODE(2, 4)); + CastSummon(0, 0, RAID_MODE(2, 4)); break; default: - SummonUndead(NPC_CHAMPION, RAID_MODE(5, 10)); - SummonUndead(NPC_GUARDIAN, RAID_MODE(5, 10)); + CastSummon(0, RAID_MODE(5, 10), RAID_MODE(5, 10)); break; } - ++waveCount; - events.ScheduleEvent(waveCount < 2 ? EVENT_WAVE : EVENT_GROUND, urand(30000, 45000)); - return; + events.ScheduleEvent(EVENT_WAVE, urand(30, 45) * IN_MILLISECONDS, 0, PHASE_BALCONY); + break; case EVENT_GROUND: - { ++balconyCount; - float x, y, z, o; - me->GetHomePosition(x, y, z, o); - me->NearTeleportTo(x, y, z, o); - events.ScheduleEvent(EVENT_BALCONY, 110000); + + DoCastAOE(SPELL_TELEPORT_BACK); + Talk(EMOTE_TELEPORT_2); + EnterPhaseGround(); - return; - } + break; + case EVENT_GROUND_ATTACKABLE: + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NOT_SELECTABLE); + me->SetReactState(REACT_AGGRESSIVE); + break; } } - if (me->HasReactState(REACT_AGGRESSIVE)) - DoMeleeAttackIfReady(); + if (events.IsInPhase(PHASE_GROUND)) + { + /* workaround for movechase breaking after blinking + without this noth would just stand there unless his current target moves */ + if (justBlinked && me->GetVictim() && !me->IsWithinMeleeRange(me->EnsureVictim())) + { + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MoveChase(me->EnsureVictim()); + justBlinked = false; + } + else + DoMeleeAttackIfReady(); + } } private: - uint32 waveCount; uint32 balconyCount; + + bool justBlinked; + + uint32 _SummonWarriorSpells[N_WARRIOR_SPELLS]; + uint32 _SummonChampionSpells[N_CHAMPION_SPELLS]; + uint32 _SummonGuardianSpells[N_GUARDIAN_SPELLS]; }; CreatureAI* GetAI(Creature* creature) const override diff --git a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp index 1d7c7a2794a..37aaa639bb1 100644 --- a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp +++ b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp @@ -77,12 +77,13 @@ ObjectData const objectData[] = { 0, 0, } }; -float const HeiganPos[2] = { 2796.0f, -3707.0f }; +// from P2 teleport spell stored target +float const HeiganPos[2] = { 2793.86f, -3707.38f }; float const HeiganEruptionSlope[3] = { - (-3685.0f - HeiganPos[1]) / (2724.0f - HeiganPos[0]), - (-3647.0f - HeiganPos[1]) / (2749.0f - HeiganPos[0]), - (-3637.0f - HeiganPos[1]) / (2771.0f - HeiganPos[0]) + (-3703.303223f - HeiganPos[1]) / (2777.494141f - HeiganPos[0]), // between right center and far right + (-3696.948242f - HeiganPos[1]) / (2785.624268f - HeiganPos[0]), // between left and right halves + (-3691.880615f - HeiganPos[1]) / (2790.280029f - HeiganPos[0]) // between far left and left center }; // 0 H x @@ -246,7 +247,6 @@ class instance_naxxramas : public InstanceMapScript if (go->GetGOInfo()->displayId == 6785 || go->GetGOInfo()->displayId == 1287) { uint32 section = GetEruptionSection(go->GetPositionX(), go->GetPositionY()); - HeiganEruptionGUID[section].erase(go->GetGUID()); return; } @@ -557,7 +557,7 @@ class instance_naxxramas : public InstanceMapScript // This Function is called in CheckAchievementCriteriaMeet and CheckAchievementCriteriaMeet is called before SetBossState(bossId, DONE), // so to check if all bosses are done the checker must exclude 1 boss, the last done, if there is at most 1 encouter in progress when is // called this function then all bosses are done. The one boss that check is the boss that calls this function, so it is dead. - bool AreAllEncoutersDone() + bool AreAllEncountersDone() { uint32 numBossAlive = 0; for (uint32 i = 0; i < EncounterCount; ++i) @@ -594,7 +594,7 @@ class instance_naxxramas : public InstanceMapScript case 13239: // Loatheb case 13240: // Thaddius case 7617: // Kel'Thuzad - if (AreAllEncoutersDone() && !playerDied) + if (AreAllEncountersDone() && !playerDied) return true; return false; } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp index 25d1e214260..7618a0b9156 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp @@ -242,7 +242,7 @@ class ActivateLivingConstellation : public BasicEvent { } - bool Execute(uint64 execTime, uint32 /*diff*/) + bool Execute(uint64 execTime, uint32 /*diff*/) override { if (!_instance || _instance->GetBossState(BOSS_ALGALON) != IN_PROGRESS) return true; // delete event @@ -264,7 +264,7 @@ class CosmicSmashDamageEvent : public BasicEvent { } - bool Execute(uint64 /*execTime*/, uint32 /*diff*/) + bool Execute(uint64 /*execTime*/, uint32 /*diff*/) override { _caster->CastSpell((Unit*)NULL, SPELL_COSMIC_SMASH_TRIGGERED, TRIGGERED_FULL_MASK); return true; @@ -281,7 +281,7 @@ class SummonUnleashedDarkMatter : public BasicEvent { } - bool Execute(uint64 execTime, uint32 /*diff*/) + bool Execute(uint64 execTime, uint32 /*diff*/) override { _caster->CastSpell((Unit*)NULL, SPELL_SUMMON_UNLEASHED_DARK_MATTER, TRIGGERED_FULL_MASK); _caster->m_Events.AddEvent(this, execTime + 30000); @@ -322,7 +322,7 @@ class boss_algalon_the_observer : public CreatureScript void KilledUnit(Unit* victim) override { - if (victim->GetTypeId() == TYPEID_UNIT) + if (victim->GetTypeId() == TYPEID_PLAYER) { _fedOnTears = true; if (!_hasYelled) diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp index 64403ad40ca..7e005eff303 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp @@ -234,16 +234,12 @@ class boss_general_vezax : public CreatureScript void CheckShamanisticRage() { - Map* map = me->GetMap(); - if (map && map->IsDungeon()) - { - // If Shaman has Shamanistic Rage and use it during the fight, it will cast Corrupted Rage on him - Map::PlayerList const& Players = map->GetPlayers(); - for (Map::PlayerList::const_iterator itr = Players.begin(); itr != Players.end(); ++itr) - if (Player* player = itr->GetSource()) - if (player->HasSpell(SPELL_SHAMANTIC_RAGE)) - player->CastSpell(player, SPELL_CORRUPTED_RAGE, false); - } + // If Shaman has Shamanistic Rage and use it during the fight, it will cast Corrupted Rage on him + Map::PlayerList const& Players = me->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator itr = Players.begin(); itr != Players.end(); ++itr) + if (Player* player = itr->GetSource()) + if (player->HasSpell(SPELL_SHAMANTIC_RAGE)) + player->CastSpell(player, SPELL_CORRUPTED_RAGE, false); } uint32 GetData(uint32 type) const override @@ -280,34 +276,28 @@ class boss_general_vezax : public CreatureScript */ Unit* CheckPlayersInRange(uint8 playersMin, float rangeMin, float rangeMax) { - Map* map = me->GetMap(); - if (map && map->IsDungeon()) + std::list<Player*> PlayerList; + Map::PlayerList const& Players = me->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator itr = Players.begin(); itr != Players.end(); ++itr) { - std::list<Player*> PlayerList; - Map::PlayerList const& Players = map->GetPlayers(); - for (Map::PlayerList::const_iterator itr = Players.begin(); itr != Players.end(); ++itr) + if (Player* player = itr->GetSource()) { - if (Player* player = itr->GetSource()) - { - float distance = player->GetDistance(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()); - if (rangeMin > distance || distance > rangeMax) - continue; + float distance = player->GetDistance(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()); + if (rangeMin > distance || distance > rangeMax) + continue; - PlayerList.push_back(player); - } + PlayerList.push_back(player); } + } - if (PlayerList.empty()) - return NULL; - - size_t size = PlayerList.size(); - if (size < playersMin) - return NULL; + if (PlayerList.empty()) + return NULL; - return Trinity::Containers::SelectRandomContainerElement(PlayerList); - } + size_t size = PlayerList.size(); + if (size < playersMin) + return NULL; - return NULL; + return Trinity::Containers::SelectRandomContainerElement(PlayerList); } }; diff --git a/src/server/scripts/Northrend/isle_of_conquest.cpp b/src/server/scripts/Northrend/isle_of_conquest.cpp index 79a20da9702..fccdc8098b6 100644 --- a/src/server/scripts/Northrend/isle_of_conquest.cpp +++ b/src/server/scripts/Northrend/isle_of_conquest.cpp @@ -206,7 +206,7 @@ class spell_ioc_parachute_ic : public SpellScriptLoader class StartLaunchEvent : public BasicEvent { public: - StartLaunchEvent(float x, float y, float z, uint32 lowGuid) : _x(x), _y(y), _z(z), _lowGuid(lowGuid) + StartLaunchEvent(float x, float y, float z, ObjectGuid::LowType lowGuid) : _x(x), _y(y), _z(z), _lowGuid(lowGuid) { } @@ -227,7 +227,7 @@ class StartLaunchEvent : public BasicEvent private: float _x, _y, _z; - uint32 _lowGuid; + ObjectGuid::LowType _lowGuid; }; class spell_ioc_launch : public SpellScriptLoader diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp index 94ec7acba1f..d2892541373 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp @@ -162,11 +162,6 @@ bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId) // he dropped it further, summon mound GameObject* go = new GameObject; Map* map = player->GetMap(); - if (!map) - { - delete go; - return true; - } if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), SI_SILITHYST_MOUND, map, player->GetPhaseMask(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), 0, 0, 0, 0, 100, GO_STATE_READY)) { @@ -196,11 +191,6 @@ bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId) // he dropped it further, summon mound GameObject* go = new GameObject; Map* map = player->GetMap(); - if (!map) - { - delete go; - return true; - } if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), SI_SILITHYST_MOUND, map, player->GetPhaseMask(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), 0, 0, 0, 0, 100, GO_STATE_READY)) { diff --git a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp index 263fd8340b9..6e43cfa2d0f 100644 --- a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp +++ b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_shirrak_the_dead_watcher.cpp @@ -109,8 +109,7 @@ public: if (Inhibitmagic_Timer <= diff) { float dist; - Map* map = me->GetMap(); - Map::PlayerList const &PlayerList = map->GetPlayers(); + Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) if (Player* i_pl = i->GetSource()) if (i_pl->IsAlive() && (dist = i_pl->GetDistance(me)) < 45) diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp index d0e12c87a55..b16a9630335 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp @@ -182,8 +182,7 @@ class boss_grandmaster_vorpil : public CreatureScript break; case EVENT_DRAW_SHADOWS: { - Map* map = me->GetMap(); - Map::PlayerList const &PlayerList = map->GetPlayers(); + Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) if (Player* i_pl = i->GetSource()) if (i_pl->IsAlive() && !i_pl->HasAura(SPELL_BANISH)) diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp index d817c08d7f2..787b191e23d 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp @@ -257,8 +257,7 @@ public: void EnterCombat(Unit* who) override { // remove old tainted cores to prevent cheating in phase 2 - Map* map = me->GetMap(); - Map::PlayerList const &PlayerList = map->GetPlayers(); + Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr) if (Player* player = itr->GetSource()) player->DestroyItemCount(31088, 1, true); diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp index 5d967a3546f..253c601e228 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp @@ -788,8 +788,7 @@ public: if (Earthshock_Timer <= diff) { - Map* map = me->GetMap(); - Map::PlayerList const &PlayerList = map->GetPlayers(); + Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr) { if (Player* i_pl = itr->GetSource()) diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp index 096777163a6..7c4dbdeaab1 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp @@ -259,8 +259,7 @@ public: if (CheckTimer <= diff)//check if there are players in melee range { InRange = false; - Map* map = me->GetMap(); - Map::PlayerList const &PlayerList = map->GetPlayers(); + Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers(); if (!PlayerList.isEmpty()) { for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) @@ -274,15 +273,11 @@ public: if (RotTimer) { - Map* map = me->GetMap(); - if (map->IsDungeon()) + Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) { - Map::PlayerList const &PlayerList = map->GetPlayers(); - for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - { - if (i->GetSource() && i->GetSource()->IsAlive() && me->HasInArc(diff/20000.f*float(M_PI)*2.f, i->GetSource()) && me->IsWithinDist(i->GetSource(), SPOUT_DIST) && !i->GetSource()->IsInWater()) - DoCast(i->GetSource(), SPELL_SPOUT, true); // only knock back players in arc, in 100yards, not in water - } + if (i->GetSource() && i->GetSource()->IsAlive() && me->HasInArc(diff/20000.f*float(M_PI)*2.f, i->GetSource()) && me->IsWithinDist(i->GetSource(), SPOUT_DIST) && !i->GetSource()->IsInWater()) + DoCast(i->GetSource(), SPELL_SPOUT, true); // only knock back players in arc, in 100yards, not in water } if (SpoutAnimTimer <= diff) diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 0ab7c2fcb54..ca8c9a9ef93 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -3424,7 +3424,7 @@ class spell_gen_turkey_marker : public SpellScriptLoader void Register() override { - AfterEffectApply += AuraEffectApplyFn(spell_gen_turkey_marker_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL); + AfterEffectApply += AuraEffectApplyFn(spell_gen_turkey_marker_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); OnEffectPeriodic += AuraEffectPeriodicFn(spell_gen_turkey_marker_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); } diff --git a/src/server/scripts/World/action_ip_logger.cpp b/src/server/scripts/World/action_ip_logger.cpp index 4a60a80ee5a..f0ffbe1c7f3 100644 --- a/src/server/scripts/World/action_ip_logger.cpp +++ b/src/server/scripts/World/action_ip_logger.cpp @@ -96,7 +96,7 @@ class AccountActionIpLogger : public AccountScript // We declare all the required variables uint32 playerGuid = accountId; - uint32 characterGuid = 0; + ObjectGuid::LowType characterGuid = 0; std::string systemNote = "ERROR"; // "ERROR" is a placeholder here. We change it later. // With this switch, we change systemNote so that we have a more accurate phrasing of what type it is. @@ -201,7 +201,7 @@ class CharacterActionIpLogger : public PlayerScript // We declare all the required variables uint32 playerGuid = player->GetSession()->GetAccountId(); - uint32 characterGuid = player->GetGUID().GetCounter(); + ObjectGuid::LowType characterGuid = player->GetGUID().GetCounter(); const std::string currentIp = player->GetSession()->GetRemoteAddress(); std::string systemNote = "ERROR"; // "ERROR" is a placeholder here. We change it... @@ -269,7 +269,7 @@ public: // Else, this script isn't loaded in the first place: We require no config check. // We declare all the required variables - uint32 characterGuid = guid.GetCounter(); // We have no access to any member function of Player* or WorldSession*. So use old-fashioned way. + ObjectGuid::LowType characterGuid = guid.GetCounter(); // We have no access to any member function of Player* or WorldSession*. So use old-fashioned way. // Query playerGuid/accountId, as we only have characterGuid std::string systemNote = "ERROR"; // "ERROR" is a placeholder here. We change it later. diff --git a/src/server/scripts/World/duel_reset.cpp b/src/server/scripts/World/duel_reset.cpp new file mode 100644 index 00000000000..f08469d5bd5 --- /dev/null +++ b/src/server/scripts/World/duel_reset.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "ScriptMgr.h" +#include "Player.h" + +class DuelResetScript : public PlayerScript +{ + public: + DuelResetScript() : PlayerScript("DuelResetScript") { } + + // Called when a duel starts (after 3s countdown) + void OnDuelStart(Player* player1, Player* player2) override + { + if (sWorld->getBoolConfig(CONFIG_RESET_DUEL_COOLDOWNS)) + { + player1->GetSpellHistory()->SaveCooldownStateBeforeDuel(); + player2->GetSpellHistory()->SaveCooldownStateBeforeDuel(); + + player1->RemoveArenaSpellCooldowns(true); + player2->RemoveArenaSpellCooldowns(true); + } + } + + // Called when a duel ends + void OnDuelEnd(Player* winner, Player* loser, DuelCompleteType /*type*/) override + { + if (sWorld->getBoolConfig(CONFIG_RESET_DUEL_COOLDOWNS)) + { + winner->RemoveArenaSpellCooldowns(true); + loser->RemoveArenaSpellCooldowns(true); + + winner->GetSpellHistory()->RestoreCooldownStateAfterDuel(); + loser->GetSpellHistory()->RestoreCooldownStateAfterDuel(); + } + } +}; + +void AddSC_duel_reset() +{ + new DuelResetScript(); +} + diff --git a/src/server/scripts/World/npc_professions.cpp b/src/server/scripts/World/npc_professions.cpp index 44411b20aaf..9c05e4e2c08 100644 --- a/src/server/scripts/World/npc_professions.cpp +++ b/src/server/scripts/World/npc_professions.cpp @@ -179,6 +179,52 @@ enum ProfessionSpells }; /*### +# specialization trainers +###*/ +enum SpecializationTrainers +{ + /* Alchemy */ + N_TRAINER_TRANSMUTE = 22427, // Zarevhi + N_TRAINER_ELIXIR = 19052, // Lorokeem + N_TRAINER_POTION = 17909, // Lauranna Thar'well + + /* Blacksmithing */ + N_TRAINER_SMITHOMNI1 = 11145, // Myolor Sunderfury + N_TRAINER_SMITHOMNI2 = 11176, // Krathok Moltenfist + N_TRAINER_WEAPON1 = 11146, // Ironus Coldsteel + N_TRAINER_WEAPON2 = 11178, // Borgosh Corebender + N_TRAINER_ARMOR1 = 5164, // Grumnus Steelshaper + N_TRAINER_ARMOR2 = 11177, // Okothos Ironrager + N_TRAINER_HAMMER = 11191, // Lilith the Lithe + N_TRAINER_AXE = 11192, // Kilram + N_TRAINER_SWORD = 11193, // Seril Scourgebane + + /* Leatherworking */ + N_TRAINER_DRAGON1 = 7866, // Peter Galen + N_TRAINER_DRAGON2 = 7867, // Thorkaf Dragoneye + N_TRAINER_ELEMENTAL1 = 7868, // Sarah Tanner + N_TRAINER_ELEMENTAL2 = 7869, // Brumn Winterhoof + N_TRAINER_TRIBAL1 = 7870, // Caryssia Moonhunter + N_TRAINER_TRIBAL2 = 7871, // Se'Jib + + /* Tailoring */ + N_TRAINER_SPELLFIRE = 22213, // Gidge Spellweaver + N_TRAINER_MOONCLOTH = 22208, // Nasmara Moonsong + N_TRAINER_SHADOWEAVE = 22212, // Andrion Darkspinner +}; + +/*### +# specialization quests +###*/ +enum SpecializationQuests +{ + /* Alchemy */ + Q_MASTER_TRANSMUTE = 10899, + Q_MASTER_ELIXIR = 10902, + Q_MASTER_POTION = 10897, +}; + +/*### # formulas to calculate unlearning cost ###*/ @@ -395,23 +441,23 @@ public: if (player->HasSkill(SKILL_ALCHEMY) && player->GetBaseSkillValue(SKILL_ALCHEMY) >= 350 && player->getLevel() > 67) { - if (player->GetQuestRewardStatus(10899) || player->GetQuestRewardStatus(10902) || player->GetQuestRewardStatus(10897)) + if (player->GetQuestRewardStatus(Q_MASTER_TRANSMUTE) || player->GetQuestRewardStatus(Q_MASTER_ELIXIR) || player->GetQuestRewardStatus(Q_MASTER_POTION)) { switch (creature->GetEntry()) { - case 22427: //Zarevhi + case N_TRAINER_TRANSMUTE: //Zarevhi if (!HasAlchemySpell(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_TRANSMUTE, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 1); if (player->HasSpell(S_TRANSMUTE)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_TRANSMUTE, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 4); break; - case 19052: //Lorokeem + case N_TRAINER_ELIXIR: //Lorokeem if (!HasAlchemySpell(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_ELIXIR, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 2); if (player->HasSpell(S_ELIXIR)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_ELIXIR, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 5); break; - case 17909: //Lauranna Thar'well + case N_TRAINER_POTION: //Lauranna Thar'well if (!HasAlchemySpell(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_POTION, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 3); if (player->HasSpell(S_POTION)) @@ -464,17 +510,17 @@ public: { switch (creature->GetEntry()) { - case 22427: + case N_TRAINER_TRANSMUTE: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_TRANSMUTE, GOSSIP_SENDER_CHECK, action); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 19052: + case N_TRAINER_ELIXIR: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_ELIXIR, GOSSIP_SENDER_CHECK, action); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 17909: + case N_TRAINER_POTION: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_POTION, GOSSIP_SENDER_CHECK, action); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); @@ -489,17 +535,17 @@ public: { switch (creature->GetEntry()) { - case 22427: //Zarevhi + case N_TRAINER_TRANSMUTE: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_TRANSMUTE, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_ALCHEMY_SPEC, DoHighUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 19052: //Lorokeem + case N_TRAINER_ELIXIR: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_ELIXIR, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_ALCHEMY_SPEC, DoHighUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 17909: //Lauranna Thar'well + case N_TRAINER_POTION: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_POTION, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_ALCHEMY_SPEC, DoHighUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); @@ -564,20 +610,20 @@ public: { switch (creatureId) { - case 11145: //Myolor Sunderfury - case 11176: //Krathok Moltenfist + case N_TRAINER_SMITHOMNI1: + case N_TRAINER_SMITHOMNI2: if (!player->HasSpell(S_ARMOR) && !player->HasSpell(S_WEAPON) && player->GetReputationRank(REP_ARMOR) >= REP_FRIENDLY) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ARMOR_LEARN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); if (!player->HasSpell(S_WEAPON) && !player->HasSpell(S_ARMOR) && player->GetReputationRank(REP_WEAPON) >= REP_FRIENDLY) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_WEAPON_LEARN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); break; - case 11146: //Ironus Coldsteel - case 11178: //Borgosh Corebender + case N_TRAINER_WEAPON1: + case N_TRAINER_WEAPON2: if (player->HasSpell(S_WEAPON)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_WEAPON_UNLEARN, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 3); break; - case 5164: //Grumnus Steelshaper - case 11177: //Okothos Ironrager + case N_TRAINER_ARMOR1: + case N_TRAINER_ARMOR2: if (player->HasSpell(S_ARMOR)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ARMOR_UNLEARN, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 4); break; @@ -588,19 +634,19 @@ public: { switch (creatureId) { - case 11191: //Lilith the Lithe + case N_TRAINER_HAMMER: if (!HasWeaponSub(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_HAMMER, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 5); if (player->HasSpell(S_HAMMER)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_HAMMER, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 8); break; - case 11192: //Kilram + case N_TRAINER_AXE: if (!HasWeaponSub(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_AXE, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 6); if (player->HasSpell(S_AXE)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_AXE, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 9); break; - case 11193: //Seril Scourgebane + case N_TRAINER_SWORD: if (!HasWeaponSub(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_SWORD, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 7); if (player->HasSpell(S_SWORD)) @@ -685,17 +731,17 @@ public: { switch (creature->GetEntry()) { - case 11191: + case N_TRAINER_HAMMER: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_HAMMER, GOSSIP_SENDER_CHECK, action); //unknown textID (TALK_HAMMER_LEARN) player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 11192: + case N_TRAINER_AXE: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_AXE, GOSSIP_SENDER_CHECK, action); //unknown textID (TALK_AXE_LEARN) player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 11193: + case N_TRAINER_SWORD: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_SWORD, GOSSIP_SENDER_CHECK, action); //unknown textID (TALK_SWORD_LEARN) player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); @@ -710,26 +756,26 @@ public: { switch (creature->GetEntry()) { - case 11146: //Ironus Coldsteel - case 11178: //Borgosh Corebender - case 5164: //Grumnus Steelshaper - case 11177: //Okothos Ironrager + case N_TRAINER_WEAPON1: + case N_TRAINER_WEAPON2: + case N_TRAINER_ARMOR1: + case N_TRAINER_ARMOR2: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_SMITH_SPEC, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_ARMORORWEAPON, DoLowUnlearnCost(player), false); //unknown textID (TALK_UNLEARN_AXEORWEAPON) player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 11191: + case N_TRAINER_HAMMER: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_HAMMER, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_WEAPON_SPEC, DoMedUnlearnCost(player), false); //unknown textID (TALK_HAMMER_UNLEARN) player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 11192: + case N_TRAINER_AXE: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_AXE, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_WEAPON_SPEC, DoMedUnlearnCost(player), false); //unknown textID (TALK_AXE_UNLEARN) player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 11193: + case N_TRAINER_SWORD: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_SWORD, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_WEAPON_SPEC, DoMedUnlearnCost(player), false); //unknown textID (TALK_SWORD_UNLEARN) player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); @@ -901,18 +947,18 @@ public: { switch (creature->GetEntry()) { - case 7866: //Peter Galen - case 7867: //Thorkaf Dragoneye + case N_TRAINER_DRAGON1: + case N_TRAINER_DRAGON2: if (player->HasSpell(S_DRAGON)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_DRAGON, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 1); break; - case 7868: //Sarah Tanner - case 7869: //Brumn Winterhoof + case N_TRAINER_ELEMENTAL1: + case N_TRAINER_ELEMENTAL2: if (player->HasSpell(S_ELEMENTAL)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_ELEMENTAL, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 2); break; - case 7870: //Caryssia Moonhunter - case 7871: //Se'Jib + case N_TRAINER_TRIBAL1: + case N_TRAINER_TRIBAL2: if (player->HasSpell(S_TRIBAL)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_TRIBAL, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 3); break; @@ -952,20 +998,20 @@ public: { switch (creature->GetEntry()) { - case 7866: //Peter Galen - case 7867: //Thorkaf Dragoneye + case N_TRAINER_DRAGON1: + case N_TRAINER_DRAGON2: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_DRAGON, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_LEATHER_SPEC, DoMedUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 7868: //Sarah Tanner - case 7869: //Brumn Winterhoof + case N_TRAINER_ELEMENTAL1: + case N_TRAINER_ELEMENTAL2: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_ELEMENTAL, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_LEATHER_SPEC, DoMedUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 7870: //Caryssia Moonhunter - case 7871: //Se'Jib + case N_TRAINER_TRIBAL1: + case N_TRAINER_TRIBAL2: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_TRIBAL, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_LEATHER_SPEC, DoMedUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); @@ -1027,19 +1073,19 @@ public: { switch (creature->GetEntry()) { - case 22213: //Gidge Spellweaver + case N_TRAINER_SPELLFIRE: if (!HasTailorSpell(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_SPELLFIRE, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 1); if (player->HasSpell(S_SPELLFIRE)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_SPELLFIRE, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 4); break; - case 22208: //Nasmara Moonsong + case N_TRAINER_MOONCLOTH: if (!HasTailorSpell(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_MOONCLOTH, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 2); if (player->HasSpell(S_MOONCLOTH)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_UNLEARN_MOONCLOTH, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 5); break; - case 22212: //Andrion Darkspinner + case N_TRAINER_SHADOWEAVE: if (!HasTailorSpell(player)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_SHADOWEAVE, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 3); if (player->HasSpell(S_SHADOWEAVE)) @@ -1092,17 +1138,17 @@ public: { switch (creature->GetEntry()) { - case 22213: + case N_TRAINER_SPELLFIRE: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_SPELLFIRE, GOSSIP_SENDER_CHECK, action); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 22208: + case N_TRAINER_MOONCLOTH: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_MOONCLOTH, GOSSIP_SENDER_CHECK, action); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 22212: + case N_TRAINER_SHADOWEAVE: player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LEARN_SHADOWEAVE, GOSSIP_SENDER_CHECK, action); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); @@ -1117,17 +1163,17 @@ public: { switch (creature->GetEntry()) { - case 22213: //Gidge Spellweaver + case N_TRAINER_SPELLFIRE: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_SPELLFIRE, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_TAILOR_SPEC, DoHighUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 22208: //Nasmara Moonsong + case N_TRAINER_MOONCLOTH: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_MOONCLOTH, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_TAILOR_SPEC, DoHighUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); break; - case 22212: //Andrion Darkspinner + case N_TRAINER_SHADOWEAVE: player->ADD_GOSSIP_ITEM_EXTENDED(0, GOSSIP_UNLEARN_SHADOWEAVE, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_TAILOR_SPEC, DoHighUnlearnCost(player), false); //unknown textID () player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID()); diff --git a/src/server/shared/Networking/MessageBuffer.h b/src/server/shared/Networking/MessageBuffer.h index 95e26974626..5f9af33a45d 100644 --- a/src/server/shared/Networking/MessageBuffer.h +++ b/src/server/shared/Networking/MessageBuffer.h @@ -84,9 +84,9 @@ public: // Ensures there's "some" free space, make sure to call Normalize() before this void EnsureFreeSpace() { - // Double the size of the buffer if it's already full + // resize buffer if it's already full if (GetRemainingSpace() == 0) - _storage.resize(_storage.size() * 2); + _storage.resize(_storage.size() * 3 / 2); } void Write(void const* data, std::size_t size) diff --git a/src/server/shared/Networking/Socket.h b/src/server/shared/Networking/Socket.h index 1989411bccb..3f588298617 100644 --- a/src/server/shared/Networking/Socket.h +++ b/src/server/shared/Networking/Socket.h @@ -160,6 +160,8 @@ protected: MessageBuffer _writeBuffer; #endif + boost::asio::io_service& io_service() { return _socket.get_io_service(); } + private: void ReadHandlerInternal(boost::system::error_code error, size_t transferredBytes) { diff --git a/src/server/worldserver/CommandLine/CliRunnable.cpp b/src/server/worldserver/CommandLine/CliRunnable.cpp index ad9ae28f712..3901e17f9c2 100644 --- a/src/server/worldserver/CommandLine/CliRunnable.cpp +++ b/src/server/worldserver/CommandLine/CliRunnable.cpp @@ -36,9 +36,9 @@ char* command_finder(const char* text, int state) { - static int idx, len; + static size_t idx, len; const char* ret; - ChatCommand* cmd = ChatHandler::getCommandTable(); + std::vector<ChatCommand> const& cmd = ChatHandler::getCommandTable(); if (!state) { @@ -46,20 +46,19 @@ char* command_finder(const char* text, int state) len = strlen(text); } - while ((ret = cmd[idx].Name)) + while (idx < cmd.size()) { + ret = cmd[idx].Name; if (!cmd[idx].AllowConsole) { - idx++; + ++idx; continue; } - idx++; + ++idx; //printf("Checking %s \n", cmd[idx].Name); if (strncmp(ret, text, len) == 0) return strdup(ret); - if (cmd[idx].Name == NULL) - break; } return ((char*)NULL); diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist index 1689f05966a..13b6b22bed4 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -1855,7 +1855,7 @@ Rate.Drop.Item.ReferencedAmount = 1 # Rate.XP.Quest # Rate.XP.Explore # Description: Experience rates. -# Default: 1 - (Rate.XP.Kill) +# Default: 1 - (Rate.XP.Kill, affects only kills outside of Battlegrounds) # 1 - (Rate.XP.Quest) # 1 - (Rate.XP.Explore) @@ -1864,6 +1864,14 @@ Rate.XP.Quest = 1 Rate.XP.Explore = 1 # +# Rate.XP.BattlegroundKill +# Description: Experience rate for honorable kills in battlegrounds, +# it works when Battleground.GiveXPForKills = 1 +# Default: 1 + +Rate.XP.BattlegroundKill = 1 + +# # Rate.Quest.Money.Reward # Rate.Quest.Money.Max.Level.Reward # Description: Multiplier for money quest rewards. Can not be below 0. @@ -2191,12 +2199,21 @@ Battleground.QueueAnnouncer.PlayerOnly = 0 Battleground.StoreStatistics.Enable = 0 # +# Battleground.TrackDeserters.Enable +# Description: Track deserters of Battlegrounds. +# Default: 0 - (Disabled) +# 1 - (Enabled) + +Battleground.TrackDeserters.Enable = 0 + +# # Battleground.InvitationType # Description: Set Battleground invitation type. # Default: 0 - (Normal, Invite as much players to battlegrounds as queued, # Don't bother with balance) # 1 - (Experimental, Don't allow to invite much more players # of one faction) +# 2 - (Experimental, Try to have even teams) Battleground.InvitationType = 0 @@ -2220,7 +2237,8 @@ BattleGround.PremadeGroupWaitForMatch = 1800000 # # Battleground.GiveXPForKills -# Description: Give experience for honorable kills in battlegrounds. +# Description: Give experience for honorable kills in battlegrounds, +# the rate can be changed in the Rate.XP.BattlegroundKill setting. # Default: 0 - (Disabled) # 1 - (Enabled) @@ -2605,12 +2623,12 @@ PlayerStart.MapsExplored = 0 HonorPointsAfterDuel = 0 # -# ResetCoolDownAfterDuel -# Description: Reset all cooldowns after duel, but only if player has no cooldowns before the duel. +# ResetDuelCooldowns +# Description: Reset all cooldowns before duel starts and restore them when duel ends. # Default: 0 - (Disabled) # 1 - (Enabled) -ResetCoolDownAfterDuel = 0 +ResetDuelCooldowns = 0 # # AlwaysMaxWeaponSkill diff --git a/src/tools/mmaps_generator/VMapExtensions.cpp b/src/tools/mmaps_generator/VMapExtensions.cpp deleted file mode 100644 index 63c8e524542..00000000000 --- a/src/tools/mmaps_generator/VMapExtensions.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/> - * Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <vector> -#include "MapTree.h" -#include "VMapManager2.h" -#include "WorldModel.h" -#include "ModelInstance.h" - -namespace VMAP -{ - // Need direct access to encapsulated VMAP data, so we add functions for MMAP generator - // maybe add MapBuilder as friend to all of the below classes would be better? - - // declared in src/shared/vmap/MapTree.h - void StaticMapTree::getModelInstances(ModelInstance* &models, uint32 &count) - { - models = iTreeValues; - count = iNTreeValues; - } - - // declared in src/shared/vmap/VMapManager2.h - void VMapManager2::getInstanceMapTree(InstanceTreeMap &instanceMapTree) - { - instanceMapTree = iInstanceMapTrees; - } - - // declared in src/shared/vmap/WorldModel.h - void WorldModel::getGroupModels(std::vector<GroupModel> &groupModels) - { - groupModels = this->groupModels; - } - - // declared in src/shared/vmap/WorldModel.h - void GroupModel::getMeshData(std::vector<G3D::Vector3> &vertices, std::vector<MeshTriangle> &triangles, WmoLiquid* &liquid) - { - vertices = this->vertices; - triangles = this->triangles; - liquid = iLiquid; - } - - // declared in src/shared/vmap/ModelInstance.h - WorldModel* ModelInstance::getWorldModel() - { - return iModel; - } - - // declared in src/shared/vmap/WorldModel.h - void WmoLiquid::getPosInfo(uint32 &tilesX, uint32 &tilesY, G3D::Vector3 &corner) const - { - tilesX = iTilesX; - tilesY = iTilesY; - corner = iCorner; - } -} |