TrinityCore
CalendarMgr Class Reference

#include <CalendarMgr.h>

Public Member Functions

void LoadFromDB ()
 
CalendarEventGetEvent (uint64 eventId) const
 
CalendarEventStore const & GetEvents () const
 
CalendarEventStore GetPlayerEvents (ObjectGuid guid)
 
CalendarInviteGetInvite (uint64 inviteId) const
 
CalendarEventInviteStore const & GetInvites () const
 
CalendarInviteStore const & GetEventInvites (uint64 eventId)
 
CalendarInviteStore GetPlayerInvites (ObjectGuid guid)
 
void FreeEventId (uint64 id)
 
uint64 GetFreeEventId ()
 
void FreeInviteId (uint64 id)
 
uint64 GetFreeInviteId ()
 
uint32 GetPlayerNumPending (ObjectGuid guid)
 
void AddEvent (CalendarEvent *calendarEvent, CalendarSendEventType sendType)
 
void RemoveEvent (uint64 eventId, ObjectGuid remover)
 
void UpdateEvent (CalendarEvent *calendarEvent)
 
void AddInvite (CalendarEvent *calendarEvent, CalendarInvite *invite)
 
void AddInvite (CalendarEvent *calendarEvent, CalendarInvite *invite, CharacterDatabaseTransaction &trans)
 
void RemoveInvite (uint64 inviteId, uint64 eventId, ObjectGuid remover)
 
void UpdateInvite (CalendarInvite *invite)
 
void UpdateInvite (CalendarInvite *invite, CharacterDatabaseTransaction &trans)
 
void RemoveAllPlayerEventsAndInvites (ObjectGuid guid)
 
void RemovePlayerGuildEventsAndSignups (ObjectGuid guid, ObjectGuid::LowType guildId)
 
void SendCalendarEvent (ObjectGuid guid, CalendarEvent const &calendarEvent, CalendarSendEventType sendType)
 
void SendCalendarEventInvite (CalendarInvite const &invite)
 
void SendCalendarEventInviteAlert (CalendarEvent const &calendarEvent, CalendarInvite const &invite)
 
void SendCalendarEventInviteRemove (CalendarEvent const &calendarEvent, CalendarInvite const &invite, uint32 flags)
 
void SendCalendarEventInviteRemoveAlert (ObjectGuid guid, CalendarEvent const &calendarEvent, CalendarInviteStatus status)
 
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=nullptr)
 
void SendPacketToAllEventRelatives (WorldPacket const *packet, CalendarEvent const &calendarEvent)
 

Static Public Member Functions

static CalendarMgrinstance ()
 

Private Member Functions

 CalendarMgr ()
 
 ~CalendarMgr ()
 

Private Attributes

CalendarEventStore _events
 
CalendarEventInviteStore _invites
 
std::deque< uint64_freeEventIds
 
std::deque< uint64_freeInviteIds
 
uint64 _maxEventId
 
uint64 _maxInviteId
 

Constructor & Destructor Documentation

◆ CalendarMgr()

CalendarMgr::CalendarMgr ( )
private
43 : _maxEventId(0), _maxInviteId(0) { }
uint64 _maxInviteId
Definition: CalendarMgr.h:287
uint64 _maxEventId
Definition: CalendarMgr.h:286

◆ ~CalendarMgr()

CalendarMgr::~CalendarMgr ( )
private
46 {
47  for (CalendarEventStore::iterator itr = _events.begin(); itr != _events.end(); ++itr)
48  delete *itr;
49 
50  for (CalendarEventInviteStore::iterator itr = _invites.begin(); itr != _invites.end(); ++itr)
51  for (CalendarInviteStore::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
52  delete *itr2;
53 }
CalendarEventStore _events
Definition: CalendarMgr.h:281
CalendarEventInviteStore _invites
Definition: CalendarMgr.h:282

Member Function Documentation

◆ AddEvent()

void CalendarMgr::AddEvent ( CalendarEvent calendarEvent,
CalendarSendEventType  sendType 
)
138 {
139  _events.insert(calendarEvent);
140  UpdateEvent(calendarEvent);
141  SendCalendarEvent(calendarEvent->GetOwnerGUID(), *calendarEvent, sendType);
142 }
ObjectGuid GetOwnerGUID() const
Definition: CalendarMgr.h:226
void UpdateEvent(CalendarEvent *calendarEvent)
Definition: CalendarMgr.cpp:243
CalendarEventStore _events
Definition: CalendarMgr.h:281
void SendCalendarEvent(ObjectGuid guid, CalendarEvent const &calendarEvent, CalendarSendEventType sendType)
Definition: CalendarMgr.cpp:556
+ Here is the call graph for this function:

◆ AddInvite() [1/2]

void CalendarMgr::AddInvite ( CalendarEvent calendarEvent,
CalendarInvite invite 
)
145 {
147  AddInvite(calendarEvent, invite, dummy);
148 }
void AddInvite(CalendarEvent *calendarEvent, CalendarInvite *invite)
Definition: CalendarMgr.cpp:144
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72

◆ AddInvite() [2/2]

void CalendarMgr::AddInvite ( CalendarEvent calendarEvent,
CalendarInvite invite,
CharacterDatabaseTransaction trans 
)
151 {
152  if (!calendarEvent->IsGuildAnnouncement() && calendarEvent->GetOwnerGUID() != invite->GetInviteeGUID())
153  SendCalendarEventInvite(*invite);
154 
155  if (!calendarEvent->IsGuildEvent() || invite->GetInviteeGUID() == calendarEvent->GetOwnerGUID())
156  SendCalendarEventInviteAlert(*calendarEvent, *invite);
157 
158  if (!calendarEvent->IsGuildAnnouncement())
159  {
160  _invites[invite->GetEventId()].push_back(invite);
161  UpdateInvite(invite, trans);
162  }
163 }
bool IsGuildAnnouncement() const
Definition: CalendarMgr.h:250
void UpdateInvite(CalendarInvite *invite)
Definition: CalendarMgr.cpp:258
ObjectGuid GetOwnerGUID() const
Definition: CalendarMgr.h:226
void SendCalendarEventInviteAlert(CalendarEvent const &calendarEvent, CalendarInvite const &invite)
Definition: CalendarMgr.cpp:531
uint64 GetEventId() const
Definition: CalendarMgr.h:164
void SendCalendarEventInvite(CalendarInvite const &invite)
Definition: CalendarMgr.cpp:436
CalendarEventInviteStore _invites
Definition: CalendarMgr.h:282
ObjectGuid GetInviteeGUID() const
Definition: CalendarMgr.h:170
bool IsGuildEvent() const
Definition: CalendarMgr.h:249
+ Here is the call graph for this function:

◆ FreeEventId()

void CalendarMgr::FreeEventId ( uint64  id)
324 {
325  if (id == _maxEventId)
326  --_maxEventId;
327  else
328  _freeEventIds.push_back(id);
329 }
std::deque< uint64 > _freeEventIds
Definition: CalendarMgr.h:284
uint64 _maxEventId
Definition: CalendarMgr.h:286

◆ FreeInviteId()

void CalendarMgr::FreeInviteId ( uint64  id)
342 {
343  if (id == _maxInviteId)
344  --_maxInviteId;
345  else
346  _freeInviteIds.push_back(id);
347 }
uint64 _maxInviteId
Definition: CalendarMgr.h:287
std::deque< uint64 > _freeInviteIds
Definition: CalendarMgr.h:285

◆ GetEvent()

CalendarEvent * CalendarMgr::GetEvent ( uint64  eventId) const
303 {
304  for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr)
305  if ((*itr)->GetEventId() == eventId)
306  return *itr;
307 
308  TC_LOG_DEBUG("calendar", "CalendarMgr::GetEvent: [" UI64FMTD "] not found!", eventId);
309  return nullptr;
310 }
CalendarEventStore _events
Definition: CalendarMgr.h:281
#define UI64FMTD
Definition: Define.h:139
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
+ Here is the caller graph for this function:

◆ GetEventInvites()

CalendarInviteStore const & CalendarMgr::GetEventInvites ( uint64  eventId)
378 {
379  return _invites[eventId];
380 }
CalendarEventInviteStore _invites
Definition: CalendarMgr.h:282

◆ GetEvents()

CalendarEventStore const& CalendarMgr::GetEvents ( ) const
inline
295 { return _events; }
CalendarEventStore _events
Definition: CalendarMgr.h:281

◆ GetFreeEventId()

uint64 CalendarMgr::GetFreeEventId ( )
332 {
333  if (_freeEventIds.empty())
334  return ++_maxEventId;
335 
336  uint64 eventId = _freeEventIds.front();
337  _freeEventIds.pop_front();
338  return eventId;
339 }
std::deque< uint64 > _freeEventIds
Definition: CalendarMgr.h:284
uint64 _maxEventId
Definition: CalendarMgr.h:286
uint64_t uint64
Definition: Define.h:151

◆ GetFreeInviteId()

uint64 CalendarMgr::GetFreeInviteId ( )
350 {
351  if (_freeInviteIds.empty())
352  return ++_maxInviteId;
353 
354  uint64 inviteId = _freeInviteIds.front();
355  _freeInviteIds.pop_front();
356  return inviteId;
357 }
uint64 _maxInviteId
Definition: CalendarMgr.h:287
std::deque< uint64 > _freeInviteIds
Definition: CalendarMgr.h:285
uint64_t uint64
Definition: Define.h:151

◆ GetInvite()

CalendarInvite * CalendarMgr::GetInvite ( uint64  inviteId) const
313 {
314  for (CalendarEventInviteStore::const_iterator itr = _invites.begin(); itr != _invites.end(); ++itr)
315  for (CalendarInviteStore::const_iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
316  if ((*itr2)->GetInviteId() == inviteId)
317  return *itr2;
318 
319  TC_LOG_DEBUG("calendar", "CalendarMgr::GetInvite: [" UI64FMTD "] not found!", inviteId);
320  return nullptr;
321 }
#define UI64FMTD
Definition: Define.h:139
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
CalendarEventInviteStore _invites
Definition: CalendarMgr.h:282
+ Here is the caller graph for this function:

◆ GetInvites()

CalendarEventInviteStore const& CalendarMgr::GetInvites ( ) const
inline
299 { return _invites; }
CalendarEventInviteStore _invites
Definition: CalendarMgr.h:282

◆ GetPlayerEvents()

CalendarEventStore CalendarMgr::GetPlayerEvents ( ObjectGuid  guid)
360 {
361  CalendarEventStore events;
362 
363  for (CalendarEventInviteStore::const_iterator itr = _invites.begin(); itr != _invites.end(); ++itr)
364  for (CalendarInviteStore::const_iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
365  if ((*itr2)->GetInviteeGUID() == guid)
366  if (CalendarEvent* event = GetEvent(itr->first)) // NULL check added as attempt to fix #11512
367  events.insert(event);
368 
369  if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
370  for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr)
371  if ((*itr)->GetGuildId() == player->GetGuildId())
372  events.insert(*itr);
373 
374  return events;
375 }
CalendarEventStore _events
Definition: CalendarMgr.h:281
CalendarEvent * GetEvent(uint64 eventId) const
Definition: CalendarMgr.cpp:302
std::set< CalendarEvent * > CalendarEventStore
Definition: CalendarMgr.h:272
Definition: CalendarMgr.h:195
CalendarEventInviteStore _invites
Definition: CalendarMgr.h:282
Definition: Player.h:1056
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:275
+ Here is the call graph for this function:

◆ GetPlayerInvites()

CalendarInviteStore CalendarMgr::GetPlayerInvites ( ObjectGuid  guid)
383 {
384  CalendarInviteStore invites;
385 
386  for (CalendarEventInviteStore::const_iterator itr = _invites.begin(); itr != _invites.end(); ++itr)
387  for (CalendarInviteStore::const_iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
388  if ((*itr2)->GetInviteeGUID() == guid)
389  invites.push_back(*itr2);
390 
391  return invites;
392 }
std::vector< CalendarInvite * > CalendarInviteStore
Definition: CalendarMgr.h:271
CalendarEventInviteStore _invites
Definition: CalendarMgr.h:282
+ Here is the caller graph for this function:

◆ GetPlayerNumPending()

uint32 CalendarMgr::GetPlayerNumPending ( ObjectGuid  guid)
395 {
396  CalendarInviteStore const& invites = GetPlayerInvites(guid);
397 
398  uint32 pendingNum = 0;
399  for (CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
400  {
401  switch ((*itr)->GetStatus())
402  {
406  ++pendingNum;
407  break;
408  default:
409  break;
410  }
411  }
412 
413  return pendingNum;
414 }
Definition: CalendarMgr.h:89
CalendarInviteStore GetPlayerInvites(ObjectGuid guid)
Definition: CalendarMgr.cpp:382
Definition: CalendarMgr.h:88
std::vector< CalendarInvite * > CalendarInviteStore
Definition: CalendarMgr.h:271
uint32_t uint32
Definition: Define.h:152
Definition: CalendarMgr.h:81
+ Here is the call graph for this function:

◆ instance()

CalendarMgr * CalendarMgr::instance ( )
static
56 {
57  static CalendarMgr instance;
58  return &instance;
59 }
static CalendarMgr * instance()
Definition: CalendarMgr.cpp:55
Definition: CalendarMgr.h:275

◆ LoadFromDB()

void CalendarMgr::LoadFromDB ( )
62 {
63  uint32 oldMSTime = getMSTime();
64 
65  uint32 count = 0;
66  _maxEventId = 0;
67  _maxInviteId = 0;
68 
69  // 0 1 2 3 4 5 6 7 8
70  if (QueryResult result = CharacterDatabase.Query("SELECT EventID, Owner, Title, Description, EventType, TextureID, Date, Flags, LockDate FROM calendar_events"))
71  do
72  {
73  Field* fields = result->Fetch();
74 
75  uint64 eventID = fields[0].GetUInt64();
76  ObjectGuid ownerGUID = ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt64());
77  std::string title = fields[2].GetString();
78  std::string description = fields[3].GetString();
79  CalendarEventType type = CalendarEventType(fields[4].GetUInt8());
80  int32 textureID = fields[5].GetInt32();
81  time_t date = fields[6].GetInt64();
82  uint32 flags = fields[7].GetUInt32();
83  time_t lockDate = fields[8].GetInt64();
84  ObjectGuid::LowType guildID = UI64LIT(0);
85 
87  guildID = sCharacterCache->GetCharacterGuildIdByGuid(ownerGUID);
88 
89  CalendarEvent* calendarEvent = new CalendarEvent(eventID, ownerGUID, guildID, type, textureID, date, flags, title, description, lockDate);
90  _events.insert(calendarEvent);
91 
92  _maxEventId = std::max(_maxEventId, eventID);
93 
94  ++count;
95  }
96  while (result->NextRow());
97 
98  TC_LOG_INFO("server.loading", ">> Loaded %u calendar events in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
99  count = 0;
100  oldMSTime = getMSTime();
101 
102  // 0 1 2 3 4 5 6 7
103  if (QueryResult result = CharacterDatabase.Query("SELECT InviteID, EventID, Invitee, Sender, Status, ResponseTime, ModerationRank, Note FROM calendar_invites"))
104  do
105  {
106  Field* fields = result->Fetch();
107 
108  uint64 inviteId = fields[0].GetUInt64();
109  uint64 eventId = fields[1].GetUInt64();
110  ObjectGuid invitee = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt64());
111  ObjectGuid senderGUID = ObjectGuid::Create<HighGuid::Player>(fields[3].GetUInt64());
112  CalendarInviteStatus status = CalendarInviteStatus(fields[4].GetUInt8());
113  time_t responseTime = fields[5].GetInt64();
114  CalendarModerationRank rank = CalendarModerationRank(fields[6].GetUInt8());
115  std::string note = fields[7].GetString();
116 
117  CalendarInvite* invite = new CalendarInvite(inviteId, eventId, invitee, senderGUID, responseTime, status, rank, note);
118  _invites[eventId].push_back(invite);
119 
120  _maxInviteId = std::max(_maxInviteId, inviteId);
121 
122  ++count;
123  }
124  while (result->NextRow());
125 
126  TC_LOG_INFO("server.loading", ">> Loaded %u calendar invites in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
127 
128  for (uint64 i = 1; i < _maxEventId; ++i)
129  if (!GetEvent(i))
130  _freeEventIds.push_back(i);
131 
132  for (uint64 i = 1; i < _maxInviteId; ++i)
133  if (!GetInvite(i))
134  _freeInviteIds.push_back(i);
135 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint64 _maxInviteId
Definition: CalendarMgr.h:287
std::deque< uint64 > _freeInviteIds
Definition: CalendarMgr.h:285
Definition: CalendarMgr.h:43
Class used to access individual fields of database query result.
Definition: Field.h:81
uint64 LowType
Definition: ObjectGuid.h:258
CalendarEventType
Definition: CalendarMgr.h:61
uint32 getMSTime()
Definition: Timer.h:24
#define UI64LIT(N)
Definition: Define.h:140
std::deque< uint64 > _freeEventIds
Definition: CalendarMgr.h:284
CalendarEventStore _events
Definition: CalendarMgr.h:281
CalendarModerationRank
Definition: CalendarMgr.h:47
uint32 GetUInt32() const
Definition: Field.cpp:105
CalendarEvent * GetEvent(uint64 eventId) const
Definition: CalendarMgr.cpp:302
#define sCharacterCache
Definition: CharacterCache.h:73
uint64 GetUInt64() const
Definition: Field.cpp:141
Definition: CalendarMgr.h:44
Definition: CalendarMgr.h:195
uint64 _maxEventId
Definition: CalendarMgr.h:286
std::string GetString() const
Definition: Field.cpp:228
int64 GetInt64() const
Definition: Field.cpp:159
int32_t int32
Definition: Define.h:148
uint32_t uint32
Definition: Define.h:152
uint64_t uint64
Definition: Define.h:151
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:180
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:28
int32 GetInt32() const
Definition: Field.cpp:123
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:42
CalendarEventInviteStore _invites
Definition: CalendarMgr.h:282
CalendarInviteStatus
Definition: CalendarMgr.h:79
Definition: ObjectGuid.h:248
uint8 flags
Definition: DisableMgr.cpp:47
Definition: CalendarMgr.h:136
CalendarInvite * GetInvite(uint64 inviteId) const
Definition: CalendarMgr.cpp:312
+ Here is the call graph for this function:

◆ RemoveAllPlayerEventsAndInvites()

void CalendarMgr::RemoveAllPlayerEventsAndInvites ( ObjectGuid  guid)
279 {
280  for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr)
281  if ((*itr)->GetOwnerGUID() == guid)
282  RemoveEvent((*itr)->GetEventId(), ObjectGuid::Empty); // don't send mail if removing a character
283 
284  CalendarInviteStore playerInvites = GetPlayerInvites(guid);
285  for (CalendarInviteStore::const_iterator itr = playerInvites.begin(); itr != playerInvites.end(); ++itr)
286  RemoveInvite((*itr)->GetInviteId(), (*itr)->GetEventId(), guid);
287 }
void RemoveEvent(uint64 eventId, ObjectGuid remover)
Definition: CalendarMgr.cpp:165
void RemoveInvite(uint64 inviteId, uint64 eventId, ObjectGuid remover)
Definition: CalendarMgr.cpp:208
static ObjectGuid const Empty
Definition: ObjectGuid.h:255
CalendarInviteStore GetPlayerInvites(ObjectGuid guid)
Definition: CalendarMgr.cpp:382
CalendarEventStore _events
Definition: CalendarMgr.h:281
std::vector< CalendarInvite * > CalendarInviteStore
Definition: CalendarMgr.h:271
+ Here is the call graph for this function:

◆ RemoveEvent()

void CalendarMgr::RemoveEvent ( uint64  eventId,
ObjectGuid  remover 
)
166 {
167  CalendarEvent* calendarEvent = GetEvent(eventId);
168 
169  if (!calendarEvent)
170  {
172  return;
173  }
174 
175  SendCalendarEventRemovedAlert(*calendarEvent);
176 
177  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
179  MailDraft mail(calendarEvent->BuildCalendarMailSubject(remover), calendarEvent->BuildCalendarMailBody());
180 
181  CalendarInviteStore& eventInvites = _invites[eventId];
182  for (size_t i = 0; i < eventInvites.size(); ++i)
183  {
184  CalendarInvite* invite = eventInvites[i];
185  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_INVITE);
186  stmt->setUInt64(0, invite->GetInviteId());
187  trans->Append(stmt);
188 
189  // guild events only? check invite status here?
190  // When an event is deleted, all invited (accepted/declined? - verify) guildies are notified via in-game mail. (wowwiki)
191  if (!remover.IsEmpty() && invite->GetInviteeGUID() != remover)
192  mail.SendMailTo(trans, MailReceiver(invite->GetInviteeGUID().GetCounter()), calendarEvent, MAIL_CHECK_MASK_COPIED);
193 
194  delete invite;
195  }
196 
197  _invites.erase(eventId);
198 
199  stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_EVENT);
200  stmt->setUInt64(0, eventId);
201  trans->Append(stmt);
202  CharacterDatabase.CommitTransaction(trans);
203 
204  delete calendarEvent;
205  _events.erase(calendarEvent);
206 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
std::string BuildCalendarMailBody() const
Definition: CalendarMgr.cpp:423
Definition: CharacterDatabase.h:583
std::string BuildCalendarMailSubject(ObjectGuid remover) const
Definition: CalendarMgr.cpp:416
LowType GetCounter() const
Definition: ObjectGuid.h:273
CalendarEventStore _events
Definition: CalendarMgr.h:281
void SendCalendarCommandResult(ObjectGuid guid, CalendarError err, char const *param=nullptr)
Definition: CalendarMgr.cpp:621
This mail was returned. Do not allow returning mail back again.
Definition: Mail.h:53
Definition: DatabaseEnvFwd.h:40
CalendarEvent * GetEvent(uint64 eventId) const
Definition: CalendarMgr.cpp:302
Definition: Mail.h:124
std::vector< CalendarInvite * > CalendarInviteStore
Definition: CalendarMgr.h:271
Definition: CalendarMgr.h:195
Definition: CalendarMgr.h:101
Definition: CharacterDatabase.h:585
bool IsEmpty() const
Definition: ObjectGuid.h:299
uint64 GetInviteId() const
Definition: CalendarMgr.h:161
CalendarEventInviteStore _invites
Definition: CalendarMgr.h:282
ObjectGuid GetInviteeGUID() const
Definition: CalendarMgr.h:170
Definition: CalendarMgr.h:136
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
Definition: Mail.h:109
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
void SendCalendarEventRemovedAlert(CalendarEvent const &calendarEvent)
Definition: CalendarMgr.cpp:499
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveInvite()

void CalendarMgr::RemoveInvite ( uint64  inviteId,
uint64  eventId,
ObjectGuid  remover 
)
209 {
210  CalendarEvent* calendarEvent = GetEvent(eventId);
211 
212  if (!calendarEvent)
213  return;
214 
215  CalendarInviteStore::iterator itr = _invites[eventId].begin();
216  for (; itr != _invites[eventId].end(); ++itr)
217  if ((*itr)->GetInviteId() == inviteId)
218  break;
219 
220  if (itr == _invites[eventId].end())
221  return;
222 
223  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
225  stmt->setUInt64(0, (*itr)->GetInviteId());
226  trans->Append(stmt);
227  CharacterDatabase.CommitTransaction(trans);
228 
229  if (!calendarEvent->IsGuildEvent())
230  SendCalendarEventInviteRemoveAlert((*itr)->GetInviteeGUID(), *calendarEvent, CALENDAR_STATUS_REMOVED);
231 
232  SendCalendarEventInviteRemove(*calendarEvent, **itr, calendarEvent->GetFlags());
233 
234  // we need to find out how to use CALENDAR_INVITE_REMOVED_MAIL_SUBJECT to force client to display different mail
235  //if ((*itr)->GetInviteeGUID() != remover)
236  // MailDraft(calendarEvent->BuildCalendarMailSubject(remover), calendarEvent->BuildCalendarMailBody())
237  // .SendMailTo(trans, MailReceiver((*itr)->GetInvitee()), calendarEvent, MAIL_CHECK_MASK_COPIED);
238 
239  delete *itr;
240  _invites[eventId].erase(itr);
241 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void SendCalendarEventInviteRemove(CalendarEvent const &calendarEvent, CalendarInvite const &invite, uint32 flags)
Definition: CalendarMgr.cpp:509
void SendCalendarEventInviteRemoveAlert(ObjectGuid guid, CalendarEvent const &calendarEvent, CalendarInviteStatus status)
Definition: CalendarMgr.cpp:601
uint32 GetFlags() const
Definition: CalendarMgr.h:247
Definition: DatabaseEnvFwd.h:40
CalendarEvent * GetEvent(uint64 eventId) const
Definition: CalendarMgr.cpp:302
Definition: CalendarMgr.h:195
Definition: CharacterDatabase.h:585
CalendarEventInviteStore _invites
Definition: CalendarMgr.h:282
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
bool IsGuildEvent() const
Definition: CalendarMgr.h:249
Definition: CalendarMgr.h:90
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemovePlayerGuildEventsAndSignups()

void CalendarMgr::RemovePlayerGuildEventsAndSignups ( ObjectGuid  guid,
ObjectGuid::LowType  guildId 
)
290 {
291  for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr)
292  if ((*itr)->GetOwnerGUID() == guid && ((*itr)->IsGuildEvent() || (*itr)->IsGuildAnnouncement()))
293  RemoveEvent((*itr)->GetEventId(), guid);
294 
295  CalendarInviteStore playerInvites = GetPlayerInvites(guid);
296  for (CalendarInviteStore::const_iterator itr = playerInvites.begin(); itr != playerInvites.end(); ++itr)
297  if (CalendarEvent* calendarEvent = GetEvent((*itr)->GetEventId()))
298  if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == guildId)
299  RemoveInvite((*itr)->GetInviteId(), (*itr)->GetEventId(), guid);
300 }
void RemoveEvent(uint64 eventId, ObjectGuid remover)
Definition: CalendarMgr.cpp:165
void RemoveInvite(uint64 inviteId, uint64 eventId, ObjectGuid remover)
Definition: CalendarMgr.cpp:208
CalendarInviteStore GetPlayerInvites(ObjectGuid guid)
Definition: CalendarMgr.cpp:382
CalendarEventStore _events
Definition: CalendarMgr.h:281
CalendarEvent * GetEvent(uint64 eventId) const
Definition: CalendarMgr.cpp:302
std::vector< CalendarInvite * > CalendarInviteStore
Definition: CalendarMgr.h:271
Definition: CalendarMgr.h:195
+ Here is the call graph for this function:

◆ SendCalendarClearPendingAction()

void CalendarMgr::SendCalendarClearPendingAction ( ObjectGuid  guid)
616 {
617  if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
618  player->SendDirectMessage(WorldPackets::Calendar::CalendarClearPendingAction().Write());
619 }
Definition: Player.h:1056
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:275
+ Here is the call graph for this function:

◆ SendCalendarCommandResult()

void CalendarMgr::SendCalendarCommandResult ( ObjectGuid  guid,
CalendarError  err,
char const *  param = nullptr 
)
622 {
623  if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
624  {
626  packet.Command = 1; // FIXME
627  packet.Result = err;
628 
629  switch (err)
630  {
634  packet.Name = param;
635  break;
636  default:
637  break;
638  }
639 
640  player->SendDirectMessage(packet.Write());
641  }
642 }
uint8 Command
Definition: CalendarPackets.h:473
WorldPacket const * Write() override
Definition: CalendarPackets.cpp:417
Definition: CalendarMgr.h:108
std::string Name
Definition: CalendarPackets.h:475
Definition: CalendarMgr.h:105
Definition: CalendarMgr.h:99
uint8 Result
Definition: CalendarPackets.h:474
Definition: Player.h:1056
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:275
Definition: CalendarPackets.h:465
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendCalendarEvent()

void CalendarMgr::SendCalendarEvent ( ObjectGuid  guid,
CalendarEvent const &  calendarEvent,
CalendarSendEventType  sendType 
)
557 {
559  if (!player)
560  return;
561 
562  CalendarInviteStore const& eventInviteeList = _invites[calendarEvent.GetEventId()];
563 
565  packet.Date = calendarEvent.GetDate();
566  packet.Description = calendarEvent.GetDescription();
567  packet.EventID = calendarEvent.GetEventId();
568  packet.EventName = calendarEvent.GetTitle();
569  packet.EventType = sendType;
570  packet.Flags = calendarEvent.GetFlags();
571  packet.GetEventType = calendarEvent.GetType();
572  packet.LockDate = calendarEvent.GetLockDate(); // Always 0 ?
573  packet.OwnerGuid = calendarEvent.GetOwnerGUID();
574  packet.TextureID = calendarEvent.GetTextureId();
575  packet.EventClubID = calendarEvent.GetGuildId();
576 
577  for (auto const& calendarInvite : eventInviteeList)
578  {
579  ObjectGuid inviteeGuid = calendarInvite->GetInviteeGUID();
580  Player* invitee = ObjectAccessor::FindPlayer(inviteeGuid);
581 
582  uint8 inviteeLevel = invitee ? invitee->getLevel() : sCharacterCache->GetCharacterLevelByGuid(inviteeGuid);
583  ObjectGuid::LowType inviteeGuildId = invitee ? invitee->GetGuildId() : sCharacterCache->GetCharacterGuildIdByGuid(inviteeGuid);
584 
586  inviteInfo.Guid = inviteeGuid;
587  inviteInfo.Level = inviteeLevel;
588  inviteInfo.Status = calendarInvite->GetStatus();
589  inviteInfo.Moderator = calendarInvite->GetRank();
590  inviteInfo.InviteType = calendarEvent.IsGuildEvent() && calendarEvent.GetGuildId() == inviteeGuildId;
591  inviteInfo.InviteID = calendarInvite->GetInviteId();
592  inviteInfo.ResponseTime = calendarInvite->GetResponseTime();
593  inviteInfo.Notes = calendarInvite->GetNote();
594 
595  packet.Invites.push_back(inviteInfo);
596  }
597 
598  player->SendDirectMessage(packet.Write());
599 }
Definition: CalendarPackets.h:205
uint8 EventType
Definition: CalendarPackets.h:232
uint32 Flags
Definition: CalendarPackets.h:229
time_t ResponseTime
Definition: CalendarPackets.h:209
std::vector< CalendarEventInviteInfo > Invites
Definition: CalendarPackets.h:235
uint8 getLevel() const
Definition: Unit.h:843
uint64 LowType
Definition: ObjectGuid.h:258
uint8 Level
Definition: CalendarPackets.h:210
ObjectGuid OwnerGuid
Definition: CalendarPackets.h:224
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:254
#define sCharacterCache
Definition: CharacterCache.h:73
uint64 EventID
Definition: CalendarPackets.h:226
WorldPacket const * Write() override
Definition: CalendarPackets.cpp:280
std::vector< CalendarInvite * > CalendarInviteStore
Definition: CalendarMgr.h:271
std::string Notes
Definition: CalendarPackets.h:214
uint8 GetEventType
Definition: CalendarPackets.h:231
uint64 EventClubID
Definition: CalendarPackets.h:225
uint8 Moderator
Definition: CalendarPackets.h:212
std::string Description
Definition: CalendarPackets.h:233
void SendDirectMessage(WorldPacket const *data) const
Definition: Player.cpp:6123
uint8 Status
Definition: CalendarPackets.h:211
time_t Date
Definition: CalendarPackets.h:227
time_t LockDate
Definition: CalendarPackets.h:228
ObjectGuid::LowType GetGuildId() const
Definition: Player.h:1885
ObjectGuid Guid
Definition: CalendarPackets.h:207
uint8 InviteType
Definition: CalendarPackets.h:213
std::string EventName
Definition: CalendarPackets.h:234
CalendarEventInviteStore _invites
Definition: CalendarMgr.h:282
uint8_t uint8
Definition: Define.h:154
uint64 InviteID
Definition: CalendarPackets.h:208
Definition: ObjectGuid.h:248
Definition: CalendarPackets.h:217
Definition: Player.h:1056
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:275
int32 TextureID
Definition: CalendarPackets.h:230
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendCalendarEventInvite()

void CalendarMgr::SendCalendarEventInvite ( CalendarInvite const &  invite)
437 {
438  CalendarEvent* calendarEvent = GetEvent(invite.GetEventId());
439 
440  ObjectGuid invitee = invite.GetInviteeGUID();
441  Player* player = ObjectAccessor::FindConnectedPlayer(invitee);
442 
443  uint8 level = player ? player->getLevel() : sCharacterCache->GetCharacterLevelByGuid(invitee);
444 
446  packet.EventID = calendarEvent ? calendarEvent->GetEventId() : 0;
447  packet.InviteGuid = invitee;
448  packet.InviteID = calendarEvent ? invite.GetInviteId() : 0;
449  packet.Level = level;
450  packet.ResponseTime = invite.GetResponseTime();
451  packet.Status = invite.GetStatus();
452  packet.Type = calendarEvent ? calendarEvent->IsGuildEvent() : 0; // Correct ?
453  packet.ClearPending = calendarEvent ? !calendarEvent->IsGuildEvent() : true; // Correct ?
454 
455  if (!calendarEvent) // Pre-invite
456  {
457  if (Player* playerSender = ObjectAccessor::FindConnectedPlayer(invite.GetSenderGUID()))
458  playerSender->SendDirectMessage(packet.Write());
459  }
460  else
461  {
462  if (calendarEvent->GetOwnerGUID() != invite.GetInviteeGUID()) // correct?
463  SendPacketToAllEventRelatives(packet.Write(), *calendarEvent);
464  }
465 }
ObjectGuid InviteGuid
Definition: CalendarPackets.h:155
bool ClearPending
Definition: CalendarPackets.h:158
Definition: CalendarPackets.h:145
uint8 getLevel() const
Definition: Unit.h:843
ObjectGuid GetOwnerGUID() const
Definition: CalendarMgr.h:226
WorldPacket const * Write() override
Definition: CalendarPackets.cpp:245
uint8 Status
Definition: CalendarPackets.h:159
uint8 Type
Definition: CalendarPackets.h:157
uint64 GetEventId() const
Definition: CalendarMgr.h:223
CalendarEvent * GetEvent(uint64 eventId) const
Definition: CalendarMgr.cpp:302
#define sCharacterCache
Definition: CharacterCache.h:73
Definition: CalendarMgr.h:195
time_t ResponseTime
Definition: CalendarPackets.h:153
void SendPacketToAllEventRelatives(WorldPacket const *packet, CalendarEvent const &calendarEvent)
Definition: CalendarMgr.cpp:644
uint8 Level
Definition: CalendarPackets.h:154
uint64 EventID
Definition: CalendarPackets.h:156
uint64 InviteID
Definition: CalendarPackets.h:152
uint8_t uint8
Definition: Define.h:154
Definition: ObjectGuid.h:248
bool IsGuildEvent() const
Definition: CalendarMgr.h:249
Definition: Player.h:1056
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:275
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendCalendarEventInviteAlert()

void CalendarMgr::SendCalendarEventInviteAlert ( CalendarEvent const &  calendarEvent,
CalendarInvite const &  invite 
)
532 {
534  packet.Date = calendarEvent.GetDate();
535  packet.EventID = calendarEvent.GetEventId();
536  packet.EventName = calendarEvent.GetTitle();
537  packet.EventType = calendarEvent.GetType();
538  packet.Flags = calendarEvent.GetFlags();
539  packet.InviteID = invite.GetInviteId();
540  packet.InvitedByGuid = invite.GetSenderGUID();
541  packet.ModeratorStatus = invite.GetRank();
542  packet.OwnerGuid = calendarEvent.GetOwnerGUID();
543  packet.Status = invite.GetStatus();
544  packet.TextureID = calendarEvent.GetTextureId();
545  packet.EventClubID = calendarEvent.GetGuildId();
546 
547  if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement())
548  {
549  if (Guild* guild = sGuildMgr->GetGuildById(calendarEvent.GetGuildId()))
550  guild->BroadcastPacket(packet.Write());
551  }
552  else if (Player* player = ObjectAccessor::FindConnectedPlayer(invite.GetInviteeGUID()))
553  player->SendDirectMessage(packet.Write());
554 }
uint8 Status
Definition: CalendarPackets.h:253
ObjectGuid InvitedByGuid
Definition: CalendarPackets.h:247
uint8 EventType
Definition: CalendarPackets.h:254
ObjectGuid OwnerGuid
Definition: CalendarPackets.h:245
#define sGuildMgr
Definition: GuildMgr.h:69
int32 TextureID
Definition: CalendarPackets.h:252
uint64 InviteID
Definition: CalendarPackets.h:248
uint64 EventID
Definition: CalendarPackets.h:249
std::string EventName
Definition: CalendarPackets.h:256
uint32 Flags
Definition: CalendarPackets.h:250
uint64 EventClubID
Definition: CalendarPackets.h:246
WorldPacket const * Write() override
Definition: CalendarPackets.cpp:305
uint8 ModeratorStatus
Definition: CalendarPackets.h:255
Definition: CalendarPackets.h:238
Definition: Guild.h:305
Definition: Player.h:1056
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:275
time_t Date
Definition: CalendarPackets.h:251
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendCalendarEventInviteRemove()

void CalendarMgr::SendCalendarEventInviteRemove ( CalendarEvent const &  calendarEvent,
CalendarInvite const &  invite,
uint32  flags 
)
510 {
512  packet.ClearPending = true; // FIXME
513  packet.EventID = calendarEvent.GetEventId();
514  packet.Flags = flags;
515  packet.InviteGuid = invite.GetInviteeGUID();
516 
517  SendPacketToAllEventRelatives(packet.Write(), calendarEvent);
518 }
Definition: CalendarPackets.h:302
ObjectGuid InviteGuid
Definition: CalendarPackets.h:309
WorldPacket const * Write() override
Definition: CalendarPackets.cpp:343
uint32 Flags
Definition: CalendarPackets.h:311
bool ClearPending
Definition: CalendarPackets.h:312
void SendPacketToAllEventRelatives(WorldPacket const *packet, CalendarEvent const &calendarEvent)
Definition: CalendarMgr.cpp:644
uint64 EventID
Definition: CalendarPackets.h:310
uint8 flags
Definition: DisableMgr.cpp:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendCalendarEventInviteRemoveAlert()

void CalendarMgr::SendCalendarEventInviteRemoveAlert ( ObjectGuid  guid,
CalendarEvent const &  calendarEvent,
CalendarInviteStatus  status 
)
602 {
603  if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
604  {
606  packet.Date = calendarEvent.GetDate();
607  packet.EventID = calendarEvent.GetEventId();
608  packet.Flags = calendarEvent.GetFlags();
609  packet.Status = status;
610 
611  player->SendDirectMessage(packet.Write());
612  }
613 }
time_t Date
Definition: CalendarPackets.h:336
uint8 Status
Definition: CalendarPackets.h:338
uint64 EventID
Definition: CalendarPackets.h:335
uint32 Flags
Definition: CalendarPackets.h:337
Definition: Player.h:1056
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:275
WorldPacket const * Write() override
Definition: CalendarPackets.cpp:367
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendCalendarEventModeratorStatusAlert()

void CalendarMgr::SendCalendarEventModeratorStatusAlert ( CalendarEvent const &  calendarEvent,
CalendarInvite const &  invite 
)
521 {
523  packet.ClearPending = true; // FIXME
524  packet.EventID = calendarEvent.GetEventId();
525  packet.InviteGuid = invite.GetInviteeGUID();
526  packet.Status = invite.GetStatus();
527 
528  SendPacketToAllEventRelatives(packet.Write(), calendarEvent);
529 }
uint8 Status
Definition: CalendarPackets.h:324
uint64 EventID
Definition: CalendarPackets.h:323
WorldPacket const * Write() override
Definition: CalendarPackets.cpp:355
Definition: CalendarPackets.h:315
bool ClearPending
Definition: CalendarPackets.h:325
void SendPacketToAllEventRelatives(WorldPacket const *packet, CalendarEvent const &calendarEvent)
Definition: CalendarMgr.cpp:644
ObjectGuid InviteGuid
Definition: CalendarPackets.h:322
+ Here is the call graph for this function:

◆ SendCalendarEventRemovedAlert()

void CalendarMgr::SendCalendarEventRemovedAlert ( CalendarEvent const &  calendarEvent)
500 {
502  packet.ClearPending = true; // FIXME
503  packet.Date = calendarEvent.GetDate();
504  packet.EventID = calendarEvent.GetEventId();
505 
506  SendPacketToAllEventRelatives(packet.Write(), calendarEvent);
507 }
bool ClearPending
Definition: CalendarPackets.h:378
Definition: CalendarPackets.h:369
WorldPacket const * Write() override
Definition: CalendarPackets.cpp:400
void SendPacketToAllEventRelatives(WorldPacket const *packet, CalendarEvent const &calendarEvent)
Definition: CalendarMgr.cpp:644
time_t Date
Definition: CalendarPackets.h:377
uint64 EventID
Definition: CalendarPackets.h:376
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendCalendarEventStatus()

void CalendarMgr::SendCalendarEventStatus ( CalendarEvent const &  calendarEvent,
CalendarInvite const &  invite 
)
486 {
488  packet.ClearPending = true; // FIXME
489  packet.Date = calendarEvent.GetDate();
490  packet.EventID = calendarEvent.GetEventId();
491  packet.Flags = calendarEvent.GetFlags();
492  packet.InviteGuid = invite.GetInviteeGUID();
493  packet.ResponseTime = invite.GetResponseTime();
494  packet.Status = invite.GetStatus();
495 
496  SendPacketToAllEventRelatives(packet.Write(), calendarEvent);
497 }
uint32 Flags
Definition: CalendarPackets.h:293
ObjectGuid InviteGuid
Definition: CalendarPackets.h:299
uint8 Status
Definition: CalendarPackets.h:295
Definition: CalendarPackets.h:286
uint64 EventID
Definition: CalendarPackets.h:294
bool ClearPending
Definition: CalendarPackets.h:296
void SendPacketToAllEventRelatives(WorldPacket const *packet, CalendarEvent const &calendarEvent)
Definition: CalendarMgr.cpp:644
WorldPacket const * Write() override
Definition: CalendarPackets.cpp:328
time_t Date
Definition: CalendarPackets.h:298
time_t ResponseTime
Definition: CalendarPackets.h:297
+ Here is the call graph for this function:

◆ SendCalendarEventUpdateAlert()

void CalendarMgr::SendCalendarEventUpdateAlert ( CalendarEvent const &  calendarEvent,
time_t  originalDate 
)
468 {
470  packet.ClearPending = true; // FIXME
471  packet.Date = calendarEvent.GetDate();
472  packet.Description = calendarEvent.GetDescription();
473  packet.EventClubID = calendarEvent.GetGuildId();
474  packet.EventID = calendarEvent.GetEventId();
475  packet.EventName = calendarEvent.GetTitle();
476  packet.EventType = calendarEvent.GetType();
477  packet.Flags = calendarEvent.GetFlags();
478  packet.LockDate = calendarEvent.GetLockDate(); // Always 0 ?
479  packet.OriginalDate = originalDate;
480  packet.TextureID = calendarEvent.GetTextureId();
481 
482  SendPacketToAllEventRelatives(packet.Write(), calendarEvent);
483 }
WorldPacket const * Write() override
Definition: CalendarPackets.cpp:377
uint32 Flags
Definition: CalendarPackets.h:359
time_t OriginalDate
Definition: CalendarPackets.h:361
uint64 EventID
Definition: CalendarPackets.h:357
uint64 EventClubID
Definition: CalendarPackets.h:356
time_t Date
Definition: CalendarPackets.h:358
bool ClearPending
Definition: CalendarPackets.h:364
std::string EventName
Definition: CalendarPackets.h:366
uint8 EventType
Definition: CalendarPackets.h:363
std::string Description
Definition: CalendarPackets.h:365
void SendPacketToAllEventRelatives(WorldPacket const *packet, CalendarEvent const &calendarEvent)
Definition: CalendarMgr.cpp:644
time_t LockDate
Definition: CalendarPackets.h:360
int32 TextureID
Definition: CalendarPackets.h:362
Definition: CalendarPackets.h:349
+ Here is the call graph for this function:

◆ SendPacketToAllEventRelatives()

void CalendarMgr::SendPacketToAllEventRelatives ( WorldPacket const *  packet,
CalendarEvent const &  calendarEvent 
)
645 {
646  // Send packet to all guild members
647  if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement())
648  if (Guild* guild = sGuildMgr->GetGuildById(calendarEvent.GetGuildId()))
649  guild->BroadcastPacket(packet);
650 
651  // Send packet to all invitees if event is non-guild, in other case only to non-guild invitees (packet was broadcasted for them)
652  CalendarInviteStore invites = _invites[calendarEvent.GetEventId()];
653  for (CalendarInviteStore::iterator itr = invites.begin(); itr != invites.end(); ++itr)
654  if (Player* player = ObjectAccessor::FindConnectedPlayer((*itr)->GetInviteeGUID()))
655  if (!calendarEvent.IsGuildEvent() || player->GetGuildId() != calendarEvent.GetGuildId())
656  player->SendDirectMessage(packet);
657 }
#define sGuildMgr
Definition: GuildMgr.h:69
std::vector< CalendarInvite * > CalendarInviteStore
Definition: CalendarMgr.h:271
CalendarEventInviteStore _invites
Definition: CalendarMgr.h:282
Definition: Guild.h:305
Definition: Player.h:1056
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:275
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateEvent()

void CalendarMgr::UpdateEvent ( CalendarEvent calendarEvent)
244 {
246  stmt->setUInt64(0, calendarEvent->GetEventId());
247  stmt->setUInt64(1, calendarEvent->GetOwnerGUID().GetCounter());
248  stmt->setString(2, calendarEvent->GetTitle());
249  stmt->setString(3, calendarEvent->GetDescription());
250  stmt->setUInt8(4, calendarEvent->GetType());
251  stmt->setInt32(5, calendarEvent->GetTextureId());
252  stmt->setInt64(6, calendarEvent->GetDate());
253  stmt->setUInt32(7, calendarEvent->GetFlags());
254  stmt->setInt64(8, calendarEvent->GetLockDate());
255  CharacterDatabase.Execute(stmt);
256 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
std::string GetDescription() const
Definition: CalendarMgr.h:235
CalendarEventType GetType() const
Definition: CalendarMgr.h:238
ObjectGuid GetOwnerGUID() const
Definition: CalendarMgr.h:226
LowType GetCounter() const
Definition: ObjectGuid.h:273
void setInt64(const uint8 index, const int64 value)
Definition: PreparedStatement.cpp:156
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:100
uint32 GetFlags() const
Definition: CalendarMgr.h:247
time_t GetLockDate() const
Definition: CalendarMgr.h:254
Definition: DatabaseEnvFwd.h:40
void setInt32(const uint8 index, const int32 value)
Definition: PreparedStatement.cpp:148
uint64 GetEventId() const
Definition: CalendarMgr.h:223
std::string GetTitle() const
Definition: CalendarMgr.h:232
time_t GetDate() const
Definition: CalendarMgr.h:244
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:116
Definition: CharacterDatabase.h:582
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:180
int32 GetTextureId() const
Definition: CalendarMgr.h:241
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateInvite() [1/2]

void CalendarMgr::UpdateInvite ( CalendarInvite invite)
259 {
261  UpdateInvite(invite, dummy);
262 }
void UpdateInvite(CalendarInvite *invite)
Definition: CalendarMgr.cpp:258
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
+ Here is the caller graph for this function:

◆ UpdateInvite() [2/2]

void CalendarMgr::UpdateInvite ( CalendarInvite invite,
CharacterDatabaseTransaction trans 
)
265 {
267  stmt->setUInt64(0, invite->GetInviteId());
268  stmt->setUInt64(1, invite->GetEventId());
269  stmt->setUInt64(2, invite->GetInviteeGUID().GetCounter());
270  stmt->setUInt64(3, invite->GetSenderGUID().GetCounter());
271  stmt->setUInt8(4, invite->GetStatus());
272  stmt->setInt64(5, invite->GetResponseTime());
273  stmt->setUInt8(6, invite->GetRank());
274  stmt->setString(7, invite->GetNote());
275  CharacterDatabase.ExecuteOrAppend(trans, stmt);
276 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
std::string GetNote() const
Definition: CalendarMgr.h:176
LowType GetCounter() const
Definition: ObjectGuid.h:273
Definition: CharacterDatabase.h:584
void setInt64(const uint8 index, const int64 value)
Definition: PreparedStatement.cpp:156
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:100
Definition: DatabaseEnvFwd.h:40
uint64 GetEventId() const
Definition: CalendarMgr.h:164
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:180
uint64 GetInviteId() const
Definition: CalendarMgr.h:161
time_t GetResponseTime() const
Definition: CalendarMgr.h:173
ObjectGuid GetInviteeGUID() const
Definition: CalendarMgr.h:170
CalendarInviteStatus GetStatus() const
Definition: CalendarMgr.h:179
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
ObjectGuid GetSenderGUID() const
Definition: CalendarMgr.h:167
CalendarModerationRank GetRank() const
Definition: CalendarMgr.h:182
+ Here is the call graph for this function:

Member Data Documentation

◆ _events

CalendarEventStore CalendarMgr::_events
private

◆ _freeEventIds

std::deque<uint64> CalendarMgr::_freeEventIds
private

◆ _freeInviteIds

std::deque<uint64> CalendarMgr::_freeInviteIds
private

◆ _invites

CalendarEventInviteStore CalendarMgr::_invites
private

◆ _maxEventId

uint64 CalendarMgr::_maxEventId
private

◆ _maxInviteId

uint64 CalendarMgr::_maxInviteId
private

The documentation for this class was generated from the following files: