mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 09:17:36 +01:00
Core/Calendar: Code refactoring/removed obsolete functions
This commit is contained in:
@@ -18,294 +18,70 @@
|
||||
|
||||
#include "Calendar.h"
|
||||
|
||||
CalendarInvite::CalendarInvite(uint64 _inviteId /* = 0 */): inviteId(_inviteId),
|
||||
eventId(0), invitee(0), senderGUID(0), statusTime(0), status(0), rank(0)
|
||||
{
|
||||
}
|
||||
|
||||
CalendarInvite::~CalendarInvite()
|
||||
{
|
||||
}
|
||||
|
||||
void CalendarInvite::SetInviteId(uint64 _inviteId)
|
||||
{
|
||||
inviteId = _inviteId;
|
||||
}
|
||||
|
||||
uint64 CalendarInvite::GetInviteId() const
|
||||
{
|
||||
return inviteId;
|
||||
}
|
||||
|
||||
void CalendarInvite::SetEventId(uint64 _eventId)
|
||||
{
|
||||
eventId = _eventId;
|
||||
}
|
||||
|
||||
uint64 CalendarInvite::GetEventId() const
|
||||
{
|
||||
return eventId;
|
||||
}
|
||||
|
||||
void CalendarInvite::SetSenderGUID(uint64 _guid)
|
||||
{
|
||||
senderGUID = _guid;
|
||||
}
|
||||
|
||||
uint64 CalendarInvite::GetSenderGUID() const
|
||||
{
|
||||
return senderGUID;
|
||||
}
|
||||
|
||||
void CalendarInvite::SetInvitee(uint64 _guid)
|
||||
{
|
||||
invitee = _guid;
|
||||
}
|
||||
|
||||
uint64 CalendarInvite::GetInvitee() const
|
||||
{
|
||||
return invitee;
|
||||
}
|
||||
|
||||
void CalendarInvite::SetStatusTime(uint32 _statusTime)
|
||||
{
|
||||
statusTime = _statusTime;
|
||||
}
|
||||
|
||||
uint32 CalendarInvite::GetStatusTime() const
|
||||
{
|
||||
return statusTime;
|
||||
}
|
||||
|
||||
void CalendarInvite::SetText(std::string _text)
|
||||
{
|
||||
text = _text;
|
||||
}
|
||||
|
||||
std::string CalendarInvite::GetText() const
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
void CalendarInvite::SetStatus(uint8 _status)
|
||||
{
|
||||
status = _status;
|
||||
}
|
||||
|
||||
uint8 CalendarInvite::GetStatus() const
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
void CalendarInvite::SetRank(uint8 _rank)
|
||||
{
|
||||
rank = _rank;
|
||||
}
|
||||
|
||||
uint8 CalendarInvite::GetRank() const
|
||||
{
|
||||
return rank;
|
||||
}
|
||||
|
||||
CalendarEvent::CalendarEvent(uint64 _eventId /* = 0 */) : eventId(_eventId),
|
||||
creatorGUID(0), guildId(0), type(CALENDAR_TYPE_OTHER), dungeonId(-1),
|
||||
maxInvites(0), eventTime(0), flags(0), repeatable(false), timezoneTime(0),
|
||||
title(""), description("")
|
||||
{
|
||||
}
|
||||
|
||||
CalendarEvent::~CalendarEvent()
|
||||
{
|
||||
}
|
||||
|
||||
void CalendarEvent::SetEventId(uint64 _eventId)
|
||||
{
|
||||
eventId = _eventId;
|
||||
}
|
||||
|
||||
uint64 CalendarEvent::GetEventId() const
|
||||
{
|
||||
return eventId;
|
||||
}
|
||||
|
||||
void CalendarEvent::SetCreatorGUID(uint64 _guid)
|
||||
{
|
||||
creatorGUID = _guid;
|
||||
}
|
||||
|
||||
uint64 CalendarEvent::GetCreatorGUID() const
|
||||
{
|
||||
return creatorGUID;
|
||||
}
|
||||
|
||||
void CalendarEvent::SetGuildId(uint32 _guildId)
|
||||
{
|
||||
guildId = _guildId;
|
||||
}
|
||||
|
||||
uint32 CalendarEvent::GetGuildId() const
|
||||
{
|
||||
return guildId;
|
||||
}
|
||||
|
||||
void CalendarEvent::SetTitle(std::string _title)
|
||||
{
|
||||
title = _title;
|
||||
}
|
||||
|
||||
std::string CalendarEvent::GetTitle() const
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
void CalendarEvent::SetDescription(std::string _description)
|
||||
{
|
||||
description = _description;
|
||||
}
|
||||
|
||||
std::string CalendarEvent::GetDescription() const
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
void CalendarEvent::SetType(uint8 _type)
|
||||
{
|
||||
type = _type;
|
||||
}
|
||||
|
||||
uint8 CalendarEvent::GetType() const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
void CalendarEvent::SetMaxInvites(uint32 max)
|
||||
{
|
||||
maxInvites = max;
|
||||
}
|
||||
|
||||
uint32 CalendarEvent::GetMaxInvites() const
|
||||
{
|
||||
return maxInvites;
|
||||
}
|
||||
|
||||
void CalendarEvent::SetDungeonId(int32 _dungeonId)
|
||||
{
|
||||
dungeonId = _dungeonId;
|
||||
}
|
||||
|
||||
int32 CalendarEvent::GetDungeonId() const
|
||||
{
|
||||
return dungeonId;
|
||||
}
|
||||
|
||||
void CalendarEvent::SetTime(uint32 _eventTime)
|
||||
{
|
||||
eventTime = _eventTime;
|
||||
}
|
||||
|
||||
uint32 CalendarEvent::GetTime() const
|
||||
{
|
||||
return eventTime;
|
||||
}
|
||||
|
||||
void CalendarEvent::SetFlags(uint32 _flags)
|
||||
{
|
||||
flags = _flags;
|
||||
}
|
||||
|
||||
uint32 CalendarEvent::GetFlags() const
|
||||
{
|
||||
return flags;
|
||||
}
|
||||
|
||||
void CalendarEvent::SetRepeatable(bool _repeatable)
|
||||
{
|
||||
repeatable = _repeatable;
|
||||
}
|
||||
|
||||
uint8 CalendarEvent::GetRepeatable() const
|
||||
{
|
||||
return repeatable;
|
||||
}
|
||||
|
||||
void CalendarEvent::SetTimeZoneTime(uint32 _timezoneTime)
|
||||
{
|
||||
timezoneTime = _timezoneTime;
|
||||
}
|
||||
|
||||
uint32 CalendarEvent::GetTimeZoneTime() const
|
||||
{
|
||||
return timezoneTime;
|
||||
}
|
||||
|
||||
void CalendarEvent::AddInvite(uint64 inviteId)
|
||||
{
|
||||
if (inviteId)
|
||||
_invites.insert(inviteId);
|
||||
}
|
||||
|
||||
void CalendarEvent::RemoveInvite(uint64 inviteId)
|
||||
{
|
||||
_invites.erase(inviteId);
|
||||
}
|
||||
|
||||
bool CalendarEvent::HasInvite(uint64 inviteId) const
|
||||
{
|
||||
return _invites.find(inviteId) != _invites.end();
|
||||
}
|
||||
|
||||
CalendarinviteIdList const& CalendarEvent::GetInviteIdList() const
|
||||
{
|
||||
return _invites;
|
||||
}
|
||||
|
||||
void CalendarEvent::SetInviteIdList(CalendarinviteIdList const& list)
|
||||
{
|
||||
_invites = list;
|
||||
}
|
||||
|
||||
void CalendarEvent::ClearInviteIdList()
|
||||
{
|
||||
_invites.clear();
|
||||
}
|
||||
|
||||
std::string CalendarInvite::GetDebugString() const
|
||||
{
|
||||
std::ostringstream data;
|
||||
|
||||
data << "CalendarInvite::"
|
||||
<< " inviteId: " << inviteId
|
||||
<< " EventId: " << eventId
|
||||
<< " Status: " << uint32(status)
|
||||
<< " Invitee: " << invitee
|
||||
<< " Sender: " << senderGUID
|
||||
<< " Rank: " << uint32(rank)
|
||||
<< " Text: " << text;
|
||||
<< " inviteId: " << _inviteId
|
||||
<< " EventId: " << _eventId
|
||||
<< " Status: " << uint32(_status)
|
||||
<< " Invitee: " << _invitee
|
||||
<< " Sender: " << _senderGUID
|
||||
<< " Rank: " << uint32(_rank)
|
||||
<< " Text: " << _text;
|
||||
|
||||
return data.str();
|
||||
}
|
||||
|
||||
void CalendarInvite::Init()
|
||||
{
|
||||
_eventId = 0;
|
||||
_invitee = 0;
|
||||
_senderGUID = 0;
|
||||
_statusTime = 0;
|
||||
_status = 0;
|
||||
_rank = 0;
|
||||
_text = "";
|
||||
}
|
||||
|
||||
std::string CalendarEvent::GetDebugString() const
|
||||
{
|
||||
std::ostringstream data;
|
||||
|
||||
data << "CalendarEvent::"
|
||||
<< " EventId: " << eventId
|
||||
<< " Title: " << title
|
||||
<< " Description" << description
|
||||
<< " Type: " << uint32(type)
|
||||
<< " Max Invites: " << maxInvites
|
||||
<< " Creator: " << creatorGUID
|
||||
<< " Flags: " << flags
|
||||
<< " Guild: " << guildId
|
||||
<< " Time: " << eventTime
|
||||
<< " Time2: " << timezoneTime
|
||||
<< " Repeatable: " << uint32(repeatable)
|
||||
<< " DungeonId: " << dungeonId;
|
||||
<< " EventId: " << _eventId
|
||||
<< " Title: " << _title
|
||||
<< " Description" << _description
|
||||
<< " Type: " << uint32(_type)
|
||||
<< " Max Invites: " << _maxInvites
|
||||
<< " Creator: " << _creatorGUID
|
||||
<< " Flags: " << _flags
|
||||
<< " Guild: " << _guildId
|
||||
<< " Time: " << _eventTime
|
||||
<< " Time2: " << _timezoneTime
|
||||
<< " Repeatable: " << uint32(_repeatable)
|
||||
<< " DungeonId: " << _dungeonId;
|
||||
|
||||
return data.str();
|
||||
}
|
||||
|
||||
void CalendarEvent::Init()
|
||||
{
|
||||
_creatorGUID = 0;
|
||||
_guildId = 0;
|
||||
_type = CALENDAR_TYPE_OTHER;
|
||||
_dungeonId = -1;
|
||||
_maxInvites = 0;
|
||||
_eventTime = 0;
|
||||
_flags = 0;
|
||||
_repeatable = false;
|
||||
_timezoneTime = 0;
|
||||
_title = "";
|
||||
_description = "";
|
||||
|
||||
}
|
||||
|
||||
std::string CalendarAction::GetDebugString() const
|
||||
{
|
||||
std::ostringstream data;
|
||||
|
||||
@@ -84,36 +84,48 @@ enum CalendarInviteStatus
|
||||
class CalendarInvite
|
||||
{
|
||||
public:
|
||||
CalendarInvite(uint64 _inviteId = 0);
|
||||
~CalendarInvite();
|
||||
CalendarInvite() : _inviteId(0) { Init(); }
|
||||
explicit CalendarInvite(uint64 inviteId) : _inviteId(inviteId) { Init(); }
|
||||
|
||||
void SetInviteId(uint64 inviteId);
|
||||
uint64 GetInviteId() const;
|
||||
void SetEventId(uint64 eventId);
|
||||
uint64 GetEventId() const;
|
||||
void SetSenderGUID(uint64 guid);
|
||||
uint64 GetSenderGUID() const;
|
||||
void SetInvitee(uint64 guid);
|
||||
uint64 GetInvitee() const;
|
||||
void SetStatusTime(uint32 statusTime);
|
||||
uint32 GetStatusTime() const;
|
||||
void SetText(std::string text);
|
||||
std::string GetText() const;
|
||||
void SetStatus(uint8 _status);
|
||||
uint8 GetStatus() const;
|
||||
void SetRank(uint8 _rank);
|
||||
uint8 GetRank() const;
|
||||
~CalendarInvite() { }
|
||||
|
||||
void SetInviteId(uint64 inviteId) { _inviteId = inviteId; }
|
||||
uint64 GetInviteId() const { return _inviteId; }
|
||||
|
||||
void SetEventId(uint64 eventId) { _eventId = eventId; }
|
||||
uint64 GetEventId() const { return _eventId; }
|
||||
|
||||
void SetSenderGUID(uint64 guid) { _senderGUID = guid; }
|
||||
uint64 GetSenderGUID() const { return _senderGUID; }
|
||||
|
||||
void SetInvitee(uint64 guid) { _invitee = guid; }
|
||||
uint64 GetInvitee() const { return _invitee; }
|
||||
|
||||
void SetStatusTime(uint32 statusTime) { _statusTime = statusTime; }
|
||||
uint32 GetStatusTime() const { return _statusTime; }
|
||||
|
||||
void SetText(std::string text) { _text = text; }
|
||||
std::string GetText() const { return _text; }
|
||||
|
||||
void SetStatus(uint8 status) { _status = status; }
|
||||
uint8 GetStatus() const { return _status; }
|
||||
|
||||
void SetRank(uint8 rank) { _rank = rank; }
|
||||
uint8 GetRank() const { return _rank; }
|
||||
|
||||
std::string GetDebugString() const;
|
||||
|
||||
private:
|
||||
uint64 inviteId;
|
||||
uint64 eventId;
|
||||
uint64 invitee;
|
||||
uint64 senderGUID;
|
||||
uint32 statusTime;
|
||||
uint8 status;
|
||||
uint8 rank;
|
||||
std::string text;
|
||||
void Init();
|
||||
|
||||
uint64 _inviteId;
|
||||
uint64 _eventId;
|
||||
uint64 _invitee;
|
||||
uint64 _senderGUID;
|
||||
uint32 _statusTime;
|
||||
uint8 _status;
|
||||
uint8 _rank;
|
||||
std::string _text;
|
||||
};
|
||||
|
||||
typedef std::set<uint64> CalendarinviteIdList;
|
||||
@@ -121,55 +133,76 @@ typedef std::set<uint64> CalendarinviteIdList;
|
||||
class CalendarEvent
|
||||
{
|
||||
public:
|
||||
CalendarEvent(uint64 _eventId = 0);
|
||||
~CalendarEvent();
|
||||
CalendarEvent() : _eventId(0) { Init(); }
|
||||
explicit CalendarEvent(uint64 eventId) : _eventId(eventId) { Init(); }
|
||||
|
||||
void SetEventId(uint64 eventId);
|
||||
uint64 GetEventId() const;
|
||||
void SetCreatorGUID(uint64 guid);
|
||||
uint64 GetCreatorGUID() const;
|
||||
void SetGuildId(uint32 guild);
|
||||
uint32 GetGuildId() const;
|
||||
void SetTitle(std::string title);
|
||||
std::string GetTitle() const;
|
||||
void SetDescription(std::string description);
|
||||
std::string GetDescription() const;
|
||||
void SetType(uint8 type);
|
||||
uint8 GetType() const;
|
||||
void SetMaxInvites(uint32 max);
|
||||
uint32 GetMaxInvites() const;
|
||||
void SetDungeonId(int32 dungeonId);
|
||||
int32 GetDungeonId() const;
|
||||
void SetTime(uint32 eventTime);
|
||||
uint32 GetTime() const;
|
||||
void SetFlags(uint32 flags);
|
||||
uint32 GetFlags() const;
|
||||
void SetRepeatable(bool repeatable);
|
||||
uint8 GetRepeatable() const;
|
||||
void SetTimeZoneTime(uint32 time);
|
||||
uint32 GetTimeZoneTime() const;
|
||||
~CalendarEvent() { }
|
||||
|
||||
void AddInvite(uint64 inviteId);
|
||||
void RemoveInvite(uint64 inviteId);
|
||||
bool HasInvite(uint64 inviteId) const;
|
||||
CalendarinviteIdList const& GetInviteIdList() const;
|
||||
void SetInviteIdList(CalendarinviteIdList const& list);
|
||||
void ClearInviteIdList();
|
||||
void SetEventId(uint64 eventId) { _eventId = eventId; }
|
||||
uint64 GetEventId() const { return _eventId; }
|
||||
|
||||
void SetCreatorGUID(uint64 guid) { _creatorGUID = guid; }
|
||||
uint64 GetCreatorGUID() const { return _creatorGUID; }
|
||||
|
||||
void SetGuildId(uint32 guildId) { _guildId = guildId; }
|
||||
uint32 GetGuildId() const { return _guildId; }
|
||||
|
||||
void SetTitle(std::string title) { _title = title; }
|
||||
std::string GetTitle() const { return _title; }
|
||||
|
||||
void SetDescription(std::string description) { _description = description; }
|
||||
std::string GetDescription() const { return _description; }
|
||||
|
||||
void SetType(uint8 type) { _type = type; }
|
||||
uint8 GetType() const { return _type; }
|
||||
|
||||
void SetMaxInvites(uint32 limit) { _maxInvites = limit; }
|
||||
uint32 GetMaxInvites() const { return _maxInvites; }
|
||||
|
||||
void SetDungeonId(int32 dungeonId) { _dungeonId = dungeonId; }
|
||||
int32 GetDungeonId() const { return _dungeonId; }
|
||||
|
||||
void SetTime(uint32 eventTime) { _eventTime = eventTime; }
|
||||
uint32 GetTime() const { return _eventTime; }
|
||||
|
||||
void SetFlags(uint32 flags) { _flags = flags; }
|
||||
uint32 GetFlags() const { return _flags; }
|
||||
|
||||
void SetRepeatable(bool repeatable) { _repeatable = repeatable; }
|
||||
uint8 GetRepeatable() const { return _repeatable; }
|
||||
|
||||
void SetTimeZoneTime(uint32 timezoneTime) { _timezoneTime = timezoneTime; }
|
||||
uint32 GetTimeZoneTime() const { return _timezoneTime; }
|
||||
|
||||
void AddInvite(uint64 inviteId)
|
||||
{
|
||||
if (inviteId)
|
||||
_invites.insert(inviteId);
|
||||
}
|
||||
|
||||
void RemoveInvite(uint64 inviteId) { _invites.erase(inviteId); }
|
||||
bool HasInvite(uint64 inviteId) const { return _invites.find(inviteId) != _invites.end(); }
|
||||
CalendarinviteIdList const& GetInviteIdList() const { return _invites; }
|
||||
void SetInviteIdList(CalendarinviteIdList const& list) { _invites = list; }
|
||||
void ClearInviteIdList() { _invites.clear(); }
|
||||
|
||||
std::string GetDebugString() const;
|
||||
|
||||
private:
|
||||
uint64 eventId;
|
||||
uint64 creatorGUID;
|
||||
uint32 guildId;
|
||||
uint8 type;
|
||||
int32 dungeonId;
|
||||
uint32 maxInvites;
|
||||
uint32 eventTime;
|
||||
uint32 flags;
|
||||
uint8 repeatable;
|
||||
uint32 timezoneTime;
|
||||
std::string title;
|
||||
std::string description;
|
||||
void Init();
|
||||
|
||||
uint64 _eventId;
|
||||
uint64 _creatorGUID;
|
||||
uint32 _guildId;
|
||||
uint8 _type;
|
||||
int32 _dungeonId;
|
||||
uint32 _maxInvites;
|
||||
uint32 _eventTime;
|
||||
uint32 _flags;
|
||||
uint8 _repeatable;
|
||||
uint32 _timezoneTime;
|
||||
std::string _title;
|
||||
std::string _description;
|
||||
CalendarinviteIdList _invites;
|
||||
};
|
||||
|
||||
@@ -181,22 +214,28 @@ typedef std::map<uint64, CalendarEvent> CalendarEventMap;
|
||||
|
||||
struct CalendarAction
|
||||
{
|
||||
CalendarAction(): _action(CALENDAR_ACTION_NONE), _guid(0), _inviteId(0), _data(0) {};
|
||||
std::string GetDebugString() const;
|
||||
CalendarAction(): _action(CALENDAR_ACTION_NONE), _guid(0), _inviteId(0), _data(0)
|
||||
{
|
||||
}
|
||||
|
||||
void SetAction(CalendarActionData data) { _action = data; }
|
||||
void SetGUID(uint64 guid) { _guid = guid; }
|
||||
void SetInviteId(uint64 id) { _inviteId = id; }
|
||||
void SetExtraData(uint32 data) { _data = data; }
|
||||
|
||||
uint64 GetGUID() const { return _guid; }
|
||||
CalendarActionData GetAction() const { return _action; }
|
||||
|
||||
void SetGUID(uint64 guid) { _guid = guid; }
|
||||
uint64 GetGUID() const { return _guid; }
|
||||
|
||||
void SetInviteId(uint64 id) { _inviteId = id; }
|
||||
uint64 GetInviteId() const { return _inviteId; }
|
||||
|
||||
void SetExtraData(uint32 data) { _data = data; }
|
||||
uint32 GetExtraData() const { return _data; }
|
||||
|
||||
CalendarEvent Event;
|
||||
CalendarInvite Invite;
|
||||
private:
|
||||
|
||||
std::string GetDebugString() const;
|
||||
|
||||
private:
|
||||
CalendarActionData _action;
|
||||
uint64 _guid;
|
||||
uint64 _inviteId;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
DROP TABLE IF EXISTS `calendar_events`;
|
||||
@@ -53,9 +53,8 @@ CREATE TABLE IF NOT EXISTS `calendar_invites` (
|
||||
#include "Player.h"
|
||||
#include "ObjectAccessor.h"
|
||||
|
||||
CalendarMgr::CalendarMgr()
|
||||
: eventNum(0)
|
||||
, InviteNum(0)
|
||||
CalendarMgr::CalendarMgr() :
|
||||
_eventNum(0), _inviteNum(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -116,11 +115,11 @@ CalendarEvent* CalendarMgr::GetEvent(uint64 eventId)
|
||||
|
||||
uint64 CalendarMgr::GetFreeEventId()
|
||||
{
|
||||
return ++eventNum;
|
||||
return ++_eventNum;
|
||||
}
|
||||
uint64 CalendarMgr::GetFreeInviteId()
|
||||
{
|
||||
return ++InviteNum;
|
||||
return ++_inviteNum;
|
||||
}
|
||||
|
||||
void CalendarMgr::LoadFromDB()
|
||||
@@ -200,7 +199,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
|
||||
{
|
||||
case CALENDAR_ACTION_ADD_EVENT:
|
||||
{
|
||||
if (addEvent(action.Event) && addInvite(action.Invite))
|
||||
if (AddEvent(action.Event) && AddInvite(action.Invite))
|
||||
{
|
||||
SendCalendarEventInviteAlert(action.Event, action.Invite);
|
||||
SendCalendarEvent(action.Event, CALENDAR_SENDTYPE_ADD);
|
||||
@@ -210,9 +209,9 @@ void CalendarMgr::AddAction(CalendarAction const& action)
|
||||
case CALENDAR_ACTION_MODIFY_EVENT:
|
||||
{
|
||||
uint64 eventId = action.Event.GetEventId();
|
||||
CalendarEvent* calendarEvent = CheckPermisions(eventId,
|
||||
CalendarEvent* calendarEvent = CheckPermisions(eventId,
|
||||
action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_MODERATOR);
|
||||
|
||||
|
||||
if (!calendarEvent)
|
||||
return;
|
||||
|
||||
@@ -226,7 +225,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
|
||||
calendarEvent->SetTitle(action.Event.GetTitle());
|
||||
calendarEvent->SetDescription(action.Event.GetDescription());
|
||||
calendarEvent->SetMaxInvites(action.Event.GetMaxInvites());
|
||||
|
||||
|
||||
CalendarinviteIdList const& invites = calendarEvent->GetInviteIdList();
|
||||
for (CalendarinviteIdList::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
|
||||
if (CalendarInvite* invite = GetInvite(*itr))
|
||||
@@ -241,7 +240,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
|
||||
|
||||
if (!calendarEvent)
|
||||
return;
|
||||
|
||||
|
||||
uint64 eventId = GetFreeEventId();
|
||||
CalendarEvent newEvent(eventId);
|
||||
newEvent.SetType(calendarEvent->GetType());
|
||||
@@ -269,14 +268,14 @@ void CalendarMgr::AddAction(CalendarAction const& action)
|
||||
newInvite.SetStatusTime(invite->GetStatusTime());
|
||||
newInvite.SetText(invite->GetText());
|
||||
newInvite.SetRank(invite->GetRank());
|
||||
if (addInvite(newInvite))
|
||||
if (AddInvite(newInvite))
|
||||
{
|
||||
SendCalendarEventInviteAlert(newEvent, newInvite);
|
||||
newEvent.AddInvite(inviteId);
|
||||
}
|
||||
}
|
||||
|
||||
if (addEvent(newEvent))
|
||||
if (AddEvent(newEvent))
|
||||
SendCalendarEvent(newEvent, CALENDAR_SENDTYPE_COPY);
|
||||
|
||||
break;
|
||||
@@ -296,10 +295,10 @@ void CalendarMgr::AddAction(CalendarAction const& action)
|
||||
|
||||
CalendarinviteIdList const& inviteIds = calendarEvent->GetInviteIdList();
|
||||
for (CalendarinviteIdList::const_iterator it = inviteIds.begin(); it != inviteIds.end(); ++it)
|
||||
if (uint64 invitee = removeInvite(*it))
|
||||
if (uint64 invitee = RemoveInvite(*it))
|
||||
SendCalendarEventRemovedAlert(invitee, *calendarEvent);
|
||||
|
||||
removeEvent(eventId);
|
||||
|
||||
RemoveEvent(eventId);
|
||||
break;
|
||||
}
|
||||
case CALENDAR_ACTION_ADD_EVENT_INVITE:
|
||||
@@ -311,14 +310,14 @@ void CalendarMgr::AddAction(CalendarAction const& action)
|
||||
if (!calendarEvent)
|
||||
return;
|
||||
|
||||
if (addInvite(action.Invite))
|
||||
if (AddInvite(action.Invite))
|
||||
{
|
||||
calendarEvent->AddInvite(action.Invite.GetInviteId());
|
||||
SendCalendarEventInvite(action.Invite, (!(calendarEvent->GetFlags() & CALENDAR_FLAG_INVITES_LOCKED) &&
|
||||
!action.Invite.GetStatusTime()));
|
||||
SendCalendarEventInviteAlert(*calendarEvent, action.Invite);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case CALENDAR_ACTION_SIGNUP_TO_EVENT:
|
||||
@@ -345,7 +344,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
|
||||
newInvite.SetInvitee(action.GetGUID());
|
||||
newInvite.SetSenderGUID(action.GetGUID());
|
||||
|
||||
if (addInvite(newInvite))
|
||||
if (AddInvite(newInvite))
|
||||
SendCalendarEventInvite(newInvite, false);
|
||||
|
||||
break;
|
||||
@@ -401,7 +400,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
|
||||
if (!calendarEvent)
|
||||
return;
|
||||
|
||||
if (uint64 invitee = removeInvite(inviteId))
|
||||
if (uint64 invitee = RemoveInvite(inviteId))
|
||||
{
|
||||
SendCalendarEventInviteRemoveAlert(invitee, *calendarEvent, CALENDAR_STATUS_9);
|
||||
SendCalendarEventInviteRemove(action.GetGUID(), action.Invite, calendarEvent->GetFlags());
|
||||
@@ -414,7 +413,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
|
||||
|
||||
}
|
||||
|
||||
bool CalendarMgr::addEvent(CalendarEvent const& newEvent)
|
||||
bool CalendarMgr::AddEvent(CalendarEvent const& newEvent)
|
||||
{
|
||||
uint64 eventId = newEvent.GetEventId();
|
||||
if (_events.find(eventId) != _events.end())
|
||||
@@ -427,7 +426,7 @@ bool CalendarMgr::addEvent(CalendarEvent const& newEvent)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalendarMgr::removeEvent(uint64 eventId)
|
||||
bool CalendarMgr::RemoveEvent(uint64 eventId)
|
||||
{
|
||||
CalendarEventMap::iterator itr = _events.find(eventId);
|
||||
if (itr == _events.end())
|
||||
@@ -444,26 +443,26 @@ bool CalendarMgr::removeEvent(uint64 eventId)
|
||||
for (CalendarinviteIdList::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
|
||||
{
|
||||
CalendarInvite* invite = GetInvite(*itr);
|
||||
if (!invite || !removePlayerEvent(invite->GetInvitee(), eventId))
|
||||
if (!invite || !RemovePlayerEvent(invite->GetInvitee(), eventId))
|
||||
val = false;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
bool CalendarMgr::addPlayerEvent(uint64 guid, uint64 eventId)
|
||||
bool CalendarMgr::AddPlayerEvent(uint64 guid, uint64 eventId)
|
||||
{
|
||||
_playerEvents[guid].insert(eventId);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalendarMgr::removePlayerEvent(uint64 guid, uint64 eventId)
|
||||
bool CalendarMgr::RemovePlayerEvent(uint64 guid, uint64 eventId)
|
||||
{
|
||||
_playerEvents[guid].erase(eventId);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalendarMgr::addInvite(CalendarInvite const& newInvite)
|
||||
bool CalendarMgr::AddInvite(CalendarInvite const& newInvite)
|
||||
{
|
||||
uint64 inviteId = newInvite.GetInviteId();
|
||||
if (!inviteId)
|
||||
@@ -480,12 +479,12 @@ bool CalendarMgr::addInvite(CalendarInvite const& newInvite)
|
||||
|
||||
_invites[inviteId] = newInvite;
|
||||
uint64 guid = newInvite.GetInvitee();
|
||||
bool inviteAdded = addPlayerInvite(guid, inviteId);
|
||||
bool eventAdded = addPlayerEvent(guid, newInvite.GetEventId());
|
||||
bool inviteAdded = AddPlayerInvite(guid, inviteId);
|
||||
bool eventAdded = AddPlayerEvent(guid, newInvite.GetEventId());
|
||||
return eventAdded && inviteAdded;
|
||||
}
|
||||
|
||||
uint64 CalendarMgr::removeInvite(uint64 inviteId)
|
||||
uint64 CalendarMgr::RemoveInvite(uint64 inviteId)
|
||||
{
|
||||
CalendarInviteMap::iterator itr = _invites.find(inviteId);
|
||||
if (itr == _invites.end())
|
||||
@@ -493,20 +492,20 @@ uint64 CalendarMgr::removeInvite(uint64 inviteId)
|
||||
sLog->outError("CalendarMgr::removeInvite: Invite [" UI64FMTD "] does not exist", inviteId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
uint64 invitee = itr->second.GetInvitee();
|
||||
_invites.erase(itr);
|
||||
|
||||
return removePlayerInvite(invitee, inviteId) ? invitee : 0;
|
||||
return RemovePlayerInvite(invitee, inviteId) ? invitee : 0;
|
||||
}
|
||||
|
||||
bool CalendarMgr::addPlayerInvite(uint64 guid, uint64 inviteId)
|
||||
bool CalendarMgr::AddPlayerInvite(uint64 guid, uint64 inviteId)
|
||||
{
|
||||
_playerInvites[guid].insert(inviteId);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalendarMgr::removePlayerInvite(uint64 guid, uint64 inviteId)
|
||||
bool CalendarMgr::RemovePlayerInvite(uint64 guid, uint64 inviteId)
|
||||
{
|
||||
_playerInvites[guid].erase(inviteId);
|
||||
return true;
|
||||
|
||||
@@ -23,7 +23,11 @@
|
||||
|
||||
class CalendarMgr
|
||||
{
|
||||
friend class ACE_Singleton<CalendarMgr, ACE_Null_Mutex>;
|
||||
friend class ACE_Singleton<CalendarMgr, ACE_Null_Mutex>;
|
||||
|
||||
CalendarMgr();
|
||||
~CalendarMgr();
|
||||
|
||||
public:
|
||||
void LoadFromDB();
|
||||
|
||||
@@ -50,27 +54,25 @@ class CalendarMgr
|
||||
void SendCalendarEventModeratorStatusAlert(CalendarInvite const& invite);
|
||||
|
||||
private:
|
||||
CalendarMgr();
|
||||
~CalendarMgr();
|
||||
CalendarEvent* CheckPermisions(uint64 eventId, uint64 guid, uint64 invitateId, CalendarRanks minRank);
|
||||
|
||||
bool addEvent(CalendarEvent const& calendarEvent);
|
||||
bool removeEvent(uint64 eventId);
|
||||
bool addPlayerEvent(uint64 guid, uint64 eventId);
|
||||
bool removePlayerEvent(uint64 guid, uint64 eventId);
|
||||
bool AddEvent(CalendarEvent const& calendarEvent);
|
||||
bool RemoveEvent(uint64 eventId);
|
||||
bool AddPlayerEvent(uint64 guid, uint64 eventId);
|
||||
bool RemovePlayerEvent(uint64 guid, uint64 eventId);
|
||||
|
||||
bool addInvite(CalendarInvite const& invite);
|
||||
uint64 removeInvite(uint64 inviteId);
|
||||
bool addPlayerInvite(uint64 guid, uint64 inviteId);
|
||||
bool removePlayerInvite(uint64 guid, uint64 inviteId);
|
||||
bool AddInvite(CalendarInvite const& invite);
|
||||
uint64 RemoveInvite(uint64 inviteId);
|
||||
bool AddPlayerInvite(uint64 guid, uint64 inviteId);
|
||||
bool RemovePlayerInvite(uint64 guid, uint64 inviteId);
|
||||
|
||||
CalendarEventMap _events;
|
||||
CalendarInviteMap _invites;
|
||||
CalendarPlayerinviteIdMap _playerInvites;
|
||||
CalendarPlayerEventIdMap _playerEvents;
|
||||
|
||||
uint64 eventNum;
|
||||
uint64 InviteNum;
|
||||
uint64 _eventNum;
|
||||
uint64 _inviteNum;
|
||||
};
|
||||
|
||||
#define sCalendarMgr ACE_Singleton<CalendarMgr, ACE_Null_Mutex>::instance()
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
----- Opcodes Not Used yet -----
|
||||
----- Opcodes Not Used yet -----
|
||||
|
||||
SMSG_CALENDAR_CLEAR_PENDING_ACTION SendCalendarClearPendingAction()
|
||||
SMSG_CALENDAR_RAID_LOCKOUT_UPDATED SendCalendarRaildLockoutUpdated(InstanceSave const* save) <--- Structure unknown, using LOCKOUT_ADDED
|
||||
@@ -130,7 +130,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/)
|
||||
data << uint32(counter); // raid reset count
|
||||
|
||||
std::set<uint32> sentMaps;
|
||||
|
||||
|
||||
ResetTimeByMapDifficultyMap const& resets = sInstanceSaveMgr->GetResetTimeMap();
|
||||
for (ResetTimeByMapDifficultyMap::const_iterator itr = resets.begin(); itr != resets.end(); ++itr)
|
||||
{
|
||||
@@ -144,7 +144,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/)
|
||||
continue;
|
||||
|
||||
sentMaps.insert(mapId);
|
||||
|
||||
|
||||
data << uint32(mapId);
|
||||
data << uint32(itr->second - cur_time);
|
||||
data << uint32(mapEntry->unk_time);
|
||||
@@ -689,7 +689,7 @@ void WorldSession::SendCalendarEventRemovedAlert(CalendarEvent const& calendarEv
|
||||
uint64 guid = _player->GetGUID();
|
||||
uint64 eventId = calendarEvent.GetEventId();
|
||||
uint32 eventTime = (calendarEvent.GetTime());
|
||||
|
||||
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_REMOVED_ALERT [" UI64FMTD "] EventId ["
|
||||
UI64FMTD "] Time %u", guid, eventId, eventTime);
|
||||
|
||||
@@ -711,7 +711,7 @@ void WorldSession::SendCalendarEventStatus(CalendarEvent const& calendarEvent, C
|
||||
uint8 status = invite.GetStatus();
|
||||
uint8 rank = invite.GetRank();
|
||||
uint32 statusTime = secsToTimeBitFields(invite.GetStatusTime());
|
||||
|
||||
|
||||
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_STATUS [" UI64FMTD "] EventId ["
|
||||
UI64FMTD "] InviteId [" UI64FMTD "] Invitee [" UI64FMTD "] Time %u "
|
||||
@@ -736,7 +736,7 @@ void WorldSession::SendCalendarEventModeratorStatusAlert(CalendarInvite const& i
|
||||
uint64 eventId = invite.GetEventId();
|
||||
uint64 invitee = invite.GetInvitee();
|
||||
uint8 status = invite.GetStatus();
|
||||
|
||||
|
||||
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_MODERATOR_STATUS_ALERT [" UI64FMTD
|
||||
"] Invitee [" UI64FMTD "] EventId [" UI64FMTD "] Status %u ", guid,
|
||||
@@ -797,7 +797,7 @@ void WorldSession::SendCalendarClearPendingAction()
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::SendCalendarRaildLockoutUpdated(InstanceSave const* save)
|
||||
void WorldSession::SendCalendarRaidLockoutUpdated(InstanceSave const* save)
|
||||
{
|
||||
if (!save)
|
||||
return;
|
||||
@@ -807,13 +807,13 @@ void WorldSession::SendCalendarRaildLockoutUpdated(InstanceSave const* save)
|
||||
"] Map: %u, Difficulty %u", guid, save->GetMapId(), save->GetDifficulty());
|
||||
|
||||
time_t cur_time = time_t(time(NULL));
|
||||
|
||||
|
||||
WorldPacket data(SMSG_CALENDAR_RAID_LOCKOUT_UPDATED, 4 + 4 + 4 + 4 + 8);
|
||||
data << secsToTimeBitFields(cur_time);
|
||||
data << uint32(save->GetMapId());
|
||||
data << uint32(save->GetDifficulty());
|
||||
data << uint32(save->GetResetTime() - cur_time);
|
||||
data << uint64(save->GetInstanceId());
|
||||
data << uint64(save->GetInstanceId());
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
@@ -828,43 +828,6 @@ void WorldSession::SendCalendarCommandResult(uint32 value)
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::SendCalendarRaildLockoutAdded(InstanceSave const* save)
|
||||
{
|
||||
if (!save)
|
||||
return;
|
||||
|
||||
uint64 guid = _player->GetGUID();
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_RAID_LOCKOUT_ADDED [" UI64FMTD
|
||||
"] Map: %u, Difficulty %u", guid, save->GetMapId(), save->GetDifficulty());
|
||||
|
||||
time_t cur_time = time_t(time(NULL));
|
||||
|
||||
WorldPacket data(SMSG_CALENDAR_RAID_LOCKOUT_ADDED, 4 + 4 + 4 + 4 + 8);
|
||||
data << secsToTimeBitFields(cur_time);
|
||||
data << uint32(save->GetMapId());
|
||||
data << uint32(save->GetDifficulty());
|
||||
data << uint32(save->GetResetTime() - cur_time);
|
||||
data << uint64(save->GetInstanceId());
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::SendCalendarRaildLockoutRemoved(InstanceSave const* save)
|
||||
{
|
||||
if (!save)
|
||||
return;
|
||||
|
||||
uint64 guid = _player->GetGUID();
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_RAID_LOCKOUT_REMOVED [" UI64FMTD
|
||||
"] Map: %u, Difficulty %u", guid, save->GetMapId(), save->GetDifficulty());
|
||||
|
||||
WorldPacket data(SMSG_CALENDAR_RAID_LOCKOUT_REMOVED, 4 + 4 + 4 + 8);
|
||||
data << uint32(save->GetMapId());
|
||||
data << uint32(save->GetDifficulty());
|
||||
data << uint32(0);
|
||||
data << uint64(save->GetInstanceId());
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::SendCalendarRaidLockout(InstanceSave* save, bool add)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "%s", add ? "SMSG_CALENDAR_RAID_LOCKOUT_ADDED" : "SMSG_CALENDAR_RAID_LOCKOUT_REMOVED");
|
||||
|
||||
Reference in New Issue
Block a user