diff options
-rw-r--r-- | sql/base/characters_database.sql | 38 | ||||
-rw-r--r-- | sql/updates/characters/yyyy_mm_dd_xx_characters.sql | 20 | ||||
-rw-r--r-- | src/server/game/Calendar/CalendarMgr.cpp | 284 | ||||
-rw-r--r-- | src/server/game/Calendar/CalendarMgr.h | 105 | ||||
-rw-r--r-- | src/server/game/Guilds/Guild.cpp | 18 | ||||
-rw-r--r-- | src/server/game/Handlers/CalendarHandler.cpp | 476 | ||||
-rw-r--r-- | src/server/game/Server/Packets/CalendarPackets.cpp | 461 | ||||
-rw-r--r-- | src/server/game/Server/Packets/CalendarPackets.h | 562 | ||||
-rw-r--r-- | src/server/game/Server/Protocol/Opcodes.cpp | 65 | ||||
-rw-r--r-- | src/server/game/Server/WorldSession.h | 49 | ||||
-rw-r--r-- | src/server/shared/Database/Implementation/CharacterDatabase.cpp | 8 |
11 files changed, 1475 insertions, 611 deletions
diff --git a/sql/base/characters_database.sql b/sql/base/characters_database.sql index 2f3490c4689..6981e227ab6 100644 --- a/sql/base/characters_database.sql +++ b/sql/base/characters_database.sql @@ -271,16 +271,16 @@ DROP TABLE IF EXISTS `calendar_events`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `calendar_events` ( - `id` bigint(20) unsigned NOT NULL DEFAULT '0', - `creator` bigint(20) 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`) + `EventID` bigint(20) unsigned NOT NULL DEFAULT '0', + `Owner` bigint(20) unsigned NOT NULL DEFAULT '0', + `Title` varchar(255) NOT NULL DEFAULT '', + `Description` varchar(255) NOT NULL DEFAULT '', + `EventType` tinyint(1) unsigned NOT NULL DEFAULT '4', + `TextureID` int(10) NOT NULL DEFAULT '-1', + `Date` int(10) unsigned NOT NULL DEFAULT '0', + `Flags` int(10) unsigned NOT NULL DEFAULT '0', + `LockDate` int(10) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`EventID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -301,15 +301,15 @@ DROP TABLE IF EXISTS `calendar_invites`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `calendar_invites` ( - `id` bigint(20) unsigned NOT NULL DEFAULT '0', - `event` bigint(20) unsigned NOT NULL DEFAULT '0', - `invitee` bigint(20) unsigned NOT NULL DEFAULT '0', - `sender` bigint(20) 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`) + `InviteID` bigint(20) unsigned NOT NULL DEFAULT '0', + `EventID` bigint(20) unsigned NOT NULL DEFAULT '0', + `Invitee` bigint(20) unsigned NOT NULL DEFAULT '0', + `Sender` bigint(20) unsigned NOT NULL DEFAULT '0', + `Status` tinyint(1) unsigned NOT NULL DEFAULT '0', + `ResponseTime` int(10) unsigned NOT NULL DEFAULT '0', + `ModerationRank` tinyint(1) unsigned NOT NULL DEFAULT '0', + `Note` varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (`InviteID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/sql/updates/characters/yyyy_mm_dd_xx_characters.sql b/sql/updates/characters/yyyy_mm_dd_xx_characters.sql new file mode 100644 index 00000000000..d2a607a9fa6 --- /dev/null +++ b/sql/updates/characters/yyyy_mm_dd_xx_characters.sql @@ -0,0 +1,20 @@ +ALTER TABLE `calendar_invites` + CHANGE COLUMN `id` `InviteID` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' FIRST, + CHANGE COLUMN `event` `EventID` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `InviteID`, + CHANGE COLUMN `invitee` `Invitee` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `EventID`, + CHANGE COLUMN `sender` `Sender` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `Invitee`, + CHANGE COLUMN `status` `Status` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `Sender`, + CHANGE COLUMN `statustime` `ResponseTime` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `Status`, + CHANGE COLUMN `rank` `ModerationRank` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `ResponseTime`, + CHANGE COLUMN `text` `Note` VARCHAR(255) NOT NULL DEFAULT '' AFTER `ModerationRank`; + +ALTER TABLE `calendar_events` + CHANGE COLUMN `id` `EventID` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' FIRST, + CHANGE COLUMN `creator` `Owner` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `EventID`, + CHANGE COLUMN `title` `Title` VARCHAR(255) NOT NULL DEFAULT '' AFTER `Owner`, + CHANGE COLUMN `description` `Description` VARCHAR(255) NOT NULL DEFAULT '' AFTER `Title`, + CHANGE COLUMN `type` `EventType` TINYINT(1) UNSIGNED NOT NULL DEFAULT '4' AFTER `Description`, + CHANGE COLUMN `dungeon` `TextureID` INT(10) NOT NULL DEFAULT '-1' AFTER `EventType`, + CHANGE COLUMN `eventtime` `Date` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `TextureID`, + CHANGE COLUMN `flags` `Flags` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `Date`, + CHANGE COLUMN `time2` `LockDate` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `Flags`; diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp index 82c8ced3801..e31b9739654 100644 --- a/src/server/game/Calendar/CalendarMgr.cpp +++ b/src/server/game/Calendar/CalendarMgr.cpp @@ -22,6 +22,7 @@ #include "GuildMgr.h" #include "ObjectAccessor.h" #include "Opcodes.h" +#include "CalendarPackets.h" CalendarInvite::~CalendarInvite() { @@ -51,30 +52,30 @@ void CalendarMgr::LoadFromDB() _maxEventId = 0; _maxInviteId = 0; - // 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")) + // 0 1 2 3 4 5 6 7 8 + if (QueryResult result = CharacterDatabase.Query("SELECT EventID, Owner, Title, Description, EventType, TextureID, Date, Flags, LockDate FROM calendar_events")) do { Field* fields = result->Fetch(); - uint64 eventId = fields[0].GetUInt64(); - ObjectGuid creatorGUID = ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt64()); + uint64 eventID = fields[0].GetUInt64(); + ObjectGuid ownerGUID = ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt64()); 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(); + int32 textureID = fields[5].GetInt32(); + uint32 date = fields[6].GetUInt32(); uint32 flags = fields[7].GetUInt32(); - uint32 timezoneTime = fields[8].GetUInt32(); - ObjectGuid::LowType guildId = UI64LIT(0); + uint32 lockDate = fields[8].GetUInt32(); + ObjectGuid::LowType guildID = UI64LIT(0); if (flags & CALENDAR_FLAG_GUILD_EVENT || flags & CALENDAR_FLAG_WITHOUT_INVITES) - guildId = Player::GetGuildIdFromDB(creatorGUID); + guildID = Player::GetGuildIdFromDB(ownerGUID); - CalendarEvent* calendarEvent = new CalendarEvent(eventId, creatorGUID, guildId, type, dungeonId, time_t(eventTime), flags, time_t(timezoneTime), title, description); + CalendarEvent* calendarEvent = new CalendarEvent(eventID, ownerGUID, guildID, type, textureID, time_t(date), flags, title, description, time_t(lockDate)); _events.insert(calendarEvent); - _maxEventId = std::max(_maxEventId, eventId); + _maxEventId = std::max(_maxEventId, eventID); ++count; } @@ -83,8 +84,8 @@ void CalendarMgr::LoadFromDB() TC_LOG_INFO("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")) + // 0 1 2 3 4 5 6 7 + if (QueryResult result = CharacterDatabase.Query("SELECT InviteID, EventID, Invitee, Sender, Status, ResponseTime, ModerationRank, Note FROM calendar_invites")) do { Field* fields = result->Fetch(); @@ -94,11 +95,11 @@ void CalendarMgr::LoadFromDB() ObjectGuid invitee = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt64()); ObjectGuid senderGUID = ObjectGuid::Create<HighGuid::Player>(fields[3].GetUInt64()); CalendarInviteStatus status = CalendarInviteStatus(fields[4].GetUInt8()); - uint32 statusTime = fields[5].GetUInt32(); + uint32 responseTime = fields[5].GetUInt32(); CalendarModerationRank rank = CalendarModerationRank(fields[6].GetUInt8()); - std::string text = fields[7].GetString(); + std::string note = fields[7].GetString(); - CalendarInvite* invite = new CalendarInvite(inviteId, eventId, invitee, senderGUID, time_t(statusTime), status, rank, text); + CalendarInvite* invite = new CalendarInvite(inviteId, eventId, invitee, senderGUID, time_t(responseTime), status, rank, note); _invites[eventId].push_back(invite); _maxInviteId = std::max(_maxInviteId, inviteId); @@ -122,7 +123,7 @@ void CalendarMgr::AddEvent(CalendarEvent* calendarEvent, CalendarSendEventType s { _events.insert(calendarEvent); UpdateEvent(calendarEvent); - SendCalendarEvent(calendarEvent->GetCreatorGUID(), *calendarEvent, sendType); + SendCalendarEvent(calendarEvent->GetOwnerGUID(), *calendarEvent, sendType); } void CalendarMgr::AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite) @@ -133,10 +134,10 @@ void CalendarMgr::AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite void CalendarMgr::AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite, SQLTransaction& trans) { - if (!calendarEvent->IsGuildAnnouncement()) + if (!calendarEvent->IsGuildAnnouncement() && calendarEvent->GetOwnerGUID() != invite->GetInviteeGUID()) SendCalendarEventInvite(*invite); - if (!calendarEvent->IsGuildEvent() || invite->GetInviteeGUID() == calendarEvent->GetCreatorGUID()) + if (!calendarEvent->IsGuildEvent() || invite->GetInviteeGUID() == calendarEvent->GetOwnerGUID()) SendCalendarEventInviteAlert(*calendarEvent, *invite); if (!calendarEvent->IsGuildAnnouncement()) @@ -228,14 +229,14 @@ void CalendarMgr::UpdateEvent(CalendarEvent* calendarEvent) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_EVENT); stmt->setUInt64(0, calendarEvent->GetEventId()); - stmt->setUInt64(1, calendarEvent->GetCreatorGUID().GetCounter()); + stmt->setUInt64(1, calendarEvent->GetOwnerGUID().GetCounter()); 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->setInt32(5, calendarEvent->GetTextureId()); + stmt->setUInt32(6, uint32(calendarEvent->GetDate())); stmt->setUInt32(7, calendarEvent->GetFlags()); - stmt->setUInt32(8, calendarEvent->GetTimeZoneTime()); // correct? + stmt->setUInt32(8, uint32(calendarEvent->GetLockDate())); CharacterDatabase.Execute(stmt); } @@ -253,16 +254,16 @@ void CalendarMgr::UpdateInvite(CalendarInvite* invite, SQLTransaction& trans) stmt->setUInt64(2, invite->GetInviteeGUID().GetCounter()); stmt->setUInt64(3, invite->GetSenderGUID().GetCounter()); stmt->setUInt8(4, invite->GetStatus()); - stmt->setUInt32(5, uint32(invite->GetStatusTime())); + stmt->setUInt32(5, uint32(invite->GetResponseTime())); stmt->setUInt8(6, invite->GetRank()); - stmt->setString(7, invite->GetText()); + stmt->setString(7, invite->GetNote()); CharacterDatabase.ExecuteOrAppend(trans, stmt); } void CalendarMgr::RemoveAllPlayerEventsAndInvites(ObjectGuid guid) { for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) - if ((*itr)->GetCreatorGUID() == guid) + if ((*itr)->GetOwnerGUID() == guid) RemoveEvent((*itr)->GetEventId(), ObjectGuid::Empty); // don't send mail if removing a character CalendarInviteStore playerInvites = GetPlayerInvites(guid); @@ -273,7 +274,7 @@ void CalendarMgr::RemoveAllPlayerEventsAndInvites(ObjectGuid guid) void CalendarMgr::RemovePlayerGuildEventsAndSignups(ObjectGuid guid, ObjectGuid::LowType guildId) { for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) - if ((*itr)->GetCreatorGUID() == guid && ((*itr)->IsGuildEvent() || (*itr)->IsGuildAnnouncement())) + if ((*itr)->GetOwnerGUID() == guid && ((*itr)->IsGuildEvent() || (*itr)->IsGuildAnnouncement())) RemoveEvent((*itr)->GetEventId(), guid); CalendarInviteStore playerInvites = GetPlayerInvites(guid); @@ -411,7 +412,7 @@ std::string CalendarEvent::BuildCalendarMailBody() const std::ostringstream strm; // we are supposed to send PackedTime so i used WorldPacket to pack it - data.AppendPackedTime(_eventTime); + data.AppendPackedTime(_date); data >> time; strm << time; return strm.str(); @@ -420,130 +421,123 @@ std::string CalendarEvent::BuildCalendarMailBody() const void CalendarMgr::SendCalendarEventInvite(CalendarInvite const& invite) { CalendarEvent* calendarEvent = GetEvent(invite.GetEventId()); - time_t statusTime = invite.GetStatusTime(); - bool hasStatusTime = statusTime != 946684800; // 01/01/2000 00:00:00 ObjectGuid invitee = invite.GetInviteeGUID(); Player* player = ObjectAccessor::FindConnectedPlayer(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 << 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 + WorldPackets::Calendar::SCalendarEventInvite packet; + packet.EventID = calendarEvent ? calendarEvent->GetEventId() : 0; + packet.InviteGuid = invitee; + packet.InviteID = calendarEvent ? invite.GetInviteId() : 0; + packet.Level = level; + packet.ResponseTime = invite.GetResponseTime(); + packet.Status = invite.GetStatus(); + packet.Type = calendarEvent ? calendarEvent->IsGuildEvent() : 0; // Correct ? + packet.ClearPending = calendarEvent ? !calendarEvent->IsGuildEvent() : true; // Correct ? if (!calendarEvent) // Pre-invite { if (Player* playerSender = ObjectAccessor::FindConnectedPlayer(invite.GetSenderGUID())) - playerSender->SendDirectMessage(&data); + playerSender->SendDirectMessage(packet.Write()); } else { - if (calendarEvent->GetCreatorGUID() != invite.GetInviteeGUID()) // correct? - SendPacketToAllEventRelatives(data, *calendarEvent); + if (calendarEvent->GetOwnerGUID() != invite.GetInviteeGUID()) // correct? + SendPacketToAllEventRelatives(packet.Write(), *calendarEvent); } } -void CalendarMgr::SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, time_t oldEventTime) +void CalendarMgr::SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, time_t originalDate) { - 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 + WorldPackets::Calendar::CalendarEventUpdatedAlert packet; + packet.ClearPending = true; // FIXME + packet.Date = calendarEvent.GetDate(); + packet.Description = calendarEvent.GetDescription(); + packet.EventID = calendarEvent.GetEventId(); + packet.EventName = calendarEvent.GetTitle(); + packet.EventType = calendarEvent.GetType(); + packet.Flags = calendarEvent.GetFlags(); + packet.LockDate = calendarEvent.GetLockDate(); // Always 0 ? + packet.OriginalDate = originalDate; + packet.TextureID = calendarEvent.GetTextureId(); - SendPacketToAllEventRelatives(data, calendarEvent); + SendPacketToAllEventRelatives(packet.Write(), calendarEvent); } void CalendarMgr::SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite) { - WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_STATUS, 8 + 8 + 4 + 4 + 1 + 1 + 4); - data << 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()); + WorldPackets::Calendar::CalendarEventInviteStatus packet; + packet.ClearPending = true; // FIXME + packet.Date = calendarEvent.GetDate(); + packet.EventID = calendarEvent.GetEventId(); + packet.Flags = calendarEvent.GetFlags(); + packet.InviteGuid = invite.GetInviteeGUID(); + packet.ResponseTime = invite.GetResponseTime(); + packet.Status = invite.GetStatus(); - SendPacketToAllEventRelatives(data, calendarEvent); + SendPacketToAllEventRelatives(packet.Write(), calendarEvent); } void CalendarMgr::SendCalendarEventRemovedAlert(CalendarEvent const& calendarEvent) { - 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()); + WorldPackets::Calendar::CalendarEventRemovedAlert packet; + packet.ClearPending = true; // FIXME + packet.Date = calendarEvent.GetDate(); + packet.EventID = calendarEvent.GetEventId(); - SendPacketToAllEventRelatives(data, calendarEvent); + SendPacketToAllEventRelatives(packet.Write(), calendarEvent); } void CalendarMgr::SendCalendarEventInviteRemove(CalendarEvent const& calendarEvent, CalendarInvite const& invite, uint32 flags) { - WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_REMOVED, 8 + 4 + 4 + 1); - data << invite.GetInviteeGUID(); - data << uint64(invite.GetEventId()); - data << uint32(flags); - data << uint8(1); // FIXME + WorldPackets::Calendar::CalendarEventInviteRemoved packet; + packet.ClearPending = true; // FIXME + packet.EventID = calendarEvent.GetEventId(); + packet.Flags = flags; + packet.InviteGuid = invite.GetInviteeGUID(); - SendPacketToAllEventRelatives(data, calendarEvent); + SendPacketToAllEventRelatives(packet.Write(), calendarEvent); } void CalendarMgr::SendCalendarEventModeratorStatusAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite) { - WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_MODERATOR_STATUS, 8 + 8 + 1 + 1); - data << invite.GetInviteeGUID(); - data << uint64(invite.GetEventId()); - data << uint8(invite.GetRank()); - data << uint8(1); // Unk boolean - Display to client? + WorldPackets::Calendar::CalendarEventInviteModeratorStatus packet; + packet.ClearPending = true; // FIXME + packet.EventID = calendarEvent.GetEventId(); + packet.InviteGuid = invite.GetInviteeGUID(); + packet.Status = invite.GetStatus(); - SendPacketToAllEventRelatives(data, calendarEvent); + SendPacketToAllEventRelatives(packet.Write(), calendarEvent); } void CalendarMgr::SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& 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()); + WorldPackets::Calendar::CalendarEventInviteAlert packet; + packet.Date = calendarEvent.GetDate(); + packet.EventID = calendarEvent.GetEventId(); + packet.EventName = calendarEvent.GetTitle(); + packet.EventType = calendarEvent.GetType(); + packet.Flags = calendarEvent.GetFlags(); + packet.InviteID = invite.GetInviteId(); + packet.InvitedByGuid = invite.GetSenderGUID(); + packet.ModeratorStatus = invite.GetRank(); + packet.OwnerGuid = calendarEvent.GetOwnerGUID(); + packet.Status = invite.GetStatus(); + packet.TextureID = calendarEvent.GetTextureId(); Guild* guild = sGuildMgr->GetGuildById(calendarEvent.GetGuildId()); - data << (guild ? guild->GetGUID() : ObjectGuid::Empty); - - data << uint8(invite.GetStatus()); - data << uint8(invite.GetRank()); - data << calendarEvent.GetCreatorGUID(); - data << invite.GetSenderGUID(); + packet.EventGuildID = guild ? guild->GetGUID() : ObjectGuid::Empty; if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement()) { if (guild) - guild->BroadcastPacket(&data); + guild->BroadcastPacket(packet.Write()); } else if (Player* player = ObjectAccessor::FindConnectedPlayer(invite.GetInviteeGUID())) - player->SendDirectMessage(&data); + player->SendDirectMessage(packet.Write()); } void CalendarMgr::SendCalendarEvent(ObjectGuid guid, CalendarEvent const& calendarEvent, CalendarSendEventType sendType) @@ -554,105 +548,99 @@ void CalendarMgr::SendCalendarEvent(ObjectGuid guid, CalendarEvent const& calend CalendarInviteStore const& eventInviteeList = _invites[calendarEvent.GetEventId()]; - WorldPacket data(SMSG_CALENDAR_SEND_EVENT, 60 + eventInviteeList.size() * 32); - data << uint8(sendType); - data << 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()); + WorldPackets::Calendar::CalendarSendEvent packet; + packet.Date = calendarEvent.GetDate(); + packet.Description = calendarEvent.GetDescription(); + packet.EventID = calendarEvent.GetEventId(); + packet.EventName = calendarEvent.GetTitle(); + packet.EventType = sendType; + packet.Flags = calendarEvent.GetFlags(); + packet.GetEventType = calendarEvent.GetType(); + packet.LockDate = calendarEvent.GetLockDate(); // Always 0 ? + packet.OwnerGuid = calendarEvent.GetOwnerGUID(); + packet.TextureID = calendarEvent.GetTextureId(); Guild* guild = sGuildMgr->GetGuildById(calendarEvent.GetGuildId()); - data << (guild ? guild->GetGUID() : ObjectGuid::Empty); + packet.EventGuildID = (guild ? guild->GetGUID() : ObjectGuid::Empty); - data << uint32(eventInviteeList.size()); - for (CalendarInviteStore::const_iterator itr = eventInviteeList.begin(); itr != eventInviteeList.end(); ++itr) + for (auto const& calendarInvite : eventInviteeList) { - CalendarInvite const* calendarInvite = (*itr); ObjectGuid inviteeGuid = calendarInvite->GetInviteeGUID(); Player* invitee = ObjectAccessor::FindPlayer(inviteeGuid); uint8 inviteeLevel = invitee ? invitee->getLevel() : Player::GetLevelFromDB(inviteeGuid); ObjectGuid::LowType inviteeGuildId = invitee ? invitee->GetGuildId() : Player::GetGuildIdFromDB(inviteeGuid); - data << 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(); + WorldPackets::Calendar::CalendarEventInviteInfo inviteInfo; + inviteInfo.Guid = inviteeGuid; + inviteInfo.Level = inviteeLevel; + inviteInfo.Status = calendarInvite->GetStatus(); + inviteInfo.Moderator = calendarInvite->GetRank(); + inviteInfo.InviteType = calendarEvent.IsGuildEvent() && calendarEvent.GetGuildId() == inviteeGuildId; + inviteInfo.InviteID = calendarInvite->GetInviteId(); + inviteInfo.ResponseTime = calendarInvite->GetResponseTime(); + inviteInfo.Notes = calendarInvite->GetNote(); + + packet.Invites.push_back(inviteInfo); } - player->SendDirectMessage(&data); + player->SendDirectMessage(packet.Write()); } void CalendarMgr::SendCalendarEventInviteRemoveAlert(ObjectGuid guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status) { if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) { - 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); + WorldPackets::Calendar::CalendarEventInviteRemovedAlert packet; + packet.Date = calendarEvent.GetDate(); + packet.EventID = calendarEvent.GetEventId(); + packet.Flags = calendarEvent.GetFlags(); + packet.Status = status; - player->SendDirectMessage(&data); + player->SendDirectMessage(packet.Write()); } } void CalendarMgr::SendCalendarClearPendingAction(ObjectGuid guid) { if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) - { - WorldPacket data(SMSG_CALENDAR_CLEAR_PENDING_ACTION, 0); - player->SendDirectMessage(&data); - } + player->SendDirectMessage(WorldPackets::Calendar::CalendarClearPendingAction().Write()); } void CalendarMgr::SendCalendarCommandResult(ObjectGuid guid, CalendarError err, char const* param /*= NULL*/) { if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) { - WorldPacket data(SMSG_CALENDAR_COMMAND_RESULT, 0); - data << uint32(0); - data << uint8(0); + WorldPackets::Calendar::CalendarCommandResult packet; + packet.Command = 1; // FIXME + packet.Result = err; + switch (err) { case CALENDAR_ERROR_OTHER_INVITES_EXCEEDED: case CALENDAR_ERROR_ALREADY_INVITED_TO_EVENT_S: case CALENDAR_ERROR_IGNORING_YOU_S: - data << param; + packet.Name = param; break; default: - data << uint8(0); break; } - data << uint32(err); - - player->SendDirectMessage(&data); + player->SendDirectMessage(packet.Write()); } } -void CalendarMgr::SendPacketToAllEventRelatives(WorldPacket& packet, CalendarEvent const& calendarEvent) +void CalendarMgr::SendPacketToAllEventRelatives(WorldPacket const* packet, CalendarEvent const& calendarEvent) { // Send packet to all guild members if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement()) if (Guild* guild = sGuildMgr->GetGuildById(calendarEvent.GetGuildId())) - guild->BroadcastPacket(&packet); + 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) CalendarInviteStore invites = _invites[calendarEvent.GetEventId()]; for (CalendarInviteStore::iterator itr = invites.begin(); itr != invites.end(); ++itr) if (Player* player = ObjectAccessor::FindConnectedPlayer((*itr)->GetInviteeGUID())) if (!calendarEvent.IsGuildEvent() || (calendarEvent.IsGuildEvent() && player->GetGuildId() != calendarEvent.GetGuildId())) - player->SendDirectMessage(&packet); + player->SendDirectMessage(packet); } diff --git a/src/server/game/Calendar/CalendarMgr.h b/src/server/game/Calendar/CalendarMgr.h index 8122f41c0f5..5449c9c739f 100644 --- a/src/server/game/Calendar/CalendarMgr.h +++ b/src/server/game/Calendar/CalendarMgr.h @@ -123,9 +123,10 @@ enum CalendarError CALENDAR_ERROR_NO_MODERATOR = 40 }; -#define CALENDAR_MAX_EVENTS 30 -#define CALENDAR_MAX_GUILD_EVENTS 100 -#define CALENDAR_MAX_INVITES 100 +#define CALENDAR_MAX_EVENTS 30 +#define CALENDAR_MAX_GUILD_EVENTS 100 +#define CALENDAR_MAX_INVITES 100 +#define CALENDAR_DEFAULT_RESPONSE_TIME 946684800 // 01/01/2000 00:00:00 struct CalendarInvite { @@ -136,19 +137,19 @@ struct CalendarInvite _eventId = eventId; _invitee = calendarInvite.GetInviteeGUID(); _senderGUID = calendarInvite.GetSenderGUID(); - _statusTime = calendarInvite.GetStatusTime(); + _responseTime = calendarInvite.GetResponseTime(); _status = calendarInvite.GetStatus(); _rank = calendarInvite.GetRank(); - _text = calendarInvite.GetText(); + _note = calendarInvite.GetNote(); } - CalendarInvite() : _inviteId(1), _eventId(0), _invitee(), _senderGUID(), _statusTime(time(NULL)), - _status(CALENDAR_STATUS_INVITED), _rank(CALENDAR_RANK_PLAYER), _text("") { } + CalendarInvite() : _inviteId(1), _eventId(0), _invitee(), _senderGUID(), _responseTime(0), + _status(CALENDAR_STATUS_INVITED), _rank(CALENDAR_RANK_PLAYER), _note("") { } - CalendarInvite(uint64 inviteId, uint64 eventId, ObjectGuid invitee, ObjectGuid 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(uint64 inviteId, uint64 eventId, ObjectGuid invitee, ObjectGuid senderGUID, time_t responseTime, + CalendarInviteStatus status, CalendarModerationRank rank, std::string note) : + _inviteId(inviteId), _eventId(eventId), _invitee(invitee), _senderGUID(senderGUID), _responseTime(responseTime), + _status(status), _rank(rank), _note(note) { } ~CalendarInvite(); @@ -164,11 +165,11 @@ struct CalendarInvite void SetInvitee(ObjectGuid guid) { _invitee = guid; } ObjectGuid GetInviteeGUID() const { return _invitee; } - void SetStatusTime(time_t statusTime) { _statusTime = statusTime; } - time_t GetStatusTime() const { return _statusTime; } + void SetResponseTime(time_t responseTime) { _responseTime = responseTime; } + time_t GetResponseTime() const { return _responseTime; } - void SetText(std::string const& text) { _text = text; } - std::string GetText() const { return _text; } + void SetNote(std::string const& note) { _note = note; } + std::string GetNote() const { return _note; } void SetStatus(CalendarInviteStatus status) { _status = status; } CalendarInviteStatus GetStatus() const { return _status; } @@ -181,10 +182,10 @@ struct CalendarInvite uint64 _eventId; ObjectGuid _invitee; ObjectGuid _senderGUID; - time_t _statusTime; + time_t _responseTime; CalendarInviteStatus _status; CalendarModerationRank _rank; - std::string _text; + std::string _note; }; struct CalendarEvent @@ -193,36 +194,35 @@ struct CalendarEvent CalendarEvent(CalendarEvent const& calendarEvent, uint64 eventId) { _eventId = eventId; - _creatorGUID = calendarEvent.GetCreatorGUID(); - _guildId = calendarEvent.GetGuildId(); - _type = calendarEvent.GetType(); - _dungeonId = calendarEvent.GetDungeonId(); - _eventTime = calendarEvent.GetEventTime(); + _ownerGUID = calendarEvent.GetOwnerGUID(); + _eventGuildId = calendarEvent.GetGuildId(); + _eventType = calendarEvent.GetType(); + _textureId = calendarEvent.GetTextureId(); + _date = calendarEvent.GetDate(); _flags = calendarEvent.GetFlags(); - _timezoneTime = calendarEvent.GetTimeZoneTime(); _title = calendarEvent.GetTitle(); _description = calendarEvent.GetDescription(); + _lockDate = calendarEvent.GetLockDate(); } - CalendarEvent(uint64 eventId, ObjectGuid creatorGUID, ObjectGuid::LowType guildId, CalendarEventType type, int32 dungeonId, - time_t eventTime, uint32 flags, time_t timezoneTime, std::string title, std::string description) : - _eventId(eventId), _creatorGUID(creatorGUID), _guildId(guildId), _type(type), _dungeonId(dungeonId), - _eventTime(eventTime), _flags(flags), _timezoneTime(timezoneTime), _title(title), - _description(description) { } + CalendarEvent(uint64 eventId, ObjectGuid ownerGUID, ObjectGuid::LowType guildId, CalendarEventType type, int32 textureId, + time_t date, uint32 flags, std::string title, std::string description, time_t lockDate) : + _eventId(eventId), _ownerGUID(ownerGUID), _eventGuildId(guildId), _eventType(type), _textureId(textureId), + _date(date), _flags(flags), _title(title), _description(description), _lockDate(lockDate) { } - CalendarEvent() : _eventId(1), _creatorGUID(), _guildId(UI64LIT(0)), _type(CALENDAR_TYPE_OTHER), _dungeonId(-1), _eventTime(0), - _flags(0), _timezoneTime(0), _title(""), _description("") { } + CalendarEvent() : _eventId(1), _ownerGUID(), _eventGuildId(UI64LIT(0)), _eventType(CALENDAR_TYPE_OTHER), _textureId(-1), _date(0), + _flags(0), _title(""), _description(""), _lockDate(0) { } ~CalendarEvent(); void SetEventId(uint64 eventId) { _eventId = eventId; } uint64 GetEventId() const { return _eventId; } - void SetCreatorGUID(ObjectGuid guid) { _creatorGUID = guid; } - ObjectGuid GetCreatorGUID() const { return _creatorGUID; } + void SetOwnerGUID(ObjectGuid guid) { _ownerGUID = guid; } + ObjectGuid GetOwnerGUID() const { return _ownerGUID; } - void SetGuildId(ObjectGuid::LowType guildId) { _guildId = guildId; } - ObjectGuid::LowType GetGuildId() const { return _guildId; } + void SetGuildId(ObjectGuid::LowType guildId) { _eventGuildId = guildId; } + ObjectGuid::LowType GetGuildId() const { return _eventGuildId; } void SetTitle(std::string const& title) { _title = title; } std::string GetTitle() const { return _title; } @@ -230,42 +230,43 @@ struct CalendarEvent void SetDescription(std::string const& description) { _description = description; } std::string GetDescription() const { return _description; } - void SetType(CalendarEventType type) { _type = type; } - CalendarEventType GetType() const { return _type; } + void SetType(CalendarEventType eventType) { _eventType = eventType; } + CalendarEventType GetType() const { return _eventType; } - void SetDungeonId(int32 dungeonId) { _dungeonId = dungeonId; } - int32 GetDungeonId() const { return _dungeonId; } + void SetTextureId(int32 textureId) { _textureId = textureId; } + int32 GetTextureId() const { return _textureId; } - void SetEventTime(time_t eventTime) { _eventTime = eventTime; } - time_t GetEventTime() const { return _eventTime; } + void SetDate(time_t date) { _date = date; } + time_t GetDate() const { return _date; } 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) != 0; } bool IsGuildAnnouncement() const { return (_flags & CALENDAR_FLAG_WITHOUT_INVITES) != 0; } + bool IsLocked() const { return (_flags & CALENDAR_FLAG_INVITES_LOCKED) != 0; } + + void SetLockDate(time_t lockDate) { _lockDate = lockDate; } + time_t GetLockDate() const { return _lockDate; } std::string BuildCalendarMailSubject(ObjectGuid remover) const; std::string BuildCalendarMailBody() const; private: uint64 _eventId; - ObjectGuid _creatorGUID; - ObjectGuid::LowType _guildId; - CalendarEventType _type; - int32 _dungeonId; - time_t _eventTime; + ObjectGuid _ownerGUID; + ObjectGuid::LowType _eventGuildId; + CalendarEventType _eventType; + int32 _textureId; + time_t _date; uint32 _flags; - time_t _timezoneTime; std::string _title; std::string _description; + time_t _lockDate; }; typedef std::vector<CalendarInvite*> CalendarInviteStore; typedef std::set<CalendarEvent*> CalendarEventStore; -typedef std::map<uint64 /* eventId */, CalendarInviteStore > CalendarEventInviteStore; +typedef std::map<uint64 /* eventID */, CalendarInviteStore > CalendarEventInviteStore; class CalendarMgr { @@ -324,14 +325,14 @@ class CalendarMgr void SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite); void SendCalendarEventInviteRemove(CalendarEvent const& calendarEvent, CalendarInvite const& invite, uint32 flags); void SendCalendarEventInviteRemoveAlert(ObjectGuid guid, CalendarEvent const& calendarEvent, CalendarInviteStatus status); - void SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, time_t oldEventTime); + void SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, time_t originalDate); void SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite); void SendCalendarEventRemovedAlert(CalendarEvent const& calendarEvent); void SendCalendarEventModeratorStatusAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite); void SendCalendarClearPendingAction(ObjectGuid guid); void SendCalendarCommandResult(ObjectGuid guid, CalendarError err, char const* param = NULL); - void SendPacketToAllEventRelatives(WorldPacket& packet, CalendarEvent const& calendarEvent); + void SendPacketToAllEventRelatives(WorldPacket const* packet, CalendarEvent const& calendarEvent); }; #define sCalendarMgr CalendarMgr::instance() diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 97a965da681..e93a1da83b3 100644 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -31,6 +31,7 @@ #include "SocialMgr.h" #include "Opcodes.h" #include "ChatPackets.h" +#include "CalendarPackets.h" #define MAX_GUILD_BANK_TAB_TEXT_LEN 500 #define EMBLEM_PRICE 10 * GOLD @@ -2533,15 +2534,12 @@ void Guild::BroadcastPacketIfTrackingAchievement(WorldPacket const* packet, uint void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 maxLevel, uint32 minRank) { - uint32 count = 0; - - WorldPacket data(SMSG_CALENDAR_EVENT_INITIAL_INVITES); - data << uint32(count); // count placeholder + WorldPackets::Calendar::CalendarEventInitialInvites packet; 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 (packet.Invites.size() >= CALENDAR_MAX_INVITES) { if (Player* player = session->GetPlayer()) sCalendarMgr->SendCalendarCommandResult(player->GetGUID(), CALENDAR_ERROR_INVITES_EXCEEDED); @@ -2552,16 +2550,10 @@ void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 max uint32 level = Player::GetLevelFromDB(member->GetGUID()); if (member->GetGUID() != session->GetPlayer()->GetGUID() && level >= minLevel && level <= maxLevel && member->IsRankNotLower(minRank)) - { - data << member->GetGUID(); - data << uint8(level); - ++count; - } + packet.Invites.emplace_back(member->GetGUID(), level); } - data.put<uint32>(0, count); - - session->SendPacket(&data); + session->SendPacket(packet.Write()); } // Members handling diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index a6f39fcd09b..36d04d6772a 100644 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -19,10 +19,10 @@ /* ----- Opcodes Not Used yet ----- -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 [ uint64(eventId), uint32(eventTime), uint32(unkFlag), uint8(deletePending) ] +SMSG_CALENDAR_EVENT_INVITE_NOTES [ ObjectGuid(InviteGuid), bool(ClearPending), std::string(Notes), uint64(EventID) ] +?CMSG_CALENDAR_EVENT_INVITE_NOTES [ ObjectGuid(Guid), uint64(EventID), uint64(InviteID), uint64(ModeratorID), std::string(Notes) ] +SMSG_CALENDAR_EVENT_INVITE_NOTES_ALERT [ uint64(EventID), std::string(Notes) ] +SMSG_CALENDAR_EVENT_INVITE_STATUS_ALERT [ uint64(EventID), uint32(Date), uint32(Flags), uint8(Status) ] SMSG_CALENDAR_RAID_LOCKOUT_UPDATED SendCalendarRaidLockoutUpdated(InstanceSave const* save) @todo @@ -46,196 +46,119 @@ Copied events should probably have a new owner #include "DatabaseEnv.h" #include "GuildMgr.h" #include "WorldSession.h" +#include "CalendarPackets.h" -void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) +void WorldSession::HandleCalendarGetCalendar(WorldPackets::Calendar::CalendarGetCalendar& /*calendarGetCalendar*/) { ObjectGuid guid = _player->GetGUID(); - TC_LOG_DEBUG("network", "CMSG_CALENDAR_GET [%s]", guid.ToString().c_str()); - time_t currTime = time(NULL); - WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 1000); // Average size if no instance + WorldPackets::Calendar::CalendarSendCalendar packet; + packet.ServerNow = currTime; + packet.RaidOrigin = 1135753200; // Constant date, unk (28.12.2005 07:00) + packet.ServerTime = currTime; - CalendarInviteStore invites = sCalendarMgr->GetPlayerInvites(guid); - data << uint32(invites.size()); - for (CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) + CalendarInviteStore playerInvites = sCalendarMgr->GetPlayerInvites(guid); + for (auto const& invite : playerInvites) { - data << uint64((*itr)->GetEventId()); - data << uint64((*itr)->GetInviteId()); - data << uint8((*itr)->GetStatus()); - data << uint8((*itr)->GetRank()); - - if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent((*itr)->GetEventId())) - { - data << uint8(calendarEvent->IsGuildEvent()); - data << calendarEvent->GetCreatorGUID(); - } - else - { - data << uint8(0); - data << (*itr)->GetSenderGUID(); - } + WorldPackets::Calendar::CalendarSendCalendarInviteInfo inviteInfo; + inviteInfo.EventID = invite->GetEventId(); + inviteInfo.InviteID = invite->GetInviteId(); + inviteInfo.InviterGuid = invite->GetSenderGUID(); + inviteInfo.Status = invite->GetStatus(); + inviteInfo.Moderator = invite->GetRank(); + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(invite->GetEventId())) + inviteInfo.InviteType = calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == _player->GetGuildId(); + + packet.Invites.push_back(inviteInfo); } CalendarEventStore playerEvents = sCalendarMgr->GetPlayerEvents(guid); - data << uint32(playerEvents.size()); - for (CalendarEventStore::const_iterator itr = playerEvents.begin(); itr != playerEvents.end(); ++itr) + for (auto const& event : playerEvents) { - 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()); - - Guild* guild = sGuildMgr->GetGuildById(calendarEvent->GetGuildId()); - data << (guild ? guild->GetGUID() : ObjectGuid::Empty); - - data << calendarEvent->GetCreatorGUID(); + WorldPackets::Calendar::CalendarSendCalendarEventInfo eventInfo; + eventInfo.EventID = event->GetEventId(); + eventInfo.Date = event->GetDate(); + Guild* guild = sGuildMgr->GetGuildById(event->GetGuildId()); + eventInfo.EventGuildID = guild ? guild->GetGUID() : ObjectGuid::Empty; + eventInfo.EventName = event->GetTitle(); + eventInfo.EventType = event->GetType(); + eventInfo.Flags = event->GetFlags(); + eventInfo.OwnerGuid = event->GetOwnerGUID(); + eventInfo.TextureID = event->GetTextureId(); + + packet.Events.push_back(eventInfo); } - data << uint32(currTime); // server time - data.AppendPackedTime(currTime); // zone time - - ByteBuffer dataBuffer; - uint32 boundCounter = 0; for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { Player::BoundInstancesMap boundInstances = _player->GetBoundInstances(Difficulty(i)); - for (Player::BoundInstancesMap::const_iterator itr = boundInstances.begin(); itr != boundInstances.end(); ++itr) + for (auto const& boundInstance : boundInstances) { - if (itr->second.perm) + if (boundInstance.second.perm) { - InstanceSave const* save = itr->second.save; - dataBuffer << uint32(save->GetMapId()); - dataBuffer << uint32(save->GetDifficultyID()); - dataBuffer << uint32(save->GetResetTime() - currTime); - dataBuffer << uint64(save->GetInstanceId()); // instance save id as unique instance copy id - ++boundCounter; + WorldPackets::Calendar::CalendarSendCalendarRaidLockoutInfo lockoutInfo; + + InstanceSave const* save = boundInstance.second.save; + lockoutInfo.MapID = save->GetMapId(); + lockoutInfo.DifficultyID = save->GetDifficultyID(); + lockoutInfo.ExpireTime = save->GetResetTime() - currTime; + lockoutInfo.InstanceID = save->GetInstanceId(); // instance save id as unique instance copy id + + packet.RaidLockouts.push_back(lockoutInfo); } } } - data << uint32(boundCounter); - data.append(dataBuffer); - - data << uint32(1135753200); // Constant date, unk (28.12.2005 07:00) - - // Reuse variables - boundCounter = 0; std::set<uint32> sentMaps; - dataBuffer.clear(); - ResetTimeByMapDifficultyMap const& resets = sInstanceSaveMgr->GetResetTimeMap(); - for (ResetTimeByMapDifficultyMap::const_iterator itr = resets.begin(); itr != resets.end(); ++itr) + for (auto const& reset : resets) { - uint32 mapId = PAIR32_LOPART(itr->first); - if (sentMaps.find(mapId) != sentMaps.end()) + uint32 mapID = PAIR64_LOPART(reset.first); + if (sentMaps.find(mapID) != sentMaps.end()) continue; - MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); + MapEntry const* mapEntry = sMapStore.LookupEntry(mapID); if (!mapEntry || !mapEntry->IsRaid()) continue; - sentMaps.insert(mapId); - - dataBuffer << int32(mapId); - dataBuffer << int32(itr->second - currTime); - dataBuffer << int32(0); // Never seen anything else in sniffs - still unknown - ++boundCounter; - } - - data << uint32(boundCounter); - data.append(dataBuffer); + sentMaps.insert(mapID); + WorldPackets::Calendar::CalendarSendCalendarRaidResetInfo resetInfo; + resetInfo.MapID = mapID; + resetInfo.Duration = reset.second - currTime; + resetInfo.Offset = 0; // Never seen anything else in sniffs - still unknown - /// @todo Fix this, how we do know how many and what holidays to send? - uint32 holidayCount = 0; - data << uint32(holidayCount); - for (uint32 i = 0; i < holidayCount; ++i) - { - HolidaysEntry const* holiday = sHolidaysStore.LookupEntry(666); - - data << uint32(holiday->ID); // m_ID - data << uint32(holiday->Region); // m_region, might be looping - data << uint32(holiday->Looping); // m_looping, might be region - data << uint32(holiday->Priority); // m_priority - data << uint32(holiday->CalendarFilterType); // m_calendarFilterType - - for (uint8 j = 0; j < MAX_HOLIDAY_DATES; ++j) - 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 - - for (uint8 j = 0; j < MAX_HOLIDAY_FLAGS; ++j) - data << uint32(holiday->CalendarFlags[j]); // 10 * m_calendarFlags - - data << holiday->TextureFilename->Str[sWorld->GetDefaultDbcLocale()]; // m_textureFilename (holiday name) + packet.RaidResets.push_back(resetInfo); } - SendPacket(&data); + SendPacket(packet.Write()); } -void WorldSession::HandleCalendarGetEvent(WorldPacket& recvData) +void WorldSession::HandleCalendarGetEvent(WorldPackets::Calendar::CalendarGetEvent& calendarGetEvent) { - uint64 eventId; - recvData >> eventId; - - TC_LOG_DEBUG("network", "CMSG_CALENDAR_GET_EVENT. Player [%s] Event [" UI64FMTD "]", _player->GetGUID().ToString().c_str(), eventId); - - if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarGetEvent.EventID)) sCalendarMgr->SendCalendarEvent(_player->GetGUID(), *calendarEvent, CALENDAR_SENDTYPE_GET); else sCalendarMgr->SendCalendarCommandResult(_player->GetGUID(), CALENDAR_ERROR_EVENT_INVALID); } -void WorldSession::HandleCalendarGuildFilter(WorldPacket& recvData) +void WorldSession::HandleCalendarGuildFilter(WorldPackets::Calendar::CalendarGuildFilter& calendarGuildFilter) { - TC_LOG_DEBUG("network", "CMSG_CALENDAR_GUILD_FILTER [%s]", _player->GetGUID().ToString().c_str()); - - uint32 minLevel; - uint32 maxLevel; - uint32 minRank; - - recvData >> minLevel >> maxLevel >> minRank; - if (Guild* guild = sGuildMgr->GetGuildById(_player->GetGuildId())) - guild->MassInviteToEvent(this, minLevel, maxLevel, minRank); - - TC_LOG_DEBUG("network", "CMSG_CALENDAR_GUILD_FILTER: Min level [%d], Max level [%d], Min rank [%d]", minLevel, maxLevel, minRank); + guild->MassInviteToEvent(this, calendarGuildFilter.MinLevel, calendarGuildFilter.MaxLevel, calendarGuildFilter.MaxRankOrder); } -void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) +void WorldSession::HandleCalendarAddEvent(WorldPackets::Calendar::CalendarAddEvent& calendarAddEvent) { ObjectGuid guid = _player->GetGUID(); - std::string title; - std::string description; - uint8 type; - uint8 repeatable; - uint32 maxInvites; - int32 dungeonId; - uint32 eventPackedTime; - uint32 unkPackedTime; - uint32 flags; - - recvData >> title >> description >> type >> repeatable >> maxInvites >> dungeonId; - recvData.ReadPackedTime(eventPackedTime); - recvData.ReadPackedTime(unkPackedTime); - recvData >> flags; - // prevent events in the past // To Do: properly handle timezones and remove the "- time_t(86400L)" hack - if (time_t(eventPackedTime) < (time(NULL) - time_t(86400L))) - { - recvData.rfinish(); + if (calendarAddEvent.EventInfo.Time < (time(NULL) - time_t(86400L))) return; - } - CalendarEvent* calendarEvent = new CalendarEvent(sCalendarMgr->GetFreeEventId(), guid, UI64LIT(0), CalendarEventType(type), dungeonId, - time_t(eventPackedTime), flags, time_t(unkPackedTime), title, description); + CalendarEvent* calendarEvent = new CalendarEvent(sCalendarMgr->GetFreeEventId(), guid, UI64LIT(0), CalendarEventType(calendarAddEvent.EventInfo.EventType), calendarAddEvent.EventInfo.TextureID, + calendarAddEvent.EventInfo.Time, calendarAddEvent.EventInfo.Flags, calendarAddEvent.EventInfo.Title, calendarAddEvent.EventInfo.Description, time_t(0)); if (calendarEvent->IsGuildEvent() || calendarEvent->IsGuildAnnouncement()) if (Player* creator = ObjectAccessor::FindPlayer(guid)) @@ -243,8 +166,7 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) if (calendarEvent->IsGuildAnnouncement()) { - // 946684800 is 01/01/2000 00:00:00 - default response time - CalendarInvite invite(0, calendarEvent->GetEventId(), ObjectGuid::Empty, guid, 946684800, CALENDAR_STATUS_NOT_SIGNED_UP, CALENDAR_RANK_PLAYER, ""); + CalendarInvite invite(0, calendarEvent->GetEventId(), ObjectGuid::Empty, guid, CALENDAR_DEFAULT_RESPONSE_TIME, CALENDAR_STATUS_NOT_SIGNED_UP, CALENDAR_RANK_PLAYER, ""); // WARNING: By passing pointer to a local variable, the underlying method(s) must NOT perform any kind // of storage of the pointer as it will lead to memory corruption sCalendarMgr->AddInvite(calendarEvent, &invite); @@ -252,24 +174,19 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) else { // client limits the amount of players to be invited to 100 - const uint32 MaxPlayerInvites = 100; - - uint32 inviteCount; - ObjectGuid invitee[MaxPlayerInvites]; - uint8 status[MaxPlayerInvites]; - uint8 rank[MaxPlayerInvites]; + ObjectGuid invitee[CALENDAR_MAX_INVITES]; + uint8 status[CALENDAR_MAX_INVITES]; + uint8 rank[CALENDAR_MAX_INVITES]; memset(status, 0, sizeof(status)); memset(rank, 0, sizeof(rank)); - try { - recvData >> inviteCount; - - for (uint32 i = 0; i < inviteCount && i < MaxPlayerInvites; ++i) + for (uint32 i = 0; i < calendarAddEvent.EventInfo.Invites.size() && i < CALENDAR_MAX_INVITES; ++i) { - recvData >> invitee[i]; - recvData >> status[i] >> rank[i]; + invitee[i] = calendarAddEvent.EventInfo.Invites[i].Guid; + status[i] = calendarAddEvent.EventInfo.Invites[i].Status; + rank[i] = calendarAddEvent.EventInfo.Invites[i].Moderator; } } catch (ByteBufferException const&) @@ -280,71 +197,42 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) } SQLTransaction trans; - if (inviteCount > 1) + if (calendarAddEvent.EventInfo.Invites.size() > 1) trans = CharacterDatabase.BeginTransaction(); - for (uint32 i = 0; i < inviteCount && i < MaxPlayerInvites; ++i) + for (uint32 i = 0; i < calendarAddEvent.EventInfo.Invites.size() && i < CALENDAR_MAX_INVITES; ++i) { - // 946684800 is 01/01/2000 00:00:00 - default response time - CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent->GetEventId(), invitee[i], guid, 946684800, CalendarInviteStatus(status[i]), CalendarModerationRank(rank[i]), ""); + CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent->GetEventId(), invitee[i], guid, CALENDAR_DEFAULT_RESPONSE_TIME, CalendarInviteStatus(status[i]), CalendarModerationRank(rank[i]), ""); sCalendarMgr->AddInvite(calendarEvent, invite, trans); } - if (inviteCount > 1) + if (calendarAddEvent.EventInfo.Invites.size() > 1) CharacterDatabase.CommitTransaction(trans); } sCalendarMgr->AddEvent(calendarEvent, CALENDAR_SENDTYPE_ADD); } -void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData) +void WorldSession::HandleCalendarUpdateEvent(WorldPackets::Calendar::CalendarUpdateEvent& calendarUpdateEvent) { ObjectGuid guid = _player->GetGUID(); - time_t oldEventTime; - - uint64 eventId; - uint64 inviteId; - std::string title; - std::string description; - uint8 type; - uint8 repetitionType; - uint32 maxInvites; - int32 dungeonId; - uint32 eventPackedTime; - uint32 timeZoneTime; - uint32 flags; - - recvData >> eventId >> inviteId >> title >> description >> type >> repetitionType >> maxInvites >> dungeonId; - recvData.ReadPackedTime(eventPackedTime); - recvData.ReadPackedTime(timeZoneTime); - recvData >> flags; + time_t oldEventTime = time_t(0); // prevent events in the past // To Do: properly handle timezones and remove the "- time_t(86400L)" hack - if (time_t(eventPackedTime) < (time(NULL) - time_t(86400L))) - { - recvData.rfinish(); + if (calendarUpdateEvent.EventInfo.Time < (time(NULL) - time_t(86400L))) return; - } - - TC_LOG_DEBUG("network", "CMSG_CALENDAR_UPDATE_EVENT [%s] EventId [" UI64FMTD - "], InviteId [" UI64FMTD "] Title %s, Description %s, type %u " - "Repeatable %u, MaxInvites %u, Dungeon ID %d, Time %u " - "Time2 %u, Flags %u", guid.ToString().c_str(), eventId, inviteId, title.c_str(), - description.c_str(), type, repetitionType, maxInvites, dungeonId, - eventPackedTime, timeZoneTime, flags); - if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarUpdateEvent.EventInfo.EventID)) { - oldEventTime = calendarEvent->GetEventTime(); + oldEventTime = calendarEvent->GetDate(); - 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); + calendarEvent->SetType(CalendarEventType(calendarUpdateEvent.EventInfo.EventType)); + calendarEvent->SetFlags(calendarUpdateEvent.EventInfo.Flags); + calendarEvent->SetDate(calendarUpdateEvent.EventInfo.Time); + calendarEvent->SetTextureId(calendarUpdateEvent.EventInfo.TextureID); + calendarEvent->SetTitle(calendarUpdateEvent.EventInfo.Title); + calendarEvent->SetDescription(calendarUpdateEvent.EventInfo.Description); sCalendarMgr->UpdateEvent(calendarEvent); sCalendarMgr->SendCalendarEventUpdateAlert(*calendarEvent, oldEventTime); @@ -353,44 +241,28 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData) sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); } -void WorldSession::HandleCalendarRemoveEvent(WorldPacket& recvData) +void WorldSession::HandleCalendarRemoveEvent(WorldPackets::Calendar::CalendarRemoveEvent& calendarRemoveEvent) { ObjectGuid guid = _player->GetGUID(); - uint64 eventId; - - recvData >> eventId; - recvData.rfinish(); // Skip flags & invite ID, we don't use them - - sCalendarMgr->RemoveEvent(eventId, guid); + sCalendarMgr->RemoveEvent(calendarRemoveEvent.EventID, guid); } -void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData) +void WorldSession::HandleCalendarCopyEvent(WorldPackets::Calendar::CalendarCopyEvent& calendarCopyEvent) { ObjectGuid guid = _player->GetGUID(); - uint64 eventId; - uint64 inviteId; - uint32 eventTime; - - recvData >> eventId >> inviteId; - recvData.ReadPackedTime(eventTime); - TC_LOG_DEBUG("network", "CMSG_CALENDAR_COPY_EVENT [%s], EventId [" UI64FMTD - "] inviteId [" UI64FMTD "] Time: %u", guid.ToString().c_str(), eventId, inviteId, eventTime); // prevent events in the past // To Do: properly handle timezones and remove the "- time_t(86400L)" hack - if (time_t(eventTime) < (time(NULL) - time_t(86400L))) - { - recvData.rfinish(); + if (calendarCopyEvent.Date < (time(NULL) - time_t(86400L))) return; - } - if (CalendarEvent* oldEvent = sCalendarMgr->GetEvent(eventId)) + if (CalendarEvent* oldEvent = sCalendarMgr->GetEvent(calendarCopyEvent.EventID)) { CalendarEvent* newEvent = new CalendarEvent(*oldEvent, sCalendarMgr->GetFreeEventId()); - newEvent->SetEventTime(time_t(eventTime)); + newEvent->SetDate(calendarCopyEvent.Date); sCalendarMgr->AddEvent(newEvent, CALENDAR_SENDTYPE_COPY); - CalendarInviteStore invites = sCalendarMgr->GetEventInvites(eventId); + CalendarInviteStore invites = sCalendarMgr->GetEventInvites(calendarCopyEvent.EventID); SQLTransaction trans; if (invites.size() > 1) trans = CharacterDatabase.BeginTransaction(); @@ -400,31 +272,21 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData) if (invites.size() > 1) CharacterDatabase.CommitTransaction(trans); - // should we change owner when somebody makes a copy of event owned by another person? + // 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) +void WorldSession::HandleCalendarEventInvite(WorldPackets::Calendar::CalendarEventInvite& calendarEventInvite) { - TC_LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_INVITE"); - ObjectGuid playerGuid = _player->GetGUID(); - uint64 eventId; - uint64 inviteId; - std::string name; - bool isPreInvite; - bool isGuildEvent; - ObjectGuid inviteeGuid; uint32 inviteeTeam = 0; ObjectGuid::LowType inviteeGuildId = UI64LIT(0); - recvData >> eventId >> inviteId >> name >> isPreInvite >> isGuildEvent; - - if (Player* player = ObjectAccessor::FindConnectedPlayerByName(name)) + if (Player* player = ObjectAccessor::FindConnectedPlayerByName(calendarEventInvite.Name)) { // Invitee is online inviteeGuid = player->GetGUID(); @@ -435,7 +297,7 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData) { // Invitee offline, get data from database PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUID_RACE_ACC_BY_NAME); - stmt->setString(0, name); + stmt->setString(0, calendarEventInvite.Name); if (PreparedQueryResult result = CharacterDatabase.Query(stmt)) { Field* fields = result->Fetch(); @@ -462,14 +324,14 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData) Field* fields = result->Fetch(); if (fields[0].GetUInt8() & SOCIAL_FLAG_IGNORED) { - sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_IGNORING_YOU_S, name.c_str()); + sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_IGNORING_YOU_S, calendarEventInvite.Name.c_str()); return; } } - if (!isPreInvite) + if (!calendarEventInvite.Creating) { - if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarEventInvite.EventID)) { if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == inviteeGuildId) { @@ -478,8 +340,7 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData) return; } - // 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, ""); + CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEventInvite.EventID, inviteeGuid, playerGuid, CALENDAR_DEFAULT_RESPONSE_TIME, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, ""); sCalendarMgr->AddInvite(calendarEvent, invite); } else @@ -487,28 +348,24 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData) } else { - if (isGuildEvent && inviteeGuildId == _player->GetGuildId()) + if (calendarEventInvite.IsSignUp && inviteeGuildId == _player->GetGuildId()) { sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NO_GUILD_INVITES); return; } - // 946684800 is 01/01/2000 00:00:00 - default response time - CalendarInvite invite(inviteId, 0, inviteeGuid, playerGuid, 946684800, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, ""); + CalendarInvite invite(sCalendarMgr->GetFreeInviteId(), NULL, inviteeGuid, playerGuid, CALENDAR_DEFAULT_RESPONSE_TIME, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, ""); sCalendarMgr->SendCalendarEventInvite(invite); } } -void WorldSession::HandleCalendarEventSignup(WorldPacket& recvData) +void WorldSession::HandleCalendarEventSignup(WorldPackets::Calendar::CalendarEventSignUp& calendarEventSignUp) { ObjectGuid guid = _player->GetGUID(); - uint64 eventId; - bool tentative; - recvData >> eventId >> tentative; - TC_LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_SIGNUP [%s] EventId [" UI64FMTD "] Tentative %u", guid.ToString().c_str(), eventId, tentative); + TC_LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_SIGNUP [%s] EventId [" UI64FMTD "] Tentative %u", guid.ToString().c_str(), calendarEventSignUp.EventID, calendarEventSignUp.Tentative); - if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarEventSignUp.EventID)) { if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() != _player->GetGuildId()) { @@ -516,8 +373,8 @@ void WorldSession::HandleCalendarEventSignup(WorldPacket& recvData) 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, ""); + CalendarInviteStatus status = calendarEventSignUp.Tentative ? CALENDAR_STATUS_TENTATIVE : CALENDAR_STATUS_SIGNED_UP; + CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEventSignUp.EventID, guid, guid, time(NULL), status, CALENDAR_RANK_PLAYER, ""); sCalendarMgr->AddInvite(calendarEvent, invite); sCalendarMgr->SendCalendarClearPendingAction(guid); } @@ -525,31 +382,23 @@ void WorldSession::HandleCalendarEventSignup(WorldPacket& recvData) sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); } -void WorldSession::HandleCalendarEventRsvp(WorldPacket& recvData) +void WorldSession::HandleCalendarEventRsvp(WorldPackets::Calendar::CalendarEventRSVP& calendarEventRSVP) { ObjectGuid guid = _player->GetGUID(); - uint64 eventId; - uint64 inviteId; - uint32 status; - - recvData >> eventId >> inviteId >> status; - TC_LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_RSVP [%s] EventId [" - UI64FMTD "], InviteId [" UI64FMTD "], status %u", guid.ToString().c_str(), eventId, - inviteId, status); - if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarEventRSVP.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) + // I think we still should be able to remove self from locked events + if (calendarEventRSVP.Status != CALENDAR_STATUS_REMOVED && calendarEvent->IsLocked()) { sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_LOCKED); return; } - if (CalendarInvite* invite = sCalendarMgr->GetInvite(inviteId)) + if (CalendarInvite* invite = sCalendarMgr->GetInvite(calendarEventRSVP.InviteID)) { - invite->SetStatus(CalendarInviteStatus(status)); - invite->SetStatusTime(time(NULL)); + invite->SetStatus(CalendarInviteStatus(calendarEventRSVP.Status)); + invite->SetResponseTime(time(NULL)); sCalendarMgr->UpdateInvite(invite); sCalendarMgr->SendCalendarEventStatus(*calendarEvent, *invite); @@ -562,61 +411,45 @@ void WorldSession::HandleCalendarEventRsvp(WorldPacket& recvData) sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); } -void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket& recvData) +void WorldSession::HandleCalendarEventRemoveInvite(WorldPackets::Calendar::CalendarRemoveInvite& calendarRemoveInvite) { ObjectGuid guid = _player->GetGUID(); - ObjectGuid invitee; - uint64 eventId; - uint64 ownerInviteId; // isn't it sender's inviteId? - uint64 inviteId; - - recvData >> invitee; - recvData >> inviteId >> ownerInviteId >> eventId; TC_LOG_DEBUG("network", "CMSG_CALENDAR_REMOVE_INVITE [%s] EventId [" UI64FMTD "], ownerInviteId [" UI64FMTD "], Invitee ([%s] id: [" UI64FMTD "])", - guid.ToString().c_str(), eventId, ownerInviteId, invitee.ToString().c_str(), inviteId); + guid.ToString().c_str(), calendarRemoveInvite.EventID, calendarRemoveInvite.ModeratorID, calendarRemoveInvite.Guid.ToString().c_str(), calendarRemoveInvite.InviteID); - if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarRemoveInvite.EventID)) { - if (calendarEvent->GetCreatorGUID() == invitee) + if (calendarEvent->GetOwnerGUID() == calendarRemoveInvite.Guid) { sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_DELETE_CREATOR_FAILED); return; } - sCalendarMgr->RemoveInvite(inviteId, eventId, guid); + sCalendarMgr->RemoveInvite(calendarRemoveInvite.InviteID, calendarRemoveInvite.EventID, guid); } else sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_NO_INVITE); } -void WorldSession::HandleCalendarEventStatus(WorldPacket& recvData) +void WorldSession::HandleCalendarEventStatus(WorldPackets::Calendar::CalendarEventStatus& calendarEventStatus) { ObjectGuid guid = _player->GetGUID(); - ObjectGuid invitee; - uint64 eventId; - uint64 inviteId; - uint64 ownerInviteId; // isn't it sender's inviteId? - uint8 status; - recvData >> invitee; - recvData >> eventId >> inviteId >> ownerInviteId >> status; TC_LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_STATUS [%s] EventId [" UI64FMTD "] ownerInviteId [" UI64FMTD "], Invitee ([%s] id: [" - UI64FMTD "], status %u", guid.ToString().c_str(), eventId, ownerInviteId, invitee.ToString().c_str(), inviteId, status); + UI64FMTD "], status %u", guid.ToString().c_str(), calendarEventStatus.EventID, calendarEventStatus.ModeratorID, calendarEventStatus.Guid.ToString().c_str(), calendarEventStatus.InviteID, calendarEventStatus.Status); - if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarEventStatus.EventID)) { - if (CalendarInvite* invite = sCalendarMgr->GetInvite(inviteId)) + if (CalendarInvite* invite = sCalendarMgr->GetInvite(calendarEventStatus.InviteID)) { - invite->SetStatus((CalendarInviteStatus)status); - // not sure if we should set response time when moderator changes invite status - //invite->SetStatusTime(time(NULL)); + invite->SetStatus((CalendarInviteStatus)calendarEventStatus.Status); sCalendarMgr->UpdateInvite(invite); sCalendarMgr->SendCalendarEventStatus(*calendarEvent, *invite); - sCalendarMgr->SendCalendarClearPendingAction(invitee); + sCalendarMgr->SendCalendarClearPendingAction(calendarEventStatus.Guid); } else sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_NO_INVITE); // correct? @@ -625,26 +458,19 @@ void WorldSession::HandleCalendarEventStatus(WorldPacket& recvData) sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); } -void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket& recvData) +void WorldSession::HandleCalendarEventModeratorStatus(WorldPackets::Calendar::CalendarEventModeratorStatus& calendarEventModeratorStatus) { ObjectGuid guid = _player->GetGUID(); - ObjectGuid invitee; - uint64 eventId; - uint64 inviteId; - uint64 ownerInviteId; // isn't it sender's inviteId? - uint8 rank; - recvData >> invitee; - recvData >> eventId >> inviteId >> ownerInviteId >> rank; - TC_LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_MODERATOR_STATUS [%s] EventId [" - UI64FMTD "] ownerInviteId [" UI64FMTD "], Invitee ([%s] id: [" - UI64FMTD "], rank %u", guid.ToString().c_str(), eventId, ownerInviteId, invitee.ToString().c_str(), inviteId, rank); + TC_LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_MODERATOR_STATUS [%s] EventID [" + UI64FMTD "] ModeratorID [" UI64FMTD "], Invitee ([%s] InviteID: [" + UI64FMTD "], Status %u", guid.ToString().c_str(), calendarEventModeratorStatus.EventID, calendarEventModeratorStatus.ModeratorID, calendarEventModeratorStatus.Guid.ToString().c_str(), calendarEventModeratorStatus.InviteID, calendarEventModeratorStatus.Status); - if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId)) + if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarEventModeratorStatus.EventID)) { - if (CalendarInvite* invite = sCalendarMgr->GetInvite(inviteId)) + if (CalendarInvite* invite = sCalendarMgr->GetInvite(calendarEventModeratorStatus.InviteID)) { - invite->SetRank(CalendarModerationRank(rank)); + invite->SetRank(CalendarModerationRank(calendarEventModeratorStatus.Status)); sCalendarMgr->UpdateInvite(invite); sCalendarMgr->SendCalendarEventModeratorStatusAlert(*calendarEvent, *invite); } @@ -669,27 +495,22 @@ void WorldSession::HandleCalendarComplain(WorldPacket& recvData) // what to do with complains? } -void WorldSession::HandleCalendarGetNumPending(WorldPacket& /*recvData*/) +void WorldSession::HandleCalendarGetNumPending(WorldPackets::Calendar::CalendarGetNumPending& /*calendarGetNumPending*/) { ObjectGuid guid = _player->GetGUID(); uint32 pending = sCalendarMgr->GetPlayerNumPending(guid); TC_LOG_DEBUG("network", "CMSG_CALENDAR_GET_NUM_PENDING: [%s] Pending: %u", guid.ToString().c_str(), pending); - WorldPacket data(SMSG_CALENDAR_SEND_NUM_PENDING, 4); - data << uint32(pending); - SendPacket(&data); + SendPacket(WorldPackets::Calendar::CalendarSendNumPending(pending).Write()); } -void WorldSession::HandleSetSavedInstanceExtend(WorldPacket& recvData) +void WorldSession::HandleSetSavedInstanceExtend(WorldPackets::Calendar::SetSavedInstanceExtend& setSavedInstanceExtend) { - uint32 mapId, difficulty; - uint8 toggleExtend; - recvData >> mapId >> difficulty>> toggleExtend; - TC_LOG_DEBUG("network", "CMSG_SET_SAVED_INSTANCE_EXTEND - MapId: %u, Difficulty: %u, ToggleExtend: %s", mapId, difficulty, toggleExtend ? "On" : "Off"); + TC_LOG_DEBUG("network", "CMSG_SET_SAVED_INSTANCE_EXTEND - MapId: %u, Difficulty: %u, ToggleExtend: %s", setSavedInstanceExtend.MapID, setSavedInstanceExtend.DifficultyID, setSavedInstanceExtend.Extend ? "On" : "Off"); /* - InstancePlayerBind* instanceBind = _player->GetBoundInstance(mapId, Difficulty(difficulty)); + InstancePlayerBind* instanceBind = _player->GetBoundInstance(setSavedInstanceExtend.MapID, Difficulty(setSavedInstanceExtend.DifficultyID)); if (!instanceBind || !instanceBind->save) return; @@ -726,16 +547,15 @@ void WorldSession::SendCalendarRaidLockoutUpdated(InstanceSave const* save) return; ObjectGuid guid = _player->GetGUID(); - TC_LOG_DEBUG("network", "SMSG_CALENDAR_RAID_LOCKOUT_UPDATED [%s] Map: %u, Difficulty %u", - guid.ToString().c_str(), save->GetMapId(), save->GetDifficultyID()); + TC_LOG_DEBUG("network", "SMSG_CALENDAR_RAID_LOCKOUT_UPDATED [%s] Map: %u, Difficulty %u", guid.ToString().c_str(), save->GetMapId(), save->GetDifficultyID()); time_t currTime = time(NULL); - WorldPacket data(SMSG_CALENDAR_RAID_LOCKOUT_UPDATED, 4 + 4 + 4 + 4 + 8); - data.AppendPackedTime(currTime); - data << uint32(save->GetMapId()); - data << uint32(save->GetDifficultyID()); - data << uint32(0); // Amount of seconds that has changed to the reset time - data << uint32(save->GetResetTime() - currTime); - SendPacket(&data); + WorldPackets::Calendar::CalendarRaidLockoutUpdated packet; + packet.DifficultyID = save->GetDifficultyID(); + packet.MapID = save->GetMapId(); + packet.NewTimeRemaining = 0; // FIXME + packet.OldTimeRemaining = save->GetResetTime() - currTime; + + SendPacket(packet.Write()); } diff --git a/src/server/game/Server/Packets/CalendarPackets.cpp b/src/server/game/Server/Packets/CalendarPackets.cpp new file mode 100644 index 00000000000..655d33da73d --- /dev/null +++ b/src/server/game/Server/Packets/CalendarPackets.cpp @@ -0,0 +1,461 @@ +/* + * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "CalendarPackets.h" +#include "CalendarMgr.h" + +ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Calendar::CalendarSendCalendarEventInfo const& eventInfo) +{ + data << uint64(eventInfo.EventID); + data << uint8(eventInfo.EventType); + data.AppendPackedTime(eventInfo.Date); + data << uint32(eventInfo.Flags); + data << int32(eventInfo.TextureID); + data << eventInfo.EventGuildID; + data << eventInfo.OwnerGuid; + + data.WriteBits(eventInfo.EventName.size(), 8); + data.FlushBits(); + data.WriteString(eventInfo.EventName); + + return data; +} + +ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Calendar::CalendarSendCalendarRaidResetInfo const& resetInfo) +{ + data << int32(resetInfo.MapID); + data << uint32(resetInfo.Duration); + data << int32(resetInfo.Offset); + + return data; +} + +ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Calendar::CalendarSendCalendarRaidLockoutInfo const& lockoutInfo) +{ + data << uint64(lockoutInfo.InstanceID); + data << int32(lockoutInfo.MapID); + data << uint32(lockoutInfo.DifficultyID); + data << uint32(lockoutInfo.ExpireTime); + + return data; +} + +ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Calendar::CalendarSendCalendarInviteInfo const& inviteInfo) +{ + data << uint64(inviteInfo.EventID); + data << uint64(inviteInfo.InviteID); + data << uint8(inviteInfo.Status); + data << uint8(inviteInfo.Moderator); + data << uint8(inviteInfo.InviteType); + data << inviteInfo.InviterGuid; + + return data; +} + +ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Calendar::CalendarEventInviteInfo const& inviteInfo) +{ + data << inviteInfo.Guid; + data << uint64(inviteInfo.InviteID); + + data << uint8(inviteInfo.Level); + data << uint8(inviteInfo.Status); + data << uint8(inviteInfo.Moderator); + data << uint8(inviteInfo.InviteType); + + data.AppendPackedTime(inviteInfo.ResponseTime); + + data.WriteBits(inviteInfo.Notes.size(), 8); + data.FlushBits(); + data.WriteString(inviteInfo.Notes); + + return data; +} + +void WorldPackets::Calendar::CalendarGetEvent::Read() +{ + _worldPacket >> EventID; +} + +void WorldPackets::Calendar::CalendarGuildFilter::Read() +{ + _worldPacket >> MinLevel; + _worldPacket >> MaxLevel; + _worldPacket >> MaxRankOrder; +} + +void WorldPackets::Calendar::CalendarAddEvent::Read() +{ + uint8 titleLength = _worldPacket.ReadBits(8); + uint16 descriptionLength = _worldPacket.ReadBits(11); + + _worldPacket >> EventInfo.EventType; + _worldPacket >> EventInfo.TextureID; + EventInfo.Time = _worldPacket.ReadPackedTime(); + _worldPacket >> EventInfo.Flags; + uint32 count = _worldPacket.read<uint32>(); + + EventInfo.Title = _worldPacket.ReadString(titleLength); + EventInfo.Description = _worldPacket.ReadString(descriptionLength); + + for (uint32 i = 0; i < count && i < CALENDAR_MAX_INVITES; i++) + { + WorldPackets::Calendar::CalendarAddEventInviteInfo invite; + _worldPacket >> invite.Guid; + _worldPacket >> invite.Status; + _worldPacket >> invite.Moderator; + + EventInfo.Invites.push_back(invite); + } + + _worldPacket >> MaxSize; +} + +void WorldPackets::Calendar::CalendarUpdateEvent::Read() +{ + _worldPacket >> EventInfo.EventID; + _worldPacket >> EventInfo.ModeratorID; + _worldPacket >> EventInfo.EventType; + _worldPacket >> EventInfo.TextureID; + EventInfo.Time = _worldPacket.ReadPackedTime(); + _worldPacket >> EventInfo.Flags; + + uint8 titleLen = _worldPacket.ReadBits(8); + uint16 descLen = _worldPacket.ReadBits(11); + + EventInfo.Title = _worldPacket.ReadString(titleLen); + EventInfo.Description = _worldPacket.ReadString(descLen); + _worldPacket >> MaxSize; +} + +void WorldPackets::Calendar::CalendarRemoveEvent::Read() +{ + _worldPacket >> EventID; + _worldPacket >> ModeratorID; + _worldPacket >> Flags; +} + +void WorldPackets::Calendar::CalendarCopyEvent::Read() +{ + _worldPacket >> EventID; + _worldPacket >> ModeratorID; + Date = _worldPacket.ReadPackedTime(); +} + +void WorldPackets::Calendar::CalendarEventRSVP::Read() +{ + _worldPacket >> EventID; + _worldPacket >> InviteID; + _worldPacket >> Status; +} + +void WorldPackets::Calendar::CalendarEventInvite::Read() +{ + _worldPacket >> EventID; + _worldPacket >> ModeratorID; + + uint16 nameLen = _worldPacket.ReadBits(9); + Creating = _worldPacket.ReadBit(); + IsSignUp = _worldPacket.ReadBit(); + + Name = _worldPacket.ReadString(nameLen); +} + +void WorldPackets::Calendar::CalendarEventSignUp::Read() +{ + _worldPacket >> EventID; + Tentative = _worldPacket.ReadBit(); +} + +void WorldPackets::Calendar::CalendarRemoveInvite::Read() +{ + _worldPacket >> Guid; + _worldPacket >> InviteID; + _worldPacket >> ModeratorID; + _worldPacket >> EventID; +} + +void WorldPackets::Calendar::CalendarEventStatus::Read() +{ + _worldPacket >> Guid; + _worldPacket >> EventID; + _worldPacket >> InviteID; + _worldPacket >> ModeratorID; + _worldPacket >> Status; +} + +void WorldPackets::Calendar::SetSavedInstanceExtend::Read() +{ + _worldPacket >> MapID; + _worldPacket >> DifficultyID; + Extend = _worldPacket.ReadBit(); +} + +void WorldPackets::Calendar::CalendarEventModeratorStatus::Read() +{ + _worldPacket >> Guid; + _worldPacket >> EventID; + _worldPacket >> InviteID; + _worldPacket >> ModeratorID; + _worldPacket >> Status; +} + +WorldPacket const* WorldPackets::Calendar::SCalendarEventInvite::Write() +{ + _worldPacket << InviteGuid; + _worldPacket << uint64(EventID); + _worldPacket << uint64(InviteID); + _worldPacket << uint8(Level); + _worldPacket << uint8(Status); + _worldPacket << uint8(Type); + _worldPacket.AppendPackedTime(ResponseTime); + + _worldPacket.WriteBit(ClearPending); + _worldPacket.FlushBits(); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Calendar::CalendarSendCalendar::Write() +{ + _worldPacket << uint32(ServerNow); + _worldPacket.AppendPackedTime(ServerTime); + _worldPacket << uint32(RaidOrigin); + _worldPacket << uint32(Invites.size()); + _worldPacket << uint32(Events.size()); + _worldPacket << uint32(RaidLockouts.size()); + _worldPacket << uint32(RaidResets.size()); + + for (auto const& invite : Invites) + _worldPacket << invite; + + for (auto const& event : Events) + _worldPacket << event; + + for (auto const& lockout : RaidLockouts) + _worldPacket << lockout; + + for (auto const& reset : RaidResets) + _worldPacket << reset; + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Calendar::CalendarSendEvent::Write() +{ + _worldPacket << uint8(EventType); + _worldPacket << OwnerGuid; + _worldPacket << uint64(EventID); + _worldPacket << uint8(GetEventType); + _worldPacket << int32(TextureID); + _worldPacket << uint32(Flags); + _worldPacket.AppendPackedTime(Date); + _worldPacket << uint32(LockDate); + _worldPacket << EventGuildID; + + _worldPacket << uint32(Invites.size()); + for (auto const& invite : Invites) + _worldPacket << invite; + + _worldPacket.WriteBits(EventName.size(), 8); + _worldPacket.WriteBits(Description.size(), 11); + _worldPacket.FlushBits(); + + _worldPacket.WriteString(EventName); + _worldPacket.WriteString(Description); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Calendar::CalendarEventInviteAlert::Write() +{ + _worldPacket << uint64(EventID); + _worldPacket.AppendPackedTime(Date); + _worldPacket << uint32(Flags); + _worldPacket << uint8(EventType); + _worldPacket << int32(TextureID); + _worldPacket << EventGuildID; + _worldPacket << uint64(InviteID); + _worldPacket << uint8(Status); + _worldPacket << uint8(ModeratorStatus); + + // Todo: check order + _worldPacket << InvitedByGuid; + _worldPacket << OwnerGuid; + + _worldPacket.WriteBits(EventName.size(), 8); + _worldPacket.FlushBits(); + _worldPacket.WriteString(EventName); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Calendar::CalendarEventInviteStatus::Write() +{ + _worldPacket << InviteGuid; + _worldPacket << uint64(EventID); + _worldPacket.AppendPackedTime(Date); + _worldPacket << uint32(Flags); + _worldPacket << uint8(Status); + _worldPacket.AppendPackedTime(ResponseTime); + + _worldPacket.WriteBit(ClearPending); + _worldPacket.FlushBits(); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Calendar::CalendarEventInviteRemoved::Write() +{ + _worldPacket << InviteGuid; + _worldPacket << uint64(EventID); + _worldPacket << uint32(Flags); + + _worldPacket.WriteBit(ClearPending); + _worldPacket.FlushBits(); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Calendar::CalendarEventInviteModeratorStatus::Write() +{ + _worldPacket << InviteGuid; + _worldPacket << uint64(EventID); + _worldPacket << uint8(Status); + + _worldPacket.WriteBit(ClearPending); + _worldPacket.FlushBits(); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Calendar::CalendarEventInviteRemovedAlert::Write() +{ + _worldPacket << uint64(EventID); + _worldPacket.AppendPackedTime(Date); + _worldPacket << uint32(Flags); + _worldPacket << uint8(Status); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Calendar::CalendarEventUpdatedAlert::Write() +{ + _worldPacket << uint64(EventID); + + _worldPacket.AppendPackedTime(OriginalDate); + _worldPacket.AppendPackedTime(Date); + _worldPacket << uint32(LockDate); + _worldPacket << uint32(Flags); + _worldPacket << uint32(TextureID); + _worldPacket << uint8(EventType); + + _worldPacket.WriteBits(EventName.size(), 8); + _worldPacket.WriteBits(Description.size(), 11); + _worldPacket.WriteBit(ClearPending); + _worldPacket.FlushBits(); + + _worldPacket.WriteString(EventName); + _worldPacket.WriteString(Description); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Calendar::CalendarEventRemovedAlert::Write() +{ + _worldPacket << uint64(EventID); + _worldPacket.AppendPackedTime(Date); + + _worldPacket.WriteBit(ClearPending); + _worldPacket.FlushBits(); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Calendar::CalendarSendNumPending::Write() +{ + _worldPacket << uint32(NumPending); + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Calendar::CalendarCommandResult::Write() +{ + _worldPacket << uint8(Command); + _worldPacket << uint8(Result); + + _worldPacket.WriteBits(Name.size(), 9); + _worldPacket.FlushBits(); + _worldPacket.WriteString(Name); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Calendar::CalendarRaidLockoutUpdated::Write() +{ + _worldPacket << uint32(ServerTime); + _worldPacket << int32(MapID); + _worldPacket << uint32(DifficultyID); + _worldPacket << int32(NewTimeRemaining); + _worldPacket << int32(OldTimeRemaining); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Calendar::CalendarEventInitialInvites::Write() +{ + _worldPacket << uint32(Invites.size()); + for (auto const& invite : Invites) + { + _worldPacket << invite.InviteGuid; + _worldPacket << uint8(invite.Level); + } + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Calendar::CalendarEventInviteStatusAlert::Write() +{ + _worldPacket << uint64(EventID); + _worldPacket.AppendPackedTime(Date); + _worldPacket << uint32(Flags); + _worldPacket << uint8(Status); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Calendar::CalendarEventInviteNotesAlert::Write() +{ + _worldPacket << uint64(EventID); + + _worldPacket.WriteBits(Notes.size(), 8); + _worldPacket.FlushBits(); + _worldPacket.WriteString(Notes); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Calendar::CalendarEventInviteNotes::Write() +{ + _worldPacket << InviteGuid; + _worldPacket << uint64(EventID); + + _worldPacket.WriteBits(Notes.size(), 8); + _worldPacket.WriteBit(ClearPending); + _worldPacket.FlushBits(); + _worldPacket.WriteString(Notes); + + return &_worldPacket; +} diff --git a/src/server/game/Server/Packets/CalendarPackets.h b/src/server/game/Server/Packets/CalendarPackets.h new file mode 100644 index 00000000000..023041d427f --- /dev/null +++ b/src/server/game/Server/Packets/CalendarPackets.h @@ -0,0 +1,562 @@ +/* + * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ +/* + * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef CalendarPackets_h__ +#define CalendarPackets_h__ + +#include "ObjectGuid.h" +#include "Packet.h" + +namespace WorldPackets +{ + namespace Calendar + { + class CalendarGetCalendar final : public ClientPacket + { + public: + CalendarGetCalendar(WorldPacket&& packet) : ClientPacket(CMSG_CALENDAR_GET, std::move(packet)) { } + + void Read() override { } + }; + + class CalendarGetEvent final : public ClientPacket + { + public: + CalendarGetEvent(WorldPacket&& packet) : ClientPacket(CMSG_CALENDAR_GET_EVENT, std::move(packet)) { } + + void Read() override; + + uint64 EventID = 0; + }; + + class CalendarGuildFilter final : public ClientPacket + { + public: + CalendarGuildFilter(WorldPacket&& packet) : ClientPacket(CMSG_CALENDAR_GUILD_FILTER, std::move(packet)) { } + + void Read() override; + + uint8 MinLevel = 1; + uint8 MaxLevel = 100; + uint8 MaxRankOrder = 0; + }; + + struct CalendarAddEventInviteInfo + { + ObjectGuid Guid; + uint8 Status = 0; + uint8 Moderator = 0; + }; + + struct CalendarAddEventInfo + { + std::string Title; + std::string Description; + uint8 EventType = 0; + int32 TextureID = 0; + time_t Time = time_t(0); + uint32 Flags = 0; + std::vector<CalendarAddEventInviteInfo> Invites; + }; + + class CalendarAddEvent final : public ClientPacket + { + public: + CalendarAddEvent(WorldPacket&& packet) : ClientPacket(CMSG_CALENDAR_ADD_EVENT, std::move(packet)) { } + + void Read() override; + + uint32 MaxSize = 100; + CalendarAddEventInfo EventInfo; + }; + + struct CalendarUpdateEventInfo + { + uint64 EventID = 0; + uint64 ModeratorID = 0; + std::string Title; + std::string Description; + uint8 EventType = 0; + uint32 TextureID = 0; + time_t Time = time_t(0); + uint32 Flags = 0; + }; + + class CalendarUpdateEvent final : public ClientPacket + { + public: + CalendarUpdateEvent(WorldPacket&& packet) : ClientPacket(CMSG_CALENDAR_UPDATE_EVENT, std::move(packet)) { } + + void Read() override; + + uint32 MaxSize = 0; + CalendarUpdateEventInfo EventInfo; + }; + + class CalendarRemoveEvent final : public ClientPacket + { + public: + CalendarRemoveEvent(WorldPacket&& packet) : ClientPacket(CMSG_CALENDAR_REMOVE_EVENT, std::move(packet)) { } + + void Read() override; + + uint64 ModeratorID = 0; + uint64 EventID = 0; + uint32 Flags = 0; + }; + + class CalendarCopyEvent final : public ClientPacket + { + public: + CalendarCopyEvent(WorldPacket&& packet) : ClientPacket(CMSG_CALENDAR_COPY_EVENT, std::move(packet)) { } + + void Read() override; + + uint64 ModeratorID = 0; + uint64 EventID = 0; + time_t Date = time_t(0); + }; + + class SCalendarEventInvite final : public ServerPacket + { + public: + SCalendarEventInvite() : ServerPacket(SMSG_CALENDAR_EVENT_INVITE, 43) { } + + WorldPacket const* Write() override; + + uint64 InviteID = 0; + time_t ResponseTime = time_t(0); + uint8 Level = 100; + ObjectGuid InviteGuid; + uint64 EventID = 0; + uint8 Type = 0; + bool ClearPending = false; + uint8 Status = 0; + }; + + struct CalendarSendCalendarInviteInfo + { + uint64 EventID = 0; + uint64 InviteID = 0; + ObjectGuid InviterGuid; + uint8 Status = 0; + uint8 Moderator = 0; + uint8 InviteType = 0; + }; + + struct CalendarSendCalendarRaidLockoutInfo + { + uint64 InstanceID = 0; + int32 MapID = 0; + uint32 DifficultyID = 0; + time_t ExpireTime = time_t(0); + }; + + struct CalendarSendCalendarRaidResetInfo + { + int32 MapID = 0; + uint32 Duration = 0; + int32 Offset = 0; + }; + + struct CalendarSendCalendarEventInfo + { + uint64 EventID = 0; + std::string EventName; + uint8 EventType = 0; + time_t Date = time_t(0); + uint32 Flags = 0; + int32 TextureID = 0; + ObjectGuid EventGuildID; + ObjectGuid OwnerGuid; + }; + + class CalendarSendCalendar final : public ServerPacket + { + public: + CalendarSendCalendar() : ServerPacket(SMSG_CALENDAR_SEND_CALENDAR, 338) { } + + WorldPacket const* Write() override; + + time_t RaidOrigin = time_t(0); + time_t ServerTime = time_t(0); + time_t ServerNow = time_t(0); + std::vector<CalendarSendCalendarInviteInfo> Invites; + std::vector<CalendarSendCalendarRaidLockoutInfo> RaidLockouts; + std::vector<CalendarSendCalendarRaidResetInfo> RaidResets; + std::vector<CalendarSendCalendarEventInfo> Events; + }; + + struct CalendarEventInviteInfo + { + ObjectGuid Guid; + uint64 InviteID = 0; + time_t ResponseTime = time_t(0); + uint8 Level = 1; + uint8 Status = 0; + uint8 Moderator = 0; + uint8 InviteType = 0; + std::string Notes; + }; + + class CalendarSendEvent final : public ServerPacket + { + public: + CalendarSendEvent() : ServerPacket(SMSG_CALENDAR_SEND_EVENT, 93) { } + + WorldPacket const* Write() override; + + ObjectGuid OwnerGuid; + ObjectGuid EventGuildID; + uint64 EventID = 0; + time_t Date = time_t(0); + time_t LockDate = time_t(0); + uint32 Flags = 0; + int32 TextureID = 0; + uint8 GetEventType = 0; + uint8 EventType = 0; + std::string Description; + std::string EventName; + std::vector<CalendarEventInviteInfo> Invites; + }; + + class CalendarEventInviteAlert final : public ServerPacket + { + public: + CalendarEventInviteAlert() : ServerPacket(SMSG_CALENDAR_EVENT_INVITE_ALERT, 80) { } + + WorldPacket const* Write() override; + + ObjectGuid OwnerGuid; + ObjectGuid EventGuildID; + ObjectGuid InvitedByGuid; + uint64 InviteID = 0; + uint64 EventID = 0; + uint32 Flags = 0; + time_t Date = time_t(0); + int32 TextureID = 0; + uint8 Status = 0; + uint8 EventType = 0; + uint8 ModeratorStatus = 0; + std::string EventName; + }; + + class CalendarEventInvite final : public ClientPacket + { + public: + CalendarEventInvite(WorldPacket&& packet) : ClientPacket(CMSG_CALENDAR_EVENT_INVITE, std::move(packet)) { } + + void Read() override; + + uint64 ModeratorID = 0; + bool IsSignUp = false; + bool Creating = true; + uint64 EventID = 0; + std::string Name; + }; + + class CalendarEventRSVP final : public ClientPacket + { + public: + CalendarEventRSVP(WorldPacket&& packet) : ClientPacket(CMSG_CALENDAR_EVENT_RSVP, std::move(packet)) { } + + void Read() override; + + uint64 InviteID = 0; + uint64 EventID = 0; + uint8 Status = 0; + }; + + class CalendarEventInviteStatus final : public ServerPacket + { + public: + CalendarEventInviteStatus() : ServerPacket(SMSG_CALENDAR_EVENT_INVITE_STATUS, 41) { } + + WorldPacket const* Write() override; + + uint32 Flags = 0; + uint64 EventID = 0; + uint8 Status = 0; + bool ClearPending = false; + time_t ResponseTime = time_t(0); + time_t Date = time_t(0); + ObjectGuid InviteGuid; + }; + + class CalendarEventInviteRemoved final : public ServerPacket + { + public: + CalendarEventInviteRemoved() : ServerPacket(SMSG_CALENDAR_EVENT_INVITE_REMOVED, 29) { } + + WorldPacket const* Write() override; + + ObjectGuid InviteGuid; + uint64 EventID = 0; + uint32 Flags = 0; + bool ClearPending = false; + }; + + class CalendarEventInviteModeratorStatus final : public ServerPacket + { + public: + CalendarEventInviteModeratorStatus() : ServerPacket(SMSG_CALENDAR_EVENT_INVITE_MODERATOR_STATUS, 26) { } + + WorldPacket const* Write() override; + + ObjectGuid InviteGuid; + uint64 EventID = 0; + uint8 Status = 0; + bool ClearPending = false; + }; + + class CalendarEventInviteRemovedAlert final : public ServerPacket + { + public: + CalendarEventInviteRemovedAlert() : ServerPacket(SMSG_CALENDAR_EVENT_INVITE_REMOVED_ALERT, 17) { } + + WorldPacket const* Write() override; + + uint64 EventID = 0; + time_t Date = time_t(0); + uint32 Flags = 0; + uint8 Status = 0; + }; + + class CalendarClearPendingAction final : public ServerPacket + { + public: + CalendarClearPendingAction() : ServerPacket(SMSG_CALENDAR_CLEAR_PENDING_ACTION, 0) { } + + WorldPacket const* Write() override { return &_worldPacket; } + }; + + class CalendarEventUpdatedAlert final : public ServerPacket + { + public: + CalendarEventUpdatedAlert() : ServerPacket(SMSG_CALENDAR_EVENT_UPDATED_ALERT, 32) { } + + WorldPacket const* Write() override; + + uint64 EventID = 0; + time_t Date = time_t(0); + uint32 Flags = 0; + time_t LockDate = time_t(0); + time_t OriginalDate = time_t(0); + int32 TextureID = 0; + uint8 EventType = 0; + bool ClearPending = false; + std::string Description; + std::string EventName; + }; + + class CalendarEventRemovedAlert final : public ServerPacket + { + public: + CalendarEventRemovedAlert() : ServerPacket(SMSG_CALENDAR_EVENT_REMOVED_ALERT, 13) { } + + WorldPacket const* Write() override; + + uint64 EventID = 0; + time_t Date = time_t(0); + bool ClearPending = false; + }; + + class CalendarSendNumPending final : public ServerPacket + { + public: + CalendarSendNumPending() : ServerPacket(SMSG_CALENDAR_SEND_NUM_PENDING, 4) { } + CalendarSendNumPending(uint32 numPending) : ServerPacket(SMSG_CALENDAR_SEND_NUM_PENDING, 4), NumPending(numPending) { } + + WorldPacket const* Write() override; + + uint32 NumPending = 0; + }; + + class CalendarGetNumPending final : public ClientPacket + { + public: + CalendarGetNumPending(WorldPacket&& packet) : ClientPacket(CMSG_CALENDAR_GET_NUM_PENDING, std::move(packet)) { } + + void Read() override { } + }; + + class CalendarEventSignUp final : public ClientPacket + { + public: + CalendarEventSignUp(WorldPacket&& packet) : ClientPacket(CMSG_CALENDAR_EVENT_SIGN_UP, std::move(packet)) { } + + void Read() override; + + bool Tentative = false; + uint64 EventID = 0; + }; + + class CalendarRemoveInvite final : public ClientPacket + { + public: + CalendarRemoveInvite(WorldPacket&& packet) : ClientPacket(CMSG_CALENDAR_REMOVE_INVITE, std::move(packet)) { } + + void Read() override; + + ObjectGuid Guid; + uint64 EventID = 0; + uint64 ModeratorID = 0; + uint64 InviteID = 0; + }; + + class CalendarEventStatus final : public ClientPacket + { + public: + CalendarEventStatus(WorldPacket&& packet) : ClientPacket(CMSG_CALENDAR_EVENT_STATUS, std::move(packet)) { } + + void Read() override; + + ObjectGuid Guid; + uint64 EventID = 0; + uint64 ModeratorID = 0; + uint64 InviteID = 0; + uint8 Status = 0; + }; + + class SetSavedInstanceExtend final : public ClientPacket + { + public: + SetSavedInstanceExtend(WorldPacket&& packet) : ClientPacket(CMSG_SET_SAVED_INSTANCE_EXTEND, std::move(packet)) { } + + void Read() override; + + int32 MapID = 0; + bool Extend = false; + uint32 DifficultyID = 0; + }; + + class CalendarEventModeratorStatus final : public ClientPacket + { + public: + CalendarEventModeratorStatus(WorldPacket&& packet) : ClientPacket(CMSG_CALENDAR_EVENT_MODERATOR_STATUS, std::move(packet)) { } + + void Read() override; + + ObjectGuid Guid; + uint64 EventID = 0; + uint64 InviteID = 0; + uint64 ModeratorID = 0; + uint8 Status = 0; + }; + + class CalendarCommandResult final : public ServerPacket + { + public: + CalendarCommandResult() : ServerPacket(SMSG_CALENDAR_COMMAND_RESULT, 3) { } + CalendarCommandResult(uint8 command, uint8 result, std::string const& name) : ServerPacket(SMSG_CALENDAR_COMMAND_RESULT, 3), Command(command), Result(result), Name(name) { } + + WorldPacket const* Write() override; + + uint8 Command = 0; + uint8 Result = 0; + std::string Name; + }; + + class CalendarRaidLockoutUpdated final : public ServerPacket + { + public: + CalendarRaidLockoutUpdated() : ServerPacket(SMSG_CALENDAR_RAID_LOCKOUT_UPDATED, 20) { } + + WorldPacket const* Write() override; + + int32 MapID = 0; + int32 OldTimeRemaining = 0; + time_t ServerTime = 0; + uint32 DifficultyID = 0; + int32 NewTimeRemaining = 0; + }; + + struct CalendarEventInitialInviteInfo + { + CalendarEventInitialInviteInfo(ObjectGuid inviteGuid, uint8 level) : InviteGuid(inviteGuid), Level(level) { } + + ObjectGuid InviteGuid; + uint8 Level = 100; + }; + + class CalendarEventInitialInvites final : public ServerPacket + { + public: + CalendarEventInitialInvites() : ServerPacket(SMSG_CALENDAR_EVENT_INITIAL_INVITES, 17) { } + + WorldPacket const* Write() override; + + std::vector<CalendarEventInitialInviteInfo> Invites; + }; + + class CalendarEventInviteStatusAlert final : public ServerPacket + { + public: + CalendarEventInviteStatusAlert() : ServerPacket(SMSG_CALENDAR_EVENT_INVITE_STATUS_ALERT, 5) { } + + WorldPacket const* Write() override; + + uint64 EventID = 0; + uint32 Flags = 0; + time_t Date = time_t(0); + uint8 Status = 0; + }; + + class CalendarEventInviteNotesAlert final : public ServerPacket + { + public: + CalendarEventInviteNotesAlert() : ServerPacket(SMSG_CALENDAR_EVENT_INVITE_NOTES_ALERT, 9) { } + CalendarEventInviteNotesAlert(uint64 eventID, std::string const& notes) : ServerPacket(SMSG_CALENDAR_EVENT_INVITE_NOTES_ALERT, 8 + notes.size()), EventID(eventID), Notes(notes) { } + + WorldPacket const* Write() override; + + uint64 EventID = 0; + std::string Notes; + }; + + class CalendarEventInviteNotes final : public ServerPacket + { + public: + CalendarEventInviteNotes() : ServerPacket(SMSG_CALENDAR_EVENT_INVITE_NOTES, 26) { } + + WorldPacket const* Write() override; + + ObjectGuid InviteGuid; + uint64 EventID = 0; + std::string Notes; + bool ClearPending = false; + }; + } +} + +#endif // CalendarPackets_h__ diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index fd7b00301b2..814a40a037d 100644 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -23,6 +23,7 @@ #include "Packets/BankPackets.h" #include "Packets/BattlegroundPackets.h" #include "Packets/BlackMarketPackets.h" +#include "Packets/CalendarPackets.h" #include "Packets/ChannelPackets.h" #include "Packets/CharacterPackets.h" #include "Packets/ChatPackets.h" @@ -230,21 +231,21 @@ void OpcodeTable::Initialize() DEFINE_HANDLER(CMSG_BUY_WOW_TOKEN_CONFIRM, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Null, &WorldSession::Handle_NULL); DEFINE_HANDLER(CMSG_BUY_WOW_TOKEN_START, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Null, &WorldSession::Handle_NULL); DEFINE_HANDLER(CMSG_CAGE_BATTLE_PET, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Null, &WorldSession::Handle_NULL); - DEFINE_OPCODE_HANDLER_OLD(CMSG_CALENDAR_ADD_EVENT, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCalendarAddEvent ); + DEFINE_HANDLER(CMSG_CALENDAR_ADD_EVENT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Calendar::CalendarAddEvent, &WorldSession::HandleCalendarAddEvent); DEFINE_OPCODE_HANDLER_OLD(CMSG_CALENDAR_COMPLAIN, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCalendarComplain ); - DEFINE_OPCODE_HANDLER_OLD(CMSG_CALENDAR_COPY_EVENT, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCalendarCopyEvent ); - DEFINE_OPCODE_HANDLER_OLD(CMSG_CALENDAR_EVENT_INVITE, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCalendarEventInvite ); - DEFINE_OPCODE_HANDLER_OLD(CMSG_CALENDAR_EVENT_MODERATOR_STATUS, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCalendarEventModeratorStatus); - DEFINE_OPCODE_HANDLER_OLD(CMSG_CALENDAR_EVENT_RSVP, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCalendarEventRsvp ); - DEFINE_OPCODE_HANDLER_OLD(CMSG_CALENDAR_EVENT_SIGN_UP, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCalendarEventSignup ); - DEFINE_OPCODE_HANDLER_OLD(CMSG_CALENDAR_EVENT_STATUS, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCalendarEventStatus ); - DEFINE_OPCODE_HANDLER_OLD(CMSG_CALENDAR_GET, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCalendarGetCalendar ); - DEFINE_OPCODE_HANDLER_OLD(CMSG_CALENDAR_GET_EVENT, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCalendarGetEvent ); - DEFINE_OPCODE_HANDLER_OLD(CMSG_CALENDAR_GET_NUM_PENDING, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCalendarGetNumPending ); - DEFINE_OPCODE_HANDLER_OLD(CMSG_CALENDAR_GUILD_FILTER, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCalendarGuildFilter ); - DEFINE_OPCODE_HANDLER_OLD(CMSG_CALENDAR_REMOVE_EVENT, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCalendarRemoveEvent ); - DEFINE_OPCODE_HANDLER_OLD(CMSG_CALENDAR_REMOVE_INVITE, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCalendarEventRemoveInvite ); - DEFINE_OPCODE_HANDLER_OLD(CMSG_CALENDAR_UPDATE_EVENT, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCalendarUpdateEvent ); + DEFINE_HANDLER(CMSG_CALENDAR_COPY_EVENT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Calendar::CalendarCopyEvent, &WorldSession::HandleCalendarCopyEvent); + DEFINE_HANDLER(CMSG_CALENDAR_EVENT_INVITE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Calendar::CalendarEventInvite, &WorldSession::HandleCalendarEventInvite); + DEFINE_HANDLER(CMSG_CALENDAR_EVENT_MODERATOR_STATUS, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Calendar::CalendarEventModeratorStatus, &WorldSession::HandleCalendarEventModeratorStatus); + DEFINE_HANDLER(CMSG_CALENDAR_EVENT_RSVP, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Calendar::CalendarEventRSVP, &WorldSession::HandleCalendarEventRsvp); + DEFINE_HANDLER(CMSG_CALENDAR_EVENT_SIGN_UP, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Calendar::CalendarEventSignUp, &WorldSession::HandleCalendarEventSignup); + DEFINE_HANDLER(CMSG_CALENDAR_EVENT_STATUS, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Calendar::CalendarEventStatus, &WorldSession::HandleCalendarEventStatus); + DEFINE_HANDLER(CMSG_CALENDAR_GET, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Calendar::CalendarGetCalendar, &WorldSession::HandleCalendarGetCalendar); + DEFINE_HANDLER(CMSG_CALENDAR_GET_EVENT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Calendar::CalendarGetEvent, &WorldSession::HandleCalendarGetEvent); + DEFINE_HANDLER(CMSG_CALENDAR_GET_NUM_PENDING, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Calendar::CalendarGetNumPending, &WorldSession::HandleCalendarGetNumPending); + DEFINE_HANDLER(CMSG_CALENDAR_GUILD_FILTER, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Calendar::CalendarGuildFilter, &WorldSession::HandleCalendarGuildFilter); + DEFINE_HANDLER(CMSG_CALENDAR_REMOVE_EVENT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Calendar::CalendarRemoveEvent, &WorldSession::HandleCalendarRemoveEvent); + DEFINE_HANDLER(CMSG_CALENDAR_REMOVE_INVITE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Calendar::CalendarRemoveInvite, &WorldSession::HandleCalendarEventRemoveInvite); + DEFINE_HANDLER(CMSG_CALENDAR_UPDATE_EVENT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Calendar::CalendarUpdateEvent, &WorldSession::HandleCalendarUpdateEvent); DEFINE_HANDLER(CMSG_CANCEL_AURA, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Spells::CancelAura, &WorldSession::HandleCancelAuraOpcode); DEFINE_OPCODE_HANDLER_OLD(CMSG_CANCEL_AUTO_REPEAT_SPELL, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleCancelAutoRepeatSpellOpcode); DEFINE_HANDLER(CMSG_CANCEL_CAST, STATUS_LOGGEDIN, PROCESS_THREADSAFE, WorldPackets::Spells::CancelCast, &WorldSession::HandleCancelCastOpcode); @@ -735,7 +736,7 @@ void OpcodeTable::Initialize() DEFINE_HANDLER(CMSG_SET_PVP, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Null, &WorldSession::Handle_NULL); DEFINE_HANDLER(CMSG_SET_RAID_DIFFICULTY, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Misc::SetRaidDifficulty, &WorldSession::HandleSetRaidDifficultyOpcode); DEFINE_HANDLER(CMSG_SET_ROLE, STATUS_LOGGEDIN, PROCESS_INPLACE, WorldPackets::Party::SetRole, &WorldSession::HandleSetRoleOpcode); - DEFINE_OPCODE_HANDLER_OLD(CMSG_SET_SAVED_INSTANCE_EXTEND, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleSetSavedInstanceExtend ); + DEFINE_HANDLER(CMSG_SET_SAVED_INSTANCE_EXTEND, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Calendar::SetSavedInstanceExtend, &WorldSession::HandleSetSavedInstanceExtend); DEFINE_HANDLER(CMSG_SET_SELECTION, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Misc::SetSelection, &WorldSession::HandleSetSelectionOpcode); DEFINE_HANDLER(CMSG_SET_SHEATHED, STATUS_LOGGEDIN, PROCESS_INPLACE, WorldPackets::Combat::SetSheathed, &WorldSession::HandleSetSheathedOpcode); DEFINE_HANDLER(CMSG_SET_SORT_BAGS_RIGHT_TO_LEFT, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Null, &WorldSession::Handle_NULL); @@ -947,26 +948,26 @@ void OpcodeTable::Initialize() DEFINE_SERVER_OPCODE_HANDLER(SMSG_BUY_FAILED, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_BUY_SUCCEEDED, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_CACHE_VERSION, STATUS_NEVER, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_CLEAR_PENDING_ACTION, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_COMMAND_RESULT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INITIAL_INVITES, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE_ALERT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE_MODERATOR_STATUS, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE_NOTES, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE_NOTES_ALERT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE_REMOVED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE_REMOVED_ALERT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE_STATUS, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE_STATUS_ALERT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_REMOVED_ALERT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_UPDATED_ALERT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_CLEAR_PENDING_ACTION, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_COMMAND_RESULT, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INITIAL_INVITES, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE_ALERT, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE_MODERATOR_STATUS, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE_NOTES, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE_NOTES_ALERT, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE_REMOVED, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE_REMOVED_ALERT, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE_STATUS, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_INVITE_STATUS_ALERT, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_REMOVED_ALERT, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_EVENT_UPDATED_ALERT, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_RAID_LOCKOUT_ADDED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_RAID_LOCKOUT_REMOVED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_RAID_LOCKOUT_UPDATED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_SEND_CALENDAR, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_SEND_EVENT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_SEND_NUM_PENDING, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_SEND_CALENDAR, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_SEND_EVENT, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_CALENDAR_SEND_NUM_PENDING, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_CAMERA_SHAKE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_CANCEL_AUTO_REPEAT, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_CANCEL_COMBAT, STATUS_NEVER, CONNECTION_TYPE_REALM); diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 9c092ec98a1..9b9e8f93f55 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -122,6 +122,25 @@ namespace WorldPackets class BlackMarketOpen; } + namespace Calendar + { + class CalendarAddEvent; + class CalendarCopyEvent; + class CalendarEventInvite; + class CalendarEventModeratorStatus; + class CalendarEventRSVP; + class CalendarEventSignUp; + class CalendarEventStatus; + class CalendarGetCalendar; + class CalendarGetEvent; + class CalendarGetNumPending; + class CalendarGuildFilter; + class CalendarRemoveEvent; + class CalendarRemoveInvite; + class CalendarUpdateEvent; + class SetSavedInstanceExtend; + } + namespace Character { struct CharacterCreateInfo; @@ -1460,25 +1479,25 @@ class WorldSession void HandleAcceptGrantLevel(WorldPackets::RaF::AcceptLevelGrant& acceptLevelGrant); // Calendar - void HandleCalendarGetCalendar(WorldPacket& recvData); - void HandleCalendarGetEvent(WorldPacket& recvData); - void HandleCalendarGuildFilter(WorldPacket& recvData); - void HandleCalendarAddEvent(WorldPacket& recvData); - void HandleCalendarUpdateEvent(WorldPacket& recvData); - void HandleCalendarRemoveEvent(WorldPacket& recvData); - void HandleCalendarCopyEvent(WorldPacket& recvData); - void HandleCalendarEventInvite(WorldPacket& recvData); - void HandleCalendarEventRsvp(WorldPacket& recvData); - void HandleCalendarEventRemoveInvite(WorldPacket& recvData); - void HandleCalendarEventStatus(WorldPacket& recvData); - void HandleCalendarEventModeratorStatus(WorldPacket& recvData); + void HandleCalendarGetCalendar(WorldPackets::Calendar::CalendarGetCalendar& calendarGetCalendar); + void HandleCalendarGetEvent(WorldPackets::Calendar::CalendarGetEvent& calendarGetEvent); + void HandleCalendarGuildFilter(WorldPackets::Calendar::CalendarGuildFilter& calendarGuildFilter); + void HandleCalendarAddEvent(WorldPackets::Calendar::CalendarAddEvent& calendarAddEvent); + void HandleCalendarUpdateEvent(WorldPackets::Calendar::CalendarUpdateEvent& calendarUpdateEvent); + void HandleCalendarRemoveEvent(WorldPackets::Calendar::CalendarRemoveEvent& calendarRemoveEvent); + void HandleCalendarCopyEvent(WorldPackets::Calendar::CalendarCopyEvent& calendarCopyEvent); + void HandleCalendarEventInvite(WorldPackets::Calendar::CalendarEventInvite& calendarEventInvite); + void HandleCalendarEventRsvp(WorldPackets::Calendar::CalendarEventRSVP& calendarEventRSVP); + void HandleCalendarEventRemoveInvite(WorldPackets::Calendar::CalendarRemoveInvite& calendarRemoveInvite); + void HandleCalendarEventStatus(WorldPackets::Calendar::CalendarEventStatus& calendarEventStatus); + void HandleCalendarEventModeratorStatus(WorldPackets::Calendar::CalendarEventModeratorStatus& calendarEventModeratorStatus); void HandleCalendarComplain(WorldPacket& recvData); - void HandleCalendarGetNumPending(WorldPacket& recvData); - void HandleCalendarEventSignup(WorldPacket& recvData); + void HandleCalendarGetNumPending(WorldPackets::Calendar::CalendarGetNumPending& calendarGetNumPending); + void HandleCalendarEventSignup(WorldPackets::Calendar::CalendarEventSignUp& calendarEventSignUp); void SendCalendarRaidLockout(InstanceSave const* save, bool add); void SendCalendarRaidLockoutUpdated(InstanceSave const* save); - void HandleSetSavedInstanceExtend(WorldPacket& recvData); + void HandleSetSavedInstanceExtend(WorldPackets::Calendar::SetSavedInstanceExtend& setSavedInstanceExtend); // Void Storage void HandleVoidStorageUnlock(WorldPackets::VoidStorage::UnlockVoidStorage& unlockVoidStorage); diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp index 233ec96bab8..5b92a105e1e 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/shared/Database/Implementation/CharacterDatabase.cpp @@ -612,10 +612,10 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_INS_ITEMCONTAINER_MONEY, "INSERT INTO item_loot_money (container_id, money) VALUES (?, ?)", CONNECTION_ASYNC); // Calendar - PrepareStatement(CHAR_REP_CALENDAR_EVENT, "REPLACE INTO calendar_events (id, creator, title, description, type, dungeon, eventtime, flags, time2) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); - PrepareStatement(CHAR_DEL_CALENDAR_EVENT, "DELETE FROM calendar_events WHERE id = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_REP_CALENDAR_INVITE, "REPLACE INTO calendar_invites (id, event, invitee, sender, status, statustime, rank, text) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); - PrepareStatement(CHAR_DEL_CALENDAR_INVITE, "DELETE FROM calendar_invites WHERE id = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_REP_CALENDAR_EVENT, "REPLACE INTO calendar_events (EventID, Owner, Title, Description, EventType, TextureID, Date, Flags, LockDate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_DEL_CALENDAR_EVENT, "DELETE FROM calendar_events WHERE EventID = ?", CONNECTION_ASYNC); + PrepareStatement(CHAR_REP_CALENDAR_INVITE, "REPLACE INTO calendar_invites (InviteID, EventID, Invitee, Sender, Status, ResponseTime, ModerationRank, Note) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(CHAR_DEL_CALENDAR_INVITE, "DELETE FROM calendar_invites WHERE InviteID = ?", CONNECTION_ASYNC); // Pet PrepareStatement(CHAR_SEL_PET_SLOTS, "SELECT owner, slot FROM character_pet WHERE owner = ? AND slot >= ? AND slot <= ? ORDER BY slot", CONNECTION_ASYNC); |