From 333b8e5159ada2f1b8cbfd1dd8eb9072754477d7 Mon Sep 17 00:00:00 2001 From: Spp Date: Fri, 9 Nov 2012 13:13:45 +0100 Subject: Core/Build: Enable Clang PCH support and OS X specific features Core: Fix warnings here and there --- src/server/shared/AutoPtr.h | 52 +++++++++++++------------- src/server/shared/CMakeLists.txt | 25 +++++-------- src/server/shared/Cryptography/BigNumber.cpp | 4 +- src/server/shared/Cryptography/BigNumber.h | 4 +- src/server/shared/Database/PreparedStatement.h | 6 ++- src/server/shared/Database/QueryResult.h | 1 - src/server/shared/Threading/DelayExecutor.cpp | 2 +- src/server/shared/Threading/DelayExecutor.h | 2 +- 8 files changed, 47 insertions(+), 49 deletions(-) (limited to 'src/server/shared') diff --git a/src/server/shared/AutoPtr.h b/src/server/shared/AutoPtr.h index f4199880abd..9afa05325c9 100644 --- a/src/server/shared/AutoPtr.h +++ b/src/server/shared/AutoPtr.h @@ -22,32 +22,32 @@ namespace Trinity { - template - class AutoPtr : public ACE_Strong_Bound_Ptr + +template +class AutoPtr : public ACE_Strong_Bound_Ptr +{ + typedef ACE_Strong_Bound_Ptr Base; + +public: + AutoPtr() + : Base() + { } + + AutoPtr(Pointer* x) + : Base(x) + { } + + operator bool() const + { + return !Base::null(); + } + + bool operator !() const { - public: - AutoPtr() : ACE_Strong_Bound_Ptr() {} - - AutoPtr(Pointer* x) - { - ACE_Strong_Bound_Ptr::reset(x); - } - - operator bool() const - { - return ACE_Strong_Bound_Ptr::get() != NULL; - } - - bool operator !() const - { - return ACE_Strong_Bound_Ptr::get() == NULL; - } - - bool operator !=(Pointer* x) const - { - return ACE_Strong_Bound_Ptr::get() != x; - } - }; -} + return Base::null(); + } +}; + +} // namespace Trinity #endif diff --git a/src/server/shared/CMakeLists.txt b/src/server/shared/CMakeLists.txt index de998442419..f057527c284 100644 --- a/src/server/shared/CMakeLists.txt +++ b/src/server/shared/CMakeLists.txt @@ -28,11 +28,9 @@ file(GLOB sources_localdir *.cpp *.h) # Build shared sourcelist # -if( USE_COREPCH AND MSVC ) - set(shared_STAT_SRCS - PrecompiledHeaders/sharedPCH.cpp - PrecompiledHeaders/sharedPCH.h - ) +if (USE_COREPCH) + set(shared_STAT_PCH_HDR PrecompiledHeaders/sharedPCH.h) + set(shared_STAT_PCH_SRC PrecompiledHeaders/sharedPCH.cpp) endif() set(shared_STAT_SRCS @@ -51,7 +49,6 @@ set(shared_STAT_SRCS ) include_directories( - ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/dep/SFMT ${CMAKE_SOURCE_DIR}/dep/sockets/include ${CMAKE_SOURCE_DIR}/dep/utf8cpp @@ -73,18 +70,16 @@ include_directories( ${OPENSSL_INCLUDE_DIR} ) -add_library(shared STATIC ${shared_STAT_SRCS}) +add_library(shared STATIC + ${shared_STAT_SRCS} + ${shared_STAT_PCH_SRC} +) target_link_libraries(shared ${ACE_LIBRARY} ) # Generate precompiled header -if( USE_COREPCH ) - if(CMAKE_COMPILER_IS_GNUCXX) - add_precompiled_header(shared ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/sharedPCH.h) - elseif(MSVC) - add_native_precompiled_header(shared ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders/sharedPCH) - endif() -endif() - +if (USE_COREPCH) + add_cxx_pch(shared ${shared_STAT_PCH_HDR} ${shared_STAT_PCH_SRC}) +endif () diff --git a/src/server/shared/Cryptography/BigNumber.cpp b/src/server/shared/Cryptography/BigNumber.cpp index 8e424e9bcdb..def0a7fd02e 100755 --- a/src/server/shared/Cryptography/BigNumber.cpp +++ b/src/server/shared/Cryptography/BigNumber.cpp @@ -192,12 +192,12 @@ uint8 *BigNumber::AsByteArray(int minSize, bool reverse) return _array; } -const char *BigNumber::AsHexStr() +char * BigNumber::AsHexStr() const { return BN_bn2hex(_bn); } -const char *BigNumber::AsDecStr() +char * BigNumber::AsDecStr() const { return BN_bn2dec(_bn); } diff --git a/src/server/shared/Cryptography/BigNumber.h b/src/server/shared/Cryptography/BigNumber.h index a27d74fb5c7..36a618056a5 100755 --- a/src/server/shared/Cryptography/BigNumber.h +++ b/src/server/shared/Cryptography/BigNumber.h @@ -84,8 +84,8 @@ class BigNumber uint32 AsDword(); uint8* AsByteArray(int minSize = 0, bool reverse = true); - const char *AsHexStr(); - const char *AsDecStr(); + char * AsHexStr() const; + char * AsDecStr() const; private: struct bignum_st *_bn; diff --git a/src/server/shared/Database/PreparedStatement.h b/src/server/shared/Database/PreparedStatement.h index 11ece3e3032..90ea435d1f9 100755 --- a/src/server/shared/Database/PreparedStatement.h +++ b/src/server/shared/Database/PreparedStatement.h @@ -21,6 +21,10 @@ #include "SQLOperation.h" #include +#ifdef __APPLE__ +#undef TYPE_BOOL +#endif + //- Union for data buffer (upper-level bind -> queue -> lower-level bind) union PreparedStatementDataUnion { @@ -157,4 +161,4 @@ class PreparedStatementTask : public SQLOperation bool m_has_result; PreparedQueryResultFuture m_result; }; -#endif \ No newline at end of file +#endif diff --git a/src/server/shared/Database/QueryResult.h b/src/server/shared/Database/QueryResult.h index e32b16555bc..be7fa7b649c 100755 --- a/src/server/shared/Database/QueryResult.h +++ b/src/server/shared/Database/QueryResult.h @@ -23,7 +23,6 @@ #include #include "Field.h" -#include "Log.h" #ifdef _WIN32 #include diff --git a/src/server/shared/Threading/DelayExecutor.cpp b/src/server/shared/Threading/DelayExecutor.cpp index cfc4987387f..685e86e2a2f 100644 --- a/src/server/shared/Threading/DelayExecutor.cpp +++ b/src/server/shared/Threading/DelayExecutor.cpp @@ -59,7 +59,7 @@ int DelayExecutor::svc() return 0; } -int DelayExecutor::activate(int num_threads, ACE_Method_Request* pre_svc_hook, ACE_Method_Request* post_svc_hook) +int DelayExecutor::start(int num_threads, ACE_Method_Request* pre_svc_hook, ACE_Method_Request* post_svc_hook) { if (activated()) return -1; diff --git a/src/server/shared/Threading/DelayExecutor.h b/src/server/shared/Threading/DelayExecutor.h index 664d8ca78a2..5eaaacdb98b 100644 --- a/src/server/shared/Threading/DelayExecutor.h +++ b/src/server/shared/Threading/DelayExecutor.h @@ -16,7 +16,7 @@ class DelayExecutor : protected ACE_Task_Base int execute(ACE_Method_Request* new_req); - int activate(int num_threads = 1, ACE_Method_Request* pre_svc_hook = NULL, ACE_Method_Request* post_svc_hook = NULL); + int start(int num_threads = 1, ACE_Method_Request* pre_svc_hook = NULL, ACE_Method_Request* post_svc_hook = NULL); int deactivate(); -- cgit v1.2.3 From 6bd90626eaeceea2a619f55124f95e141a6c3022 Mon Sep 17 00:00:00 2001 From: Spp Date: Sat, 10 Nov 2012 14:49:28 +0100 Subject: Core/Build: Fix compile using mysqllite included with core Closes #8283 --- src/server/collision/CMakeLists.txt | 1 + src/server/shared/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) (limited to 'src/server/shared') diff --git a/src/server/collision/CMakeLists.txt b/src/server/collision/CMakeLists.txt index 9a6b8ee75f4..3182b20d008 100644 --- a/src/server/collision/CMakeLists.txt +++ b/src/server/collision/CMakeLists.txt @@ -31,6 +31,7 @@ set(collision_STAT_SRCS ) include_directories( + ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/dep/g3dlite/include ${CMAKE_SOURCE_DIR}/src/server/shared ${CMAKE_SOURCE_DIR}/src/server/shared/Debugging diff --git a/src/server/shared/CMakeLists.txt b/src/server/shared/CMakeLists.txt index f057527c284..e9f414d34e5 100644 --- a/src/server/shared/CMakeLists.txt +++ b/src/server/shared/CMakeLists.txt @@ -49,6 +49,7 @@ set(shared_STAT_SRCS ) include_directories( + ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/dep/SFMT ${CMAKE_SOURCE_DIR}/dep/sockets/include ${CMAKE_SOURCE_DIR}/dep/utf8cpp -- cgit v1.2.3 From db4a69f77340eb96041680a875af86b1f09823fc Mon Sep 17 00:00:00 2001 From: Spp Date: Sat, 17 Nov 2012 14:34:25 +0100 Subject: Crash Fix after b99c347 --- src/server/game/Entities/Player/Player.h | 8 ++------ src/server/game/Globals/ObjectMgr.cpp | 23 ++++++++++++----------- src/server/shared/Packets/ByteBuffer.h | 2 +- 3 files changed, 15 insertions(+), 18 deletions(-) (limited to 'src/server/shared') diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index d55d070614a..3b1f47b8f69 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -20,25 +20,21 @@ #define _PLAYER_H #include "AchievementMgr.h" -#include "Bag.h" #include "Common.h" #include "DatabaseEnv.h" #include "DBCEnums.h" #include "GroupReference.h" -#include "ItemPrototype.h" #include "Item.h" #include "MapReference.h" -#include "NPCHandler.h" #include "Pet.h" #include "QuestDef.h" #include "ReputationMgr.h" #include "Unit.h" -#include "Util.h" // for Tokens typedef #include "WorldSession.h" #include "SpellMgr.h" -#include -#include +#include +#include struct Mail; class Channel; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 6af9ffdf235..d17478bf30a 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -2950,6 +2950,9 @@ PetLevelInfo const* ObjectMgr::GetPetLevelInfo(uint32 creature_id, uint8 level) void ObjectMgr::PlayerCreateInfoAddItemHelper(uint32 race_, uint32 class_, uint32 itemId, int32 count) { + if (!_playerInfo[race_][class_]) + return; + if (count > 0) _playerInfo[race_][class_]->item.push_back(PlayerCreateInfoItem(itemId, count)); else @@ -3239,8 +3242,8 @@ void ObjectMgr::LoadPlayerInfo() continue; } - PlayerInfo* pInfo = _playerInfo[current_race][current_class]; - pInfo->action.push_back(PlayerCreateInfoAction(fields[2].GetUInt16(), fields[3].GetUInt32(), fields[4].GetUInt16())); + if (PlayerInfo* info = _playerInfo[current_race][current_class]) + info->action.push_back(PlayerCreateInfoAction(fields[2].GetUInt16(), fields[3].GetUInt32(), fields[4].GetUInt16())); ++count; } @@ -3380,16 +3383,14 @@ void ObjectMgr::LoadPlayerInfo() continue; } - PlayerInfo* pInfo = _playerInfo[current_race][current_class]; - - if (!pInfo->levelInfo) - pInfo->levelInfo = new PlayerLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)]; - - PlayerLevelInfo* pLevelInfo = &pInfo->levelInfo[current_level-1]; - - for (int i = 0; i < MAX_STATS; i++) + if (PlayerInfo* info = _playerInfo[current_race][current_class]) { - pLevelInfo->stats[i] = fields[i+3].GetUInt8(); + if (!info->levelInfo) + info->levelInfo = new PlayerLevelInfo[sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)]; + + PlayerLevelInfo& levelInfo = info->levelInfo[current_level-1]; + for (int i = 0; i < MAX_STATS; i++) + levelInfo.stats[i] = fields[i+3].GetUInt8(); } ++count; diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index 1fa3148504a..e79544e7315 100755 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -372,7 +372,7 @@ class ByteBuffer lt.tm_mon = (packedDate >> 20) & 0xF; lt.tm_year = ((packedDate >> 24) & 0x1F) + 100; - return mktime(<) + timezone; + return uint32(mktime(<) + timezone); } ByteBuffer& ReadPackedTime(uint32& time) -- cgit v1.2.3 From 771aafc4990d915f52582aa4d0b5b68c32f722db Mon Sep 17 00:00:00 2001 From: horn Date: Sun, 18 Nov 2012 22:42:28 +0000 Subject: Core/Calendar: Completely rewrite and fix most of the calendar system There are still some issues that need to be fixed, for more info see CalendarHandler.cpp TODO part. Some unblizzlike behaviour possible, we don't have a lot of sniffs. Big thanks to @Warpten, he joined my project and helped a lot. IMPORTANT NOTE: Read / append packed time functions in ByteBuffer.h are not correct, they need to be fixed in order to have event times accurate Signed-off-by: Nay --- sql/base/characters_database.sql | 41 + .../2012_11_11_00_character_calendar.sql | 26 + src/server/game/Battlegrounds/ArenaTeam.cpp | 17 + src/server/game/Battlegrounds/ArenaTeam.h | 2 + src/server/game/Calendar/Calendar.cpp | 99 --- src/server/game/Calendar/Calendar.h | 189 ----- src/server/game/Calendar/CalendarMgr.cpp | 895 +++++++++++---------- src/server/game/Calendar/CalendarMgr.h | 317 +++++++- src/server/game/Guilds/Guild.cpp | 36 + src/server/game/Guilds/Guild.h | 2 + src/server/game/Handlers/CalendarHandler.cpp | 884 ++++++++------------ src/server/game/Handlers/CharacterHandler.cpp | 2 + src/server/game/Handlers/MailHandler.cpp | 6 +- src/server/game/Mails/Mail.cpp | 10 +- src/server/game/Mails/Mail.h | 4 +- src/server/game/Miscellaneous/SharedDefines.h | 98 --- src/server/game/Server/Protocol/Opcodes.cpp | 2 +- src/server/game/Server/WorldSession.h | 14 +- .../Database/Implementation/CharacterDatabase.cpp | 6 + .../Database/Implementation/CharacterDatabase.h | 5 + 20 files changed, 1235 insertions(+), 1420 deletions(-) create mode 100644 sql/updates/characters/2012_11_11_00_character_calendar.sql delete mode 100755 src/server/game/Calendar/Calendar.cpp delete mode 100755 src/server/game/Calendar/Calendar.h (limited to 'src/server/shared') diff --git a/sql/base/characters_database.sql b/sql/base/characters_database.sql index 5548630d2d6..02efbe77101 100644 --- a/sql/base/characters_database.sql +++ b/sql/base/characters_database.sql @@ -237,6 +237,47 @@ LOCK TABLES `bugreport` WRITE; /*!40000 ALTER TABLE `bugreport` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `calendar_events` +-- + +DROP TABLE IF EXISTS `calendar_events`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `calendar_events` ( + `id` bigint(20) unsigned NOT NULL DEFAULT '0', + `creator` int(10) unsigned NOT NULL DEFAULT '0', + `title` varchar(255) NOT NULL DEFAULT '', + `description` varchar(255) NOT NULL DEFAULT '', + `type` tinyint(1) unsigned NOT NULL DEFAULT '4', + `dungeon` int(10) NOT NULL DEFAULT '-1', + `eventtime` int(10) unsigned NOT NULL DEFAULT '0', + `flags` int(10) unsigned NOT NULL DEFAULT '0', + `time2` int(10) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `calendar_invites` +-- + +DROP TABLE IF EXISTS `calendar_invites`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `calendar_invites` ( + `id` bigint(20) unsigned NOT NULL DEFAULT '0', + `event` bigint(20) unsigned NOT NULL DEFAULT '0', + `invitee` int(10) unsigned NOT NULL DEFAULT '0', + `sender` int(10) unsigned NOT NULL DEFAULT '0', + `status` tinyint(1) unsigned NOT NULL DEFAULT '0', + `statustime` int(10) unsigned NOT NULL DEFAULT '0', + `rank` tinyint(1) unsigned NOT NULL DEFAULT '0', + `text` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `channels` -- diff --git a/sql/updates/characters/2012_11_11_00_character_calendar.sql b/sql/updates/characters/2012_11_11_00_character_calendar.sql new file mode 100644 index 00000000000..a3e7c352788 --- /dev/null +++ b/sql/updates/characters/2012_11_11_00_character_calendar.sql @@ -0,0 +1,26 @@ +DROP TABLE IF EXISTS `calendar_events`; +CREATE TABLE IF NOT EXISTS `calendar_events` ( + `id` bigint(20) unsigned NOT NULL DEFAULT '0', + `creator` int(10) unsigned NOT NULL DEFAULT '0', + `title` varchar(255) NOT NULL DEFAULT '', + `description` varchar(255) NOT NULL DEFAULT '', + `type` tinyint(1) unsigned NOT NULL DEFAULT '4', + `dungeon` int(10) NOT NULL DEFAULT '-1', + `eventtime` int(10) unsigned NOT NULL DEFAULT '0', + `flags` int(10) unsigned NOT NULL DEFAULT '0', + `time2` int(10) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +DROP TABLE IF EXISTS `calendar_invites`; +CREATE TABLE IF NOT EXISTS `calendar_invites` ( + `id` bigint(20) unsigned NOT NULL DEFAULT '0', + `event` bigint(20) unsigned NOT NULL DEFAULT '0', + `invitee` int(10) unsigned NOT NULL DEFAULT '0', + `sender` int(10) unsigned NOT NULL DEFAULT '0', + `status` tinyint(1) unsigned NOT NULL DEFAULT '0', + `statustime` int(10) unsigned NOT NULL DEFAULT '0', + `rank` tinyint(1) unsigned NOT NULL DEFAULT '0', + `text` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp index 0223541335c..cc543544c7a 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.cpp +++ b/src/server/game/Battlegrounds/ArenaTeam.cpp @@ -511,6 +511,23 @@ void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCoun sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_ARENA_TEAM_EVENT"); } +void ArenaTeam::MassInviteToEvent(WorldSession* session) +{ + WorldPacket data(SMSG_CALENDAR_ARENA_TEAM, (Members.size() - 1) * (4 + 8 + 1)); + data << uint32(Members.size() - 1); + + for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr) + { + if (itr->Guid != session->GetPlayer()->GetGUID()) + { + data.appendPackGUID(itr->Guid); + data << uint8(0); // unk + } + } + + session->SendPacket(&data); +} + uint8 ArenaTeam::GetSlotByType(uint32 type) { switch (type) diff --git a/src/server/game/Battlegrounds/ArenaTeam.h b/src/server/game/Battlegrounds/ArenaTeam.h index 7d2d680cddc..137ac93d3c0 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.h +++ b/src/server/game/Battlegrounds/ArenaTeam.h @@ -162,6 +162,8 @@ class ArenaTeam void BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3); void NotifyStatsChanged(); + void MassInviteToEvent(WorldSession* session); + void Roster(WorldSession* session); void Query(WorldSession* session); void SendStats(WorldSession* session); diff --git a/src/server/game/Calendar/Calendar.cpp b/src/server/game/Calendar/Calendar.cpp deleted file mode 100755 index 139e63614cc..00000000000 --- a/src/server/game/Calendar/Calendar.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2008-2012 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * 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 . - */ - -#include "Player.h" -#include "Calendar.h" - -std::string CalendarInvite::GetDebugString() const -{ - std::ostringstream data; - - data << "CalendarInvite::" - << " inviteId: " << _inviteId - << " EventId: " << _eventId - << " Status: " << uint32(_status) - << " Invitee: " << _invitee - << " Sender: " << _senderGUID - << " Rank: " << uint32(_rank) - << " Text: " << _text; - - return data.str(); -} - -void CalendarInvite::Init() -{ - _eventId = 0; - _invitee = 0; - _senderGUID = 0; - _statusTime = 0; - _status = CALENDAR_STATUS_INVITED; // default (0)? - _rank = CALENDAR_RANK_PLAYER; - _text = ""; -} - -std::string CalendarEvent::GetDebugString() const -{ - std::ostringstream data; - - data << "CalendarEvent::" - << " EventId: " << _eventId - << " Title: " << _title - << " Description" << _description - << " Type: " << uint32(_type) - << " Max Invites: " << _maxInvites - << " Creator: " << _creatorGUID - << " Flags: " << _flags - << " Guild: " << _guildId - << " Time: " << _eventTime - << " Time2: " << _timezoneTime - << " Repeatable: " << uint32(_repeatable) - << " DungeonId: " << _dungeonId; - - return data.str(); -} - -void CalendarEvent::Init() -{ - _creatorGUID = 0; - _guildId = 0; - _type = CALENDAR_TYPE_OTHER; - _dungeonId = -1; - _maxInvites = 0; - _eventTime = 0; - _flags = 0; - _repeatable = false; - _timezoneTime = 0; - _title = ""; - _description = ""; - -} - -std::string CalendarAction::GetDebugString() const -{ - std::ostringstream data; - - data << "CalendarAction::" - << " Action: " << GetAction() - << " Guid: " << GetPlayer()->GetGUID() - << " Invite Id: " << GetInviteId() - << " Extra data: " << GetExtraData() - << " Event: " << Event.GetDebugString() - << " Invite: " << Invite.GetDebugString(); - - return data.str(); -} diff --git a/src/server/game/Calendar/Calendar.h b/src/server/game/Calendar/Calendar.h deleted file mode 100755 index 273db4c3854..00000000000 --- a/src/server/game/Calendar/Calendar.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (C) 2008-2012 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * 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 . - */ - -#ifndef TRINITY_CALENDAR_H -#define TRINITY_CALENDAR_H - -#include "Errors.h" -#include "SharedDefines.h" -#include - -class CalendarInvite -{ - public: - CalendarInvite() : _inviteId(0) { Init(); } - explicit CalendarInvite(uint64 inviteId) : _inviteId(inviteId) { Init(); } - - ~CalendarInvite() { } - - void SetInviteId(uint64 inviteId) { _inviteId = inviteId; } - uint64 GetInviteId() const { return _inviteId; } - - void SetEventId(uint64 eventId) { _eventId = eventId; } - uint64 GetEventId() const { return _eventId; } - - void SetSenderGUID(uint64 guid) { _senderGUID = guid; } - uint64 GetSenderGUID() const { return _senderGUID; } - - void SetInvitee(uint64 guid) { _invitee = guid; } - uint64 GetInvitee() const { return _invitee; } - - void SetStatusTime(uint32 statusTime) { _statusTime = statusTime; } - uint32 GetStatusTime() const { return _statusTime; } - - void SetText(std::string const& text) { _text = text; } - std::string const& GetText() const { return _text; } - - void SetStatus(CalendarInviteStatus status) { _status = status; } - CalendarInviteStatus GetStatus() const { return _status; } - - void SetRank(CalendarModerationRank rank) { _rank = rank; } - CalendarModerationRank GetRank() const { return _rank; } - - std::string GetDebugString() const; - - private: - void Init(); - - uint64 _inviteId; - uint64 _eventId; - uint64 _invitee; - uint64 _senderGUID; - uint32 _statusTime; - CalendarInviteStatus _status; - CalendarModerationRank _rank; - std::string _text; -}; - -typedef std::set CalendarInviteIdList; - -class CalendarEvent -{ - public: - CalendarEvent() : _eventId(0) { Init(); } - explicit CalendarEvent(uint64 eventId) : _eventId(eventId) { Init(); } - - ~CalendarEvent() { } - - void SetEventId(uint64 eventId) { _eventId = eventId; } - uint64 GetEventId() const { return _eventId; } - - void SetCreatorGUID(uint64 guid) { _creatorGUID = guid; } - uint64 GetCreatorGUID() const { return _creatorGUID; } - - void SetGuildId(uint32 guildId) { _guildId = guildId; } - uint32 GetGuildId() const { return _guildId; } - - void SetTitle(std::string const& title) { _title = title; } - std::string const& GetTitle() const { return _title; } - - void SetDescription(std::string const& description) { _description = description; } - std::string const& GetDescription() const { return _description; } - - void SetType(CalendarEventType type) { _type = type; } - CalendarEventType GetType() const { return _type; } - - void SetMaxInvites(uint32 limit) { _maxInvites = limit; } - uint32 GetMaxInvites() const { return _maxInvites; } - - void SetDungeonId(int32 dungeonId) { _dungeonId = dungeonId; } - int32 GetDungeonId() const { return _dungeonId; } - - void SetTime(uint32 eventTime) { _eventTime = eventTime; } - uint32 GetTime() const { return _eventTime; } - - void SetFlags(uint32 flags) { _flags = flags; } - uint32 GetFlags() const { return _flags; } - - void SetRepeatable(bool repeatable) { _repeatable = repeatable; } - bool GetRepeatable() const { return _repeatable; } - - void SetTimeZoneTime(uint32 timezoneTime) { _timezoneTime = timezoneTime; } - uint32 GetTimeZoneTime() const { return _timezoneTime; } - - void AddInvite(uint64 inviteId) - { - if (inviteId) - _invites.insert(inviteId); - } - - void RemoveInvite(uint64 inviteId) { _invites.erase(inviteId); } - bool HasInvite(uint64 inviteId) const { return _invites.find(inviteId) != _invites.end(); } - CalendarInviteIdList const& GetInviteIdList() const { return _invites; } - void SetInviteIdList(CalendarInviteIdList const& list) { _invites = list; } - void ClearInviteIdList() { _invites.clear(); } - - std::string GetDebugString() const; - - private: - void Init(); - - uint64 _eventId; - uint64 _creatorGUID; - uint32 _guildId; - CalendarEventType _type; - int32 _dungeonId; - uint32 _maxInvites; - uint32 _eventTime; - uint32 _flags; - bool _repeatable; - uint32 _timezoneTime; - std::string _title; - std::string _description; - CalendarInviteIdList _invites; -}; - -typedef std::set CalendarEventIdList; -typedef std::map CalendarPlayerInviteIdMap; -typedef std::map CalendarPlayerEventIdMap; -typedef std::map CalendarInviteMap; -typedef std::map CalendarEventMap; - -class Player; - -struct CalendarAction -{ - CalendarAction(): _action(CALENDAR_ACTION_NONE), _player(NULL), _inviteId(0), _data(0) - { - } - - void SetAction(CalendarActionData data) { _action = data; } - CalendarActionData GetAction() const { return _action; } - - void SetPlayer(Player* player) { ASSERT(player); _player = player; } - Player* GetPlayer() const { return _player; } - - void SetInviteId(uint64 id) { _inviteId = id; } - uint64 GetInviteId() const { return _inviteId; } - - void SetExtraData(uint32 data) { _data = data; } - uint32 GetExtraData() const { return _data; } - - CalendarEvent Event; - CalendarInvite Invite; - - std::string GetDebugString() const; - - private: - CalendarActionData _action; - Player* _player; - uint64 _inviteId; - uint32 _data; -}; - -#endif diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp index 80de42c0ce2..3f909bb85fb 100644 --- a/src/server/game/Calendar/CalendarMgr.cpp +++ b/src/server/game/Calendar/CalendarMgr.cpp @@ -15,579 +15,620 @@ * with this program. If not, see . */ -/* - -DROP TABLE IF EXISTS `calendar_events`; -CREATE TABLE IF NOT EXISTS `calendar_events` ( - `id` int(11) unsigned NOT NULL DEFAULT '0', - `creator` int(11) unsigned NOT NULL DEFAULT '0', - `title` varchar(255) NOT NULL DEFAULT '', - `description` varchar(255) NOT NULL DEFAULT '', - `type` tinyint(1) unsigned NOT NULL DEFAULT '4', - `dungeon` tinyint(3) NOT NULL DEFAULT '-1', - `eventtime` int(10) unsigned NOT NULL DEFAULT '0', - `flags` int(10) unsigned NOT NULL DEFAULT '0', - `repeatable` tinyint(1) unsigned NOT NULL DEFAULT '0', - `time2` int(10) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -); - -DROP TABLE IF EXISTS `calendar_invites`; -CREATE TABLE IF NOT EXISTS `calendar_invites` ( - `id` int(11) unsigned NOT NULL DEFAULT '0', - `event` int(11) unsigned NOT NULL DEFAULT '0', - `invitee` int(11) unsigned NOT NULL DEFAULT '0', - `sender` int(11) unsigned NOT NULL DEFAULT '0', - `status` tinyint(1) unsigned NOT NULL DEFAULT '0', - `statustime` int(10) unsigned NOT NULL DEFAULT '0', - `rank` tinyint(1) unsigned NOT NULL DEFAULT '0', - `text` varchar(255) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) -); -*/ - #include "CalendarMgr.h" #include "QueryResult.h" #include "DatabaseEnv.h" #include "Log.h" #include "Player.h" +#include "GuildMgr.h" #include "ObjectAccessor.h" -CalendarMgr::CalendarMgr() : - _eventNum(0), _inviteNum(0) +CalendarInvite::~CalendarInvite() { + sCalendarMgr->FreeInviteId(_inviteId); } -CalendarMgr::~CalendarMgr() +CalendarEvent::~CalendarEvent() { + sCalendarMgr->FreeEventId(_eventId); } -uint32 CalendarMgr::GetPlayerNumPending(uint64 guid) +CalendarMgr::CalendarMgr() { - if (!guid) - return 0; - - CalendarPlayerInviteIdMap::const_iterator itr = _playerInvites.find(guid); - if (itr == _playerInvites.end()) - return 0; - - uint32 pendingNum = 0; - for (CalendarInviteIdList::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it) - if (CalendarInvite* invite = GetInvite(*it)) - if (invite->GetRank() != CALENDAR_RANK_OWNER - && invite->GetStatus() != CALENDAR_STATUS_CONFIRMED - && invite->GetStatus() != CALENDAR_STATUS_8 - && invite->GetStatus() != CALENDAR_STATUS_9) // FIXME Check the proper value - ++pendingNum; - - return pendingNum; } -CalendarInviteIdList const& CalendarMgr::GetPlayerInvites(uint64 guid) +CalendarMgr::~CalendarMgr() { - return _playerInvites[guid]; } -CalendarEventIdList const& CalendarMgr::GetPlayerEvents(uint64 guid) +void CalendarMgr::LoadFromDB() { - return _playerEvents[guid]; -} + uint32 count = 0; + _maxEventId = 1; + _maxInviteId = 1; -CalendarInvite* CalendarMgr::GetInvite(uint64 inviteId) -{ - CalendarInviteMap::iterator itr = _invites.find(inviteId); - if (itr != _invites.end()) - return &(itr->second); + // 0 1 2 3 4 5 6 7 8 + if (QueryResult result = CharacterDatabase.Query("SELECT id, creator, title, description, type, dungeon, eventtime, flags, time2 FROM calendar_events")) + do + { + Field* fields = result->Fetch(); - sLog->outError(LOG_FILTER_CALENDAR, "CalendarMgr::GetInvite: [" UI64FMTD "] not found!", inviteId); - return NULL; -} + uint64 eventId = fields[0].GetUInt64(); + uint64 creatorGUID = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER); + std::string title = fields[2].GetString(); + std::string description = fields[3].GetString(); + CalendarEventType type = CalendarEventType(fields[4].GetUInt8()); + int32 dungeonId = fields[5].GetInt32(); + uint32 eventTime = fields[6].GetUInt32(); + uint32 flags = fields[7].GetUInt32(); + uint32 timezoneTime = fields[8].GetUInt32(); + uint32 guildId = 0; -CalendarEvent* CalendarMgr::GetEvent(uint64 eventId) -{ - CalendarEventMap::iterator itr = _events.find(eventId); - if (itr != _events.end()) - return &(itr->second); + if (flags & CALENDAR_FLAG_GUILD_EVENT || flags & CALENDAR_FLAG_WITHOUT_INVITES) + guildId = Player::GetGuildIdFromDB(creatorGUID); - sLog->outError(LOG_FILTER_CALENDAR, "CalendarMgr::GetEvent: [" UI64FMTD "] not found!", eventId); - return NULL; -} + CalendarEvent* calendarEvent = new CalendarEvent(eventId, creatorGUID , guildId, type, dungeonId, time_t(eventTime), flags, time_t(timezoneTime), title, description); + _events.insert(calendarEvent); -uint64 CalendarMgr::GetFreeEventId() -{ - return ++_eventNum; -} -uint64 CalendarMgr::GetFreeInviteId() -{ - return ++_inviteNum; -} + _maxEventId = std::max(_maxEventId, eventId); -void CalendarMgr::LoadFromDB() -{ - /* - uint32 count = 0; - // 0 1 2 3 4 5 6 7 8 9 - if (QueryResult result = CharacterDatabase.Query("SELECT id, creator, title, description, type, dungeon, eventtime, flags, repeatable, time2 FROM calendar_events")) - do - { - Field * fields = result->Fetch(); - - uint64 eventId = fields[0].GetUInt64(); - CalendarEvent& calendarEvent = _events[eventId]; - - calendarEvent.SetEventId(eventId); - calendarEvent.SetCreatorGUID(fields[1].GetUInt64()); - calendarEvent.SetTitle(fields[2].GetString()); - calendarEvent.SetDescription(fields[3].GetString()); - calendarEvent.SetType(fields[4].GetUInt8()); - calendarEvent.SetDungeonId(fields[5].GetInt32()); - calendarEvent.SetTime(fields[6].GetUInt32()); - calendarEvent.SetFlags(fields[7].GetUInt32()); - calendarEvent.SetRepeatable(fields[8].GetBool()); - calendarEvent.SetTimeZoneTime(fields[9].GetUInt32()); ++count; } while (result->NextRow()); - sLog->outInfo(LOG_FILTER_CALENDAR, ">> Loaded %u calendar events", count); + sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u calendar events", count); count = 0; // 0 1 2 3 4 5 6 7 if (QueryResult result = CharacterDatabase.Query("SELECT id, event, invitee, sender, status, statustime, rank, text FROM calendar_invites")) do { - Field * fields = result->Fetch(); + Field* fields = result->Fetch(); - uint64 inviteId = fields[0].GetUInt64(); - uint64 eventId = fields[1].GetUInt64(); + uint64 inviteId = fields[0].GetUInt64(); + uint64 eventId = fields[1].GetUInt64(); + uint64 invitee = MAKE_NEW_GUID(fields[2].GetUInt32(), 0, HIGHGUID_PLAYER); + uint64 senderGUID = MAKE_NEW_GUID(fields[3].GetUInt32(), 0, HIGHGUID_PLAYER); + CalendarInviteStatus status = CalendarInviteStatus(fields[4].GetUInt8()); + uint32 statusTime = fields[5].GetUInt32(); + CalendarModerationRank rank = CalendarModerationRank(fields[6].GetUInt8()); + std::string text = fields[7].GetString(); - CalendarInvite& invite = _invites[inviteId]; + CalendarInvite* invite = new CalendarInvite(inviteId, eventId, invitee, senderGUID, time_t(statusTime), status, rank, text); + _invites[eventId].push_back(invite); - invite.SetEventId(eventId); - invite.SetInvitee(fields[2].GetUInt64()); - invite.SetSenderGUID(fields[3].GetUInt64()); - invite.SetStatus(fields[4].GetUInt8()); - invite.SetStatusTime(fields[5].GetUInt32()); - invite.SetRank(fields[6].GetUInt8()); - invite.SetText(fields[7].GetString()); + _maxInviteId = std::max(_maxInviteId, inviteId); - CalendarEvent& calendarEvent = _events[eventId]; - calendarEvent.AddInvite(inviteId); + ++count; } while (result->NextRow()); - sLog->outInfo(LOG_FILTER_CALENDAR, ">> Loaded %u calendar Invites", count); - */ + sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u calendar invites", count); + + for (uint64 i = 1; i < _maxEventId; ++i) + if (!GetEvent(i)) + _freeEventIds.push_back(i); + + for (uint64 i = 1; i < _maxInviteId; ++i) + if (!GetInvite(i)) + _freeInviteIds.push_back(i); } -CalendarEvent* CalendarMgr::CheckPermisions(uint64 eventId, Player* player, uint64 inviteId, CalendarModerationRank minRank) +void CalendarMgr::AddEvent(CalendarEvent* calendarEvent, CalendarSendEventType sendType) { - if (!player) - return NULL; // CALENDAR_ERROR_INTERNAL + _events.insert(calendarEvent); + UpdateEvent(calendarEvent); + SendCalendarEvent(calendarEvent->GetCreatorGUID(), *calendarEvent, sendType); +} - CalendarEvent* calendarEvent = GetEvent(eventId); - if (!calendarEvent) - { - player->GetSession()->SendCalendarCommandResult(CALENDAR_ERROR_EVENT_INVALID); - return NULL; - } +void CalendarMgr::AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite) +{ + if (!calendarEvent->IsGuildAnnouncement()) + SendCalendarEventInvite(*invite); - CalendarInvite* invite = GetInvite(inviteId); - if (!invite) - { - player->GetSession()->SendCalendarCommandResult(CALENDAR_ERROR_NO_INVITE); - return NULL; - } + if (!calendarEvent->IsGuildEvent() || invite->GetInviteeGUID() == calendarEvent->GetCreatorGUID()) + SendCalendarEventInviteAlert(*calendarEvent, *invite); - if (!calendarEvent->HasInvite(inviteId)) + if (!calendarEvent->IsGuildAnnouncement()) { - player->GetSession()->SendCalendarCommandResult(CALENDAR_ERROR_NOT_INVITED); - return NULL; + _invites[invite->GetEventId()].push_back(invite); + UpdateInvite(invite); } +} + +void CalendarMgr::RemoveEvent(uint64 eventId, uint64 remover) +{ + CalendarEvent* calendarEvent = GetEvent(eventId); - if (invite->GetEventId() != calendarEvent->GetEventId() || invite->GetInvitee() != player->GetGUID()) + if (!calendarEvent) { - player->GetSession()->SendCalendarCommandResult(CALENDAR_ERROR_INTERNAL); - return NULL; + SendCalendarCommandResult(remover, CALENDAR_ERROR_EVENT_INVALID); + return; } - if (invite->GetRank() < minRank) + SendCalendarEventRemovedAlert(*calendarEvent); + + SQLTransaction trans = CharacterDatabase.BeginTransaction(); + PreparedStatement* stmt; + MailDraft mail(calendarEvent->BuildCalendarMailSubject(remover), calendarEvent->BuildCalendarMailBody()); + + std::vector::iterator itr = _invites[eventId].begin(); + while (itr != _invites[eventId].end()) { - player->GetSession()->SendCalendarCommandResult(CALENDAR_ERROR_PERMISSIONS); - return NULL; + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_INVITE); + stmt->setUInt64(0, (*itr)->GetInviteId()); + trans->Append(stmt); + + // guild events only? check invite status here? + // When an event is deleted, all invited (accepted/declined? - verify) guildies are notified via in-game mail. (wowwiki) + if (remover && (*itr)->GetInviteeGUID() != remover) + mail.SendMailTo(trans, MailReceiver((*itr)->GetInviteeGUID()), calendarEvent, MAIL_CHECK_MASK_COPIED); + + delete *itr; + _invites[eventId].erase(itr); } - return calendarEvent; + _invites.erase(eventId); + + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_EVENT); + stmt->setUInt64(0, eventId); + trans->Append(stmt); + CharacterDatabase.CommitTransaction(trans); + + delete calendarEvent; + _events.erase(calendarEvent); } -void CalendarMgr::AddAction(CalendarAction const& action) +void CalendarMgr::RemoveInvite(uint64 inviteId, uint64 eventId, uint64 remover) { - switch (action.GetAction()) - { - case CALENDAR_ACTION_ADD_EVENT: - { - if (AddEvent(action.Event) && AddInvite(action.Invite)) - { - SendCalendarEventInviteAlert(action.Event, action.Invite); - SendCalendarEvent(action.Event, CALENDAR_SENDTYPE_ADD); - } - break; - } - case CALENDAR_ACTION_MODIFY_EVENT: - { - uint64 eventId = action.Event.GetEventId(); - CalendarEvent* calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_MODERATOR); - if (!calendarEvent) - return; - - calendarEvent->SetEventId(action.Event.GetEventId()); - calendarEvent->SetType(action.Event.GetType()); - calendarEvent->SetFlags(action.Event.GetFlags()); - calendarEvent->SetTime(action.Event.GetTime()); - calendarEvent->SetTimeZoneTime(action.Event.GetTimeZoneTime()); - calendarEvent->SetRepeatable(action.Event.GetRepeatable()); - calendarEvent->SetDungeonId(action.Event.GetDungeonId()); - calendarEvent->SetTitle(action.Event.GetTitle()); - calendarEvent->SetDescription(action.Event.GetDescription()); - calendarEvent->SetMaxInvites(action.Event.GetMaxInvites()); - - CalendarInviteIdList const& invites = calendarEvent->GetInviteIdList(); - for (CalendarInviteIdList::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) - if (CalendarInvite* invite = GetInvite(*itr)) - SendCalendarEventUpdateAlert(invite->GetInvitee(), *calendarEvent, CALENDAR_SENDTYPE_ADD); + CalendarEvent* calendarEvent = GetEvent(eventId); - break; - } - case CALENDAR_ACTION_COPY_EVENT: - { - CalendarEvent* calendarEvent = CheckPermisions(action.Event.GetEventId(), action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_OWNER); - - if (!calendarEvent) - return; - - uint64 eventId = GetFreeEventId(); - CalendarEvent newEvent(eventId); - newEvent.SetType(calendarEvent->GetType()); - newEvent.SetFlags(calendarEvent->GetFlags()); - newEvent.SetTime(action.Event.GetTime()); - newEvent.SetTimeZoneTime(calendarEvent->GetTimeZoneTime()); - newEvent.SetRepeatable(calendarEvent->GetRepeatable()); - newEvent.SetDungeonId(calendarEvent->GetDungeonId()); - newEvent.SetTitle(calendarEvent->GetTitle()); - newEvent.SetDescription(calendarEvent->GetDescription()); - newEvent.SetMaxInvites(calendarEvent->GetMaxInvites()); - newEvent.SetCreatorGUID(calendarEvent->GetCreatorGUID()); - newEvent.SetGuildId(calendarEvent->GetGuildId()); - - CalendarInviteIdList const invites = calendarEvent->GetInviteIdList(); - for (CalendarInviteIdList::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) - { - if (CalendarInvite* invite = GetInvite(*itr)) - { - uint64 inviteId = GetFreeInviteId(); - CalendarInvite newInvite(inviteId); - newInvite.SetEventId(eventId); - newInvite.SetSenderGUID(action.GetPlayer()->GetGUID()); - newInvite.SetInvitee(invite->GetInvitee()); - newInvite.SetStatus(invite->GetStatus()); - newInvite.SetStatusTime(invite->GetStatusTime()); - newInvite.SetText(invite->GetText()); - newInvite.SetRank(invite->GetRank()); - if (AddInvite(newInvite)) - { - SendCalendarEventInviteAlert(newEvent, newInvite); - newEvent.AddInvite(inviteId); - } - } - } - - if (AddEvent(newEvent)) - SendCalendarEvent(newEvent, CALENDAR_SENDTYPE_COPY); + if (!calendarEvent) + return; + std::vector::iterator itr = _invites[eventId].begin(); + for (; itr != _invites[eventId].end(); ++itr) + if ((*itr)->GetInviteId() == inviteId) break; - } - case CALENDAR_ACTION_REMOVE_EVENT: - { - uint64 eventId = action.Event.GetEventId(); - //uint32 flags = action.Event.GetFlags(); - // FIXME - Use of Flags here! - CalendarEvent* calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_OWNER); - if (!calendarEvent) - return; + if (itr == _invites[eventId].end()) + return; - RemoveEvent(eventId); - break; - } - case CALENDAR_ACTION_ADD_EVENT_INVITE: - { - uint64 eventId = action.Invite.GetEventId(); - CalendarEvent* calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_MODERATOR); - if (!calendarEvent) - return; - - if (AddInvite(action.Invite)) - { - calendarEvent->AddInvite(action.Invite.GetInviteId()); - SendCalendarEventInvite(action.Invite, (!(calendarEvent->GetFlags() & CALENDAR_FLAG_INVITES_LOCKED) && - !action.Invite.GetStatusTime())); - SendCalendarEventInviteAlert(*calendarEvent, action.Invite); - } + SQLTransaction trans = CharacterDatabase.BeginTransaction(); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_INVITE); + stmt->setUInt64(0, (*itr)->GetInviteId()); + trans->Append(stmt); + CharacterDatabase.CommitTransaction(trans); - break; - } - case CALENDAR_ACTION_SIGNUP_TO_EVENT: - { - uint64 eventId = action.Event.GetEventId(); - CalendarEvent* calendarEvent = GetEvent(eventId); - CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_MODERATOR); + if (!calendarEvent->IsGuildEvent()) + SendCalendarEventInviteRemoveAlert((*itr)->GetInviteeGUID(), *calendarEvent, CALENDAR_STATUS_REMOVED); - if (!calendarEvent || !(calendarEvent->GetFlags() & CALENDAR_FLAG_GUILD_ONLY) - || !calendarEvent->GetGuildId() || calendarEvent->GetGuildId() != action.GetExtraData()) - return; + SendCalendarEventInviteRemove(*calendarEvent, **itr, calendarEvent->GetFlags()); - CalendarInviteStatus status = action.Invite.GetStatus(); + // we need to find out how to use CALENDAR_INVITE_REMOVED_MAIL_SUBJECT to force client to display different mail + //if ((*itr)->GetInviteeGUID() != remover) + // MailDraft(calendarEvent->BuildCalendarMailSubject(remover), calendarEvent->BuildCalendarMailBody()) + // .SendMailTo(trans, MailReceiver((*itr)->GetInvitee()), calendarEvent, MAIL_CHECK_MASK_COPIED); - if (status == CALENDAR_STATUS_INVITED) - status = CALENDAR_STATUS_CONFIRMED; - else if (status == CALENDAR_STATUS_ACCEPTED) - status = CALENDAR_STATUS_8; + delete *itr; + _invites[eventId].erase(itr); +} - CalendarInvite newInvite(GetFreeInviteId()); - newInvite.SetStatus(status); - newInvite.SetStatusTime(uint32(time(NULL))); - newInvite.SetEventId(eventId); - newInvite.SetInvitee(action.GetPlayer()->GetGUID()); - newInvite.SetSenderGUID(action.GetPlayer()->GetGUID()); +void CalendarMgr::UpdateEvent(CalendarEvent* calendarEvent) +{ + SQLTransaction trans = CharacterDatabase.BeginTransaction(); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_EVENT); + stmt->setUInt64(0, calendarEvent->GetEventId()); + stmt->setUInt32(1, GUID_LOPART(calendarEvent->GetCreatorGUID())); + stmt->setString(2, calendarEvent->GetTitle()); + stmt->setString(3, calendarEvent->GetDescription()); + stmt->setUInt8(4, calendarEvent->GetType()); + stmt->setInt32(5, calendarEvent->GetDungeonId()); + stmt->setUInt32(6, uint32(calendarEvent->GetEventTime())); + stmt->setUInt32(7, calendarEvent->GetFlags()); + stmt->setUInt32(8, calendarEvent->GetTimeZoneTime()); // correct? + trans->Append(stmt); + CharacterDatabase.CommitTransaction(trans); +} - if (AddInvite(newInvite)) - SendCalendarEventInvite(newInvite, false); +void CalendarMgr::UpdateInvite(CalendarInvite* invite) +{ + SQLTransaction trans = CharacterDatabase.BeginTransaction(); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_INVITE); + stmt->setUInt64(0, invite->GetInviteId()); + stmt->setUInt64(1, invite->GetEventId()); + stmt->setUInt32(2, GUID_LOPART(invite->GetInviteeGUID())); + stmt->setUInt32(3, GUID_LOPART(invite->GetSenderGUID())); + stmt->setUInt8(4, invite->GetStatus()); + stmt->setUInt32(5, uint32(invite->GetStatusTime())); + stmt->setUInt8(6, invite->GetRank()); + stmt->setString(7, invite->GetText()); + trans->Append(stmt); + CharacterDatabase.CommitTransaction(trans); +} - break; - } - case CALENDAR_ACTION_MODIFY_EVENT_INVITE: - { - uint64 eventId = action.Invite.GetEventId(); - uint64 inviteId = action.Invite.GetInviteId(); +void CalendarMgr::RemoveAllPlayerEventsAndInvites(uint64 guid) +{ + for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) + if ((*itr)->GetCreatorGUID() == guid) + RemoveEvent((*itr)->GetEventId(), 0); // don't send mail if removing a character - CalendarEvent* calendarEvent = NULL; - if (action.GetInviteId() != action.Invite.GetInviteId()) - calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_MODERATOR); - else - calendarEvent = GetEvent(eventId); + std::vector playerInvites = GetPlayerInvites(guid); + for (std::vector::const_iterator itr = playerInvites.begin(); itr != playerInvites.end(); ++itr) + RemoveInvite((*itr)->GetInviteId(), (*itr)->GetEventId(), guid); +} - CalendarInvite* invite = GetInvite(inviteId); +void CalendarMgr::RemovePlayerGuildEventsAndSignups(uint64 guid, uint32 guildId) +{ + for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) + if ((*itr)->GetCreatorGUID() == guid && ((*itr)->IsGuildEvent() || (*itr)->IsGuildAnnouncement())) + RemoveEvent((*itr)->GetEventId(), guid); + + std::vector playerInvites = GetPlayerInvites(guid); + for (std::vector::const_iterator itr = playerInvites.begin(); itr != playerInvites.end(); ++itr) + if (CalendarEvent* calendarEvent = GetEvent((*itr)->GetEventId())) + if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == guildId) + RemoveInvite((*itr)->GetInviteId(), (*itr)->GetEventId(), guid); +} - if (!calendarEvent || !invite || !calendarEvent->HasInvite(inviteId)) - return; +CalendarEvent* CalendarMgr::GetEvent(uint64 eventId) +{ + for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) + if ((*itr)->GetEventId() == eventId) + return *itr; - invite->SetStatus(action.Invite.GetStatus()); - SendCalendarEventStatus(invite->GetSenderGUID(), *calendarEvent, *invite); - break; - } - case CALENDAR_ACTION_MODIFY_MODERATOR_EVENT_INVITE: - { - uint64 eventId = action.Invite.GetEventId(); - uint64 inviteId = action.Invite.GetInviteId(); + sLog->outDebug(LOG_FILTER_CALENDAR, "CalendarMgr::GetEvent: [" UI64FMTD "] not found!", eventId); + return NULL; +} - CalendarEvent* calendarEvent = NULL; - if (action.GetInviteId() != action.Invite.GetInviteId()) - calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_OWNER); - else - calendarEvent = GetEvent(eventId); +CalendarInvite* CalendarMgr::GetInvite(uint64 inviteId) +{ + for (CalendarInviteStore::const_iterator itr = _invites.begin(); itr != _invites.end(); ++itr) + for (std::vector::const_iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2) + if ((*itr2)->GetInviteId() == inviteId) + return *itr2; - CalendarInvite* invite = GetInvite(inviteId); + sLog->outDebug(LOG_FILTER_CALENDAR, "CalendarMgr::GetInvite: [" UI64FMTD "] not found!", inviteId); + return NULL; +} - if (!calendarEvent || !invite || !calendarEvent->HasInvite(inviteId)) - return; +void CalendarMgr::FreeEventId(uint64 id) +{ + if (id == _maxEventId) + --_maxEventId; + else + _freeEventIds.push_back(id); +} - invite->SetStatus(action.Invite.GetStatus()); - SendCalendarEventModeratorStatusAlert(*invite); - break; - } - case CALENDAR_ACTION_REMOVE_EVENT_INVITE: - { - uint64 eventId = action.Invite.GetEventId(); - uint64 inviteId = action.Invite.GetInviteId(); - CalendarEvent* calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_MODERATOR); - if (!calendarEvent) - return; - - // already checked in CheckPermisions - CalendarInvite* invite = GetInvite(inviteId); - if (!invite) - return; - - if (calendarEvent->GetCreatorGUID() == invite->GetInvitee()) - { - action.GetPlayer()->GetSession()->SendCalendarCommandResult(CALENDAR_ERROR_DELETE_CREATOR_FAILED); - return; - } - - if (uint64 invitee = RemoveInvite(inviteId)) - { - SendCalendarEventInviteRemoveAlert(invitee, *calendarEvent, CALENDAR_STATUS_9); - SendCalendarEventInviteRemove(action.GetPlayer()->GetGUID(), action.Invite, calendarEvent->GetFlags()); - } - break; - } - default: - break; +uint64 CalendarMgr::GetFreeEventId() +{ + if (_freeEventIds.empty()) + return ++_maxEventId; + else + { + uint64 eventId = _freeEventIds.front(); + _freeEventIds.pop_front(); + return eventId; } +} +void CalendarMgr::FreeInviteId(uint64 id) +{ + if (id == _maxInviteId) + --_maxInviteId; + else + _freeInviteIds.push_back(id); } -bool CalendarMgr::AddEvent(CalendarEvent const& newEvent) +uint64 CalendarMgr::GetFreeInviteId() { - uint64 eventId = newEvent.GetEventId(); - if (_events.find(eventId) != _events.end()) + if (_freeInviteIds.empty()) + return ++_maxInviteId; + else { - sLog->outError(LOG_FILTER_CALENDAR, "CalendarMgr::AddEvent: Event [" UI64FMTD "] exists", eventId); - return false; + uint64 inviteId = _freeInviteIds.front(); + _freeInviteIds.pop_front(); + return inviteId; } +} + +CalendarEventStore CalendarMgr::GetPlayerEvents(uint64 guid) +{ + CalendarEventStore events; + + for (CalendarInviteStore::const_iterator itr = _invites.begin(); itr != _invites.end(); ++itr) + for (std::vector::const_iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2) + if ((*itr2)->GetInviteeGUID() == guid) + events.insert(GetEvent(itr->first)); - _events[eventId] = newEvent; - return true; + if (Player* player = ObjectAccessor::FindPlayer(guid)) + for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) + if ((*itr)->GetGuildId() == player->GetGuildId()) + events.insert(*itr); + + return events; } -bool CalendarMgr::RemoveEvent(uint64 eventId) +std::vector CalendarMgr::GetEventInvites(uint64 eventId) { - CalendarEventMap::iterator itr = _events.find(eventId); - if (itr == _events.end()) - { - sLog->outError(LOG_FILTER_CALENDAR, "CalendarMgr::RemoveEvent: Event [" UI64FMTD "] does not exist", eventId); - return false; - } + return _invites[eventId]; +} - bool val = true; +std::vector CalendarMgr::GetPlayerInvites(uint64 guid) +{ + std::vector invites; - CalendarInviteIdList const& invites = itr->second.GetInviteIdList(); - for (CalendarInviteIdList::const_iterator itrInvites = invites.begin(); itrInvites != invites.end(); ++itrInvites) - { - CalendarInvite* invite = GetInvite(*itrInvites); - if (!invite || !RemovePlayerEvent(invite->GetInvitee(), eventId)) - val = false; + for (CalendarInviteStore::const_iterator itr = _invites.begin(); itr != _invites.end(); ++itr) + for (std::vector::const_iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2) + if ((*itr2)->GetInviteeGUID() == guid) + invites.push_back(*itr2); - if (uint64 invitee = RemoveInvite(*itrInvites)) - SendCalendarEventRemovedAlert(invitee, itr->second); - } + return invites; +} + +uint32 CalendarMgr::GetPlayerNumPending(uint64 guid) +{ + std::vector const& invites = GetPlayerInvites(guid); - _events.erase(itr); + uint32 pendingNum = 0; + for (std::vector::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) + // correct? + if ((*itr)->GetStatus() == CALENDAR_STATUS_INVITED || (*itr)->GetStatus() == CALENDAR_STATUS_TENTATIVE || (*itr)->GetStatus() == CALENDAR_STATUS_NOT_SIGNED_UP) + ++pendingNum; - return val; + return pendingNum; } -bool CalendarMgr::AddPlayerEvent(uint64 guid, uint64 eventId) +std::string CalendarEvent::BuildCalendarMailSubject(uint64 remover) const { - _playerEvents[guid].insert(eventId); - return true; + std::ostringstream strm; + strm << remover << ':' << _title; + return strm.str(); } -bool CalendarMgr::RemovePlayerEvent(uint64 guid, uint64 eventId) +std::string CalendarEvent::BuildCalendarMailBody() const { - _playerEvents[guid].erase(eventId); - return true; + WorldPacket data; + uint32 time; + std::ostringstream strm; + + // we are supposed to send PackedTime so i used WorldPacket to pack it + data.AppendPackedTime(_eventTime); + data >> time; + strm << time; + return strm.str(); } -bool CalendarMgr::AddInvite(CalendarInvite const& newInvite) +void CalendarMgr::SendCalendarEventInvite(CalendarInvite const& invite) { - uint64 inviteId = newInvite.GetInviteId(); - if (!inviteId) + CalendarEvent* calendarEvent = GetEvent(invite.GetEventId()); + time_t statusTime = invite.GetStatusTime(); + bool hasStatusTime = statusTime != 946684800; // 01/01/2000 00:00:00 + + uint64 invitee = invite.GetInviteeGUID(); + Player* player = ObjectAccessor::FindPlayer(invitee); + + uint8 level = player ? player->getLevel() : Player::GetLevelFromDB(invitee); + + WorldPacket data(SMSG_CALENDAR_EVENT_INVITE, 8 + 8 + 8 + 1 + 1 + 1 + (statusTime ? 4 : 0) + 1); + data.appendPackGUID(invitee); + data << uint64(invite.GetEventId()); + data << uint64(invite.GetInviteId()); + data << uint8(level); + data << uint8(invite.GetStatus()); + data << uint8(hasStatusTime); + if (hasStatusTime) + data.AppendPackedTime(statusTime); + data << uint8(invite.GetSenderGUID() != invite.GetInviteeGUID()); // false only if the invite is sign-up + + if (!calendarEvent) // Pre-invite { - sLog->outError(LOG_FILTER_CALENDAR, "CalendarMgr::AddInvite: Cant add Invite 0"); - return false; + if (Player* player = ObjectAccessor::FindPlayer(invite.GetSenderGUID())) + player->SendDirectMessage(&data); } - - if (_invites.find(inviteId) != _invites.end()) + else { - sLog->outError(LOG_FILTER_CALENDAR, "CalendarMgr::AddInvite: Invite [" UI64FMTD "] exists", inviteId); - return false; + if (calendarEvent->GetCreatorGUID() != invite.GetInviteeGUID()) // correct? + SendPacketToAllEventRelatives(data, *calendarEvent); } - - _invites[inviteId] = newInvite; - uint64 guid = newInvite.GetInvitee(); - bool inviteAdded = AddPlayerInvite(guid, inviteId); - bool eventAdded = AddPlayerEvent(guid, newInvite.GetEventId()); - return eventAdded && inviteAdded; } -uint64 CalendarMgr::RemoveInvite(uint64 inviteId) +void CalendarMgr::SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, time_t oldEventTime) { - CalendarInviteMap::iterator itr = _invites.find(inviteId); - if (itr == _invites.end()) - { - sLog->outError(LOG_FILTER_CALENDAR, "CalendarMgr::RemoveInvite: Invite [" UI64FMTD "] does not exist", inviteId); - return 0; - } - - uint64 invitee = itr->second.GetInvitee(); - _invites.erase(itr); - - return RemovePlayerInvite(invitee, inviteId) ? invitee : 0; + WorldPacket data(SMSG_CALENDAR_EVENT_UPDATED_ALERT, 1 + 8 + 4 + 4 + 4 + 1 + 4 + + calendarEvent.GetTitle().size() + calendarEvent.GetDescription().size() + 1 + 4 + 4); + data << uint8(1); // unk + data << uint64(calendarEvent.GetEventId()); + data.AppendPackedTime(oldEventTime); + data << uint32(calendarEvent.GetFlags()); + data.AppendPackedTime(calendarEvent.GetEventTime()); + data << uint8(calendarEvent.GetType()); + data << int32(calendarEvent.GetDungeonId()); + data << calendarEvent.GetTitle(); + data << calendarEvent.GetDescription(); + data << uint8(CALENDAR_REPEAT_NEVER); // repeatable + data << uint32(CALENDAR_MAX_INVITES); + data << uint32(0); // unk + + SendPacketToAllEventRelatives(data, calendarEvent); } -bool CalendarMgr::AddPlayerInvite(uint64 guid, uint64 inviteId) +void CalendarMgr::SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite) { - _playerInvites[guid].insert(inviteId); - return true; + WorldPacket data(SMSG_CALENDAR_EVENT_STATUS, 8 + 8 + 4 + 4 + 1 + 1 + 4); + data.appendPackGUID(invite.GetInviteeGUID()); + data << uint64(calendarEvent.GetEventId()); + data.AppendPackedTime(calendarEvent.GetEventTime()); + data << uint32(calendarEvent.GetFlags()); + data << uint8(invite.GetStatus()); + data << uint8(invite.GetRank()); + data.AppendPackedTime(invite.GetStatusTime()); + + SendPacketToAllEventRelatives(data, calendarEvent); } -bool CalendarMgr::RemovePlayerInvite(uint64 guid, uint64 inviteId) +void CalendarMgr::SendCalendarEventRemovedAlert(CalendarEvent const& calendarEvent) { - _playerInvites[guid].erase(inviteId); - return true; + WorldPacket data(SMSG_CALENDAR_EVENT_REMOVED_ALERT, 1 + 8 + 1); + data << uint8(1); // FIXME: If true does not SignalEvent(EVENT_CALENDAR_ACTION_PENDING) + data << uint64(calendarEvent.GetEventId()); + data.AppendPackedTime(calendarEvent.GetEventTime()); + + SendPacketToAllEventRelatives(data, calendarEvent); } -void CalendarMgr::SendCalendarEvent(CalendarEvent const& calendarEvent, CalendarSendEventType type) +void CalendarMgr::SendCalendarEventInviteRemove(CalendarEvent const& calendarEvent, CalendarInvite const& invite, uint32 flags) { - if (Player* player = ObjectAccessor::FindPlayer(calendarEvent.GetCreatorGUID())) - player->GetSession()->SendCalendarEvent(calendarEvent, type); + WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_REMOVED, 8 + 4 + 4 + 1); + data.appendPackGUID(invite.GetInviteeGUID()); + data << uint64(invite.GetEventId()); + data << uint32(flags); + data << uint8(1); // FIXME + + SendPacketToAllEventRelatives(data, calendarEvent); } -void CalendarMgr::SendCalendarEventInvite(CalendarInvite const& invite, bool pending) +void CalendarMgr::SendCalendarEventModeratorStatusAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite) { - if (Player* player = ObjectAccessor::FindPlayer(invite.GetSenderGUID())) - player->GetSession()->SendCalendarEventInvite(invite, pending); + WorldPacket data(SMSG_CALENDAR_EVENT_MODERATOR_STATUS_ALERT, 8 + 8 + 1 + 1); + data.appendPackGUID(invite.GetInviteeGUID()); + data << uint64(invite.GetEventId()); + data << uint8(invite.GetRank()); + data << uint8(1); // Unk boolean - Display to client? + + SendPacketToAllEventRelatives(data, calendarEvent); } void CalendarMgr::SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite) { - if (Player* player = ObjectAccessor::FindPlayer(invite.GetInvitee())) - player->GetSession()->SendCalendarEventInviteAlert(calendarEvent, invite); + WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_ALERT); + data << uint64(calendarEvent.GetEventId()); + data << calendarEvent.GetTitle(); + data.AppendPackedTime(calendarEvent.GetEventTime()); + data << uint32(calendarEvent.GetFlags()); + data << uint32(calendarEvent.GetType()); + data << int32(calendarEvent.GetDungeonId()); + data << uint64(invite.GetInviteId()); + data << uint8(invite.GetStatus()); + data << uint8(invite.GetRank()); + data.appendPackGUID(calendarEvent.GetCreatorGUID()); + data.appendPackGUID(invite.GetSenderGUID()); + + if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement()) + { + if (Guild* guild = sGuildMgr->GetGuildById(calendarEvent.GetGuildId())) + guild->BroadcastPacket(&data); + } + else + if (Player* player = ObjectAccessor::FindPlayer(invite.GetInviteeGUID())) + player->SendDirectMessage(&data); } -void CalendarMgr::SendCalendarEventUpdateAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarSendEventType type) +void CalendarMgr::SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType) { - if (Player* player = ObjectAccessor::FindPlayer(guid)) - player->GetSession()->SendCalendarEventUpdateAlert(calendarEvent, type); -} + Player* player = ObjectAccessor::FindPlayer(guid); + if (!player) + return; + + std::vector const& eventInviteeList = _invites[calendarEvent.GetEventId()]; + + WorldPacket data(SMSG_CALENDAR_SEND_EVENT, 60 + eventInviteeList.size() * 32); + data << uint8(sendType); + data.appendPackGUID(calendarEvent.GetCreatorGUID()); + data << uint64(calendarEvent.GetEventId()); + data << calendarEvent.GetTitle(); + data << calendarEvent.GetDescription(); + data << uint8(calendarEvent.GetType()); + data << uint8(CALENDAR_REPEAT_NEVER); // repeatable + data << uint32(CALENDAR_MAX_INVITES); + data << int32(calendarEvent.GetDungeonId()); + data << uint32(calendarEvent.GetFlags()); + data.AppendPackedTime(calendarEvent.GetEventTime()); + data.AppendPackedTime(calendarEvent.GetTimeZoneTime()); + data << uint32(calendarEvent.GetGuildId()); + + data << uint32(eventInviteeList.size()); + for (std::vector::const_iterator itr = eventInviteeList.begin(); itr != eventInviteeList.end(); ++itr) + { + CalendarInvite const* calendarInvite = (*itr); + uint64 inviteeGuid = calendarInvite->GetInviteeGUID(); + Player* invitee = ObjectAccessor::FindPlayer(inviteeGuid); + + uint8 inviteeLevel = invitee ? invitee->getLevel() : Player::GetLevelFromDB(inviteeGuid); + uint32 inviteeGuildId = invitee ? invitee->GetGuildId() : Player::GetGuildIdFromDB(inviteeGuid); + + data.appendPackGUID(inviteeGuid); + data << uint8(inviteeLevel); + data << uint8(calendarInvite->GetStatus()); + data << uint8(calendarInvite->GetRank()); + data << uint8(calendarEvent.IsGuildEvent() && calendarEvent.GetGuildId() == inviteeGuildId); + data << uint64(calendarInvite->GetInviteId()); + data.AppendPackedTime(calendarInvite->GetStatusTime()); + data << calendarInvite->GetText(); + } -void CalendarMgr::SendCalendarEventStatus(uint64 guid, CalendarEvent const& calendarEvent, CalendarInvite const& invite) -{ - if (Player* player = ObjectAccessor::FindPlayer(guid)) - player->GetSession()->SendCalendarEventStatus(calendarEvent, invite); + player->SendDirectMessage(&data); } -void CalendarMgr::SendCalendarEventRemovedAlert(uint64 guid, CalendarEvent const& calendarEvent) +void CalendarMgr::SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status) { if (Player* player = ObjectAccessor::FindPlayer(guid)) - player->GetSession()->SendCalendarEventRemovedAlert(calendarEvent); + { + WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_REMOVED_ALERT, 8 + 4 + 4 + 1); + data << uint64(calendarEvent.GetEventId()); + data.AppendPackedTime(calendarEvent.GetEventTime()); + data << uint32(calendarEvent.GetFlags()); + data << uint8(status); + + player->SendDirectMessage(&data); + } } -void CalendarMgr::SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status) +void CalendarMgr::SendCalendarClearPendingAction(uint64 guid) { if (Player* player = ObjectAccessor::FindPlayer(guid)) - player->GetSession()->SendCalendarEventInviteRemoveAlert(calendarEvent, status); + { + WorldPacket data(SMSG_CALENDAR_CLEAR_PENDING_ACTION, 0); + player->SendDirectMessage(&data); + } } -void CalendarMgr::SendCalendarEventInviteRemove(uint64 guid, CalendarInvite const& invite, uint32 flags) +void CalendarMgr::SendCalendarCommandResult(uint64 guid, CalendarError err, char const* param /*= NULL*/) { if (Player* player = ObjectAccessor::FindPlayer(guid)) - player->GetSession()->SendCalendarEventInviteRemove(invite, flags); + { + WorldPacket data(SMSG_CALENDAR_COMMAND_RESULT, 0); + data << uint32(0); + data << uint8(0); + switch (err) + { + case CALENDAR_ERROR_OTHER_INVITES_EXCEEDED: + case CALENDAR_ERROR_ALREADY_INVITED_TO_EVENT_S: + case CALENDAR_ERROR_IGNORING_YOU_S: + data << param; + break; + default: + data << uint8(0); + break; + } + + data << uint32(err); + + player->SendDirectMessage(&data); + } } -void CalendarMgr::SendCalendarEventModeratorStatusAlert(CalendarInvite const& invite) +void CalendarMgr::SendPacketToAllEventRelatives(WorldPacket packet, CalendarEvent const& calendarEvent) { - if (Player* player = ObjectAccessor::FindPlayer(invite.GetInvitee())) - player->GetSession()->SendCalendarEventModeratorStatusAlert(invite); + // Send packet to all guild members + if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement()) + if (Guild* guild = sGuildMgr->GetGuildById(calendarEvent.GetGuildId())) + guild->BroadcastPacket(&packet); + + // Send packet to all invitees if event is non-guild, in other case only to non-guild invitees (packet was broadcasted for them) + std::vector invites = _invites[calendarEvent.GetEventId()]; + for (std::vector::iterator itr = invites.begin(); itr != invites.end(); ++itr) + if (Player* player = ObjectAccessor::FindPlayer((*itr)->GetInviteeGUID())) + if (!calendarEvent.IsGuildEvent() || (calendarEvent.IsGuildEvent() && player->GetGuildId() != calendarEvent.GetGuildId())) + player->SendDirectMessage(&packet); } diff --git a/src/server/game/Calendar/CalendarMgr.h b/src/server/game/Calendar/CalendarMgr.h index a8749778cb3..db6acb667ec 100644 --- a/src/server/game/Calendar/CalendarMgr.h +++ b/src/server/game/Calendar/CalendarMgr.h @@ -19,60 +19,311 @@ #define TRINITY_CALENDARMGR_H #include -#include "Calendar.h" +#include "Common.h" +#include "WorldPacket.h" + +enum CalendarMailAnswers +{ + // else + CALENDAR_EVENT_REMOVED_MAIL_SUBJECT = 0, + // if ( *(_DWORD *)(a1 + 8292) & 0x100 ) + CALENDAR_INVITE_REMOVED_MAIL_SUBJECT = 0x100 +}; + +enum CalendarFlags +{ + CALENDAR_FLAG_ALL_ALLOWED = 0x001, + CALENDAR_FLAG_INVITES_LOCKED = 0x010, + CALENDAR_FLAG_WITHOUT_INVITES = 0x040, + CALENDAR_FLAG_GUILD_EVENT = 0x400 +}; + +enum CalendarModerationRank +{ + CALENDAR_RANK_PLAYER = 0, + CALENDAR_RANK_MODERATOR = 1, + CALENDAR_RANK_OWNER = 2 +}; + +enum CalendarSendEventType +{ + CALENDAR_SENDTYPE_GET = 0, + CALENDAR_SENDTYPE_ADD = 1, + CALENDAR_SENDTYPE_COPY = 2 +}; + +enum CalendarEventType +{ + CALENDAR_TYPE_RAID = 0, + CALENDAR_TYPE_DUNGEON = 1, + CALENDAR_TYPE_PVP = 2, + CALENDAR_TYPE_MEETING = 3, + CALENDAR_TYPE_OTHER = 4 +}; + +enum CalendarRepeatType +{ + CALENDAR_REPEAT_NEVER = 0, + CALENDAR_REPEAT_WEEKLY = 1, + CALENDAR_REPEAT_BIWEEKLY = 2, + CALENDAR_REPEAT_MONTHLY = 3 +}; + +enum CalendarInviteStatus +{ + CALENDAR_STATUS_INVITED = 0, + CALENDAR_STATUS_ACCEPTED = 1, + CALENDAR_STATUS_DECLINED = 2, + CALENDAR_STATUS_CONFIRMED = 3, + CALENDAR_STATUS_OUT = 4, + CALENDAR_STATUS_STANDBY = 5, + CALENDAR_STATUS_SIGNED_UP = 6, + CALENDAR_STATUS_NOT_SIGNED_UP = 7, + CALENDAR_STATUS_TENTATIVE = 8, + CALENDAR_STATUS_REMOVED = 9 // correct name? +}; + +enum CalendarError +{ + CALENDAR_OK = 0, + CALENDAR_ERROR_GUILD_EVENTS_EXCEEDED = 1, + CALENDAR_ERROR_EVENTS_EXCEEDED = 2, + CALENDAR_ERROR_SELF_INVITES_EXCEEDED = 3, + CALENDAR_ERROR_OTHER_INVITES_EXCEEDED = 4, + CALENDAR_ERROR_PERMISSIONS = 5, + CALENDAR_ERROR_EVENT_INVALID = 6, + CALENDAR_ERROR_NOT_INVITED = 7, + CALENDAR_ERROR_INTERNAL = 8, + CALENDAR_ERROR_GUILD_PLAYER_NOT_IN_GUILD = 9, + CALENDAR_ERROR_ALREADY_INVITED_TO_EVENT_S = 10, + CALENDAR_ERROR_PLAYER_NOT_FOUND = 11, + CALENDAR_ERROR_NOT_ALLIED = 12, + CALENDAR_ERROR_IGNORING_YOU_S = 13, + CALENDAR_ERROR_INVITES_EXCEEDED = 14, + CALENDAR_ERROR_INVALID_DATE = 16, + CALENDAR_ERROR_INVALID_TIME = 17, + + CALENDAR_ERROR_NEEDS_TITLE = 19, + CALENDAR_ERROR_EVENT_PASSED = 20, + CALENDAR_ERROR_EVENT_LOCKED = 21, + CALENDAR_ERROR_DELETE_CREATOR_FAILED = 22, + CALENDAR_ERROR_SYSTEM_DISABLED = 24, + CALENDAR_ERROR_RESTRICTED_ACCOUNT = 25, + CALENDAR_ERROR_ARENA_EVENTS_EXCEEDED = 26, + CALENDAR_ERROR_RESTRICTED_LEVEL = 27, + CALENDAR_ERROR_USER_SQUELCHED = 28, + CALENDAR_ERROR_NO_INVITE = 29, + + CALENDAR_ERROR_EVENT_WRONG_SERVER = 36, + CALENDAR_ERROR_INVITE_WRONG_SERVER = 37, + CALENDAR_ERROR_NO_GUILD_INVITES = 38, + CALENDAR_ERROR_INVALID_SIGNUP = 39, + CALENDAR_ERROR_NO_MODERATOR = 40 +}; + +#define CALENDAR_MAX_EVENTS 30 +#define CALENDAR_MAX_GUILD_EVENTS 100 +#define CALENDAR_MAX_INVITES 100 + +struct CalendarInvite +{ + public: + CalendarInvite(CalendarInvite const& calendarInvite, uint64 inviteId, uint64 eventId) + { + _inviteId = inviteId; + _eventId = eventId; + _invitee = calendarInvite.GetInviteeGUID(); + _senderGUID = calendarInvite.GetSenderGUID(); + _statusTime = calendarInvite.GetStatusTime(); + _status = calendarInvite.GetStatus(); + _rank = calendarInvite.GetRank(); + _text = calendarInvite.GetText(); + } + + CalendarInvite() : _inviteId(1), _eventId(0), _invitee(0), _senderGUID(0), _statusTime(time(NULL)), + _status(CALENDAR_STATUS_INVITED), _rank(CALENDAR_RANK_PLAYER), _text("") { } + + CalendarInvite(uint64 inviteId, uint64 eventId, uint64 invitee, uint64 senderGUID, time_t statusTime, + CalendarInviteStatus status, CalendarModerationRank rank, std::string text) : + _inviteId(inviteId), _eventId(eventId), _invitee(invitee), _senderGUID(senderGUID), _statusTime(statusTime), + _status(status), _rank(rank), _text(text) { } + + ~CalendarInvite(); + + void SetInviteId(uint64 inviteId) { _inviteId = inviteId; } + uint64 GetInviteId() const { return _inviteId; } + + void SetEventId(uint64 eventId) { _eventId = eventId; } + uint64 GetEventId() const { return _eventId; } + + void SetSenderGUID(uint64 guid) { _senderGUID = guid; } + uint64 GetSenderGUID() const { return _senderGUID; } + + void SetInvitee(uint64 guid) { _invitee = guid; } + uint64 GetInviteeGUID() const { return _invitee; } + + void SetStatusTime(time_t statusTime) { _statusTime = statusTime; } + time_t GetStatusTime() const { return _statusTime; } + + void SetText(std::string text) { _text = text; } + std::string GetText() const { return _text; } + + void SetStatus(CalendarInviteStatus status) { _status = status; } + CalendarInviteStatus GetStatus() const { return _status; } + + void SetRank(CalendarModerationRank rank) { _rank = rank; } + CalendarModerationRank GetRank() const { return _rank; } + + private: + uint64 _inviteId; + uint64 _eventId; + uint64 _invitee; + uint64 _senderGUID; + time_t _statusTime; + CalendarInviteStatus _status; + CalendarModerationRank _rank; + std::string _text; +}; + +struct CalendarEvent +{ + public: + CalendarEvent(CalendarEvent const& calendarEvent, uint64 eventId) + { + _eventId = eventId; + _creatorGUID = calendarEvent.GetCreatorGUID(); + _guildId = calendarEvent.GetGuildId(); + _type = calendarEvent.GetType(); + _dungeonId = calendarEvent.GetDungeonId(); + _eventTime = calendarEvent.GetEventTime(); + _flags = calendarEvent.GetFlags(); + _timezoneTime = calendarEvent.GetTimeZoneTime(); + _title = calendarEvent.GetTitle(); + _description = calendarEvent.GetDescription(); + } + + CalendarEvent(uint64 eventId, uint64 creatorGUID, uint32 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), + _description(description) { } + + CalendarEvent() : _eventId(1), _creatorGUID(0), _guildId(0), _type(CALENDAR_TYPE_OTHER), _dungeonId(-1), _eventTime(0), + _flags(0), _timezoneTime(0), _title(""), _description("") { } + + ~CalendarEvent(); + + void SetEventId(uint64 eventId) { _eventId = eventId; } + uint64 GetEventId() const { return _eventId; } + + void SetCreatorGUID(uint64 guid) { _creatorGUID = guid; } + uint64 GetCreatorGUID() const { return _creatorGUID; } + + void SetGuildId(uint32 guildId) { _guildId = guildId; } + uint32 GetGuildId() const { return _guildId; } + + void SetTitle(std::string title) { _title = title; } + std::string GetTitle() const { return _title; } + + void SetDescription(std::string description) { _description = description; } + std::string GetDescription() const { return _description; } + + void SetType(CalendarEventType type) { _type = type; } + CalendarEventType GetType() const { return _type; } + + void SetDungeonId(int32 dungeonId) { _dungeonId = dungeonId; } + int32 GetDungeonId() const { return _dungeonId; } + + void SetEventTime(time_t eventTime) { _eventTime = eventTime; } + time_t GetEventTime() const { return _eventTime; } + + void SetFlags(uint32 flags) { _flags = flags; } + uint32 GetFlags() const { return _flags; } + + void SetTimeZoneTime(time_t timezoneTime) { _timezoneTime = timezoneTime; } + time_t GetTimeZoneTime() const { return _timezoneTime; } + + bool IsGuildEvent() const { return _flags & CALENDAR_FLAG_GUILD_EVENT; } + bool IsGuildAnnouncement() const { return _flags & CALENDAR_FLAG_WITHOUT_INVITES; } + + std::string BuildCalendarMailSubject(uint64 remover) const; + std::string BuildCalendarMailBody() const; + + private: + uint64 _eventId; + uint64 _creatorGUID; + uint32 _guildId; + CalendarEventType _type; + int32 _dungeonId; + time_t _eventTime; + uint32 _flags; + time_t _timezoneTime; + std::string _title; + std::string _description; +}; + +typedef std::set CalendarEventStore; +typedef std::map > CalendarInviteStore; class CalendarMgr { - friend class ACE_Singleton; + friend class ACE_Singleton; + private: CalendarMgr(); ~CalendarMgr(); + CalendarEventStore _events; + CalendarInviteStore _invites; + + std::deque _freeEventIds; + std::deque _freeInviteIds; + uint64 _maxEventId; + uint64 _maxInviteId; + public: void LoadFromDB(); - CalendarInvite* GetInvite(uint64 inviteId); CalendarEvent* GetEvent(uint64 eventId); + CalendarEventStore const& GetEvents() const { return _events; } + CalendarEventStore GetPlayerEvents(uint64 guid); - CalendarInviteIdList const& GetPlayerInvites(uint64 guid); - CalendarEventIdList const& GetPlayerEvents(uint64 guid); + CalendarInvite* GetInvite(uint64 inviteId); + CalendarInviteStore const& GetInvites() const { return _invites; } + std::vector GetEventInvites(uint64 eventId); + std::vector GetPlayerInvites(uint64 guid); - uint32 GetPlayerNumPending(uint64 guid); + void FreeEventId(uint64 id); uint64 GetFreeEventId(); + void FreeInviteId(uint64 id); uint64 GetFreeInviteId(); - void AddAction(CalendarAction const& action); - - void SendCalendarEvent(CalendarEvent const& calendarEvent, CalendarSendEventType type); - void SendCalendarEventInvite(CalendarInvite const& invite, bool pending); - void SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite); - void SendCalendarEventInviteRemove(uint64 guid, CalendarInvite const& invite, uint32 flags); - void SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status); - void SendCalendarEventUpdateAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarSendEventType type); - void SendCalendarEventStatus(uint64 guid, CalendarEvent const& calendarEvent, CalendarInvite const& invite); - void SendCalendarEventRemovedAlert(uint64 guid, CalendarEvent const& calendarEvent); - void SendCalendarEventModeratorStatusAlert(CalendarInvite const& invite); + uint32 GetPlayerNumPending(uint64 guid); - private: - CalendarEvent* CheckPermisions(uint64 eventId, Player* player, uint64 inviteId, CalendarModerationRank minRank); + void AddEvent(CalendarEvent* calendarEvent, CalendarSendEventType sendType); + void RemoveEvent(uint64 eventId, uint64 remover); + void UpdateEvent(CalendarEvent* calendarEvent); - bool AddEvent(CalendarEvent const& calendarEvent); - bool RemoveEvent(uint64 eventId); - bool AddPlayerEvent(uint64 guid, uint64 eventId); - bool RemovePlayerEvent(uint64 guid, uint64 eventId); + void AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite); + void RemoveInvite(uint64 inviteId, uint64 eventId, uint64 remover); + void UpdateInvite(CalendarInvite* invite); - bool AddInvite(CalendarInvite const& invite); - uint64 RemoveInvite(uint64 inviteId); - bool AddPlayerInvite(uint64 guid, uint64 inviteId); - bool RemovePlayerInvite(uint64 guid, uint64 inviteId); + void RemoveAllPlayerEventsAndInvites(uint64 guid); + void RemovePlayerGuildEventsAndSignups(uint64 guid, uint32 guildId); - CalendarEventMap _events; - CalendarInviteMap _invites; - CalendarPlayerInviteIdMap _playerInvites; - CalendarPlayerEventIdMap _playerEvents; + void SendCalendarEvent(uint64 guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType); + void SendCalendarEventInvite(CalendarInvite const& invite); + void SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite); + void SendCalendarEventInviteRemove(CalendarEvent const& calendarEvent, CalendarInvite const& invite, uint32 flags); + void SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status); + void SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, time_t oldEventTime); + void SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite); + void SendCalendarEventRemovedAlert(CalendarEvent const& calendarEvent); + void SendCalendarEventModeratorStatusAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite); + void SendCalendarClearPendingAction(uint64 guid); + void SendCalendarCommandResult(uint64 guid, CalendarError err, char const* param = NULL); - uint64 _eventNum; - uint64 _inviteNum; + void SendPacketToAllEventRelatives(WorldPacket packet, CalendarEvent const& calendarEvent); }; #define sCalendarMgr ACE_Singleton::instance() diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 4db293f0e89..e1be2049dad 100755 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -25,6 +25,7 @@ #include "SocialMgr.h" #include "Log.h" #include "AccountMgr.h" +#include "CalendarMgr.h" #define MAX_GUILD_BANK_TAB_TEXT_LEN 500 #define EMBLEM_PRICE 10 * GOLD @@ -1579,6 +1580,8 @@ void Guild::HandleLeaveMember(WorldSession* session) SendCommandResult(session, GUILD_COMMAND_QUIT, ERR_GUILD_COMMAND_SUCCESS, m_name); } + + sCalendarMgr->RemovePlayerGuildEventsAndSignups(player->GetGUID(), GetId()); } void Guild::HandleRemoveMember(WorldSession* session, std::string const& name) @@ -2138,6 +2141,39 @@ void Guild::BroadcastPacket(WorldPacket* packet) const player->GetSession()->SendPacket(packet); } +void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 maxLevel, uint32 minRank) +{ + uint32 count = 0; + + WorldPacket data(SMSG_CALENDAR_FILTER_GUILD); + data << uint32(count); // count placeholder + + for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) + { + // not sure if needed, maybe client checks it as well + if (count >= CALENDAR_MAX_INVITES) + { + if (Player* player = session->GetPlayer()) + sCalendarMgr->SendCalendarCommandResult(player->GetGUID(), CALENDAR_ERROR_INVITES_EXCEEDED); + return; + } + + Member* member = itr->second; + uint32 level = Player::GetLevelFromDB(member->GetGUID()); + + if (member->GetGUID() != session->GetPlayer()->GetGUID() && level >= minLevel && level <= maxLevel && member->IsRankNotLower(minRank)) + { + data.appendPackGUID(member->GetGUID()); + data << uint8(0); // unk + ++count; + } + } + + data.put(0, count); + + session->SendPacket(&data); +} + // Members handling bool Guild::AddMember(uint64 guid, uint8 rankId) { diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index a8bf5dcdb62..2f43245159b 100755 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -711,6 +711,8 @@ public: void BroadcastPacketToRank(WorldPacket* packet, uint8 rankId) const; void BroadcastPacket(WorldPacket* packet) const; + void MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 maxLevel, uint32 minRank); + template void BroadcastWorker(Do& _do, Player* except = NULL) { diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index 0cecd3d615a..8eb52ee3c0a 100755 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -19,131 +19,116 @@ /* ----- Opcodes Not Used yet ----- -SMSG_CALENDAR_CLEAR_PENDING_ACTION SendCalendarClearPendingAction() -SMSG_CALENDAR_RAID_LOCKOUT_UPDATED SendCalendarRaidLockoutUpdated(InstanceSave const* save) - ------ Opcodes without Sniffs ----- -SMSG_CALENDAR_FILTER_GUILD [ for (... uint32(count) { packguid(???), uint8(???) } ] -SMSG_CALENDAR_ARENA_TEAM [ for (... uint32(count) { packguid(???), uint8(???) } ] -CMSG_CALENDAR_EVENT_INVITE_NOTES [ packguid(Invitee), uint64(inviteId), string(Text), Boolean(Unk) ] -SMSG_CALENDAR_EVENT_INVITE_NOTES [ uint32(unk1), uint32(unk2), uint32(unk3), uint32(unk4), uint32(unk5) ] +SMSG_CALENDAR_EVENT_INVITE_NOTES [ packguid(Invitee), uint64(inviteId), string(Text), Boolean(Unk) ] +?CMSG_CALENDAR_EVENT_INVITE_NOTES [ uint32(unk1), uint32(unk2), uint32(unk3), uint32(unk4), uint32(unk5) ] SMSG_CALENDAR_EVENT_INVITE_NOTES_ALERT [ uint64(inviteId), string(Text) ] -SMSG_CALENDAR_EVENT_INVITE_STATUS_ALERT [ Structure unkown ] +SMSG_CALENDAR_EVENT_INVITE_STATUS_ALERT [ uint64(eventId), uint32(eventTime), uint32(unkFlag), uint8(deletePending) ] +SMSG_CALENDAR_RAID_LOCKOUT_UPDATED SendCalendarRaidLockoutUpdated(InstanceSave const* save) -*/ +----- TODO ----- -#include "Common.h" -#include "WorldPacket.h" -#include "WorldSession.h" +Finish complains' handling - what to do with received complains and how to respond? +Find out what to do with all "not used yet" opcodes +Correct errors sending (event/invite not found, invites exceeded, event already passed, permissions etc.) +Fix locked events to be displayed properly and response time shouldn't be shown for people that haven't respond yet +Copied events should probably have a new owner + +*/ #include "InstanceSaveMgr.h" #include "Log.h" #include "Opcodes.h" #include "Player.h" +#include "SocialMgr.h" #include "CalendarMgr.h" #include "ObjectMgr.h" #include "ObjectAccessor.h" #include "DatabaseEnv.h" +#include "GuildMgr.h" +#include "ArenaTeamMgr.h" +#include "WorldSession.h" void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) { uint64 guid = _player->GetGUID(); sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GET_CALENDAR [" UI64FMTD "]", guid); - time_t cur_time = time_t(time(NULL)); + time_t currTime = time(NULL); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_SEND_CALENDAR [" UI64FMTD "]", guid); - WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 1000); // Impossible to get the correct size without doing a double iteration of some elements + WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 1000); // Average size if no instance - CalendarInviteIdList const& invites = sCalendarMgr->GetPlayerInvites(guid); + std::vector invites = sCalendarMgr->GetPlayerInvites(guid); data << uint32(invites.size()); - for (CalendarInviteIdList::const_iterator it = invites.begin(); it != invites.end(); ++it) + for (std::vector::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) { - CalendarInvite* invite = sCalendarMgr->GetInvite(*it); - CalendarEvent* calendarEvent = invite ? sCalendarMgr->GetEvent(invite->GetEventId()) : NULL; + data << uint64((*itr)->GetEventId()); + data << uint64((*itr)->GetInviteId()); + data << uint8((*itr)->GetStatus()); + data << uint8((*itr)->GetRank()); - if (calendarEvent) + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent((*itr)->GetEventId())) { - data << uint64(invite->GetEventId()); - data << uint64(invite->GetInviteId()); - data << uint8(invite->GetStatus()); - data << uint8(invite->GetRank()); - data << uint8(calendarEvent->GetGuildId() != 0); + data << uint8(calendarEvent->IsGuildEvent()); data.appendPackGUID(calendarEvent->GetCreatorGUID()); } else { - sLog->outError(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_SEND_CALENDAR: No Invite found with id [" UI64FMTD "]", *it); - data << uint64(0); - data << uint64(0); - data << uint8(0); data << uint8(0); - data << uint8(0); - data.appendPackGUID(0); + data.appendPackGUID((*itr)->GetSenderGUID()); } } - CalendarEventIdList const& events = sCalendarMgr->GetPlayerEvents(guid); - data << uint32(events.size()); - for (CalendarEventIdList::const_iterator it = events.begin(); it != events.end(); ++it) + CalendarEventStore playerEvents = sCalendarMgr->GetPlayerEvents(guid); + data << uint32(playerEvents.size()); + for (CalendarEventStore::const_iterator itr = playerEvents.begin(); itr != playerEvents.end(); ++itr) { - if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(*it)) - { - data << uint64(*it); - data << calendarEvent->GetTitle(); - data << uint32(calendarEvent->GetType()); - data.AppendPackedTime(calendarEvent->GetTime()); - data << uint32(calendarEvent->GetFlags()); - data << uint32(calendarEvent->GetDungeonId()); - data.appendPackGUID(calendarEvent->GetCreatorGUID()); - } - else - { - sLog->outError(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_SEND_CALENDAR: No Event found with id [" UI64FMTD "]", *it); - data << uint64(0); - data << uint8(0); - data << uint32(0); - data << uint32(0); - data << uint32(0); - data << uint32(0); - data.appendPackGUID(0); - } + CalendarEvent* calendarEvent = *itr; + + data << uint64(calendarEvent->GetEventId()); + data << calendarEvent->GetTitle(); + data << uint32(calendarEvent->GetType()); + data.AppendPackedTime(calendarEvent->GetEventTime()); + data << uint32(calendarEvent->GetFlags()); + data << int32(calendarEvent->GetDungeonId()); + data.appendPackGUID(calendarEvent->GetCreatorGUID()); } - data << uint32(cur_time); // server time - data.AppendPackedTime(cur_time); // server time - - uint32 counter = 0; - size_t p_counter = data.wpos(); - data << uint32(counter); // instance save count + data << uint32(currTime); // server time + data.AppendPackedTime(currTime); // zone time + ByteBuffer dataBuffer; + uint32 boundCounter = 0; for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) - for (Player::BoundInstancesMap::const_iterator itr = _player->m_boundInstances[i].begin(); itr != _player->m_boundInstances[i].end(); ++itr) + { + Player::BoundInstancesMap boundInstances = _player->GetBoundInstances(Difficulty(i)); + for (Player::BoundInstancesMap::const_iterator itr = boundInstances.begin(); itr != boundInstances.end(); ++itr) + { if (itr->second.perm) { InstanceSave const* save = itr->second.save; - data << uint32(save->GetMapId()); - data << uint32(save->GetDifficulty()); - data << uint32(save->GetResetTime() - cur_time); - data << uint64(save->GetInstanceId()); // instance save id as unique instance copy id - ++counter; + dataBuffer << uint32(save->GetMapId()); + dataBuffer << uint32(save->GetDifficulty()); + dataBuffer << uint32(save->GetResetTime() - currTime); + dataBuffer << uint64(save->GetInstanceId()); // instance save id as unique instance copy id + ++boundCounter; } + } + } - data.put(p_counter, counter); - - data << uint32(1135753200); // unk (28.12.2005 07:00) + data << uint32(boundCounter); + data.append(dataBuffer); - counter = 0; - p_counter = data.wpos(); - data << uint32(counter); // raid reset count + data << uint32(1135753200); // Constant date, unk (28.12.2005 07:00) + // Reuse variables + boundCounter = 0; std::set sentMaps; + dataBuffer.clear(); ResetTimeByMapDifficultyMap const& resets = sInstanceSaveMgr->GetResetTimeMap(); for (ResetTimeByMapDifficultyMap::const_iterator itr = resets.begin(); itr != resets.end(); ++itr) { uint32 mapId = PAIR32_LOPART(itr->first); - if (sentMaps.find(mapId) != sentMaps.end()) continue; @@ -153,12 +138,14 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) sentMaps.insert(mapId); - data << uint32(mapId); - data << uint32(itr->second - cur_time); - data << uint32(mapEntry->unk_time); - ++counter; + dataBuffer << int32(mapId); + dataBuffer << int32(itr->second - currTime); + dataBuffer << int32(0); // Never seen anything else in sniffs - still unknown + ++boundCounter; } - data.put(p_counter, counter); + + data << uint32(boundCounter); + data.append(dataBuffer); // TODO: Fix this, how we do know how many and what holidays to send? uint32 holidayCount = 0; @@ -174,7 +161,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) data << uint32(holiday->CalendarFilterType); // m_calendarFilterType for (uint8 j = 0; j < MAX_HOLIDAY_DATES; ++j) - data << uint32(holiday->Date[j]); // 26 * m_date + data << uint32(holiday->Date[j]); // 26 * m_date -- WritePackedTime ? for (uint8 j = 0; j < MAX_HOLIDAY_DURATIONS; ++j) data << uint32(holiday->Duration[j]); // 10 * m_duration @@ -193,133 +180,114 @@ void WorldSession::HandleCalendarGetEvent(WorldPacket& recvData) uint64 eventId; recvData >> eventId; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GET_EVENT. Event: [" + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GET_EVENT. Player [" UI64FMTD "] Event [" UI64FMTD "]", _player->GetGUID(), eventId); if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) - SendCalendarEvent(*calendarEvent, CALENDAR_SENDTYPE_GET); + sCalendarMgr->SendCalendarEvent(_player->GetGUID(), *calendarEvent, CALENDAR_SENDTYPE_GET); + else + sCalendarMgr->SendCalendarCommandResult(_player->GetGUID(), CALENDAR_ERROR_EVENT_INVALID); } void WorldSession::HandleCalendarGuildFilter(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GUILD_FILTER [" UI64FMTD "]", _player->GetGUID()); - int32 unk1, unk2, unk3; - recvData >> unk1; - recvData >> unk2; - recvData >> unk3; + uint32 minLevel; + uint32 maxLevel; + uint32 minRank; + + recvData >> minLevel >> maxLevel >> minRank; + + if (Guild* guild = sGuildMgr->GetGuildById(_player->GetGuildId())) + guild->MassInviteToEvent(this, minLevel, maxLevel, minRank); - sLog->outDebug(LOG_FILTER_NETWORKIO, "Calendar: CMSG_CALENDAR_GUILD_FILTER - unk1: %d unk2: %d unk3: %d", unk1, unk2, unk3); + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GUILD_FILTER: Min level [%d], Max level [%d], Min rank [%d]", minLevel, maxLevel, minRank); } void WorldSession::HandleCalendarArenaTeam(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_ARENA_TEAM [" UI64FMTD "]", _player->GetGUID()); - int32 unk1; - recvData >> unk1; + uint32 arenaTeamId; + recvData >> arenaTeamId; - sLog->outDebug(LOG_FILTER_NETWORKIO, "Calendar: CMSG_CALENDAR_ARENA_TEAM - unk1: %d", unk1); + if (ArenaTeam* team = sArenaTeamMgr->GetArenaTeamById(arenaTeamId)) + team->MassInviteToEvent(this); } void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) { uint64 guid = _player->GetGUID(); + std::string title; std::string description; uint8 type; - bool repeatable; + uint8 repeatable; uint32 maxInvites; int32 dungeonId; uint32 eventPackedTime; uint32 unkPackedTime; uint32 flags; - uint64 inviteId = 0; - uint64 invitee = 0; - uint8 status; - uint8 rank; - recvData >> title >> description >> type >> repeatable >> maxInvites; - recvData >> dungeonId; + recvData >> title >> description >> type >> repeatable >> maxInvites >> dungeonId; recvData.ReadPackedTime(eventPackedTime); recvData.ReadPackedTime(unkPackedTime); recvData >> flags; - if (!(flags & CALENDAR_FLAG_WITHOUT_INVITES)) + CalendarEvent* calendarEvent = new CalendarEvent(sCalendarMgr->GetFreeEventId(), guid, 0, CalendarEventType(type), dungeonId, + time_t(eventPackedTime), flags, time_t(unkPackedTime), title, description); + + if (calendarEvent->IsGuildEvent() || calendarEvent->IsGuildAnnouncement()) + if (Player* creator = ObjectAccessor::FindPlayer(guid)) + calendarEvent->SetGuildId(creator->GetGuildId()); + + if (calendarEvent->IsGuildAnnouncement()) + { + // 946684800 is 01/01/2000 00:00:00 - default response time + CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent->GetEventId(), 0, guid, 946684800, CALENDAR_STATUS_NOT_SIGNED_UP, CALENDAR_RANK_PLAYER, ""); + sCalendarMgr->AddInvite(calendarEvent, invite); + } + else { uint32 inviteCount; recvData >> inviteCount; - recvData.readPackGUID(invitee); - recvData >> status >> rank; - if (inviteCount != 1 || invitee != guid) + for (uint32 i = 0; i < inviteCount; ++i) { - sLog->outError(LOG_FILTER_NETWORKIO, "HandleCalendarAddEvent: [" UI64FMTD - "]: More than one invite (%d) or Invitee [" UI64FMTD - "] differs", guid, inviteCount, invitee); - return; + uint64 invitee = 0; + uint8 status = 0; + uint8 rank = 0; + recvData.readPackGUID(invitee); + recvData >> status >> rank; + + // 946684800 is 01/01/2000 00:00:00 - default response time + CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent->GetEventId(), invitee, guid, 946684800, CalendarInviteStatus(status), CalendarModerationRank(rank), ""); + sCalendarMgr->AddInvite(calendarEvent, invite); } - - inviteId = sCalendarMgr->GetFreeInviteId(); - } - else - { - inviteId = 0; - status = CALENDAR_STATUS_NO_OWNER; - rank = CALENDAR_RANK_PLAYER; } - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_ADD_EVENT: [" UI64FMTD "] " - "Title %s, Description %s, type %u, Repeatable %u, MaxInvites %u, " - "Dungeon ID %d, Time %u, Time2 %u, Flags %u, Invitee [" UI64FMTD "] " - "Status %d, Rank %d", guid, title.c_str(), description.c_str(), - type, repeatable, maxInvites, dungeonId, eventPackedTime, - unkPackedTime, flags, invitee, status, rank); - - CalendarAction action; - - action.SetAction(CALENDAR_ACTION_ADD_EVENT); - action.SetPlayer(_player); - action.Event.SetEventId(sCalendarMgr->GetFreeEventId()); - action.Event.SetCreatorGUID(guid); - action.Event.SetType((CalendarEventType) type); - action.Event.SetFlags(flags); - action.Event.SetTime(eventPackedTime); - action.Event.SetTimeZoneTime(unkPackedTime); - action.Event.SetRepeatable(repeatable); - action.Event.SetMaxInvites(maxInvites); - action.Event.SetDungeonId(dungeonId); - action.Event.SetGuildId((flags & CALENDAR_FLAG_GUILD_ONLY) ? GetPlayer()->GetGuildId() : 0); - action.Event.SetTitle(title); - action.Event.SetDescription(description); - action.Event.AddInvite(inviteId); - action.Invite.SetEventId(action.Event.GetEventId()); - action.Invite.SetInviteId(inviteId); - action.Invite.SetInvitee(invitee); - action.Invite.SetStatus((CalendarInviteStatus) status); - action.Invite.SetRank((CalendarModerationRank) rank); - action.Invite.SetSenderGUID(guid); - - sCalendarMgr->AddAction(action); + sCalendarMgr->AddEvent(calendarEvent, CALENDAR_SENDTYPE_ADD); } void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData) { uint64 guid = _player->GetGUID(); + time_t oldEventTime; + uint64 eventId; uint64 inviteId; std::string title; std::string description; uint8 type; - bool repeatable; + uint8 repetitionType; uint32 maxInvites; int32 dungeonId; uint32 eventPackedTime; uint32 timeZoneTime; uint32 flags; - recvData >> eventId >> inviteId >> title >> description >> type; - recvData >> repeatable >> maxInvites >> dungeonId; + recvData >> eventId >> inviteId >> title >> description >> type >> repetitionType >> maxInvites >> dungeonId; recvData.ReadPackedTime(eventPackedTime); recvData.ReadPackedTime(timeZoneTime); recvData >> flags; @@ -328,46 +296,37 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData) "], InviteId [" UI64FMTD "] Title %s, Description %s, type %u " "Repeatable %u, MaxInvites %u, Dungeon ID %d, Time %u " "Time2 %u, Flags %u", guid, eventId, inviteId, title.c_str(), - description.c_str(), type, repeatable, maxInvites, dungeonId, + description.c_str(), type, repetitionType, maxInvites, dungeonId, eventPackedTime, timeZoneTime, flags); - CalendarAction action; - action.SetAction(CALENDAR_ACTION_MODIFY_EVENT); - action.SetPlayer(_player); - action.SetInviteId(inviteId); - action.Event.SetEventId(eventId); - action.Event.SetType((CalendarEventType) type); - action.Event.SetFlags((CalendarFlags) flags); - action.Event.SetTime(eventPackedTime); - action.Event.SetTimeZoneTime(timeZoneTime); - action.Event.SetRepeatable(repeatable); - action.Event.SetDungeonId(dungeonId); - action.Event.SetTitle(title); - action.Event.SetDescription(description); - action.Event.SetMaxInvites(maxInvites); - - sCalendarMgr->AddAction(action); + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + { + oldEventTime = calendarEvent->GetEventTime(); + + calendarEvent->SetType(CalendarEventType(type)); + calendarEvent->SetFlags(flags); + calendarEvent->SetEventTime(time_t(eventPackedTime)); + calendarEvent->SetTimeZoneTime(time_t(timeZoneTime)); // Not sure, seems constant from the little sniffs we have + calendarEvent->SetDungeonId(dungeonId); + calendarEvent->SetTitle(title); + calendarEvent->SetDescription(description); + + sCalendarMgr->UpdateEvent(calendarEvent); + sCalendarMgr->SendCalendarEventUpdateAlert(*calendarEvent, oldEventTime); + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); } void WorldSession::HandleCalendarRemoveEvent(WorldPacket& recvData) { uint64 guid = _player->GetGUID(); uint64 eventId; - uint64 inviteId; - uint32 flags; - recvData >> eventId >> inviteId >> flags; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_REMOVE_EVENT [" UI64FMTD "], EventId [" UI64FMTD - "] inviteId [" UI64FMTD "] Flags?: %u", guid, eventId, inviteId, flags); - - CalendarAction action; - action.SetAction(CALENDAR_ACTION_REMOVE_EVENT); - action.SetPlayer(_player); - action.SetInviteId(inviteId); - action.Event.SetEventId(eventId); - action.Event.SetFlags((CalendarFlags) flags); + recvData >> eventId; + recvData.rfinish(); // Skip flags & invite ID, we don't use them - sCalendarMgr->AddAction(action); + sCalendarMgr->RemoveEvent(eventId, guid); } void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData) @@ -382,94 +341,140 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData) sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_COPY_EVENT [" UI64FMTD "], EventId [" UI64FMTD "] inviteId [" UI64FMTD "] Time: %u", guid, eventId, inviteId, time); - CalendarAction action; - action.SetAction(CALENDAR_ACTION_COPY_EVENT); - action.SetPlayer(_player); - action.SetInviteId(inviteId); - action.Event.SetEventId(eventId); - action.Event.SetTime(time); + if (CalendarEvent* oldEvent = sCalendarMgr->GetEvent(eventId)) + { + CalendarEvent* newEvent = new CalendarEvent(*oldEvent, sCalendarMgr->GetFreeEventId()); + newEvent->SetEventTime(time_t(time)); + sCalendarMgr->AddEvent(newEvent, CALENDAR_SENDTYPE_COPY); + + std::vector invites = sCalendarMgr->GetEventInvites(eventId); + + for (std::vector::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) + sCalendarMgr->AddInvite(newEvent, new CalendarInvite(**itr, sCalendarMgr->GetFreeInviteId(), newEvent->GetEventId())); - sCalendarMgr->AddAction(action); + // should we change owner when somebody makes a copy of event owned by another person? + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); } void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData) { - uint64 guid = _player->GetGUID(); + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_INVITE"); + + uint64 playerGuid = _player->GetGUID(); + uint64 eventId; uint64 inviteId; std::string name; - uint8 status; - uint8 rank; - uint64 invitee = 0; - uint32 team = 0; + bool isPreInvite; + bool isGuildEvent; + + uint64 inviteeGuid = 0; + uint32 inviteeTeam = 0; + uint32 inviteeGuildId = 0; - recvData >> eventId >> inviteId >> name >> status >> rank; - if (Player* player = sObjectAccessor->FindPlayerByName(name)) + recvData >> eventId >> inviteId >> name >> isPreInvite >> isGuildEvent; + + if (Player* player = sObjectAccessor->FindPlayerByName(name.c_str())) { - invitee = player->GetGUID(); - team = player->GetTeam(); + // Invitee is online + inviteeGuid = player->GetGUID(); + inviteeTeam = player->GetTeam(); + inviteeGuildId = player->GetGuildId(); } else { + // Invitee offline, get data from database PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUID_RACE_ACC_BY_NAME); stmt->setString(0, name); if (PreparedQueryResult result = CharacterDatabase.Query(stmt)) { Field* fields = result->Fetch(); - invitee = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER); - team = Player::TeamForRace(fields[1].GetUInt8()); + inviteeGuid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER); + inviteeTeam = Player::TeamForRace(fields[1].GetUInt8()); + inviteeGuildId = Player::GetGuildIdFromDB(inviteeGuid); } } - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_INVITE [" UI64FMTD "], EventId [" - UI64FMTD "] InviteId [" UI64FMTD "] Name %s ([" UI64FMTD "]), status %u, " - "Rank %u", guid, eventId, inviteId, name.c_str(), invitee, status, rank); - - if (!invitee) + if (!inviteeGuid) { - SendCalendarCommandResult(CALENDAR_ERROR_PLAYER_NOT_FOUND); + sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_PLAYER_NOT_FOUND); return; } - if (_player->GetTeam() != team && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CALENDAR)) + if (_player->GetTeam() != inviteeTeam && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CALENDAR)) { - SendCalendarCommandResult(CALENDAR_ERROR_NOT_ALLIED); + sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NOT_ALLIED); return; } - // TODO: Check ignore, even if offline (db query) + if (QueryResult result = CharacterDatabase.PQuery("SELECT flags FROM character_social WHERE guid = " UI64FMTD " AND friend = " UI64FMTD, inviteeGuid, playerGuid)) + { + Field* fields = result->Fetch(); + if (fields[0].GetUInt8() & SOCIAL_FLAG_IGNORED) + { + sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_IGNORING_YOU_S, name.c_str()); + return; + } + } + + if (!isPreInvite) + { + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + { + if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == inviteeGuildId) + { + // we can't invite guild members to guild events + sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NO_GUILD_INVITES); + return; + } - CalendarAction action; - action.SetAction(CALENDAR_ACTION_ADD_EVENT_INVITE); - action.SetPlayer(_player); - action.SetInviteId(inviteId); - action.Invite.SetEventId(eventId); - action.Invite.SetInviteId(sCalendarMgr->GetFreeInviteId()); - action.Invite.SetSenderGUID(_player->GetGUID()); - action.Invite.SetInvitee(invitee); - action.Invite.SetRank((CalendarModerationRank) rank); - action.Invite.SetStatus((CalendarInviteStatus) status); + // 946684800 is 01/01/2000 00:00:00 - default response time + CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), eventId, inviteeGuid, playerGuid, 946684800, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, ""); + sCalendarMgr->AddInvite(calendarEvent, invite); + } + else + sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_EVENT_INVALID); + } + else + { + if (isGuildEvent && inviteeGuildId == _player->GetGuildId()) + { + sCalendarMgr->SendCalendarCommandResult(inviteeGuid, CALENDAR_ERROR_NO_GUILD_INVITES); + return; + } - sCalendarMgr->AddAction(action); + // 946684800 is 01/01/2000 00:00:00 - default response time + CalendarInvite* invite = new CalendarInvite(inviteId, 0, inviteeGuid, playerGuid, 946684800, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, ""); + sCalendarMgr->SendCalendarEventInvite(*invite); + } } void WorldSession::HandleCalendarEventSignup(WorldPacket& recvData) { uint64 guid = _player->GetGUID(); uint64 eventId; - uint8 status; + bool tentative; + + recvData >> eventId >> tentative; + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_SIGNUP [" UI64FMTD "] EventId [" UI64FMTD "] Tentative %u", guid, eventId, tentative); - recvData >> eventId >> status; - sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_SIGNUP [" UI64FMTD "] EventId [" - UI64FMTD "] Status %u", guid, eventId, status); - - CalendarAction action; - action.SetAction(CALENDAR_ACTION_SIGNUP_TO_EVENT); - action.SetPlayer(_player); - action.SetExtraData(GetPlayer()->GetGuildId()); - action.Event.SetEventId(eventId); - action.Invite.SetStatus((CalendarInviteStatus) status); - sCalendarMgr->AddAction(action); + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + { + if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() != _player->GetGuildId()) + { + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_GUILD_PLAYER_NOT_IN_GUILD); + return; + } + + CalendarInviteStatus status = tentative ? CALENDAR_STATUS_TENTATIVE : CALENDAR_STATUS_SIGNED_UP; + CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), eventId, guid, guid, time(NULL), status, CALENDAR_RANK_PLAYER, ""); + sCalendarMgr->AddInvite(calendarEvent, invite); + sCalendarMgr->SendCalendarClearPendingAction(guid); + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); } void WorldSession::HandleCalendarEventRsvp(WorldPacket& recvData) @@ -477,22 +482,36 @@ void WorldSession::HandleCalendarEventRsvp(WorldPacket& recvData) uint64 guid = _player->GetGUID(); uint64 eventId; uint64 inviteId; - uint8 status; + uint32 status; recvData >> eventId >> inviteId >> status; sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_RSVP [" UI64FMTD"] EventId [" UI64FMTD "], InviteId [" UI64FMTD "], status %u", guid, eventId, inviteId, status); - CalendarAction action; - action.SetAction(CALENDAR_ACTION_MODIFY_EVENT_INVITE); - action.SetPlayer(_player); - action.SetInviteId(inviteId); - action.Invite.SetInviteId(inviteId); - action.Invite.SetEventId(eventId); - action.Invite.SetStatus((CalendarInviteStatus) status); + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + { + // i think we still should be able to remove self from locked events + if (status != CALENDAR_STATUS_REMOVED && calendarEvent->GetFlags() & CALENDAR_FLAG_INVITES_LOCKED) + { + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_LOCKED); + return; + } + + if (CalendarInvite* invite = sCalendarMgr->GetInvite(inviteId)) + { + invite->SetStatus(CalendarInviteStatus(status)); + invite->SetStatusTime(time(NULL)); - sCalendarMgr->AddAction(action); + sCalendarMgr->UpdateInvite(invite); + sCalendarMgr->SendCalendarEventStatus(*calendarEvent, *invite); + sCalendarMgr->SendCalendarClearPendingAction(guid); + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_NO_INVITE); // correct? + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); } void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket& recvData) @@ -500,26 +519,29 @@ void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket& recvData) uint64 guid = _player->GetGUID(); uint64 invitee; uint64 eventId; - uint64 owninviteId; + uint64 ownerInviteId; // isn't it sender's inviteId? uint64 inviteId; recvData.readPackGUID(invitee); - recvData >> inviteId >> owninviteId >> eventId; + recvData >> inviteId >> ownerInviteId >> eventId; sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_REMOVE_INVITE [" - UI64FMTD "] EventId [" UI64FMTD "], OwnInviteId [" + UI64FMTD "] EventId [" UI64FMTD "], ownerInviteId [" UI64FMTD "], Invitee ([" UI64FMTD "] id: [" UI64FMTD "])", - guid, eventId, owninviteId, invitee, inviteId); + guid, eventId, ownerInviteId, invitee, inviteId); - CalendarAction action; - action.SetAction(CALENDAR_ACTION_REMOVE_EVENT_INVITE); - action.SetPlayer(_player); - action.SetInviteId(owninviteId); - action.Invite.SetInviteId(inviteId); - action.Invite.SetEventId(eventId); - action.Invite.SetInvitee(invitee); + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + { + if (calendarEvent->GetCreatorGUID() == invitee) + { + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_DELETE_CREATOR_FAILED); + return; + } - sCalendarMgr->AddAction(action); + sCalendarMgr->RemoveInvite(inviteId, eventId, guid); + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_NO_INVITE); } void WorldSession::HandleCalendarEventStatus(WorldPacket& recvData) @@ -528,25 +550,32 @@ void WorldSession::HandleCalendarEventStatus(WorldPacket& recvData) uint64 invitee; uint64 eventId; uint64 inviteId; - uint64 owninviteId; + uint64 ownerInviteId; // isn't it sender's inviteId? uint8 status; recvData.readPackGUID(invitee); - recvData >> eventId >> inviteId >> owninviteId >> status; + recvData >> eventId >> inviteId >> ownerInviteId >> status; sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_STATUS [" UI64FMTD"] EventId [" - UI64FMTD "] OwnInviteId [" UI64FMTD "], Invitee ([" UI64FMTD "] id: [" - UI64FMTD "], status %u", guid, eventId, owninviteId, invitee, inviteId, status); - - CalendarAction action; - action.SetAction(CALENDAR_ACTION_MODIFY_EVENT_INVITE); - action.SetPlayer(_player); - action.SetInviteId(owninviteId); - action.Invite.SetInviteId(inviteId); - action.Invite.SetEventId(eventId); - action.Invite.SetInvitee(invitee); - action.Invite.SetStatus((CalendarInviteStatus) status); - - sCalendarMgr->AddAction(action); + UI64FMTD "] ownerInviteId [" UI64FMTD "], Invitee ([" UI64FMTD "] id: [" + UI64FMTD "], status %u", guid, eventId, ownerInviteId, invitee, inviteId, status); + + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + { + if (CalendarInvite* invite = sCalendarMgr->GetInvite(inviteId)) + { + invite->SetStatus((CalendarInviteStatus)status); + // not sure if we should set response time when moderator changes invite status + //invite->SetStatusTime(time(NULL)); + + sCalendarMgr->UpdateInvite(invite); + sCalendarMgr->SendCalendarEventStatus(*calendarEvent, *invite); + sCalendarMgr->SendCalendarClearPendingAction(invitee); + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_NO_INVITE); // correct? + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); } void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket& recvData) @@ -555,25 +584,28 @@ void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket& recvData) uint64 invitee; uint64 eventId; uint64 inviteId; - uint64 owninviteId; - uint8 status; + uint64 ownerInviteId; // isn't it sender's inviteId? + uint8 rank; recvData.readPackGUID(invitee); - recvData >> eventId >> inviteId >> owninviteId >> status; + recvData >> eventId >> inviteId >> ownerInviteId >> rank; sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_MODERATOR_STATUS [" UI64FMTD "] EventId [" - UI64FMTD "] OwnInviteId [" UI64FMTD "], Invitee ([" UI64FMTD "] id: [" - UI64FMTD "], status %u", guid, eventId, owninviteId, invitee, inviteId, status); - - CalendarAction action; - action.SetAction(CALENDAR_ACTION_MODIFY_MODERATOR_EVENT_INVITE); - action.SetPlayer(_player); - action.SetInviteId(owninviteId); - action.Invite.SetInviteId(inviteId); - action.Invite.SetEventId(eventId); - action.Invite.SetInvitee(invitee); - action.Invite.SetStatus((CalendarInviteStatus) status); - - sCalendarMgr->AddAction(action); + UI64FMTD "] ownerInviteId [" UI64FMTD "], Invitee ([" UI64FMTD "] id: [" + UI64FMTD "], rank %u", guid, eventId, ownerInviteId, invitee, inviteId, rank); + + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + { + if (CalendarInvite* invite = sCalendarMgr->GetInvite(inviteId)) + { + invite->SetRank(CalendarModerationRank(rank)); + sCalendarMgr->UpdateInvite(invite); + sCalendarMgr->SendCalendarEventModeratorStatusAlert(*calendarEvent, *invite); + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_NO_INVITE); // correct? + } + else + sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); } void WorldSession::HandleCalendarComplain(WorldPacket& recvData) @@ -585,6 +617,8 @@ void WorldSession::HandleCalendarComplain(WorldPacket& recvData) recvData >> eventId >> complainGUID; sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_COMPLAIN [" UI64FMTD "] EventId [" UI64FMTD "] guid [" UI64FMTD "]", guid, eventId, complainGUID); + + // what to do with complains? } void WorldSession::HandleCalendarGetNumPending(WorldPacket& /*recvData*/) @@ -600,279 +634,23 @@ void WorldSession::HandleCalendarGetNumPending(WorldPacket& /*recvData*/) SendPacket(&data); } -// ----------------------------------- SEND ------------------------------------ - -void WorldSession::SendCalendarEvent(CalendarEvent const& calendarEvent, CalendarSendEventType sendEventType) -{ - uint64 eventId = calendarEvent.GetEventId(); - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_SEND_EVENT [" UI64FMTD "] EventId [" - UI64FMTD "] SendType %u", _player->GetGUID(), eventId, sendEventType); - - WorldPacket data(SMSG_CALENDAR_SEND_EVENT); - data << uint8(sendEventType); - data.appendPackGUID(calendarEvent.GetCreatorGUID()); - data << uint64(eventId); - data << calendarEvent.GetTitle(); - data << calendarEvent.GetDescription(); - data << uint8(calendarEvent.GetType()); - data << uint8(calendarEvent.GetRepeatable()); - data << uint32(calendarEvent.GetMaxInvites()); - data << int32(calendarEvent.GetDungeonId()); - data << uint32(calendarEvent.GetFlags()); - data.AppendPackedTime(calendarEvent.GetTime()); - data.AppendPackedTime(calendarEvent.GetTimeZoneTime()); - data << uint32(calendarEvent.GetGuildId()); - - CalendarInviteIdList const& invites = calendarEvent.GetInviteIdList(); - data << uint32(invites.size()); - for (CalendarInviteIdList::const_iterator it = invites.begin(); it != invites.end(); ++it) - { - if (CalendarInvite* invite = sCalendarMgr->GetInvite(*it)) - { - uint64 guid = invite->GetInvitee(); - Player* player = ObjectAccessor::FindPlayer(guid); - uint8 level = player ? player->getLevel() : Player::GetLevelFromDB(guid); - - data.appendPackGUID(guid); - data << uint8(level); - data << uint8(invite->GetStatus()); - data << uint8(invite->GetRank()); - data << uint8(calendarEvent.GetGuildId() != 0); - data << uint64(invite->GetInviteId()); - data << uint32(invite->GetStatusTime()); - data << invite->GetText(); - } - else - { - data.appendPackGUID(_player->GetGUID()); - data << uint8(0) << uint8(0) << uint8(0) << uint8(0) - << uint64(0) << uint32(0) << uint8(0); - - sLog->outError(LOG_FILTER_NETWORKIO, "SendCalendarEvent: No Invite found with id [" UI64FMTD "]", *it); - } - } - SendPacket(&data); -} - -void WorldSession::SendCalendarEventInvite(CalendarInvite const& invite, bool pending) -{ - uint64 guid = _player->GetGUID(); - uint64 eventId = invite.GetEventId(); - uint64 inviteId = invite.GetInviteId(); - uint64 invitee = invite.GetInvitee(); - uint8 status = invite.GetStatus(); - uint32 statusTime = invite.GetStatusTime(); - Player* player = ObjectAccessor::FindPlayer(invitee); - uint8 level = player ? player->getLevel() : Player::GetLevelFromDB(invitee); - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_INVITE [" UI64FMTD "] EventId [" - UI64FMTD "] InviteId [" UI64FMTD "] Invitee [" UI64FMTD "] " - " Level %u, Status %u, StatusTime %u" , guid, eventId, inviteId, - invitee, level, status, statusTime); - - WorldPacket data(SMSG_CALENDAR_EVENT_INVITE, 8 + 8 + 8 + 1 + 1 + 1 + (statusTime ? 4 : 0) + 1); - data.appendPackGUID(invitee); - data << uint64(eventId); - data << uint64(inviteId); - data << uint8(level); - data << uint8(status); - if (statusTime) - data << uint8(1) << uint32(statusTime); - else - data << uint8(0); - data << uint8(pending); - - SendPacket(&data); -} - -void WorldSession::SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite) -{ - uint64 guid = _player->GetGUID(); - uint64 eventId = calendarEvent.GetEventId(); - uint64 inviteId = invite.GetInviteId(); - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_INVITE_ALERT [" UI64FMTD "] EventId [" - UI64FMTD "] InviteId [" UI64FMTD "]", guid, eventId, inviteId); - - WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_ALERT); - data << uint64(eventId); - data << calendarEvent.GetTitle().c_str(); - data.AppendPackedTime(calendarEvent.GetTime()); - data << uint32(calendarEvent.GetFlags()); - data << uint32(calendarEvent.GetType()); - data << uint32(calendarEvent.GetDungeonId()); - data << uint64(inviteId); - data << uint8(invite.GetStatus()); - data << uint8(invite.GetRank()); - data.appendPackGUID(calendarEvent.GetCreatorGUID()); - data.appendPackGUID(invite.GetSenderGUID()); - SendPacket(&data); -} - -void WorldSession::SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, CalendarSendEventType sendEventType) +void WorldSession::HandleSetSavedInstanceExtend(WorldPacket& recvData) { - uint64 guid = _player->GetGUID(); - uint64 eventId = calendarEvent.GetEventId(); - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_UPDATED_ALERT [" - UI64FMTD "] EventId [" UI64FMTD "]", guid, eventId); - - - WorldPacket data(SMSG_CALENDAR_EVENT_UPDATED_ALERT, 1 + 8 + 4 + 4 + 4 + 1 + 4 + - calendarEvent.GetTitle().size() + calendarEvent.GetDescription().size() + 1 + 4 + 4); - data << uint8(sendEventType); - data << uint64(eventId); - data.AppendPackedTime(calendarEvent.GetTime()); - data << uint32(calendarEvent.GetFlags()); - data.AppendPackedTime(calendarEvent.GetTime()); - data << uint8(calendarEvent.GetType()); - data << uint32(calendarEvent.GetDungeonId()); - data << calendarEvent.GetTitle().c_str(); - data << calendarEvent.GetDescription().c_str(); - data << uint8(calendarEvent.GetRepeatable()); - data << uint32(calendarEvent.GetMaxInvites()); - data << uint32(0); // FIXME - SendPacket(&data); -} - -void WorldSession::SendCalendarEventRemovedAlert(CalendarEvent const& calendarEvent) -{ - uint64 guid = _player->GetGUID(); - uint64 eventId = calendarEvent.GetEventId(); - uint32 eventTime = calendarEvent.GetTime(); - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_REMOVED_ALERT [" UI64FMTD "] EventId [" - UI64FMTD "] Time %u", guid, eventId, eventTime); - - WorldPacket data(SMSG_CALENDAR_EVENT_REMOVED_ALERT, 1 + 8 + 1); - data << uint8(1); // FIXME: If true does not SignalEvent(EVENT_CALENDAR_ACTION_PENDING) - data << uint64(eventId); - data.AppendPackedTime(eventTime); - SendPacket(&data); -} - -void WorldSession::SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite) -{ - uint64 guid = _player->GetGUID(); - uint64 eventId = calendarEvent.GetEventId(); - uint64 inviteId = invite.GetInviteId(); - uint64 invitee = invite.GetInvitee(); - uint32 eventTime = calendarEvent.GetTime(); - uint32 flags = calendarEvent.GetFlags(); - uint8 status = invite.GetStatus(); - uint8 rank = invite.GetRank(); - uint32 statusTime = invite.GetStatusTime(); - - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_STATUS [" UI64FMTD "] EventId [" - UI64FMTD "] InviteId [" UI64FMTD "] Invitee [" UI64FMTD "] Time %u " - "Flags %u, Status %u, Rank %u, StatusTime %u", - guid, eventId, inviteId, invitee, eventTime, flags, status, rank, - statusTime); - - WorldPacket data(SMSG_CALENDAR_EVENT_STATUS, 8 + 8 + 4 + 4 + 1 + 1 + 4); - data.appendPackGUID(invitee); - data << uint64(eventId); - data.AppendPackedTime(eventTime); - data << uint32(flags); - data << uint8(status); - data << uint8(rank); - data.AppendPackedTime(statusTime); - SendPacket(&data); -} - -void WorldSession::SendCalendarEventModeratorStatusAlert(CalendarInvite const& invite) -{ - uint64 guid = _player->GetGUID(); - uint64 eventId = invite.GetEventId(); - uint64 invitee = invite.GetInvitee(); - uint8 status = invite.GetStatus(); - - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_MODERATOR_STATUS_ALERT [" UI64FMTD - "] Invitee [" UI64FMTD "] EventId [" UI64FMTD "] Status %u ", guid, - invitee, eventId, status); - - - WorldPacket data(SMSG_CALENDAR_EVENT_MODERATOR_STATUS_ALERT, 8 + 8 + 1 + 1); - data.appendPackGUID(invitee); - data << uint64(eventId); - data << uint8(status); - data << uint8(1); // FIXME - SendPacket(&data); -} - -void WorldSession::SendCalendarEventInviteRemoveAlert(CalendarEvent const& calendarEvent, CalendarInviteStatus status) -{ - uint64 guid = _player->GetGUID(); - uint64 eventId = calendarEvent.GetEventId(); - uint32 eventTime = calendarEvent.GetTime(); - uint32 flags = calendarEvent.GetFlags(); - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_INVITE_REMOVED_ALERT [" - UI64FMTD "] EventId [" UI64FMTD "] Time %u, Flags %u, Status %u", - guid, eventId, eventTime, flags, status); - - WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_REMOVED_ALERT, 8 + 4 + 4 + 1); - data << uint64(eventId); - data.AppendPackedTime(eventTime); - data << uint32(flags); - data << uint8(status); - SendPacket(&data); -} + uint32 mapId, difficulty; + uint8 toggleExtend; + recvData >> mapId >> difficulty>> toggleExtend; + sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_SET_SAVED_INSTANCE_EXTEND - MapId: %u, Difficulty: %u, ToggleExtend: %s", mapId, difficulty, toggleExtend ? "On" : "Off"); -void WorldSession::SendCalendarEventInviteRemove(CalendarInvite const& invite, uint32 flags) -{ - uint64 guid = _player->GetGUID(); - uint64 eventId = invite.GetEventId(); - uint64 invitee = invite.GetInvitee(); - - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_INVITE_REMOVED [" - UI64FMTD "] Invitee [" UI64FMTD "] EventId [" UI64FMTD - "] Flags %u", guid, invitee, eventId, flags); - - WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_REMOVED, 8 + 4 + 4 + 1); - data.appendPackGUID(invitee); - data << uint32(eventId); - data << uint32(flags); - data << uint8(1); // FIXME - SendPacket(&data); -} - -void WorldSession::SendCalendarClearPendingAction() -{ - uint64 guid = _player->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_CLEAR_PENDING_ACTION [" UI64FMTD "]", guid); + InstancePlayerBind* instanceBind = _player->GetBoundInstance(mapId, Difficulty(difficulty)); + if (!instanceBind || !instanceBind->save) + return; - WorldPacket data(SMSG_CALENDAR_CLEAR_PENDING_ACTION, 0); - SendPacket(&data); + InstanceSave* save = instanceBind->save; + // http://www.wowwiki.com/Instance_Lock_Extension + // SendCalendarRaidLockoutUpdated(save); } -void WorldSession::SendCalendarCommandResult(CalendarError err, char const* param /*= NULL*/) -{ - uint64 guid = _player->GetGUID(); - sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_COMMAND_RESULT [" UI64FMTD "] Value: %u", guid, err); - - WorldPacket data(SMSG_CALENDAR_COMMAND_RESULT, 0); - data << uint32(0); - data << uint8(0); - switch (err) - { - case CALENDAR_ERROR_OTHER_INVITES_EXCEEDED: - case CALENDAR_ERROR_ALREADY_INVITED_TO_EVENT_S: - case CALENDAR_ERROR_IGNORING_YOU_S: - data << param; - break; - default: - data << uint8(0); - break; - } - - data << uint32(err); - - SendPacket(&data); -} +// ----------------------------------- SEND ------------------------------------ void WorldSession::SendCalendarRaidLockout(InstanceSave const* save, bool add) { @@ -902,13 +680,13 @@ void WorldSession::SendCalendarRaidLockoutUpdated(InstanceSave const* save) sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_RAID_LOCKOUT_UPDATED [" UI64FMTD "] Map: %u, Difficulty %u", guid, save->GetMapId(), save->GetDifficulty()); - time_t cur_time = time_t(time(NULL)); + time_t currTime = time(NULL); WorldPacket data(SMSG_CALENDAR_RAID_LOCKOUT_UPDATED, 4 + 4 + 4 + 4 + 8); - data.AppendPackedTime(cur_time); + data.AppendPackedTime(currTime); data << uint32(save->GetMapId()); data << uint32(save->GetDifficulty()); data << uint32(0); // Amount of seconds that has changed to the reset time - data << uint32(save->GetResetTime() - cur_time); + data << uint32(save->GetResetTime() - currTime); SendPacket(&data); -} +} \ No newline at end of file diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 8e6cdbc9dc2..d0aad7072f7 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -44,6 +44,7 @@ #include "Battleground.h" #include "AccountMgr.h" #include "LFGMgr.h" +#include "CalendarMgr.h" class LoginQueryHolder : public SQLQueryHolder { @@ -726,6 +727,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket & recvData) sLog->outCharDump(dump.c_str(), GetAccountId(), GUID_LOPART(guid), name.c_str()); } + sCalendarMgr->RemoveAllPlayerEventsAndInvites(guid); Player::DeleteFromDB(guid, GetAccountId()); WorldPacket data(SMSG_CHAR_DELETE, 1); diff --git a/src/server/game/Handlers/MailHandler.cpp b/src/server/game/Handlers/MailHandler.cpp index 5a7a3b52b56..cb3a6d920b8 100755 --- a/src/server/game/Handlers/MailHandler.cpp +++ b/src/server/game/Handlers/MailHandler.cpp @@ -607,10 +607,8 @@ void WorldSession::HandleGetMailList(WorldPacket & recvData) case MAIL_CREATURE: case MAIL_GAMEOBJECT: case MAIL_AUCTION: - data << uint32((*itr)->sender); // creature/gameobject entry, auction id - break; - case MAIL_ITEM: // item entry (?) sender = "Unknown", NYI - data << uint32(0); // item entry + case MAIL_CALENDAR: + data << uint32((*itr)->sender); // creature/gameobject entry, auction id, calendar event id? break; } diff --git a/src/server/game/Mails/Mail.cpp b/src/server/game/Mails/Mail.cpp index 929a1d81d57..108856d81b6 100755 --- a/src/server/game/Mails/Mail.cpp +++ b/src/server/game/Mails/Mail.cpp @@ -26,6 +26,7 @@ #include "BattlegroundMgr.h" #include "Item.h" #include "AuctionHouseMgr.h" +#include "CalendarMgr.h" MailSender::MailSender(Object* sender, MailStationery stationery) : m_stationery(stationery) { @@ -39,10 +40,10 @@ MailSender::MailSender(Object* sender, MailStationery stationery) : m_stationery m_messageType = MAIL_GAMEOBJECT; m_senderId = sender->GetEntry(); break; - case TYPEID_ITEM: + /*case TYPEID_ITEM: m_messageType = MAIL_ITEM; m_senderId = sender->GetEntry(); - break; + break;*/ case TYPEID_PLAYER: m_messageType = MAIL_NORMAL; m_senderId = sender->GetGUIDLow(); @@ -55,6 +56,11 @@ MailSender::MailSender(Object* sender, MailStationery stationery) : m_stationery } } +MailSender::MailSender(CalendarEvent* sender) + : m_messageType(MAIL_CALENDAR), m_senderId(sender->GetEventId()), m_stationery(MAIL_STATIONERY_DEFAULT) // what stationery we should use here? +{ +} + MailSender::MailSender(AuctionEntry* sender) : m_messageType(MAIL_AUCTION), m_senderId(sender->GetHouseId()), m_stationery(MAIL_STATIONERY_AUCTION) { diff --git a/src/server/game/Mails/Mail.h b/src/server/game/Mails/Mail.h index 7c12ac1a1c6..c2771f4b57c 100755 --- a/src/server/game/Mails/Mail.h +++ b/src/server/game/Mails/Mail.h @@ -23,6 +23,7 @@ #include struct AuctionEntry; +struct CalendarEvent; class Item; class Object; class Player; @@ -36,7 +37,7 @@ enum MailMessageType MAIL_AUCTION = 2, MAIL_CREATURE = 3, // client send CMSG_CREATURE_QUERY on this mailmessagetype MAIL_GAMEOBJECT = 4, // client send CMSG_GAMEOBJECT_QUERY on this mailmessagetype - MAIL_ITEM = 5 // client send CMSG_ITEM_QUERY on this mailmessagetype + MAIL_CALENDAR = 5 }; enum MailCheckMask @@ -85,6 +86,7 @@ class MailSender { } MailSender(Object* sender, MailStationery stationery = MAIL_STATIONERY_DEFAULT); + MailSender(CalendarEvent* sender); MailSender(AuctionEntry* sender); MailSender(Player* sender); public: // Accessors diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index 57e92c77655..810419bc2ea 100755 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -3428,104 +3428,6 @@ enum DuelCompleteType DUEL_WON = 1, DUEL_FLED = 2 }; - -enum CalendarFlags -{ - CALENDAR_FLAG_ALL_ALLOWED = 0x001, - CALENDAR_FLAG_INVITES_LOCKED = 0x010, - CALENDAR_FLAG_WITHOUT_INVITES = 0x040, - CALENDAR_FLAG_GUILD_ONLY = 0x400 -}; - -enum CalendarActionData -{ - CALENDAR_ACTION_NONE, - CALENDAR_ACTION_ADD_EVENT, - CALENDAR_ACTION_MODIFY_EVENT, - CALENDAR_ACTION_REMOVE_EVENT, - CALENDAR_ACTION_COPY_EVENT, - CALENDAR_ACTION_ADD_EVENT_INVITE, - CALENDAR_ACTION_MODIFY_EVENT_INVITE, - CALENDAR_ACTION_MODIFY_MODERATOR_EVENT_INVITE, - CALENDAR_ACTION_REMOVE_EVENT_INVITE, - CALENDAR_ACTION_SIGNUP_TO_EVENT -}; - -enum CalendarModerationRank -{ - CALENDAR_RANK_PLAYER, - CALENDAR_RANK_MODERATOR, - CALENDAR_RANK_OWNER -}; - -enum CalendarSendEventType -{ - CALENDAR_SENDTYPE_GET, - CALENDAR_SENDTYPE_ADD, - CALENDAR_SENDTYPE_COPY -}; - -enum CalendarEventType -{ - CALENDAR_TYPE_RAID, - CALENDAR_TYPE_DUNGEON, - CALENDAR_TYPE_PVP, - CALENDAR_TYPE_MEETING, - CALENDAR_TYPE_OTHER -}; - -enum CalendarInviteStatus -{ - CALENDAR_STATUS_INVITED, - CALENDAR_STATUS_ACCEPTED, - CALENDAR_STATUS_DECLINED, - CALENDAR_STATUS_TENTATIVE, - CALENDAR_STATUS_OUT, - CALENDAR_STATUS_STANDBY, - CALENDAR_STATUS_CONFIRMED, - CALENDAR_STATUS_NO_OWNER, - CALENDAR_STATUS_8, - CALENDAR_STATUS_9 -}; - -enum CalendarError -{ - CALENDAR_OK = 0, - CALENDAR_ERROR_GUILD_EVENTS_EXCEEDED = 1, - CALENDAR_ERROR_EVENTS_EXCEEDED = 2, - CALENDAR_ERROR_SELF_INVITES_EXCEEDED = 3, - CALENDAR_ERROR_OTHER_INVITES_EXCEEDED = 4, - CALENDAR_ERROR_PERMISSIONS = 5, - CALENDAR_ERROR_EVENT_INVALID = 6, - CALENDAR_ERROR_NOT_INVITED = 7, - CALENDAR_ERROR_INTERNAL = 8, - CALENDAR_ERROR_GUILD_PLAYER_NOT_IN_GUILD = 9, - CALENDAR_ERROR_ALREADY_INVITED_TO_EVENT_S = 10, - CALENDAR_ERROR_PLAYER_NOT_FOUND = 11, - CALENDAR_ERROR_NOT_ALLIED = 12, - CALENDAR_ERROR_IGNORING_YOU_S = 13, - CALENDAR_ERROR_INVITES_EXCEEDED = 14, - CALENDAR_ERROR_INVALID_DATE = 16, - CALENDAR_ERROR_INVALID_TIME = 17, - - CALENDAR_ERROR_NEEDS_TITLE = 19, - CALENDAR_ERROR_EVENT_PASSED = 20, - CALENDAR_ERROR_EVENT_LOCKED = 21, - CALENDAR_ERROR_DELETE_CREATOR_FAILED = 22, - CALENDAR_ERROR_SYSTEM_DISABLED = 24, - CALENDAR_ERROR_RESTRICTED_ACCOUNT = 25, - CALENDAR_ERROR_ARENA_EVENTS_EXCEEDED = 26, - CALENDAR_ERROR_RESTRICTED_LEVEL = 27, - CALENDAR_ERROR_USER_SQUELCHED = 28, - CALENDAR_ERROR_NO_INVITE = 29, - - CALENDAR_ERROR_EVENT_WRONG_SERVER = 36, - CALENDAR_ERROR_INVITE_WRONG_SERVER = 37, - CALENDAR_ERROR_NO_GUILD_INVITES = 38, - CALENDAR_ERROR_INVALID_SIGNUP = 39, - CALENDAR_ERROR_NO_MODERATOR = 40 -}; - // handle the queue types and bg types separately to enable joining queue for different sized arenas at the same time enum BattlegroundQueueTypeId { diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index 9078f6720a0..0821be2abb9 100755 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -684,7 +684,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x28F*/ { "CMSG_GROUP_ASSISTANT_LEADER", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGroupAssistantLeaderOpcode}, /*0x290*/ { "CMSG_BUYBACK_ITEM", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBuybackItem }, /*0x291*/ { "SMSG_SERVER_MESSAGE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x292*/ { "CMSG_SET_SAVED_INSTANCE_EXTEND", STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x292*/ { "CMSG_SET_SAVED_INSTANCE_EXTEND", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleSetSavedInstanceExtend }, /*0x293*/ { "SMSG_LFG_OFFER_CONTINUE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x294*/ { "CMSG_TEST_DROP_RATE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x295*/ { "SMSG_TEST_DROP_RATE_RESULT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 1158559f315..2060ab54cba 100755 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -31,8 +31,6 @@ #include "WorldPacket.h" #include "Cryptography/BigNumber.h" -class CalendarEvent; -class CalendarInvite; class Creature; class GameObject; class InstanceSave; @@ -904,19 +902,9 @@ class WorldSession void HandleCalendarGetNumPending(WorldPacket& recvData); void HandleCalendarEventSignup(WorldPacket& recvData); - void SendCalendarEvent(CalendarEvent const& calendarEvent, CalendarSendEventType sendEventType); - void SendCalendarEventInvite(CalendarInvite const& invite, bool pending); - void SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& calendarInvite); - void SendCalendarEventInviteRemove(CalendarInvite const& invite, uint32 flags); - void SendCalendarEventInviteRemoveAlert(CalendarEvent const& calendarEvent, CalendarInviteStatus status); - void SendCalendarEventRemovedAlert(CalendarEvent const& calendarEvent); - void SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, CalendarSendEventType sendEventType); - void SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite); - void SendCalendarEventModeratorStatusAlert(CalendarInvite const& invite); - void SendCalendarClearPendingAction(); void SendCalendarRaidLockout(InstanceSave const* save, bool add); void SendCalendarRaidLockoutUpdated(InstanceSave const* save); - void SendCalendarCommandResult(CalendarError err, char const* param = NULL); + void HandleSetSavedInstanceExtend(WorldPacket& recvData); void HandleSpellClick(WorldPacket& recvData); void HandleMirrorImageDataRequest(WorldPacket& recvData); diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp index db9a5646a69..5210ee6f39d 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/shared/Database/Implementation/CharacterDatabase.cpp @@ -535,4 +535,10 @@ void CharacterDatabaseConnection::DoPrepareStatements() PREPARE_STATEMENT(CHAR_INS_CHAR_TALENT, "INSERT INTO character_talent (guid, spell, spec) VALUES (?, ?, ?)", CONNECTION_ASYNC); PREPARE_STATEMENT(CHAR_DEL_CHAR_ACTION_EXCEPT_SPEC, "DELETE FROM character_action WHERE spec<>? AND guid = ?", CONNECTION_ASYNC); PREPARE_STATEMENT(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT, "SELECT id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, CreatedBySpell, PetType FROM character_pet WHERE owner = ? AND slot = ?", CONNECTION_SYNCH); + + // Calendar + PREPARE_STATEMENT(CHAR_REP_CALENDAR_EVENT, "REPLACE INTO calendar_events (id, creator, title, description, type, dungeon, eventtime, flags, time2) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PREPARE_STATEMENT(CHAR_DEL_CALENDAR_EVENT, "DELETE FROM calendar_events WHERE id = ?", CONNECTION_ASYNC); + PREPARE_STATEMENT(CHAR_REP_CALENDAR_INVITE, "REPLACE INTO calendar_invites (id, event, invitee, sender, status, statustime, rank, text) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PREPARE_STATEMENT(CHAR_DEL_CALENDAR_INVITE, "DELETE FROM calendar_invites WHERE id = ?", CONNECTION_ASYNC); } diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.h b/src/server/shared/Database/Implementation/CharacterDatabase.h index e421a7917ca..7e4fe6a0b0e 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.h +++ b/src/server/shared/Database/Implementation/CharacterDatabase.h @@ -496,6 +496,11 @@ enum CharacterDatabaseStatements CHAR_DEL_CHAR_ACTION_EXCEPT_SPEC, CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT, + CHAR_REP_CALENDAR_EVENT, + CHAR_DEL_CALENDAR_EVENT, + CHAR_REP_CALENDAR_INVITE, + CHAR_DEL_CALENDAR_INVITE, + MAX_CHARACTERDATABASE_STATEMENTS }; -- cgit v1.2.3 From b5c9ab88023c49ab0e3ab2365c789cd27a6629f1 Mon Sep 17 00:00:00 2001 From: Spp Date: Tue, 20 Nov 2012 12:30:30 +0100 Subject: Core/Misc: Reduction of header dependencies - Step II --- src/server/game/AI/SmartScripts/SmartAI.h | 1 - src/server/game/AI/SmartScripts/SmartScript.cpp | 22 +- src/server/game/AI/SmartScripts/SmartScript.h | 1 - src/server/game/Achievements/AchievementMgr.cpp | 34 +-- .../game/Battlefield/Zones/BattlefieldWG.cpp | 5 +- src/server/game/Battlegrounds/Battleground.cpp | 14 +- .../game/Battlegrounds/BattlegroundQueue.cpp | 9 +- .../game/Battlegrounds/Zones/BattlegroundDS.cpp | 5 +- src/server/game/Conditions/ConditionMgr.cpp | 13 +- src/server/game/Conditions/ConditionMgr.h | 5 +- src/server/game/DungeonFinding/LFGMgr.cpp | 1 + src/server/game/Entities/Creature/Creature.cpp | 54 ++--- src/server/game/Entities/Object/Object.cpp | 113 ---------- src/server/game/Entities/Pet/Pet.h | 67 +----- src/server/game/Entities/Pet/PetDefines.h | 80 +++++++ src/server/game/Entities/Player/Player.cpp | 250 +++++++++++++++------ src/server/game/Entities/Player/Player.h | 26 ++- src/server/game/Entities/Unit/Unit.cpp | 65 +++--- src/server/game/Globals/ObjectAccessor.cpp | 26 +-- src/server/game/Globals/ObjectMgr.cpp | 44 ++-- src/server/game/Guilds/Guild.cpp | 11 +- src/server/game/Handlers/AuctionHouseHandler.cpp | 1 + src/server/game/Handlers/CharacterHandler.cpp | 36 +-- src/server/game/Handlers/GroupHandler.cpp | 15 +- src/server/game/Handlers/LootHandler.cpp | 2 +- src/server/game/Handlers/NPCHandler.cpp | 1 + src/server/game/Handlers/SkillHandler.cpp | 7 +- src/server/game/Instances/InstanceScript.cpp | 13 +- src/server/game/Maps/Map.cpp | 21 +- src/server/game/Scripting/MapScripts.cpp | 13 +- src/server/game/Scripting/ScriptMgr.cpp | 4 +- src/server/game/Scripting/ScriptMgr.h | 2 +- src/server/game/Spells/Auras/SpellAuraEffects.cpp | 2 + src/server/game/Spells/SpellEffects.cpp | 1 + src/server/game/Tickets/TicketMgr.cpp | 1 + src/server/scripts/Commands/cs_account.cpp | 3 +- src/server/scripts/Commands/cs_achievement.cpp | 3 +- src/server/scripts/Commands/cs_ban.cpp | 5 +- src/server/scripts/Commands/cs_cast.cpp | 2 + src/server/scripts/Commands/cs_character.cpp | 5 +- src/server/scripts/Commands/cs_cheat.cpp | 5 +- src/server/scripts/Commands/cs_debug.cpp | 1 + src/server/scripts/Commands/cs_disable.cpp | 7 +- src/server/scripts/Commands/cs_event.cpp | 5 +- src/server/scripts/Commands/cs_gm.cpp | 1 + src/server/scripts/Commands/cs_go.cpp | 1 + src/server/scripts/Commands/cs_gobject.cpp | 1 + src/server/scripts/Commands/cs_guild.cpp | 3 +- src/server/scripts/Commands/cs_honor.cpp | 5 +- src/server/scripts/Commands/cs_learn.cpp | 2 + src/server/scripts/Commands/cs_lfg.cpp | 1 + src/server/scripts/Commands/cs_list.cpp | 1 + src/server/scripts/Commands/cs_lookup.cpp | 5 +- src/server/scripts/Commands/cs_message.cpp | 1 + src/server/scripts/Commands/cs_misc.cpp | 2 + src/server/scripts/Commands/cs_modify.cpp | 6 +- src/server/scripts/Commands/cs_npc.cpp | 2 + src/server/scripts/Commands/cs_quest.cpp | 5 +- src/server/scripts/Commands/cs_reload.cpp | 22 +- src/server/scripts/Commands/cs_reset.cpp | 5 +- src/server/scripts/Commands/cs_server.cpp | 5 +- src/server/scripts/Commands/cs_tele.cpp | 7 +- src/server/scripts/Commands/cs_ticket.cpp | 7 +- src/server/scripts/Commands/cs_titles.cpp | 5 +- src/server/scripts/Commands/cs_wp.cpp | 7 +- src/server/scripts/Spells/spell_generic.cpp | 12 +- src/server/scripts/Spells/spell_hunter.cpp | 2 +- .../shared/Dynamic/LinkedReference/Reference.h | 1 + 68 files changed, 602 insertions(+), 508 deletions(-) create mode 100644 src/server/game/Entities/Pet/PetDefines.h (limited to 'src/server/shared') diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index ca6450aa746..6f748f9dee2 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -22,7 +22,6 @@ #include "Creature.h" #include "CreatureAI.h" #include "Unit.h" -#include "ConditionMgr.h" #include "Spell.h" #include "SmartScript.h" diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index b8c0f952df9..a22978632fe 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -15,25 +15,25 @@ * with this program. If not, see . */ +#include "Cell.h" +#include "CellImpl.h" +#include "CreatureTextMgr.h" #include "DatabaseEnv.h" -#include "ObjectMgr.h" -#include "ObjectDefines.h" +#include "GossipDef.h" #include "GridDefines.h" #include "GridNotifiers.h" -#include "SpellMgr.h" #include "GridNotifiersImpl.h" -#include "Cell.h" -#include "CellImpl.h" +#include "Group.h" #include "InstanceScript.h" +#include "Language.h" +#include "ObjectDefines.h" +#include "ObjectMgr.h" #include "ScriptedCreature.h" -#include "GossipDef.h" -#include "ScriptedCreature.h" -#include "SmartScript.h" +#include "ScriptedGossip.h" #include "SmartAI.h" -#include "Group.h" +#include "SmartScript.h" +#include "SpellMgr.h" #include "Vehicle.h" -#include "ScriptedGossip.h" -#include "CreatureTextMgr.h" class TrinityStringTextBuilder { diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h index 2a0eceb574a..61e22b25d17 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.h +++ b/src/server/game/AI/SmartScripts/SmartScript.h @@ -22,7 +22,6 @@ #include "Creature.h" #include "CreatureAI.h" #include "Unit.h" -#include "ConditionMgr.h" #include "Spell.h" #include "GridNotifiers.h" diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index 0504effa651..2c20db8e5d4 100755 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -16,30 +16,32 @@ * with this program. If not, see . */ -#include "Common.h" -#include "DBCEnums.h" -#include "ObjectMgr.h" -#include "ArenaTeamMgr.h" -#include "GuildMgr.h" -#include "World.h" -#include "WorldPacket.h" -#include "DatabaseEnv.h" #include "AchievementMgr.h" #include "ArenaTeam.h" +#include "ArenaTeamMgr.h" +#include "BattlegroundAB.h" +#include "Battleground.h" #include "CellImpl.h" +#include "Common.h" +#include "DatabaseEnv.h" +#include "DBCEnums.h" +#include "DisableMgr.h" #include "GameEventMgr.h" #include "GridNotifiersImpl.h" #include "Guild.h" +#include "GuildMgr.h" +#include "InstanceScript.h" #include "Language.h" +#include "Map.h" +#include "MapManager.h" +#include "ObjectMgr.h" #include "Player.h" -#include "SpellMgr.h" -#include "DisableMgr.h" +#include "ReputationMgr.h" #include "ScriptMgr.h" -#include "MapManager.h" -#include "Battleground.h" -#include "BattlegroundAB.h" -#include "Map.h" -#include "InstanceScript.h" +#include "SpellMgr.h" +#include "World.h" +#include "WorldPacket.h" + namespace Trinity { @@ -355,7 +357,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un return false; return target->getGender() == gender.gender; case ACHIEVEMENT_CRITERIA_DATA_TYPE_SCRIPT: - return sScriptMgr->OnCriteriaCheck(this, const_cast(source), const_cast(target)); + return sScriptMgr->OnCriteriaCheck(ScriptId, const_cast(source), const_cast(target)); case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY: if (source->GetMap()->IsRaid()) if (source->GetMap()->Is25ManRaid() != ((difficulty.difficulty & RAID_DIFFICULTY_MASK_25MAN) != 0)) diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index 9d48bc6115f..812dd5a1c2a 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -20,11 +20,12 @@ // TODO: Use spell victory/defeat in wg instead of RewardMarkOfHonor() && RewardHonor // TODO: Add proper implement of achievement -#include "ObjectMgr.h" #include "BattlefieldWG.h" +#include "ObjectMgr.h" +#include "Player.h" #include "SpellAuras.h" +#include "TemporarySummon.h" #include "Vehicle.h" -#include "Player.h" enum WGVehicles { diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 54422a8c5d3..40a74a49b69 100755 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -16,24 +16,24 @@ * with this program. If not, see . */ -#include "Player.h" -#include "ObjectMgr.h" -#include "ArenaTeamMgr.h" -#include "World.h" -#include "WorldPacket.h" #include "ArenaTeam.h" +#include "ArenaTeamMgr.h" #include "Battleground.h" #include "BattlegroundMgr.h" #include "Creature.h" #include "Formulas.h" #include "GridNotifiersImpl.h" #include "Group.h" -#include "Language.h" #include "MapManager.h" #include "Object.h" -#include "SpellAuras.h" +#include "ObjectMgr.h" +#include "Player.h" +#include "ReputationMgr.h" #include "SpellAuraEffects.h" +#include "SpellAuras.h" #include "Util.h" +#include "World.h" +#include "WorldPacket.h" namespace Trinity { diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index cc53de7e39a..c610cafa1b1 100755 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -16,14 +16,15 @@ * with this program. If not, see . */ -#include "BattlegroundQueue.h" #include "ArenaTeam.h" +#include "ArenaTeamMgr.h" #include "BattlegroundMgr.h" +#include "BattlegroundQueue.h" #include "Chat.h" -#include "ObjectMgr.h" -#include "ArenaTeamMgr.h" -#include "Log.h" #include "Group.h" +#include "Log.h" +#include "Language.h" +#include "ObjectMgr.h" #include "Player.h" /*********************************************************/ diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp index a64184261c7..02c5167c9ec 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp @@ -17,11 +17,12 @@ */ #include "BattlegroundDS.h" -#include "ObjectAccessor.h" +#include "Creature.h" +#include "GameObject.h" #include "Language.h" +#include "ObjectAccessor.h" #include "Player.h" #include "WorldPacket.h" -#include "GameObject.h" BattlegroundDS::BattlegroundDS() { diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 72f00406c69..2f3cb0fbaaf 100755 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -16,15 +16,16 @@ * with this program. If not, see . */ -#include "Player.h" -#include "SpellAuras.h" -#include "SpellMgr.h" +#include "ConditionMgr.h" #include "GameEventMgr.h" -#include "ObjectMgr.h" #include "InstanceScript.h" -#include "ConditionMgr.h" -#include "ScriptMgr.h" +#include "ObjectMgr.h" +#include "Player.h" +#include "ReputationMgr.h" #include "ScriptedCreature.h" +#include "ScriptMgr.h" +#include "SpellAuras.h" +#include "SpellMgr.h" #include "Spell.h" // Checks if object meets the condition diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index 57af0562dcd..7b0dc1f20bf 100755 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -19,8 +19,11 @@ #ifndef TRINITY_CONDITIONMGR_H #define TRINITY_CONDITIONMGR_H -#include "LootMgr.h" +#include "Define.h" +#include "Errors.h" #include +#include +#include class Player; class Unit; diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index c91be00080e..7cb9efa2f2f 100755 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -21,6 +21,7 @@ #include "DisableMgr.h" #include "ObjectMgr.h" #include "SocialMgr.h" +#include "Language.h" #include "LFGMgr.h" #include "LFGScripts.h" #include "LFGGroupData.h" diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 9bcd4d9c1e2..2300876048b 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -16,40 +16,42 @@ * with this program. If not, see . */ +#include "BattlegroundMgr.h" +#include "CellImpl.h" #include "Common.h" -#include "DatabaseEnv.h" -#include "WorldPacket.h" -#include "World.h" -#include "ObjectMgr.h" -#include "GroupMgr.h" -#include "SpellMgr.h" -#include "Creature.h" -#include "QuestDef.h" -#include "GossipDef.h" -#include "Player.h" -#include "PoolMgr.h" -#include "Opcodes.h" -#include "Log.h" -#include "LootMgr.h" -#include "MapManager.h" #include "CreatureAI.h" #include "CreatureAISelector.h" +#include "CreatureGroups.h" +#include "Creature.h" +#include "DatabaseEnv.h" #include "Formulas.h" -#include "WaypointMovementGenerator.h" -#include "InstanceScript.h" -#include "BattlegroundMgr.h" -#include "Util.h" +#include "GameEventMgr.h" +#include "GossipDef.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" -#include "CellImpl.h" -#include "OutdoorPvPMgr.h" -#include "GameEventMgr.h" -#include "CreatureGroups.h" -#include "Vehicle.h" -#include "SpellAuraEffects.h" #include "Group.h" -#include "MoveSplineInit.h" +#include "GroupMgr.h" +#include "InstanceScript.h" +#include "Log.h" +#include "LootMgr.h" +#include "MapManager.h" #include "MoveSpline.h" +#include "MoveSplineInit.h" +#include "ObjectMgr.h" +#include "Opcodes.h" +#include "OutdoorPvPMgr.h" +#include "Player.h" +#include "PoolMgr.h" +#include "QuestDef.h" +#include "SpellAuraEffects.h" +#include "SpellMgr.h" +#include "TemporarySummon.h" +#include "Util.h" +#include "Vehicle.h" +#include "WaypointMovementGenerator.h" +#include "World.h" +#include "WorldPacket.h" + // apply implementation of the singletons TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index d8287b68fc5..7818cdc6942 100755 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2360,119 +2360,6 @@ TempSummon* WorldObject::SummonCreature(uint32 entry, const Position &pos, TempS return NULL; } -Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 duration) -{ - Pet* pet = new Pet(this, petType); - - if (petType == SUMMON_PET && pet->LoadPetFromDB(this, entry)) - { - // Remove Demonic Sacrifice auras (known pet) - Unit::AuraEffectList const& auraClassScripts = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for (Unit::AuraEffectList::const_iterator itr = auraClassScripts.begin(); itr != auraClassScripts.end();) - { - if ((*itr)->GetMiscValue() == 2228) - { - RemoveAurasDueToSpell((*itr)->GetId()); - itr = auraClassScripts.begin(); - } - else - ++itr; - } - - if (duration > 0) - pet->SetDuration(duration); - - return NULL; - } - - // petentry == 0 for hunter "call pet" (current pet summoned if any) - if (!entry) - { - delete pet; - return NULL; - } - - pet->Relocate(x, y, z, ang); - if (!pet->IsPositionValid()) - { - sLog->outError(LOG_FILTER_GENERAL, "Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)", pet->GetGUIDLow(), pet->GetEntry(), pet->GetPositionX(), pet->GetPositionY()); - delete pet; - return NULL; - } - - Map* map = GetMap(); - uint32 pet_number = sObjectMgr->GeneratePetNumber(); - if (!pet->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_PET), map, GetPhaseMask(), entry, pet_number)) - { - sLog->outError(LOG_FILTER_GENERAL, "no such creature entry %u", entry); - delete pet; - return NULL; - } - - pet->SetCreatorGUID(GetGUID()); - pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, getFaction()); - - pet->setPowerType(POWER_MANA); - pet->SetUInt32Value(UNIT_NPC_FLAGS, 0); - pet->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - pet->InitStatsForLevel(getLevel()); - - SetMinion(pet, true); - - switch (petType) - { - case SUMMON_PET: - // this enables pet details window (Shift+P) - pet->GetCharmInfo()->SetPetNumber(pet_number, true); - pet->SetUInt32Value(UNIT_FIELD_BYTES_0, 2048); - pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); - pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000); - pet->SetFullHealth(); - pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA)); - pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped in this case - break; - default: - break; - } - - map->AddToMap(pet->ToCreature()); - - switch (petType) - { - case SUMMON_PET: - pet->InitPetCreateSpells(); - pet->InitTalentForLevel(); - pet->SavePetToDB(PET_SAVE_AS_CURRENT); - PetSpellInitialize(); - break; - default: - break; - } - - if (petType == SUMMON_PET) - { - // Remove Demonic Sacrifice auras (known pet) - Unit::AuraEffectList const& auraClassScripts = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for (Unit::AuraEffectList::const_iterator itr = auraClassScripts.begin(); itr != auraClassScripts.end();) - { - if ((*itr)->GetMiscValue() == 2228) - { - RemoveAurasDueToSpell((*itr)->GetId()); - itr = auraClassScripts.begin(); - } - else - ++itr; - } - } - - if (duration > 0) - pet->SetDuration(duration); - - //ObjectAccessor::UpdateObjectVisibility(pet); - - return pet; -} - GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime) { if (!IsInWorld()) diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h index f24bb665710..a1dd57a26cc 100755 --- a/src/server/game/Entities/Pet/Pet.h +++ b/src/server/game/Entities/Pet/Pet.h @@ -19,50 +19,11 @@ #ifndef TRINITYCORE_PET_H #define TRINITYCORE_PET_H -#include "ObjectDefines.h" -#include "Unit.h" +#include "PetDefines.h" #include "TemporarySummon.h" -enum PetType -{ - SUMMON_PET = 0, - HUNTER_PET = 1, - MAX_PET_TYPE = 4 -}; - -#define MAX_PET_STABLES 4 - -// stored in character_pet.slot -enum PetSaveMode -{ - PET_SAVE_AS_DELETED = -1, // not saved in fact - PET_SAVE_AS_CURRENT = 0, // in current slot (with player) - PET_SAVE_FIRST_STABLE_SLOT = 1, - PET_SAVE_LAST_STABLE_SLOT = MAX_PET_STABLES, // last in DB stable slot index (including), all higher have same meaning as PET_SAVE_NOT_IN_SLOT - PET_SAVE_NOT_IN_SLOT = 100 // for avoid conflict with stable size grow will use 100 -}; - -enum HappinessState -{ - UNHAPPY = 1, - CONTENT = 2, - HAPPY = 3 -}; - -enum PetSpellState -{ - PETSPELL_UNCHANGED = 0, - PETSPELL_CHANGED = 1, - PETSPELL_NEW = 2, - PETSPELL_REMOVED = 3 -}; - -enum PetSpellType -{ - PETSPELL_NORMAL = 0, - PETSPELL_FAMILY = 1, - PETSPELL_TALENT = 2 -}; +#define PET_FOCUS_REGEN_INTERVAL 4 * IN_MILLISECONDS +#define HAPPINESS_LEVEL_SIZE 333000 struct PetSpell { @@ -71,31 +32,9 @@ struct PetSpell PetSpellType type; }; -enum ActionFeedback -{ - FEEDBACK_NONE = 0, - FEEDBACK_PET_DEAD = 1, - FEEDBACK_NOTHING_TO_ATT = 2, - FEEDBACK_CANT_ATT_TARGET = 3 -}; - -enum PetTalk -{ - PET_TALK_SPECIAL_SPELL = 0, - PET_TALK_ATTACK = 1 -}; - typedef UNORDERED_MAP PetSpellMap; typedef std::vector AutoSpellList; -#define HAPPINESS_LEVEL_SIZE 333000 - -#define ACTIVE_SPELLS_MAX 4 - -#define PET_FOLLOW_DIST 1.0f -#define PET_FOLLOW_ANGLE (M_PI/2) -#define PET_FOCUS_REGEN_INTERVAL 4 * IN_MILLISECONDS - class Player; class Pet : public Guardian diff --git a/src/server/game/Entities/Pet/PetDefines.h b/src/server/game/Entities/Pet/PetDefines.h new file mode 100644 index 00000000000..76de2647c8c --- /dev/null +++ b/src/server/game/Entities/Pet/PetDefines.h @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2008-2012 TrinityCore + * Copyright (C) 2005-2009 MaNGOS + * + * 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 . + */ + +#ifndef TRINITYCORE_PET_DEFINES_H +#define TRINITYCORE_PET_DEFINES_H + +enum PetType +{ + SUMMON_PET = 0, + HUNTER_PET = 1, + MAX_PET_TYPE = 4 +}; + +#define MAX_PET_STABLES 4 + +// stored in character_pet.slot +enum PetSaveMode +{ + PET_SAVE_AS_DELETED = -1, // not saved in fact + PET_SAVE_AS_CURRENT = 0, // in current slot (with player) + PET_SAVE_FIRST_STABLE_SLOT = 1, + PET_SAVE_LAST_STABLE_SLOT = MAX_PET_STABLES, // last in DB stable slot index (including), all higher have same meaning as PET_SAVE_NOT_IN_SLOT + PET_SAVE_NOT_IN_SLOT = 100 // for avoid conflict with stable size grow will use 100 +}; + +enum HappinessState +{ + UNHAPPY = 1, + CONTENT = 2, + HAPPY = 3 +}; + +enum PetSpellState +{ + PETSPELL_UNCHANGED = 0, + PETSPELL_CHANGED = 1, + PETSPELL_NEW = 2, + PETSPELL_REMOVED = 3 +}; + +enum PetSpellType +{ + PETSPELL_NORMAL = 0, + PETSPELL_FAMILY = 1, + PETSPELL_TALENT = 2 +}; + +enum ActionFeedback +{ + FEEDBACK_NONE = 0, + FEEDBACK_PET_DEAD = 1, + FEEDBACK_NOTHING_TO_ATT = 2, + FEEDBACK_CANT_ATT_TARGET = 3 +}; + +enum PetTalk +{ + PET_TALK_SPECIAL_SPELL = 0, + PET_TALK_ATTACK = 1 +}; + +#define PET_FOLLOW_DIST 1.0f +#define PET_FOLLOW_ANGLE (M_PI/2) + +#endif diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 21db9ac4ff9..a95ce52c3f6 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -16,67 +16,68 @@ * with this program. If not, see . */ -#include "Common.h" -#include "Language.h" -#include "DatabaseEnv.h" -#include "Log.h" -#include "Opcodes.h" -#include "SpellMgr.h" -#include "World.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "UpdateMask.h" #include "Player.h" -#include "Vehicle.h" -#include "SkillDiscovery.h" -#include "QuestDef.h" -#include "GossipDef.h" -#include "UpdateData.h" +#include "AccountMgr.h" +#include "AchievementMgr.h" +#include "ArenaTeam.h" +#include "ArenaTeamMgr.h" +#include "Battlefield.h" +#include "BattlefieldMgr.h" +#include "BattlefieldWG.h" +#include "BattlegroundAV.h" +#include "Battleground.h" +#include "BattlegroundMgr.h" +#include "CellImpl.h" #include "Channel.h" #include "ChannelMgr.h" -#include "MapManager.h" -#include "MapInstanced.h" -#include "InstanceSaveMgr.h" -#include "GridNotifiers.h" -#include "GridNotifiersImpl.h" -#include "CellImpl.h" -#include "ObjectMgr.h" -#include "ArenaTeamMgr.h" -#include "GuildMgr.h" -#include "GroupMgr.h" -#include "ObjectAccessor.h" +#include "CharacterDatabaseCleaner.h" +#include "Chat.h" +#include +#include "Common.h" +#include "ConditionMgr.h" #include "CreatureAI.h" +#include "DatabaseEnv.h" +#include "DisableMgr.h" #include "Formulas.h" +#include "GameEventMgr.h" +#include "GossipDef.h" +#include "GridNotifiers.h" +#include "GridNotifiersImpl.h" #include "Group.h" +#include "GroupMgr.h" #include "Guild.h" -#include "Pet.h" -#include "Util.h" -#include "Transport.h" -#include "Weather.h" -#include "Battleground.h" -#include "BattlegroundAV.h" -#include "BattlegroundMgr.h" +#include "GuildMgr.h" +#include "InstanceSaveMgr.h" +#include "InstanceScript.h" +#include "Language.h" +#include "LFGMgr.h" +#include "Log.h" +#include "MapInstanced.h" +#include "MapManager.h" +#include "ObjectAccessor.h" +#include "ObjectMgr.h" +#include "Opcodes.h" #include "OutdoorPvP.h" #include "OutdoorPvPMgr.h" -#include "ArenaTeam.h" -#include "Chat.h" -#include "Spell.h" +#include "ReputationMgr.h" +#include "Pet.h" +#include "QuestDef.h" +#include "SkillDiscovery.h" #include "SocialMgr.h" -#include "GameEventMgr.h" -#include "AchievementMgr.h" -#include "SpellAuras.h" #include "SpellAuraEffects.h" -#include "ConditionMgr.h" -#include "DisableMgr.h" +#include "SpellAuras.h" +#include "Spell.h" +#include "SpellMgr.h" +#include "Transport.h" +#include "UpdateData.h" +#include "UpdateMask.h" +#include "Util.h" +#include "Vehicle.h" +#include "Weather.h" #include "WeatherMgr.h" -#include "LFGMgr.h" -#include "CharacterDatabaseCleaner.h" -#include "InstanceScript.h" -#include -#include "AccountMgr.h" -#include "Battlefield.h" -#include "BattlefieldMgr.h" -#include "BattlefieldWG.h" +#include "World.h" +#include "WorldPacket.h" +#include "WorldSession.h" #define ZONE_UPDATE_INTERVAL (1*IN_MILLISECONDS) @@ -643,7 +644,7 @@ void KillRewarder::Reward() #ifdef _MSC_VER #pragma warning(disable:4355) #endif -Player::Player(WorldSession* session): Unit(true), m_achievementMgr(this), m_reputationMgr(this) +Player::Player(WorldSession* session): Unit(true) { #ifdef _MSC_VER #pragma warning(default:4355) @@ -869,6 +870,8 @@ Player::Player(WorldSession* session): Unit(true), m_achievementMgr(this), m_rep SetPendingBind(0, 0); _activeCheats = CHEAT_NONE; + m_achievementMgr = new AchievementMgr(this); + m_reputationMgr = new ReputationMgr(this); } Player::~Player() @@ -904,6 +907,8 @@ Player::~Player() delete m_declinedname; delete m_runes; + delete m_achievementMgr; + delete m_reputationMgr; sWorld->DecreasePlayerCount(); } @@ -1609,7 +1614,7 @@ void Player::Update(uint32 p_time) } } - m_achievementMgr.UpdateTimedAchievements(p_time); + m_achievementMgr->UpdateTimedAchievements(p_time); if (HasUnitState(UNIT_STATE_MELEE_ATTACKING) && !HasUnitState(UNIT_STATE_CASTING)) { @@ -16732,7 +16737,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f); // load achievements before anything else to prevent multiple gains for the same achievement/criteria on every loading (as loading does call UpdateAchievementCriteria) - m_achievementMgr.LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS), holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS)); + m_achievementMgr->LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS), holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS)); uint32 money = fields[8].GetUInt32(); if (money > MAX_MONEY_AMOUNT) @@ -17176,7 +17181,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) learnDefaultSpells(); // must be before inventory (some items required reputation check) - m_reputationMgr.LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADREPUTATION)); + m_reputationMgr->LoadFromDB(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADREPUTATION)); _LoadInventory(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADINVENTORY), time_diff); @@ -17284,7 +17289,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) _LoadDeclinedNames(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES)); - m_achievementMgr.CheckAllAchievementCriteria(); + m_achievementMgr->CheckAllAchievementCriteria(); _LoadEquipmentSets(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS)); @@ -18828,8 +18833,8 @@ void Player::SaveToDB(bool create /*=false*/) _SaveActions(trans); _SaveAuras(trans); _SaveSkills(trans); - m_achievementMgr.SaveToDB(trans); - m_reputationMgr.SaveToDB(trans); + m_achievementMgr->SaveToDB(trans); + m_reputationMgr->SaveToDB(trans); _SaveEquipmentSets(trans); GetSession()->SaveTutorialsData(trans); // changed only while character in game _SaveGlyphs(trans); @@ -22077,8 +22082,8 @@ void Player::SendInitialPacketsBeforeAddToMap() GetSession()->SendPacket(&data); SendInitialActionButtons(); - m_reputationMgr.SendInitialReputations(); - m_achievementMgr.SendAllAchievementData(); + m_reputationMgr->SendInitialReputations(); + m_achievementMgr->SendAllAchievementData(); SendEquipmentSetList(); @@ -24189,42 +24194,42 @@ void Player::HandleFall(MovementInfo const& movementInfo) void Player::ResetAchievements() { - m_achievementMgr.Reset(); + m_achievementMgr->Reset(); } void Player::SendRespondInspectAchievements(Player* player) const { - m_achievementMgr.SendRespondInspectAchievements(player); + m_achievementMgr->SendRespondInspectAchievements(player); } bool Player::HasAchieved(uint32 achievementId) const { - return m_achievementMgr.HasAchieved(achievementId); + return m_achievementMgr->HasAchieved(achievementId); } void Player::StartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry, uint32 timeLost/* = 0*/) { - m_achievementMgr.StartTimedAchievement(type, entry, timeLost); + m_achievementMgr->StartTimedAchievement(type, entry, timeLost); } void Player::RemoveTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry) { - m_achievementMgr.RemoveTimedAchievement(type, entry); + m_achievementMgr->RemoveTimedAchievement(type, entry); } void Player::ResetAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1 /*= 0*/, uint32 miscValue2 /*= 0*/, bool evenIfCriteriaComplete /* = false*/) { - m_achievementMgr.ResetAchievementCriteria(type, miscValue1, miscValue2, evenIfCriteriaComplete); + m_achievementMgr->ResetAchievementCriteria(type, miscValue1, miscValue2, evenIfCriteriaComplete); } void Player::UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1 /*= 0*/, uint32 miscValue2 /*= 0*/, Unit* unit /*= NULL*/) { - m_achievementMgr.UpdateAchievementCriteria(type, miscValue1, miscValue2, unit); + m_achievementMgr->UpdateAchievementCriteria(type, miscValue1, miscValue2, unit); } void Player::CompletedAchievement(AchievementEntry const* entry) { - m_achievementMgr.CompletedAchievement(entry); + m_achievementMgr->CompletedAchievement(entry); } void Player::LearnTalent(uint32 talentId, uint32 talentRank) @@ -25594,3 +25599,116 @@ Guild* Player::GetGuild() uint32 guildId = GetGuildId(); return guildId ? sGuildMgr->GetGuildById(guildId) : NULL; } + +Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 duration) +{ + Pet* pet = new Pet(this, petType); + + if (petType == SUMMON_PET && pet->LoadPetFromDB(this, entry)) + { + // Remove Demonic Sacrifice auras (known pet) + Unit::AuraEffectList const& auraClassScripts = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for (Unit::AuraEffectList::const_iterator itr = auraClassScripts.begin(); itr != auraClassScripts.end();) + { + if ((*itr)->GetMiscValue() == 2228) + { + RemoveAurasDueToSpell((*itr)->GetId()); + itr = auraClassScripts.begin(); + } + else + ++itr; + } + + if (duration > 0) + pet->SetDuration(duration); + + return NULL; + } + + // petentry == 0 for hunter "call pet" (current pet summoned if any) + if (!entry) + { + delete pet; + return NULL; + } + + pet->Relocate(x, y, z, ang); + if (!pet->IsPositionValid()) + { + sLog->outError(LOG_FILTER_GENERAL, "Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)", pet->GetGUIDLow(), pet->GetEntry(), pet->GetPositionX(), pet->GetPositionY()); + delete pet; + return NULL; + } + + Map* map = GetMap(); + uint32 pet_number = sObjectMgr->GeneratePetNumber(); + if (!pet->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_PET), map, GetPhaseMask(), entry, pet_number)) + { + sLog->outError(LOG_FILTER_GENERAL, "no such creature entry %u", entry); + delete pet; + return NULL; + } + + pet->SetCreatorGUID(GetGUID()); + pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, getFaction()); + + pet->setPowerType(POWER_MANA); + pet->SetUInt32Value(UNIT_NPC_FLAGS, 0); + pet->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + pet->InitStatsForLevel(getLevel()); + + SetMinion(pet, true); + + switch (petType) + { + case SUMMON_PET: + // this enables pet details window (Shift+P) + pet->GetCharmInfo()->SetPetNumber(pet_number, true); + pet->SetUInt32Value(UNIT_FIELD_BYTES_0, 2048); + pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); + pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000); + pet->SetFullHealth(); + pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA)); + pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped in this case + break; + default: + break; + } + + map->AddToMap(pet->ToCreature()); + + switch (petType) + { + case SUMMON_PET: + pet->InitPetCreateSpells(); + pet->InitTalentForLevel(); + pet->SavePetToDB(PET_SAVE_AS_CURRENT); + PetSpellInitialize(); + break; + default: + break; + } + + if (petType == SUMMON_PET) + { + // Remove Demonic Sacrifice auras (known pet) + Unit::AuraEffectList const& auraClassScripts = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for (Unit::AuraEffectList::const_iterator itr = auraClassScripts.begin(); itr != auraClassScripts.end();) + { + if ((*itr)->GetMiscValue() == 2228) + { + RemoveAurasDueToSpell((*itr)->GetId()); + itr = auraClassScripts.begin(); + } + else + ++itr; + } + } + + if (duration > 0) + pet->SetDuration(duration); + + //ObjectAccessor::UpdateObjectVisibility(pet); + + return pet; +} diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 3b1f47b8f69..07c00031e6b 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -19,26 +19,27 @@ #ifndef _PLAYER_H #define _PLAYER_H -#include "AchievementMgr.h" -#include "Common.h" -#include "DatabaseEnv.h" -#include "DBCEnums.h" +#include "DBCStores.h" #include "GroupReference.h" -#include "Item.h" #include "MapReference.h" -#include "Pet.h" + +#include "Item.h" +#include "PetDefines.h" #include "QuestDef.h" -#include "ReputationMgr.h" #include "Unit.h" -#include "WorldSession.h" #include "SpellMgr.h" #include #include struct Mail; +struct VendorItem; + +class AchievementMgr; +class ReputationMgr; class Channel; class Creature; +class CreatureTemplate; class DynamicObject; class Group; class Guild; @@ -47,6 +48,7 @@ class Pet; class PlayerMenu; class PlayerSocial; class SpellCastTargets; +class TrainerSpell; class UpdateMask; typedef std::deque PlayerMails; @@ -2012,8 +2014,8 @@ class Player : public Unit, public GridObject uint8 GetGrantableLevels() { return m_grantableLevels; } void SetGrantableLevels(uint8 val) { m_grantableLevels = val; } - ReputationMgr& GetReputationMgr() { return m_reputationMgr; } - ReputationMgr const& GetReputationMgr() const { return m_reputationMgr; } + ReputationMgr& GetReputationMgr() { return *m_reputationMgr; } + ReputationMgr const& GetReputationMgr() const { return *m_reputationMgr; } ReputationRank GetReputationRank(uint32 faction_id) const; void RewardReputation(Unit* victim, float rate); void RewardReputation(Quest const* quest); @@ -2835,8 +2837,8 @@ class Player : public Unit, public GridObject uint32 m_temporaryUnsummonedPetNumber; uint32 m_oldpetspell; - AchievementMgr m_achievementMgr; - ReputationMgr m_reputationMgr; + AchievementMgr* m_achievementMgr; + ReputationMgr* m_reputationMgr; SpellCooldowns m_spellCooldowns; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index c886c046427..13b3335cfdc 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -16,49 +16,50 @@ * with this program. If not, see . */ +#include "Battlefield.h" +#include "BattlefieldMgr.h" +#include "Battleground.h" +#include "CellImpl.h" #include "Common.h" +#include "ConditionMgr.h" +#include "CreatureAI.h" #include "CreatureAIImpl.h" -#include "Log.h" -#include "Opcodes.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "World.h" -#include "ObjectMgr.h" -#include "SpellMgr.h" -#include "Unit.h" -#include "QuestDef.h" -#include "Player.h" +#include "CreatureGroups.h" #include "Creature.h" -#include "Spell.h" +#include "Formulas.h" +#include "GridNotifiersImpl.h" #include "Group.h" -#include "SpellAuras.h" -#include "SpellAuraEffects.h" +#include "InstanceSaveMgr.h" +#include "InstanceScript.h" +#include "Log.h" #include "MapManager.h" +#include "MoveSpline.h" +#include "MoveSplineInit.h" #include "ObjectAccessor.h" -#include "CreatureAI.h" -#include "Formulas.h" -#include "Pet.h" -#include "Util.h" -#include "Totem.h" -#include "Battleground.h" +#include "ObjectMgr.h" +#include "Opcodes.h" #include "OutdoorPvP.h" -#include "InstanceSaveMgr.h" -#include "GridNotifiersImpl.h" -#include "CellImpl.h" -#include "CreatureGroups.h" -#include "PetAI.h" #include "PassiveAI.h" +#include "PetAI.h" +#include "Pet.h" +#include "Player.h" +#include "QuestDef.h" +#include "ReputationMgr.h" +#include "SpellAuraEffects.h" +#include "SpellAuras.h" +#include "Spell.h" +#include "SpellInfo.h" +#include "SpellMgr.h" #include "TemporarySummon.h" -#include "Vehicle.h" +#include "Totem.h" #include "Transport.h" -#include "InstanceScript.h" -#include "SpellInfo.h" -#include "MoveSplineInit.h" -#include "MoveSpline.h" -#include "ConditionMgr.h" +#include "Unit.h" #include "UpdateFieldFlags.h" -#include "Battlefield.h" -#include "BattlefieldMgr.h" +#include "Util.h" +#include "Vehicle.h" +#include "World.h" +#include "WorldPacket.h" +#include "WorldSession.h" #include diff --git a/src/server/game/Globals/ObjectAccessor.cpp b/src/server/game/Globals/ObjectAccessor.cpp index 6999eb301f5..cedb20eccf1 100755 --- a/src/server/game/Globals/ObjectAccessor.cpp +++ b/src/server/game/Globals/ObjectAccessor.cpp @@ -17,25 +17,25 @@ */ #include "ObjectAccessor.h" -#include "ObjectMgr.h" - -#include "Player.h" +#include "CellImpl.h" +#include "Corpse.h" #include "Creature.h" -#include "GameObject.h" #include "DynamicObject.h" -#include "Vehicle.h" -#include "WorldPacket.h" -#include "Item.h" -#include "Corpse.h" +#include "GameObject.h" #include "GridNotifiers.h" -#include "MapManager.h" -#include "Map.h" -#include "CellImpl.h" #include "GridNotifiersImpl.h" -#include "Opcodes.h" -#include "ObjectDefines.h" +#include "Item.h" +#include "Map.h" #include "MapInstanced.h" +#include "MapManager.h" +#include "ObjectDefines.h" +#include "ObjectMgr.h" +#include "Opcodes.h" +#include "Pet.h" +#include "Player.h" +#include "Vehicle.h" #include "World.h" +#include "WorldPacket.h" #include diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 245079f2495..a94a12a99fe 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -16,36 +16,38 @@ * with this program. If not, see . */ +#include "AccountMgr.h" +#include "AchievementMgr.h" +#include "ArenaTeam.h" +#include "ArenaTeamMgr.h" +#include "Chat.h" #include "Common.h" #include "DatabaseEnv.h" +#include "DisableMgr.h" +#include "GameEventMgr.h" +#include "GossipDef.h" +#include "GroupMgr.h" +#include "GuildMgr.h" +#include "InstanceSaveMgr.h" +#include "Language.h" +#include "LFGMgr.h" #include "Log.h" #include "MapManager.h" #include "ObjectMgr.h" -#include "ArenaTeamMgr.h" -#include "GuildMgr.h" -#include "GroupMgr.h" +#include "Pet.h" +#include "PoolMgr.h" +#include "ReputationMgr.h" +#include "ScriptMgr.h" +#include "SpellAuras.h" +#include "Spell.h" #include "SpellMgr.h" -#include "UpdateMask.h" -#include "World.h" -#include "ArenaTeam.h" +#include "SpellScript.h" #include "Transport.h" -#include "Language.h" -#include "GameEventMgr.h" -#include "Spell.h" -#include "Chat.h" -#include "AccountMgr.h" -#include "InstanceSaveMgr.h" -#include "SpellAuras.h" +#include "UpdateMask.h" #include "Util.h" -#include "WaypointManager.h" -#include "GossipDef.h" #include "Vehicle.h" -#include "AchievementMgr.h" -#include "DisableMgr.h" -#include "ScriptMgr.h" -#include "SpellScript.h" -#include "PoolMgr.h" -#include "LFGMgr.h" +#include "WaypointManager.h" +#include "World.h" ScriptMapMap sQuestEndScripts; ScriptMapMap sQuestStartScripts; diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index e1be2049dad..5cb02603598 100755 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -16,16 +16,17 @@ * with this program. If not, see . */ +#include "AccountMgr.h" +#include "CalendarMgr.h" +#include "Chat.h" +#include "Config.h" #include "DatabaseEnv.h" #include "Guild.h" #include "GuildMgr.h" +#include "Language.h" +#include "Log.h" #include "ScriptMgr.h" -#include "Chat.h" -#include "Config.h" #include "SocialMgr.h" -#include "Log.h" -#include "AccountMgr.h" -#include "CalendarMgr.h" #define MAX_GUILD_BANK_TAB_TEXT_LEN 500 #define EMBLEM_PRICE 10 * GOLD diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp index 3c3a6978384..7e23429be2f 100755 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -24,6 +24,7 @@ #include "AuctionHouseMgr.h" #include "Log.h" +#include "Language.h" #include "Opcodes.h" #include "UpdateMask.h" #include "Util.h" diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index d0aad7072f7..0b01c796511 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -16,35 +16,37 @@ * with this program. If not, see . */ -#include "Common.h" -#include "ObjectAccessor.h" -#include "ObjectMgr.h" -#include "ArenaTeamMgr.h" -#include "GuildMgr.h" -#include "SystemConfig.h" -#include "World.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "DatabaseEnv.h" - +#include "AccountMgr.h" #include "ArenaTeam.h" +#include "ArenaTeamMgr.h" +#include "Battleground.h" +#include "CalendarMgr.h" #include "Chat.h" +#include "Common.h" +#include "DatabaseEnv.h" #include "Group.h" #include "Guild.h" +#include "GuildMgr.h" #include "Language.h" +#include "LFGMgr.h" #include "Log.h" +#include "ObjectAccessor.h" +#include "ObjectMgr.h" #include "Opcodes.h" -#include "Player.h" +#include "Pet.h" #include "PlayerDump.h" +#include "Player.h" +#include "ReputationMgr.h" +#include "ScriptMgr.h" #include "SharedDefines.h" #include "SocialMgr.h" +#include "SystemConfig.h" #include "UpdateMask.h" #include "Util.h" -#include "ScriptMgr.h" -#include "Battleground.h" -#include "AccountMgr.h" -#include "LFGMgr.h" -#include "CalendarMgr.h" +#include "World.h" +#include "WorldPacket.h" +#include "WorldSession.h" + class LoginQueryHolder : public SQLQueryHolder { diff --git a/src/server/game/Handlers/GroupHandler.cpp b/src/server/game/Handlers/GroupHandler.cpp index 223a5316c7a..8555b4a6a1f 100755 --- a/src/server/game/Handlers/GroupHandler.cpp +++ b/src/server/game/Handlers/GroupHandler.cpp @@ -18,19 +18,20 @@ #include "Common.h" #include "DatabaseEnv.h" -#include "Opcodes.h" +#include "Group.h" +#include "GroupMgr.h" #include "Log.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "World.h" #include "ObjectMgr.h" -#include "GroupMgr.h" +#include "Opcodes.h" +#include "Pet.h" #include "Player.h" -#include "Group.h" #include "SocialMgr.h" -#include "Util.h" #include "SpellAuras.h" +#include "Util.h" #include "Vehicle.h" +#include "World.h" +#include "WorldPacket.h" +#include "WorldSession.h" class Aura; diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp index 83deaaa1bc6..635afd55a87 100755 --- a/src/server/game/Handlers/LootHandler.cpp +++ b/src/server/game/Handlers/LootHandler.cpp @@ -28,7 +28,7 @@ #include "Object.h" #include "Group.h" #include "World.h" -#include "Util.h" +#include "Creature.h" void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket & recvData) { diff --git a/src/server/game/Handlers/NPCHandler.cpp b/src/server/game/Handlers/NPCHandler.cpp index 0265d1e6f60..ef0f8e130b6 100755 --- a/src/server/game/Handlers/NPCHandler.cpp +++ b/src/server/game/Handlers/NPCHandler.cpp @@ -31,6 +31,7 @@ #include "ObjectAccessor.h" #include "Creature.h" #include "Pet.h" +#include "ReputationMgr.h" #include "BattlegroundMgr.h" #include "Battleground.h" #include "ScriptMgr.h" diff --git a/src/server/game/Handlers/SkillHandler.cpp b/src/server/game/Handlers/SkillHandler.cpp index 88ae01f59be..ec389142182 100755 --- a/src/server/game/Handlers/SkillHandler.cpp +++ b/src/server/game/Handlers/SkillHandler.cpp @@ -18,13 +18,14 @@ #include "Common.h" #include "DatabaseEnv.h" -#include "Opcodes.h" #include "Log.h" +#include "ObjectAccessor.h" +#include "Opcodes.h" #include "Player.h" +#include "Pet.h" +#include "UpdateMask.h" #include "WorldPacket.h" #include "WorldSession.h" -#include "ObjectAccessor.h" -#include "UpdateMask.h" void WorldSession::HandleLearnTalentOpcode(WorldPacket & recvData) { diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp index f8df5862df0..a2628fbb265 100755 --- a/src/server/game/Instances/InstanceScript.cpp +++ b/src/server/game/Instances/InstanceScript.cpp @@ -16,15 +16,16 @@ * with this program. If not, see . */ -#include "InstanceScript.h" -#include "DatabaseEnv.h" -#include "Map.h" -#include "Player.h" -#include "GameObject.h" #include "Creature.h" #include "CreatureAI.h" -#include "Log.h" +#include "DatabaseEnv.h" +#include "GameObject.h" +#include "InstanceScript.h" #include "LFGMgr.h" +#include "Log.h" +#include "Map.h" +#include "Player.h" +#include "Pet.h" void InstanceScript::SaveToDB() { diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index d40be13c6d8..115d56a607c 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -17,23 +17,24 @@ */ #include "Map.h" -#include "GridStates.h" -#include "ScriptMgr.h" -#include "VMapFactory.h" -#include "MapInstanced.h" +#include "Battleground.h" #include "CellImpl.h" +#include "DynamicTree.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" -#include "Transport.h" +#include "GridStates.h" +#include "Group.h" #include "InstanceScript.h" -#include "ObjectAccessor.h" +#include "LFGMgr.h" +#include "MapInstanced.h" #include "MapManager.h" +#include "ObjectAccessor.h" #include "ObjectMgr.h" -#include "Group.h" -#include "LFGMgr.h" -#include "DynamicTree.h" +#include "Pet.h" +#include "ScriptMgr.h" +#include "Transport.h" #include "Vehicle.h" -#include "Battleground.h" +#include "VMapFactory.h" union u_map_magic { diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp index 517ea6cb6bd..069ae71b7cb 100755 --- a/src/server/game/Scripting/MapScripts.cpp +++ b/src/server/game/Scripting/MapScripts.cpp @@ -16,19 +16,20 @@ * with this program. If not, see . */ -#include "Map.h" -#include "World.h" #include "CellImpl.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" -#include "Transport.h" -#include "ScriptedCreature.h" -#include "WaypointManager.h" #include "GossipDef.h" +#include "Map.h" #include "MapManager.h" -#include "ObjectMgr.h" #include "MapRefManager.h" +#include "ObjectMgr.h" +#include "Pet.h" +#include "ScriptedCreature.h" #include "ScriptMgr.h" +#include "Transport.h" +#include "WaypointManager.h" +#include "World.h" /// Put scripts in the execution queue void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, Object* target) diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index d1e7f87ccff..ac745eb1b5f 100755 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -1187,12 +1187,12 @@ void ScriptMgr::OnShutdown() FOREACH_SCRIPT(WorldScript)->OnShutdown(); } -bool ScriptMgr::OnCriteriaCheck(AchievementCriteriaData const* data, Player* source, Unit* target) +bool ScriptMgr::OnCriteriaCheck(uint32 scriptId, Player* source, Unit* target) { ASSERT(source); // target can be NULL. - GET_SCRIPT_RET(AchievementCriteriaScript, data->ScriptId, tmpscript, false); + GET_SCRIPT_RET(AchievementCriteriaScript, scriptId, tmpscript, false); return tmpscript->OnCheck(source, target); } diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 0f16c648b20..947be2b73fe 100755 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -979,7 +979,7 @@ class ScriptMgr public: /* AchievementCriteriaScript */ - bool OnCriteriaCheck(AchievementCriteriaData const* data, Player* source, Unit* target); + bool OnCriteriaCheck(uint32 scriptId, Player* source, Unit* target); public: /* PlayerScript */ diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 5e9e8cc090b..b29f1498152 100755 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -38,6 +38,8 @@ #include "Vehicle.h" #include "Battlefield.h" #include "BattlefieldMgr.h" +#include "Pet.h" +#include "ReputationMgr.h" class Aura; // diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 1f0532d9b1e..15a3887ac0e 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -63,6 +63,7 @@ #include "GameObjectAI.h" #include "AccountMgr.h" #include "InstanceScript.h" +#include "ReputationMgr.h" pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= { diff --git a/src/server/game/Tickets/TicketMgr.cpp b/src/server/game/Tickets/TicketMgr.cpp index 5667b31048e..3003221b650 100755 --- a/src/server/game/Tickets/TicketMgr.cpp +++ b/src/server/game/Tickets/TicketMgr.cpp @@ -20,6 +20,7 @@ #include "TicketMgr.h" #include "DatabaseEnv.h" #include "Log.h" +#include "Language.h" #include "WorldPacket.h" #include "WorldSession.h" #include "Chat.h" diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index 6b6e94f75fb..9269bbb07ee 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -22,10 +22,11 @@ Comment: All account related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" #include "AccountMgr.h" #include "Chat.h" +#include "Language.h" #include "Player.h" +#include "ScriptMgr.h" class account_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_achievement.cpp b/src/server/scripts/Commands/cs_achievement.cpp index 1cb9c4829ec..9f5c861c52f 100644 --- a/src/server/scripts/Commands/cs_achievement.cpp +++ b/src/server/scripts/Commands/cs_achievement.cpp @@ -22,9 +22,10 @@ Comment: All achievement related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" #include "Chat.h" +#include "Language.h" #include "Player.h" +#include "ScriptMgr.h" class achievement_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp index af04a3b7989..3d340f3aaea 100644 --- a/src/server/scripts/Commands/cs_ban.cpp +++ b/src/server/scripts/Commands/cs_ban.cpp @@ -22,12 +22,13 @@ Comment: All ban related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "Chat.h" #include "AccountMgr.h" +#include "Chat.h" +#include "Language.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "Player.h" +#include "ScriptMgr.h" class ban_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_cast.cpp b/src/server/scripts/Commands/cs_cast.cpp index 5a45f980c2c..7539ebd2b0c 100644 --- a/src/server/scripts/Commands/cs_cast.cpp +++ b/src/server/scripts/Commands/cs_cast.cpp @@ -24,6 +24,8 @@ EndScriptData */ #include "ScriptMgr.h" #include "Chat.h" +#include "Creature.h" +#include "Language.h" #include "Player.h" class cast_commandscript : public CommandScript diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp index a352f930410..f8db39e0338 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -22,12 +22,13 @@ Comment: All character related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "Chat.h" #include "AccountMgr.h" +#include "Chat.h" #include "ObjectMgr.h" #include "PlayerDump.h" #include "Player.h" +#include "ReputationMgr.h" +#include "ScriptMgr.h" class character_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_cheat.cpp b/src/server/scripts/Commands/cs_cheat.cpp index 1fe50038d59..026177ece6d 100644 --- a/src/server/scripts/Commands/cs_cheat.cpp +++ b/src/server/scripts/Commands/cs_cheat.cpp @@ -22,10 +22,11 @@ Comment: All cheat related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" #include "Chat.h" +#include "Language.h" +#include "ObjectMgr.h" #include "Player.h" +#include "ScriptMgr.h" class cheat_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 99ed8cc4301..956d9ac3376 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -31,6 +31,7 @@ EndScriptData */ #include "GridNotifiers.h" #include "GridNotifiersImpl.h" #include "GossipDef.h" +#include "Language.h" #include diff --git a/src/server/scripts/Commands/cs_disable.cpp b/src/server/scripts/Commands/cs_disable.cpp index d9be14f67e4..73ed341a21c 100644 --- a/src/server/scripts/Commands/cs_disable.cpp +++ b/src/server/scripts/Commands/cs_disable.cpp @@ -22,13 +22,14 @@ Comment: All disable related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" #include "Chat.h" #include "DisableMgr.h" +#include "Language.h" +#include "ObjectMgr.h" #include "OutdoorPvP.h" -#include "SpellMgr.h" #include "Player.h" +#include "ScriptMgr.h" +#include "SpellMgr.h" class disable_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_event.cpp b/src/server/scripts/Commands/cs_event.cpp index 8d053a2f061..b0a646b7288 100644 --- a/src/server/scripts/Commands/cs_event.cpp +++ b/src/server/scripts/Commands/cs_event.cpp @@ -22,10 +22,11 @@ Comment: All event related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "GameEventMgr.h" #include "Chat.h" +#include "GameEventMgr.h" +#include "Language.h" #include "Player.h" +#include "ScriptMgr.h" class event_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp index 520df4b7b85..0c24a9d8746 100644 --- a/src/server/scripts/Commands/cs_gm.cpp +++ b/src/server/scripts/Commands/cs_gm.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ObjectMgr.h" #include "Chat.h" #include "AccountMgr.h" +#include "Language.h" #include "World.h" #include "Player.h" diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp index 82ca77eb65b..6d75e63d053 100644 --- a/src/server/scripts/Commands/cs_go.cpp +++ b/src/server/scripts/Commands/cs_go.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "MapManager.h" #include "TicketMgr.h" #include "Chat.h" +#include "Language.h" #include "Player.h" class go_commandscript : public CommandScript diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index 7955678b8fd..5a24df4ee66 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -28,6 +28,7 @@ EndScriptData */ #include "PoolMgr.h" #include "MapManager.h" #include "Chat.h" +#include "Language.h" #include "Player.h" class gobject_commandscript : public CommandScript diff --git a/src/server/scripts/Commands/cs_guild.cpp b/src/server/scripts/Commands/cs_guild.cpp index a453122aef6..73955a6b9b2 100644 --- a/src/server/scripts/Commands/cs_guild.cpp +++ b/src/server/scripts/Commands/cs_guild.cpp @@ -22,11 +22,12 @@ Comment: All guild related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" #include "Chat.h" +#include "Language.h" #include "Guild.h" #include "GuildMgr.h" #include "ObjectAccessor.h" +#include "ScriptMgr.h" class guild_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_honor.cpp b/src/server/scripts/Commands/cs_honor.cpp index 76f5badb707..c1d9229ccd3 100644 --- a/src/server/scripts/Commands/cs_honor.cpp +++ b/src/server/scripts/Commands/cs_honor.cpp @@ -22,10 +22,11 @@ Comment: All honor related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" #include "Chat.h" +#include "Language.h" +#include "ObjectMgr.h" #include "Player.h" +#include "ScriptMgr.h" class honor_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_learn.cpp b/src/server/scripts/Commands/cs_learn.cpp index 786b949b5b4..9c383153d46 100644 --- a/src/server/scripts/Commands/cs_learn.cpp +++ b/src/server/scripts/Commands/cs_learn.cpp @@ -25,9 +25,11 @@ EndScriptData */ #include "Chat.h" #include "ScriptMgr.h" #include "ObjectMgr.h" +#include "Language.h" #include "SpellMgr.h" #include "SpellInfo.h" #include "Player.h" +#include "Pet.h" class learn_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_lfg.cpp b/src/server/scripts/Commands/cs_lfg.cpp index 6739694f228..c4da37d032c 100644 --- a/src/server/scripts/Commands/cs_lfg.cpp +++ b/src/server/scripts/Commands/cs_lfg.cpp @@ -17,6 +17,7 @@ #include "ScriptMgr.h" #include "Chat.h" +#include "Language.h" #include "LFGMgr.h" #include "Group.h" #include "Player.h" diff --git a/src/server/scripts/Commands/cs_list.cpp b/src/server/scripts/Commands/cs_list.cpp index 8d333338be3..977369d1405 100644 --- a/src/server/scripts/Commands/cs_list.cpp +++ b/src/server/scripts/Commands/cs_list.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "Chat.h" #include "SpellAuraEffects.h" +#include "Language.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "Player.h" diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp index f07862342fd..e7e86fedef0 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -22,13 +22,14 @@ Comment: All lookup related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "Chat.h" #include "AccountMgr.h" +#include "Chat.h" #include "GameEventMgr.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "Player.h" +#include "ReputationMgr.h" +#include "ScriptMgr.h" class lookup_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_message.cpp b/src/server/scripts/Commands/cs_message.cpp index d7c2f6117ac..30c94442c51 100644 --- a/src/server/scripts/Commands/cs_message.cpp +++ b/src/server/scripts/Commands/cs_message.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "Chat.h" #include "ChannelMgr.h" +#include "Language.h" #include "Player.h" class message_commandscript : public CommandScript diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 1cd78759d60..8a5af6c0df3 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -23,6 +23,7 @@ #include "GridNotifiers.h" #include "Group.h" #include "InstanceSaveMgr.h" +#include "Language.h" #include "MovementGenerator.h" #include "ObjectAccessor.h" #include "SpellAuras.h" @@ -30,6 +31,7 @@ #include "WeatherMgr.h" #include "ace/INET_Addr.h" #include "Player.h" +#include "Pet.h" class misc_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index 1fc5e99a094..23a1d90368f 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -22,10 +22,12 @@ Comment: All modify related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" #include "Chat.h" +#include "ObjectMgr.h" +#include "Pet.h" #include "Player.h" +#include "ReputationMgr.h" +#include "ScriptMgr.h" class modify_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 91711072545..28e0744c29d 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -27,9 +27,11 @@ EndScriptData */ #include "Chat.h" #include "Transport.h" #include "CreatureGroups.h" +#include "Language.h" #include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand #include "CreatureAI.h" #include "Player.h" +#include "Pet.h" class npc_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp index 5776022e59f..22d6e0831d6 100644 --- a/src/server/scripts/Commands/cs_quest.cpp +++ b/src/server/scripts/Commands/cs_quest.cpp @@ -22,10 +22,11 @@ Comment: All quest related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" #include "Chat.h" +#include "ObjectMgr.h" #include "Player.h" +#include "ReputationMgr.h" +#include "ScriptMgr.h" class quest_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index 10b3fd1b997..c2791c815ad 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -22,22 +22,24 @@ Comment: All reload related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" -#include "SpellMgr.h" -#include "TicketMgr.h" -#include "MapManager.h" +#include "AchievementMgr.h" +#include "AuctionHouseMgr.h" +#include "Chat.h" #include "CreatureEventAIMgr.h" +#include "CreatureTextMgr.h" #include "DisableMgr.h" +#include "Language.h" #include "LFGMgr.h" -#include "AuctionHouseMgr.h" -#include "CreatureTextMgr.h" -#include "SmartAI.h" +#include "MapManager.h" +#include "ObjectMgr.h" +#include "ScriptMgr.h" #include "SkillDiscovery.h" #include "SkillExtraItems.h" -#include "Chat.h" -#include "WaypointManager.h" +#include "SmartAI.h" +#include "SpellMgr.h" +#include "TicketMgr.h" #include "WardenCheckMgr.h" +#include "WaypointManager.h" class reload_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_reset.cpp b/src/server/scripts/Commands/cs_reset.cpp index d4610d57292..21a22381ae0 100644 --- a/src/server/scripts/Commands/cs_reset.cpp +++ b/src/server/scripts/Commands/cs_reset.cpp @@ -22,10 +22,13 @@ Comment: All reset related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" +#include "AchievementMgr.h" #include "Chat.h" +#include "Language.h" #include "ObjectAccessor.h" #include "Player.h" +#include "Pet.h" +#include "ScriptMgr.h" class reset_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp index 131d7a4149a..bb4f9be5ffe 100644 --- a/src/server/scripts/Commands/cs_server.cpp +++ b/src/server/scripts/Commands/cs_server.cpp @@ -22,12 +22,13 @@ Comment: All server related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" #include "Chat.h" -#include "SystemConfig.h" #include "Config.h" +#include "Language.h" #include "ObjectAccessor.h" #include "Player.h" +#include "ScriptMgr.h" +#include "SystemConfig.h" class server_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp index 553559afd1c..756bd75387b 100644 --- a/src/server/scripts/Commands/cs_tele.cpp +++ b/src/server/scripts/Commands/cs_tele.cpp @@ -22,12 +22,13 @@ Comment: All tele related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" -#include "MapManager.h" #include "Chat.h" #include "Group.h" +#include "Language.h" +#include "MapManager.h" +#include "ObjectMgr.h" #include "Player.h" +#include "ScriptMgr.h" class tele_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_ticket.cpp b/src/server/scripts/Commands/cs_ticket.cpp index 72804ed5727..c0b3809c836 100644 --- a/src/server/scripts/Commands/cs_ticket.cpp +++ b/src/server/scripts/Commands/cs_ticket.cpp @@ -22,12 +22,13 @@ Comment: All ticket related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "Chat.h" #include "AccountMgr.h" +#include "Chat.h" +#include "Language.h" #include "ObjectMgr.h" -#include "TicketMgr.h" #include "Player.h" +#include "TicketMgr.h" +#include "ScriptMgr.h" class ticket_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_titles.cpp b/src/server/scripts/Commands/cs_titles.cpp index d25899cb094..c6e11c930fb 100644 --- a/src/server/scripts/Commands/cs_titles.cpp +++ b/src/server/scripts/Commands/cs_titles.cpp @@ -22,10 +22,11 @@ Comment: All titles related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" #include "Chat.h" +#include "Language.h" +#include "ObjectMgr.h" #include "Player.h" +#include "ScriptMgr.h" class titles_commandscript : public CommandScript { diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index 33adfe62391..c0b2938c156 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -22,11 +22,12 @@ Comment: All wp related commands Category: commandscripts EndScriptData */ -#include "ScriptMgr.h" -#include "ObjectMgr.h" -#include "WaypointManager.h" #include "Chat.h" +#include "Language.h" +#include "ObjectMgr.h" #include "Player.h" +#include "ScriptMgr.h" +#include "WaypointManager.h" class wp_commandscript : public CommandScript { diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 8e3be212081..026a0c7b280 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -23,17 +23,19 @@ */ #include "ScriptMgr.h" -#include "SpellScript.h" -#include "SpellAuraEffects.h" -#include "SkillDiscovery.h" +#include "Battleground.h" #include "Cell.h" #include "CellImpl.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" -#include "InstanceScript.h" #include "Group.h" +#include "InstanceScript.h" #include "LFGMgr.h" -#include "Battleground.h" +#include "Pet.h" +#include "ReputationMgr.h" +#include "SkillDiscovery.h" +#include "SpellScript.h" +#include "SpellAuraEffects.h" class spell_gen_absorb0_hitlimit1 : public SpellScriptLoader { diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 0f8fa9614a7..a73af6892ca 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -21,7 +21,7 @@ * Scriptnames of files in this file should be prefixed with "spell_hun_". */ -#include "Player.h" +#include "Pet.h" #include "ScriptMgr.h" #include "Cell.h" #include "CellImpl.h" diff --git a/src/server/shared/Dynamic/LinkedReference/Reference.h b/src/server/shared/Dynamic/LinkedReference/Reference.h index 6c9710381b9..22921b075fe 100755 --- a/src/server/shared/Dynamic/LinkedReference/Reference.h +++ b/src/server/shared/Dynamic/LinkedReference/Reference.h @@ -20,6 +20,7 @@ #define _REFERENCE_H #include "Dynamic/LinkedList.h" +#include //===================================================== -- cgit v1.2.3