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() : sCharacterCache->GetCharacterLevelByGuid(invitee); WorldPacket data(SMSG_CALENDAR_EVENT_INVITE, 8 + 8 + 8 + 1 + 1 + 1 + (4) + 1); data << invitee.WriteAsPacked(); data << uint64(invite.GetEventId()); data << uint64(invite.GetInviteId()); data << uint8(level); data << uint8(invite.GetStatus()); data << uint8(hasStatusTime); if (hasStatusTime) data.AppendPackedTime(statusTime); data << uint8(invite.GetSenderGUID() != invite.GetInviteeGUID()); // false only if the invite is sign-up if (!calendarEvent) // Pre-invite { if (Player* playerSender = ObjectAccessor::FindConnectedPlayer(invite.GetSenderGUID())) playerSender->SendDirectMessage(&data); } else { if (calendarEvent->GetCreatorGUID() != invite.GetInviteeGUID()) // correct? SendPacketToAllEventRelatives(data, *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()); Guild* guild = sGuildMgr->GetGuildById(calendarEvent.GetGuildId()); data << uint64(guild ? guild->GetGUID() : 0); data << uint8(invite.GetStatus()); data << uint8(invite.GetRank()); data.appendPackGUID(calendarEvent.GetCreatorGUID()); data.appendPackGUID(invite.GetSenderGUID()); if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement()) { if (Guild* guild = sGuildMgr->GetGuildById(calendarEvent.GetGuildId())) guild->BroadcastPacket(&data); } else if (Player* player = ObjectAccessor::FindPlayer(invite.GetInviteeGUID())) player->SendDirectMessage(&data); }
CalendarEventStore::iterator CalendarMgr::RemoveEvent(uint64 eventId, uint64 remover) { CalendarEventStore::iterator current; CalendarEvent* calendarEvent = GetEvent(eventId, ¤t); if (!calendarEvent) { SendCalendarCommandResult(remover, CALENDAR_ERROR_EVENT_INVALID); return _events.end(); } SendCalendarEventRemovedAlert(*calendarEvent); SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt; MailDraft mail(calendarEvent->BuildCalendarMailSubject(remover), calendarEvent->BuildCalendarMailBody()); CalendarInviteStore& eventInvites = _invites[eventId]; for (size_t i = 0; i < eventInvites.size(); ++i) { CalendarInvite* invite = eventInvites[i]; stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_INVITE); stmt->setUInt64(0, invite->GetInviteId()); trans->Append(stmt); // guild events only? check invite status here? // When an event is deleted, all invited (accepted/declined? - verify) guildies are notified via in-game mail. (wowwiki) if (remover && invite->GetInviteeGUID() != remover) mail.SendMailTo(trans, MailReceiver(invite->GetInviteeGUID()), calendarEvent, MAIL_CHECK_MASK_COPIED); delete invite; } _invites.erase(eventId); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_EVENT); stmt->setUInt64(0, eventId); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); delete calendarEvent; current = _events.erase(current); return current; }
void CalendarMgr::SendCalendarEventModeratorStatusAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite) { WorldPacket data(SMSG_CALENDAR_EVENT_MODERATOR_STATUS_ALERT, 8 + 8 + 1 + 1); data << invite.GetInviteeGUID().WriteAsPacked(); data << uint64(invite.GetEventId()); data << uint8(invite.GetRank()); data << uint8(1); // Unk boolean - Display to client? SendPacketToAllEventRelatives(data, 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().WriteAsPacked(); data << uint64(invite.GetEventId()); data << uint32(flags); data << uint8(1); // FIXME SendPacketToAllEventRelatives(data, calendarEvent); }
void CalendarMgr::SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite) { WorldPacket data(SMSG_CALENDAR_EVENT_STATUS, 8 + 8 + 4 + 4 + 1 + 1 + 4); data << invite.GetInviteeGUID().WriteAsPacked(); data << uint64(calendarEvent.GetEventId()); data.AppendPackedTime(calendarEvent.GetEventTime()); data << uint32(calendarEvent.GetFlags()); data << uint8(invite.GetStatus()); data << uint8(invite.GetRank()); data.AppendPackedTime(invite.GetStatusTime()); SendPacketToAllEventRelatives(data, calendarEvent); }