aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorSpp <spp@jorge.gr>2012-02-24 20:11:29 +0100
committerSpp <spp@jorge.gr>2012-02-24 20:11:29 +0100
commit32eab3dca794cf0da17153349b9e76f3a49c7a0f (patch)
tree155e04eef648b919a2c140c2248428cd8660ee10 /src/server
parenta934abbbb7b6454983ec8e6ac5c34cc8382c87c0 (diff)
Core/Calendar: WIP Calendar.
Diffstat (limited to 'src/server')
-rwxr-xr-xsrc/server/game/Calendar/Calendar.cpp303
-rwxr-xr-xsrc/server/game/Calendar/Calendar.h219
-rw-r--r--src/server/game/Calendar/CalendarMgr.cpp589
-rw-r--r--src/server/game/Calendar/CalendarMgr.h93
-rwxr-xr-xsrc/server/game/Handlers/CalendarHandler.cpp904
-rwxr-xr-xsrc/server/game/Server/Protocol/Opcodes.cpp2
-rwxr-xr-xsrc/server/game/Server/WorldSession.h21
-rwxr-xr-xsrc/server/game/World/World.cpp4
8 files changed, 1751 insertions, 384 deletions
diff --git a/src/server/game/Calendar/Calendar.cpp b/src/server/game/Calendar/Calendar.cpp
index 2dadd66f64c..82ba3c1b062 100755
--- a/src/server/game/Calendar/Calendar.cpp
+++ b/src/server/game/Calendar/Calendar.cpp
@@ -17,3 +17,306 @@
*/
#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;
+
+ return data.str();
+}
+
+std::string CalendarEvent::GetDebugString() const
+{
+ std::ostringstream data;
+
+ data << "CalendarEvent::"
+ << " EventId: " << eventId
+ << " Title: " << title
+ << " Description" << description
+ << " Type: " << uint32(type)
+ << " Max Invites: " << maxInvites
+ << " Creator: " << creatorGUID
+ << " Flags: " << flags
+ << " Guild: " << guildId
+ << " Time: " << eventTime
+ << " Time2: " << timezoneTime
+ << " Repeatable: " << uint32(repeatable)
+ << " DungeonId: " << dungeonId;
+
+ return data.str();
+}
+
+std::string CalendarAction::GetDebugString() const
+{
+ std::ostringstream data;
+
+ data << "CalendarAction::"
+ << " Action: " << GetAction()
+ << " Guid: " << GetGUID()
+ << " Invite Id: " << GetInviteId()
+ << " Extra data: " << GetExtraData()
+ << " Event: " << Event.GetDebugString()
+ << " Invite: " << Invite.GetDebugString();
+
+ return data.str();
+}
diff --git a/src/server/game/Calendar/Calendar.h b/src/server/game/Calendar/Calendar.h
index d8da4ce7ffe..ffe2f97269c 100755
--- a/src/server/game/Calendar/Calendar.h
+++ b/src/server/game/Calendar/Calendar.h
@@ -20,86 +20,187 @@
#define TRINITY_CALENDAR_H
#include "Common.h"
+#include <map>
-enum CalendarEventType
+enum CalendarFlags
{
- CALENDARTYPE_RAID = 0,
- CALENDARTYPE_DUNGEON,
- CALENDARTYPE_PVP,
- CALENDARTYPE_MEETING,
- CALENDARTYPE_OTHER,
+ CALENDAR_FLAG_ALL_ALLOWED = 0x001,
+ CALENDAR_FLAG_INVITES_LOCKED = 0x010,
+ CALENDAR_FLAG_WITHOUT_INVITES = 0x040,
+ CALENDAR_FLAG_GUILD_ONLY = 0x400,
};
-enum CalendarSendEventType
+enum CalendarActionData
{
- CALENDARSENDEVENTTYPE_GET = 0,
- CALENDARSENDEVENTTYPE_ADD,
- CALENDARSENDEVENTTYPE_COPY
+ CALENDAR_ACTION_NONE,
+ CALENDAR_ACTION_ADD_EVENT,
+ CALENDAR_ACTION_MODIFY_EVENT,
+ CALENDAR_ACTION_REMOVE_EVENT,
+ CALENDAR_ACTION_COPY_EVENT,
+ CALENDAR_ACTION_ADD_EVENT_INVITE,
+ CALENDAR_ACTION_MODIFY_EVENT_INVITE,
+ CALENDAR_ACTION_MODIFY_MODERATOR_EVENT_INVITE,
+ CALENDAR_ACTION_REMOVE_EVENT_INVITE,
+ CALENDAR_ACTION_SIGNUP_TO_EVENT,
};
-enum CalendarModerationRank
+enum CalendarRanks
{
- CALENDARMODERATIONRANK_PLAYER = 0,
- CALENDARMODERATIONRANK_MODERATOR,
- CALENDARMODERATIONRANK_OWNER
+ CALENDAR_RANK_PLAYER,
+ CALENDAR_RANK_MODERATOR,
+ CALENDAR_RANK_OWNER,
};
-enum CalendarEventStatus
+enum CalendarSendEventType
{
- CALENDARSTATUS_INVITED = 0,
- CALENDARSTATUS_ACCEPTED,
- CALENDARSTATUS_DECLINED,
- CALENDARSTATUS_TENTATIVE,
- CALENDARSTATUS_OUT,
- CALENDARSTATUS_STANDBY,
- CALENDARSTATUS_CONFIRMED,
- // CALENDARSTATUS_UNK7
- // CALENDARSTATUS_UNK8
- // CALENDARSTATUS_UNK9
+ CALENDAR_SENDTYPE_GET,
+ CALENDAR_SENDTYPE_ADD,
+ CALENDAR_SENDTYPE_COPY,
};
-enum CalendarFlags
+enum CalendarEventType
{
- CALENDARFLAG_NONE = 0x000000,
- CALENDARFLAG_NORMAL = 0x000001,
- CALENDARFLAG_INVITES_LOCKED = 0x000010,
- CALENDARFLAG_WITHOUT_INVITES = 0x000040,
- CALENDARFLAG_GUILD_EVENT = 0x000400
- // CALENDARFLAG_Unk10000 = 0x010000,
- // CALENDARFLAG_Unk400000 = 0x400000
+ CALENDAR_TYPE_RAID,
+ CALENDAR_TYPE_DUNGEON,
+ CALENDAR_TYPE_PVP,
+ CALENDAR_TYPE_MEETING,
+ CALENDAR_TYPE_OTHER,
};
-struct CalendarEvent
+enum CalendarInviteStatus
{
- uint64 Id;
- uint64 CreatorGuid;
- std::string Name;
- std::string Description;
- CalendarEventType Type;
- uint8 Unk;
- uint32 DungeonId;
- uint32 UnkTime;
- uint32 Time;
- CalendarFlags Flags;
- uint32 GuildId;
+ CALENDAR_STATUS_INVITED,
+ CALENDAR_STATUS_ACCEPTED,
+ CALENDAR_STATUS_DECLINED,
+ CALENDAR_STATUS_TENTATIVE,
+ CALENDAR_STATUS_OUT,
+ CALENDAR_STATUS_STANDBY,
+ CALENDAR_STATUS_CONFIRMED,
+ CALENDAR_STATUS_NO_OWNER,
+ CALENDAR_STATUS_8,
+ CALENDAR_STATUS_9,
};
-struct CalendarInvite
+class CalendarInvite
{
- uint64 Id;
- uint64 Event;
- CalendarEventStatus Status;
- CalendarModerationRank Rank;
- uint8 Unk1;
- uint8 Unk2;
- uint8 Unk3;
- std::string Text;
- uint64 CreatorGuid;
- uint32 Time;
- uint64 TargetGuid;
+ public:
+ CalendarInvite(uint64 _inviteId = 0);
+ ~CalendarInvite();
+
+ 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;
+
+ std::string GetDebugString() const;
+ private:
+ uint64 inviteId;
+ uint64 eventId;
+ uint64 invitee;
+ uint64 senderGUID;
+ uint32 statusTime;
+ uint8 status;
+ uint8 rank;
+ std::string text;
};
-typedef UNORDERED_MAP<uint64, CalendarInvite> CalendarInviteMap;
-typedef UNORDERED_MAP<uint64, CalendarEvent> CalendarEventMap;
+typedef std::set<uint64> CalendarinviteIdList;
+
+class CalendarEvent
+{
+ public:
+ CalendarEvent(uint64 _eventId = 0);
+ ~CalendarEvent();
+
+ 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;
+
+ void AddInvite(uint64 inviteId);
+ void RemoveInvite(uint64 inviteId);
+ bool HasInvite(uint64 inviteId) const;
+ CalendarinviteIdList const& GetInviteIdList() const;
+ void SetInviteIdList(CalendarinviteIdList const& list);
+ void ClearInviteIdList();
+
+ 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;
+ CalendarinviteIdList _invites;
+};
+
+typedef std::set<uint64> CalendarEventIdList;
+typedef std::map<uint64, CalendarinviteIdList> CalendarPlayerinviteIdMap;
+typedef std::map<uint64, CalendarEventIdList> CalendarPlayerEventIdMap;
+typedef std::map<uint64, CalendarInvite> CalendarInviteMap;
+typedef std::map<uint64, CalendarEvent> CalendarEventMap;
+
+struct CalendarAction
+{
+ CalendarAction(): _action(CALENDAR_ACTION_NONE), _guid(0), _inviteId(0), _data(0) {};
+ std::string GetDebugString() const;
+
+ 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; }
+ uint64 GetInviteId() const { return _inviteId; }
+ uint32 GetExtraData() const { return _data; }
+
+ CalendarEvent Event;
+ CalendarInvite Invite;
+ private:
+ CalendarActionData _action;
+ uint64 _guid;
+ uint64 _inviteId;
+ uint32 _data;
+};
#endif
diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp
index d947faed42f..0a4d9e36f49 100644
--- a/src/server/game/Calendar/CalendarMgr.cpp
+++ b/src/server/game/Calendar/CalendarMgr.cpp
@@ -1,25 +1,61 @@
/*
- * Copyright (C) 2008-2012 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2012 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 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.
+ * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * 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`;
+CREATE TABLE IF NOT EXISTS `calendar_events` (
+ `id` int(11) unsigned NOT NULL DEFAULT '0',
+ `creator` int(11) unsigned NOT NULL DEFAULT '0',
+ `title` varchar(255) NOT NULL DEFAULT '',
+ `description` varchar(255) NOT NULL DEFAULT '',
+ `type` tinyint(1) unsigned NOT NULL DEFAULT '4',
+ `dungeon` tinyint(3) NOT NULL DEFAULT '-1',
+ `eventtime` int(10) unsigned NOT NULL DEFAULT '0',
+ `flags` int(10) unsigned NOT NULL DEFAULT '0',
+ `repeatable` tinyint(1) unsigned NOT NULL DEFAULT '0',
+ `time2` int(10) unsigned NOT NULL DEFAULT '0',
+ PRIMARY KEY (`id`)
+);
+
+DROP TABLE IF EXISTS `calendar_invites`;
+CREATE TABLE IF NOT EXISTS `calendar_invites` (
+ `id` int(11) unsigned NOT NULL DEFAULT '0',
+ `event` int(11) unsigned NOT NULL DEFAULT '0',
+ `invitee` int(11) unsigned NOT NULL DEFAULT '0',
+ `sender` int(11) unsigned NOT NULL DEFAULT '0',
+ `status` tinyint(1) unsigned NOT NULL DEFAULT '0',
+ `statustime` int(10) unsigned NOT NULL DEFAULT '0',
+ `rank` tinyint(1) unsigned NOT NULL DEFAULT '0',
+ `text` varchar(255) NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`)
+);
+*/
#include "CalendarMgr.h"
#include "QueryResult.h"
+#include "DatabaseEnv.h"
+#include "Log.h"
+#include "Player.h"
+#include "ObjectAccessor.h"
-CalendarMgr::CalendarMgr() : _currentEventId(0), _currentInviteId(0)
+CalendarMgr::CalendarMgr()
+ : eventNum(0)
+ , InviteNum(0)
{
}
@@ -27,54 +63,505 @@ CalendarMgr::~CalendarMgr()
{
}
-void CalendarMgr::AppendInvitesToCalendarPacketForPlayer(WorldPacket& data, Player* player)
+uint32 CalendarMgr::GetPlayerNumPending(uint64 guid)
{
- size_t pCounter = data.wpos();
- data << uint32(0);
- uint32 counter = 0;
- for (CalendarInviteMap::iterator itr = _inviteMap.begin(); itr != _inviteMap.end(); ++itr)
- {
- CalendarInvite invite = itr->second;
- if (invite.TargetGuid == player->GetGUID())
+ if (!guid)
+ return 0;
+
+ CalendarPlayerinviteIdMap::const_iterator itr = _playerInvites.find(guid);
+ if (itr == _playerInvites.end())
+ return 0;
+
+ uint32 pendingNum = 0;
+ for (CalendarinviteIdList::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it)
+ if (CalendarInvite* invite = GetInvite(*it))
+ if (invite->GetRank() != CALENDAR_RANK_OWNER
+ && invite->GetStatus() != CALENDAR_STATUS_CONFIRMED
+ && invite->GetStatus() != CALENDAR_STATUS_8
+ && invite->GetStatus() != CALENDAR_STATUS_9) // FIXME Check the proper value
+ ++pendingNum;
+
+ return pendingNum;
+}
+
+CalendarinviteIdList const& CalendarMgr::GetPlayerInvites(uint64 guid)
+{
+ return _playerInvites[guid];
+}
+
+CalendarEventIdList const& CalendarMgr::GetPlayerEvents(uint64 guid)
+{
+ return _playerEvents[guid];
+}
+
+CalendarInvite* CalendarMgr::GetInvite(uint64 inviteId)
+{
+ CalendarInviteMap::iterator it = _invites.find(inviteId);
+ if (it != _invites.end())
+ return &(it->second);
+
+ sLog->outError("SPP: CalendarMgr::GetInvite: [" UI64FMTD "] not found!", inviteId);
+ return NULL;
+}
+
+CalendarEvent* CalendarMgr::GetEvent(uint64 eventId)
+{
+ CalendarEventMap::iterator it = _events.find(eventId);
+ if (it != _events.end())
+ return &(it->second);
+
+ sLog->outError("SPP: CalendarMgr::GetEvent: [" UI64FMTD "] not found!", eventId);
+ return NULL;
+}
+
+uint64 CalendarMgr::GetFreeEventId()
+{
+ return ++eventNum;
+}
+uint64 CalendarMgr::GetFreeInviteId()
+{
+ return ++InviteNum;
+}
+
+void CalendarMgr::LoadFromDB()
+{
+ /*
+ uint32 count = 0;
+ // 0 1 2 3 4 5 6 7 8 9
+ if (QueryResult result = CharacterDatabase.Query("SELECT id, creator, title, description, type, dungeon, eventtime, flags, repeatable, time2 FROM calendar_events"))
+ do
+ {
+ Field * fields = result->Fetch();
+
+ uint64 eventId = fields[0].GetUInt64();
+ CalendarEvent& calendarEvent = _events[eventId];
+
+ calendarEvent.SetEventId(eventId);
+ calendarEvent.SetCreatorGUID(fields[1].GetUInt64());
+ calendarEvent.SetTitle(fields[2].GetString());
+ calendarEvent.SetDescription(fields[3].GetString());
+ calendarEvent.SetType(fields[4].GetUInt8());
+ calendarEvent.SetDungeonId(fields[5].GetInt32());
+ calendarEvent.SetTime(fields[6].GetUInt32());
+ calendarEvent.SetFlags(fields[7].GetUInt32());
+ calendarEvent.SetRepeatable(fields[8].GetBool());
+ calendarEvent.SetTimeZoneTime(fields[9].GetUInt32());
+ ++count;
+ }
+ while (result->NextRow());
+
+ sLog->outString(">> Loaded %u calendar events", count);
+ count = 0;
+
+ // 0 1 2 3 4 5 6 7
+ if (QueryResult result = CharacterDatabase.Query("SELECT id, event, invitee, sender, status, statustime, rank, text FROM calendar_invites"))
+ do
{
- data << uint64(invite.Id); // Invite ID
- data << uint64(invite.Event); // Event ID
- data << uint8(invite.Rank); // rank
- data << uint8(0); // unk - TODO: Figure out what this is
- data << uint8(0); // unk
- data.appendPackGUID(invite.CreatorGuid); // creator's guid
- counter++;
+ Field * fields = result->Fetch();
+
+ uint64 inviteId = fields[0].GetUInt64();
+ uint64 eventId = fields[1].GetUInt64();
+
+ CalendarInvite& invite = _invites[inviteId];
+
+ invite.SetEventId(eventId);
+ invite.SetInvitee(fields[2].GetUInt64());
+ invite.SetSenderGUID(fields[3].GetUInt64());
+ invite.SetStatus(fields[4].GetUInt8());
+ invite.SetStatusTime(fields[5].GetUInt32());
+ invite.SetRank(fields[6].GetUInt8());
+ invite.SetText(fields[7].GetString());
+
+ CalendarEvent& calendarEvent = _events[eventId];
+ calendarEvent.AddInvite(inviteId);
}
- }
- data.put<uint32>(pCounter, counter); // update number of invites
+ while (result->NextRow());
+
+ sLog->outString(">> Loaded %u calendar Invites", count);
+ */
}
-void CalendarMgr::AppendEventsToCalendarPacketForPlayer(WorldPacket& data, Player* player)
+CalendarEvent* CalendarMgr::CheckPermisions(uint64 eventId, uint64 guid, uint64 inviteId, CalendarRanks minRank)
{
- // TODO: There's gotta be a better way to do this
- size_t pCounter = data.wpos();
- data << uint32(0);
- uint32 counter = 0;
- std::set<uint64> alreadyAdded;
- for (CalendarInviteMap::iterator itr = _inviteMap.begin(); itr != _inviteMap.end(); ++itr)
+ if (CalendarEvent* calendarEvent = GetEvent(eventId))
+ if (CalendarInvite* invite = GetInvite(inviteId))
+ if (calendarEvent->HasInvite(inviteId)
+ && invite->GetEventId() == calendarEvent->GetEventId()
+ && invite->GetInvitee() == guid
+ && invite->GetRank() >= minRank)
+ return calendarEvent;
+
+ return NULL;
+}
+
+void CalendarMgr::AddAction(CalendarAction const& action)
+{
+ switch (action.GetAction())
{
- CalendarInvite invite = itr->second;
- if (invite.TargetGuid == player->GetGUID())
+ case CALENDAR_ACTION_ADD_EVENT:
{
- if (alreadyAdded.find(invite.Event) == alreadyAdded.end())
+ if (addEvent(action.Event) && addInvite(action.Invite))
{
- CalendarEvent const* event = GetEvent(invite.Event);
- data << uint64(event->Id); // event ID
- data << event->Name; // event title
- data << uint32(event->Type); // event type
- data << uint32(event->Time); // event time as time bit field
- data << uint32(event->Flags); // event flags
- data << uint32(event->DungeonId); // dungeon ID
- data.appendPackGUID(event->CreatorGuid); // creator guid
- alreadyAdded.insert(invite.Event);
- counter++;
+ SendCalendarEventInviteAlert(action.Event, action.Invite);
+ SendCalendarEvent(action.Event, CALENDAR_SENDTYPE_ADD);
}
+ break;
}
+ case CALENDAR_ACTION_MODIFY_EVENT:
+ {
+ uint64 eventId = action.Event.GetEventId();
+ CalendarEvent* calendarEvent = CheckPermisions(eventId,
+ action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_MODERATOR);
+
+ if (!calendarEvent)
+ return;
+
+ calendarEvent->SetEventId(action.Event.GetEventId());
+ calendarEvent->SetType(action.Event.GetType());
+ calendarEvent->SetFlags(action.Event.GetFlags());
+ calendarEvent->SetTime(action.Event.GetTime());
+ calendarEvent->SetTimeZoneTime(action.Event.GetTimeZoneTime());
+ calendarEvent->SetRepeatable(action.Event.GetRepeatable());
+ calendarEvent->SetDungeonId(action.Event.GetDungeonId());
+ calendarEvent->SetTitle(action.Event.GetTitle());
+ calendarEvent->SetDescription(action.Event.GetDescription());
+ calendarEvent->SetMaxInvites(action.Event.GetMaxInvites());
+
+ CalendarinviteIdList const& invites = calendarEvent->GetInviteIdList();
+ for (CalendarinviteIdList::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
+ if (CalendarInvite* invite = GetInvite(*itr))
+ SendCalendarEventUpdateAlert(invite->GetInvitee(), *calendarEvent, CALENDAR_SENDTYPE_ADD);
+
+ break;
+ }
+ case CALENDAR_ACTION_COPY_EVENT:
+ {
+ CalendarEvent* calendarEvent = CheckPermisions(action.Event.GetEventId(),
+ action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_OWNER);
+
+ if (!calendarEvent)
+ return;
+
+ uint64 eventId = GetFreeEventId();
+ CalendarEvent newEvent(eventId);
+ newEvent.SetType(calendarEvent->GetType());
+ newEvent.SetFlags(calendarEvent->GetFlags());
+ newEvent.SetTime(action.Event.GetTime());
+ newEvent.SetTimeZoneTime(calendarEvent->GetTimeZoneTime());
+ newEvent.SetRepeatable(calendarEvent->GetRepeatable());
+ newEvent.SetDungeonId(calendarEvent->GetDungeonId());
+ newEvent.SetTitle(calendarEvent->GetTitle());
+ newEvent.SetDescription(calendarEvent->GetDescription());
+ newEvent.SetMaxInvites(calendarEvent->GetMaxInvites());
+ newEvent.SetCreatorGUID(calendarEvent->GetCreatorGUID());
+ newEvent.SetGuildId(calendarEvent->GetGuildId());
+
+ CalendarinviteIdList const invites = calendarEvent->GetInviteIdList();
+ for (CalendarinviteIdList::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
+ if (CalendarInvite* invite = GetInvite(*itr))
+ {
+ uint64 inviteId = GetFreeInviteId();
+ CalendarInvite newInvite(inviteId);
+ newInvite.SetEventId(eventId);
+ newInvite.SetSenderGUID(action.GetGUID());
+ newInvite.SetInvitee(invite->GetInvitee());
+ newInvite.SetStatus(invite->GetStatus());
+ newInvite.SetStatusTime(invite->GetStatusTime());
+ newInvite.SetText(invite->GetText());
+ newInvite.SetRank(invite->GetRank());
+ if (addInvite(newInvite))
+ {
+ SendCalendarEventInviteAlert(newEvent, newInvite);
+ newEvent.AddInvite(inviteId);
+ }
+ }
+
+ if (addEvent(newEvent))
+ SendCalendarEvent(newEvent, CALENDAR_SENDTYPE_COPY);
+
+ break;
+ }
+ case CALENDAR_ACTION_REMOVE_EVENT:
+ {
+ uint64 eventId = action.Event.GetEventId();
+ uint32 flags = action.Event.GetFlags();
+ sLog->outError("CalendarMgr::AddAction:: Flags %u", flags);
+ // FIXME - Use of Flags here!
+
+ CalendarEvent* calendarEvent = CheckPermisions(eventId,
+ action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_OWNER);
+
+ if (!calendarEvent)
+ return;
+
+ CalendarinviteIdList const& inviteIds = calendarEvent->GetInviteIdList();
+ for (CalendarinviteIdList::const_iterator it = inviteIds.begin(); it != inviteIds.end(); ++it)
+ if (uint64 invitee = removeInvite(*it))
+ SendCalendarEventRemovedAlert(invitee, *calendarEvent);
+
+ removeEvent(eventId);
+ break;
+ }
+ case CALENDAR_ACTION_ADD_EVENT_INVITE:
+ {
+ uint64 eventId = action.Invite.GetEventId();
+ CalendarEvent* calendarEvent = CheckPermisions(eventId,
+ action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_MODERATOR);
+
+ if (!calendarEvent)
+ return;
+
+ if (addInvite(action.Invite))
+ {
+ calendarEvent->AddInvite(action.Invite.GetInviteId());
+ SendCalendarEventInvite(action.Invite, (!(calendarEvent->GetFlags() & CALENDAR_FLAG_INVITES_LOCKED) &&
+ !action.Invite.GetStatusTime()));
+ SendCalendarEventInviteAlert(*calendarEvent, action.Invite);
+ }
+
+ break;
+ }
+ case CALENDAR_ACTION_SIGNUP_TO_EVENT:
+ {
+ uint64 eventId = action.Event.GetEventId();
+ CalendarEvent* calendarEvent = GetEvent(eventId);
+ CheckPermisions(eventId,
+ action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_MODERATOR);
+
+ if (!calendarEvent || !(calendarEvent->GetFlags() & CALENDAR_FLAG_GUILD_ONLY)
+ || !calendarEvent->GetGuildId() || calendarEvent->GetGuildId() != action.GetExtraData())
+ return;
+
+ uint8 status = action.Invite.GetStatus();
+
+ if (status == CALENDAR_STATUS_INVITED)
+ status = CALENDAR_STATUS_CONFIRMED;
+ else if (status == CALENDAR_STATUS_ACCEPTED)
+ status = CALENDAR_STATUS_8;
+ CalendarInvite newInvite(GetFreeInviteId());
+ newInvite.SetStatus(status);
+ newInvite.SetStatusTime(uint32(time(NULL)));
+ newInvite.SetEventId(eventId);
+ newInvite.SetInvitee(action.GetGUID());
+ newInvite.SetSenderGUID(action.GetGUID());
+
+ if (addInvite(newInvite))
+ SendCalendarEventInvite(newInvite, false);
+
+ break;
+ }
+ case CALENDAR_ACTION_MODIFY_EVENT_INVITE:
+ {
+ uint64 eventId = action.Invite.GetEventId();
+ uint64 inviteId = action.Invite.GetInviteId();
+
+ CalendarEvent* calendarEvent;
+ if (action.GetInviteId() != action.Invite.GetInviteId())
+ calendarEvent = CheckPermisions(eventId, action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_MODERATOR);
+ else
+ calendarEvent = GetEvent(eventId);
+
+ CalendarInvite* invite = GetInvite(inviteId);
+
+ if (!calendarEvent || !invite || !calendarEvent->HasInvite(inviteId))
+ return;
+
+ invite->SetStatus(action.Invite.GetStatus());
+ SendCalendarEventStatus(invite->GetSenderGUID(), *calendarEvent, *invite);
+ break;
+ }
+ case CALENDAR_ACTION_MODIFY_MODERATOR_EVENT_INVITE:
+ {
+ uint64 eventId = action.Invite.GetEventId();
+ uint64 inviteId = action.Invite.GetInviteId();
+
+ CalendarEvent* calendarEvent;
+ if (action.GetInviteId() != action.Invite.GetInviteId())
+ calendarEvent = CheckPermisions(eventId, action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_OWNER);
+ else
+ calendarEvent = GetEvent(eventId);
+
+ CalendarInvite* invite = GetInvite(inviteId);
+
+ if (!calendarEvent || !invite || !calendarEvent->HasInvite(inviteId))
+ return;
+
+ sLog->outError("SPP: CALENDAR_ACTION_MODIFY_MODERATOR_EVENT_INVITE: All OK");
+ invite->SetStatus(action.Invite.GetStatus());
+ SendCalendarEventModeratorStatusAlert(*invite);
+ break;
+ }
+ case CALENDAR_ACTION_REMOVE_EVENT_INVITE:
+ {
+ uint64 eventId = action.Invite.GetEventId();
+ uint64 inviteId = action.Invite.GetInviteId();
+ CalendarEvent* calendarEvent = CheckPermisions(eventId,
+ action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_MODERATOR);
+
+ if (!calendarEvent)
+ return;
+
+ if (uint64 invitee = removeInvite(inviteId))
+ {
+ SendCalendarEventInviteRemoveAlert(invitee, *calendarEvent, CALENDAR_STATUS_9);
+ SendCalendarEventInviteRemove(action.GetGUID(), action.Invite, calendarEvent->GetFlags());
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+}
+
+bool CalendarMgr::addEvent(CalendarEvent const& newEvent)
+{
+ uint64 eventId = newEvent.GetEventId();
+ if (_events.find(eventId) != _events.end())
+ {
+ sLog->outError("CalendarMgr::addEvent: Event [" UI64FMTD "] exists", eventId);
+ return false;
+ }
+
+ _events[eventId] = newEvent;
+ return true;
+}
+
+bool CalendarMgr::removeEvent(uint64 eventId)
+{
+ CalendarEventMap::iterator itr = _events.find(eventId);
+ if (itr == _events.end())
+ {
+ sLog->outError("CalendarMgr::removeEvent: Event [" UI64FMTD "] does not exist", eventId);
+ return false;
+ }
+
+ _events.erase(itr);
+
+ bool val = true;
+
+ CalendarinviteIdList const& invites = itr->second.GetInviteIdList();
+ for (CalendarinviteIdList::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
+ {
+ CalendarInvite* invite = GetInvite(*itr);
+ if (!invite || !removePlayerEvent(invite->GetInvitee(), eventId))
+ val = false;
+ }
+
+ return val;
+}
+
+bool CalendarMgr::addPlayerEvent(uint64 guid, uint64 eventId)
+{
+ _playerEvents[guid].insert(eventId);
+ return true;
+}
+
+bool CalendarMgr::removePlayerEvent(uint64 guid, uint64 eventId)
+{
+ _playerEvents[guid].erase(eventId);
+ return true;
+}
+
+bool CalendarMgr::addInvite(CalendarInvite const& newInvite)
+{
+ uint64 inviteId = newInvite.GetInviteId();
+ if (!inviteId)
+ {
+ sLog->outError("CalendarMgr::addInvite: Cant add Invite 0");
+ return false;
+ }
+
+ if (_invites.find(inviteId) != _invites.end())
+ {
+ sLog->outError("CalendarMgr::addInvite: Invite [" UI64FMTD "] exists", inviteId);
+ return false;
}
- data.put<uint32>(pCounter, counter); // update number of invites
+
+ _invites[inviteId] = newInvite;
+ uint64 guid = newInvite.GetInvitee();
+ bool inviteAdded = addPlayerInvite(guid, inviteId);
+ bool eventAdded = addPlayerEvent(guid, newInvite.GetEventId());
+ return eventAdded && inviteAdded;
+}
+
+uint64 CalendarMgr::removeInvite(uint64 inviteId)
+{
+ CalendarInviteMap::iterator itr = _invites.find(inviteId);
+ if (itr == _invites.end())
+ {
+ 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;
+}
+
+bool CalendarMgr::addPlayerInvite(uint64 guid, uint64 inviteId)
+{
+ _playerInvites[guid].insert(inviteId);
+ return true;
+}
+
+bool CalendarMgr::removePlayerInvite(uint64 guid, uint64 inviteId)
+{
+ _playerInvites[guid].erase(inviteId);
+ return true;
+}
+
+void CalendarMgr::SendCalendarEvent(CalendarEvent const& calendarEvent, CalendarSendEventType type)
+{
+ if (Player* player = ObjectAccessor::FindPlayer(calendarEvent.GetCreatorGUID()))
+ player->GetSession()->SendCalendarEvent(calendarEvent, type);
+}
+
+void CalendarMgr::SendCalendarEventInvite(CalendarInvite const& invite, bool pending)
+{
+ if (Player* player = ObjectAccessor::FindPlayer(invite.GetSenderGUID()))
+ player->GetSession()->SendCalendarEventInvite(invite, pending);
+}
+
+void CalendarMgr::SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite)
+{
+ if (Player* player = ObjectAccessor::FindPlayer(invite.GetInvitee()))
+ player->GetSession()->SendCalendarEventInviteAlert(calendarEvent, invite);
+}
+
+void CalendarMgr::SendCalendarEventUpdateAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarSendEventType type)
+{
+ if (Player* player = ObjectAccessor::FindPlayer(guid))
+ player->GetSession()->SendCalendarEventUpdateAlert(calendarEvent, type);
+}
+
+void CalendarMgr::SendCalendarEventStatus(uint64 guid, CalendarEvent const& calendarEvent, CalendarInvite const& invite)
+{
+ if (Player* player = ObjectAccessor::FindPlayer(guid))
+ player->GetSession()->SendCalendarEventStatus(calendarEvent, invite);
+}
+
+void CalendarMgr::SendCalendarEventRemovedAlert(uint64 guid, CalendarEvent const& calendarEvent)
+{
+ if (Player* player = ObjectAccessor::FindPlayer(guid))
+ player->GetSession()->SendCalendarEventRemovedAlert(calendarEvent);
+}
+
+void CalendarMgr::SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent const& calendarEvent, uint8 status)
+{
+ if (Player* player = ObjectAccessor::FindPlayer(guid))
+ player->GetSession()->SendCalendarEventInviteRemoveAlert(calendarEvent, status);
+}
+
+void CalendarMgr::SendCalendarEventInviteRemove(uint64 guid, CalendarInvite const& invite, uint32 flags)
+{
+ if (Player* player = ObjectAccessor::FindPlayer(guid))
+ player->GetSession()->SendCalendarEventInviteRemove(invite, flags);
+}
+
+void CalendarMgr::SendCalendarEventModeratorStatusAlert(CalendarInvite const& invite)
+{
+ if (Player* player = ObjectAccessor::FindPlayer(invite.GetInvitee()))
+ player->GetSession()->SendCalendarEventModeratorStatusAlert(invite);
}
diff --git a/src/server/game/Calendar/CalendarMgr.h b/src/server/game/Calendar/CalendarMgr.h
index 50acde647cc..f80a21d6960 100644
--- a/src/server/game/Calendar/CalendarMgr.h
+++ b/src/server/game/Calendar/CalendarMgr.h
@@ -1,19 +1,18 @@
/*
- * Copyright (C) 2008-2012 Trinity <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2012 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 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.
+ * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * 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 TRINITY_CALENDARMGR_H
@@ -21,49 +20,57 @@
#include <ace/Singleton.h>
#include "Calendar.h"
-#include "Player.h"
class CalendarMgr
{
friend class ACE_Singleton<CalendarMgr, ACE_Null_Mutex>;
+ public:
+ void LoadFromDB();
-public:
- CalendarMgr();
- ~CalendarMgr();
+ CalendarInvite* GetInvite(uint64 inviteId);
+ CalendarEvent* GetEvent(uint64 eventId);
- CalendarInvite const* GetInvite(uint64 inviteId)
- {
- CalendarInviteMap::const_iterator itr = _inviteMap.find(inviteId);
- if(itr != _inviteMap.end())
- return &itr->second;
- return NULL;
- }
+ CalendarinviteIdList const& GetPlayerInvites(uint64 guid);
+ CalendarEventIdList const& GetPlayerEvents(uint64 guid);
- void AddInvite(CalendarInvite invite) { _inviteMap[invite.Id] = invite; }
- void RemoveInvite(uint64 inviteId) { _inviteMap.erase(inviteId); }
+ uint32 GetPlayerNumPending(uint64 guid);
+ uint64 GetFreeEventId();
+ uint64 GetFreeInviteId();
- CalendarEvent const* GetEvent(uint64 eventId)
- {
- CalendarEventMap::const_iterator itr = _eventMap.find(eventId);
- if(itr != _eventMap.end())
- return &itr->second;
- return NULL;
- }
+ void AddAction(CalendarAction const& action);
- void AddEvent(CalendarEvent event) { _eventMap[event.Id] = event; }
- void RemoveEvent(uint64 eventId) { _eventMap.erase(eventId); }
+ void SendCalendarEvent(CalendarEvent const& calendarEvent, CalendarSendEventType type);
+ void SendCalendarEventInvite(CalendarInvite const& invite, bool pending);
+ void SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite);
+ void SendCalendarEventInviteRemove(uint64 guid, CalendarInvite const& invite, uint32 flags);
+ void SendCalendarEventInviteRemoveAlert(uint64 guid, CalendarEvent const& calendarEvent, uint8 status);
+ void SendCalendarEventUpdateAlert(uint64 guid, CalendarEvent const& calendarEvent, CalendarSendEventType type);
+ void SendCalendarEventStatus(uint64 guid, CalendarEvent const& calendarEvent, CalendarInvite const& invite);
+ void SendCalendarEventRemovedAlert(uint64 guid, CalendarEvent const& calendarEvent);
+ void SendCalendarEventModeratorStatusAlert(CalendarInvite const& invite);
- void AppendInvitesToCalendarPacketForPlayer(WorldPacket& data, Player* player);
- void AppendEventsToCalendarPacketForPlayer(WorldPacket& data, Player* player);
+ private:
+ CalendarMgr();
+ ~CalendarMgr();
+ CalendarEvent* CheckPermisions(uint64 eventId, uint64 guid, uint64 invitateId, CalendarRanks minRank);
- uint64 GetNextEventId() { return ++_currentEventId; }
- uint64 GetNextInviteId() { return ++_currentInviteId; }
+ bool addEvent(CalendarEvent const& calendarEvent);
+ bool removeEvent(uint64 eventId);
+ bool addPlayerEvent(uint64 guid, uint64 eventId);
+ bool removePlayerEvent(uint64 guid, uint64 eventId);
-private:
- CalendarInviteMap _inviteMap;
- CalendarEventMap _eventMap;
- uint64 _currentEventId;
- uint64 _currentInviteId;
+ 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;
};
#define sCalendarMgr ACE_Singleton<CalendarMgr, ACE_Null_Mutex>::instance()
diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp
index 26465691c64..8c1de583d06 100755
--- a/src/server/game/Handlers/CalendarHandler.cpp
+++ b/src/server/game/Handlers/CalendarHandler.cpp
@@ -16,15 +16,34 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/*
+----- Opcodes Not Used yet -----
+
+SMSG_CALENDAR_CLEAR_PENDING_ACTION SendCalendarClearPendingAction()
+SMSG_CALENDAR_RAID_LOCKOUT_UPDATED SendCalendarRaildLockoutUpdated(InstanceSave const* save) <--- Structure unknown, using LOCKOUT_ADDED
+SMSG_CALENDAR_COMMAND_RESULT SendCalendarCommandResult(uint32 value) <--- Structure meanings not known using in a Hack way
+
+----- Opcodes without Sniffs -----
+SMSG_CALENDAR_FILTER_GUILD [ for (... uint32(count) { packguid(???), uint8(???) } ]
+SMSG_CALENDAR_ARENA_TEAM [ for (... uint32(count) { packguid(???), uint8(???) } ]
+CMSG_CALENDAR_EVENT_INVITE_NOTES [ packguid(Invitee), uint64(inviteId), string(Text), Boolean(Unk) ]
+SMSG_CALENDAR_EVENT_INVITE_NOTES [ uint32(unk1), uint32(unk2), uint32(unk3), uint32(unk4), uint32(unk5) ]
+SMSG_CALENDAR_EVENT_INVITE_NOTES_ALERT [ uint64(inviteId), string(Text) ]
+SMSG_CALENDAR_EVENT_INVITE_STATUS_ALERT [ Structure unkown ]
+
+*/
+
#include "Common.h"
#include "WorldPacket.h"
#include "WorldSession.h"
-#include "CalendarMgr.h"
#include "InstanceSaveMgr.h"
#include "Log.h"
#include "Opcodes.h"
#include "Player.h"
+#include "CalendarMgr.h"
+#include "ObjectMgr.h"
+#include "ObjectAccessor.h"
void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/)
{
@@ -34,25 +53,67 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/)
time_t cur_time = time_t(time(NULL));
sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_SEND_CALENDAR [" UI64FMTD "]", guid);
- // we can't really get the real size of this packet...
- WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 4+4*0+4+4*0+4+4);
+ WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 1000); // Impossible to get the correct size without doing a double iteration of some elements
+
+ CalendarinviteIdList const& invites = sCalendarMgr->GetPlayerInvites(guid);
+ data << uint32(invites.size());
+ for (CalendarinviteIdList::const_iterator it = invites.begin(); it != invites.end(); ++it)
+ {
+ CalendarInvite* invite = sCalendarMgr->GetInvite(*it);
+ CalendarEvent* calendarEvent = invite ? sCalendarMgr->GetEvent(invite->GetEventId()) : NULL;
+
+ if (calendarEvent)
+ {
+ data << uint64(invite->GetEventId());
+ data << uint64(invite->GetInviteId());
+ data << uint8(invite->GetStatus());
+ data << uint8(invite->GetRank());
+ data << uint8(calendarEvent->GetGuildId() != 0);
+ data.appendPackGUID(calendarEvent->GetCreatorGUID());
+ }
+ else
+ {
+ sLog->outError("SMSG_CALENDAR_SEND_CALENDAR: No Invite found with id [" UI64FMTD "]", *it);
+ data << uint64(0) << uint64(0) << uint8(0) << uint8(0);
+ data.appendPackGUID(0);
+ }
+ }
- sCalendarMgr->AppendInvitesToCalendarPacketForPlayer(data, GetPlayer());
- sCalendarMgr->AppendEventsToCalendarPacketForPlayer(data, GetPlayer());
+ CalendarEventIdList const& events = sCalendarMgr->GetPlayerEvents(guid);
+ data << uint32(events.size());
+ for (CalendarEventIdList::const_iterator it = events.begin(); it != events.end(); ++it)
+ {
+ if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(*it))
+ {
+ data << uint64(*it);
+ data << calendarEvent->GetTitle().c_str();
+ data << uint32(calendarEvent->GetType());
+ data << uint32(calendarEvent->GetTime());
+ data << uint32(calendarEvent->GetFlags());
+ data << uint32(calendarEvent->GetDungeonId());
+ data.appendPackGUID(calendarEvent->GetCreatorGUID());
+ }
+ else
+ {
+ sLog->outError("SMSG_CALENDAR_SEND_CALENDAR: No Event found with id [" UI64FMTD "]", *it);
+ data << uint64(0) << uint8(0) << uint32(0)
+ << uint32(0) << uint32(0) << uint32(0);
+ data.appendPackGUID(0);
+ }
+ }
- data << uint32(cur_time); // current time
- data << uint32(secsToTimeBitFields(cur_time)); // unknown packed time
+ data << uint32(cur_time); // server time
+ data << uint32(secsToTimeBitFields(cur_time)); // server time
- InstanceSave *save = NULL;
uint32 counter = 0;
size_t p_counter = data.wpos();
- data << uint32(counter); // instance reset count
+ data << uint32(counter); // instance save count
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
for (Player::BoundInstancesMap::const_iterator itr = _player->m_boundInstances[i].begin(); itr != _player->m_boundInstances[i].end(); ++itr)
if (itr->second.perm)
{
- save = itr->second.save;
+ InstanceSave const* save = itr->second.save;
data << uint32(save->GetMapId());
data << uint32(save->GetDifficulty());
data << uint32(save->GetResetTime() - cur_time);
@@ -69,12 +130,12 @@ 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)
{
uint32 mapId = PAIR32_LOPART(itr->first);
- Difficulty difficulty = Difficulty(PAIR32_HIPART(itr->first));
+
if (sentMaps.find(mapId) != sentMaps.end())
continue;
@@ -82,40 +143,36 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/)
if (!mapEntry || !mapEntry->IsRaid())
continue;
- MapDifficulty const* diff = GetMapDifficultyData(mapId, difficulty);
- if (!diff)
- continue;
-
sentMaps.insert(mapId);
-
+
data << uint32(mapId);
- data << uint32(diff->resetTime);
+ data << uint32(itr->second - cur_time);
data << uint32(mapEntry->unk_time);
++counter;
}
data.put<uint32>(p_counter, counter);
-
- // TODO: Fix this -- read from DBC?
- std::string holidayName = "";
- uint32 holidayCount = 0;
- data << uint32(holidayCount); // holiday count
- for (uint32 i = 0; i < holidayCount; ++i)
+ data << uint32(0); // holiday count?
+ /*
+ for (;;)
{
- data << uint32(0); // Unk
- data << uint32(0); // Unk
- data << uint32(0); // Unk
- data << uint32(0); // Unk
- data << uint32(0); // Unk
- for (uint8 j = 0; j < 26; ++j)
- data << uint32(0); // Unk
- for (uint8 j = 0; j < 10; ++j)
- data << uint32(0); // Unk
- for (uint8 j = 0; j < 10; ++j)
- data << uint32(0); // Unk
- data << holidayName.c_str(); // holiday name
+ uint32 unk5, unk6, unk7, unk8, unk9;
+ for (uint32 j = 0; j < 26; ++j)
+ {
+ uint32 unk10;
+ }
+ for (uint32 j = 0; j < 10; ++j)
+ {
+ uint32 unk11;
+ }
+ for (uint32 j = 0; j < 10; ++j)
+ {
+ uint32 unk12;
+ }
+ std::string holidayName; // 64 chars
}
+ */
SendPacket(&data);
}
@@ -124,294 +181,687 @@ void WorldSession::HandleCalendarGetEvent(WorldPacket& recv_data)
{
uint64 eventId;
recv_data >> eventId;
- if (!eventId)
- return;
- //SendCalendarEvent(eventId);
+
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GET_EVENT. Event: ["
+ UI64FMTD "] Event [" UI64FMTD "]", _player->GetGUID(), eventId);
+
+ if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(eventId))
+ SendCalendarEvent(*calendarEvent, CALENDAR_SENDTYPE_GET);
}
void WorldSession::HandleCalendarGuildFilter(WorldPacket& recv_data)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_GUILD_FILTER");
-
- uint32 unk1;
- uint32 unk2;
- uint32 unk3;
- recv_data >> unk1;
- recv_data >> unk2;
- recv_data >> unk3;
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GUILD_FILTER [" UI64FMTD "]", _player->GetGUID());
+ recv_data.read_skip<uint32>(); // unk1
+ recv_data.read_skip<uint32>(); // unk2
+ recv_data.read_skip<uint32>(); // level
}
void WorldSession::HandleCalendarArenaTeam(WorldPacket& recv_data)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_ARENA_TEAM");
-
- uint32 unk1;
- recv_data >> unk1;
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_ARENA_TEAM [" UI64FMTD "]", _player->GetGUID());
+ recv_data.read_skip<uint32>(); // unk
}
void WorldSession::HandleCalendarAddEvent(WorldPacket& recv_data)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_ADD_EVENT");
-
+ uint64 guid = _player->GetGUID();
std::string title;
std::string description;
- uint8 type; // CalendarEventType
- uint8 unkbyte;
+ uint8 type;
+ bool repeatable;
uint32 maxInvites;
- uint32 dungeonId;
+ int32 dungeonId;
uint32 eventPackedTime;
uint32 unkPackedTime;
- uint32 flags; // CalendarFlags
-
- recv_data >> title;
- recv_data >> description;
- recv_data >> type;
- recv_data >> unkbyte;
- recv_data >> maxInvites;
- recv_data >> dungeonId;
- recv_data >> eventPackedTime;
- recv_data >> unkPackedTime;
- recv_data >> flags;
-
- CalendarEvent event;
- event.Id = sCalendarMgr->GetNextEventId();
- event.Name = title;
- event.Description = description;
- event.Type = (CalendarEventType) type;
- event.Unk = unkbyte;
- event.DungeonId = dungeonId;
- event.Flags = (CalendarFlags) flags;
- event.Time = eventPackedTime;
- event.UnkTime = unkPackedTime;
- event.CreatorGuid = GetPlayer()->GetGUID();
-
- sCalendarMgr->AddEvent(event);
-
- if (flags & CALENDARFLAG_WITHOUT_INVITES)
- return;
+ uint32 flags;
+ uint64 inviteId = 0;
+ uint64 invitee;
+ uint8 status;
+ uint8 rank;
- uint32 inviteCount;
- recv_data >> inviteCount;
+ recv_data >> title >> description >> type >> repeatable >> maxInvites;
+ recv_data >> dungeonId >> eventPackedTime >> unkPackedTime >> flags;
- if (!inviteCount)
- return;
+ if (!(flags & CALENDAR_FLAG_WITHOUT_INVITES))
+ {
+ uint32 inviteCount;
+ recv_data >> inviteCount;
+ recv_data.readPackGUID(invitee);
+ recv_data >> status >> rank;
- uint64 guid;
- uint8 status; // CalendarEventStatus
- uint8 rank; // CalendarModerationRank
- for (uint32 i = 0; i < inviteCount; ++i)
+ if (inviteCount != 1 || invitee != guid)
+ {
+ sLog->outError("HandleCalendarAddEvent: [" UI64FMTD
+ "]: More than one invite (%d) or Invitee [" UI64FMTD
+ "] differs", guid, inviteCount, invitee);
+ return;
+ }
+ inviteId = sCalendarMgr->GetFreeInviteId();
+ }
+ else
{
- CalendarInvite invite;
- invite.Id = sCalendarMgr->GetNextInviteId();
-
- recv_data.readPackGUID(guid);
- recv_data >> status;
- recv_data >> rank;
-
- invite.Event = event.Id;
- invite.CreatorGuid = GetPlayer()->GetGUID();
- invite.TargetGuid = guid;
- invite.Status = (CalendarEventStatus) status;
- invite.Rank = (CalendarModerationRank) rank;
- invite.Time = event.Time;
- invite.Text = ""; // hmm...
- invite.Unk1 = invite.Unk2 = invite.Unk3 = 0;
-
- sCalendarMgr->AddInvite(invite);
+ inviteId = 0;
+ status = CALENDAR_STATUS_NO_OWNER;
+ rank = CALENDAR_RANK_PLAYER;
}
- //SendCalendarEvent(eventId, true);
+
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_ADD_EVENT: [" UI64FMTD "] "
+ "Title %s, Description %s, type %u, Repeatable %u, MaxInvites %u, "
+ "Dungeon ID %d, Time %u, Time2 %u, Flags %u, Invitee [" UI64FMTD "] "
+ "Status %d, Rank %d", guid, title.c_str(), description.c_str(),
+ type, repeatable, maxInvites, dungeonId, eventPackedTime,
+ unkPackedTime, flags, invitee, status, rank);
+
+ CalendarAction action;
+
+ action.SetAction(CALENDAR_ACTION_ADD_EVENT);
+ action.SetGUID(guid);
+ action.Event.SetEventId(sCalendarMgr->GetFreeEventId());
+ action.Event.SetCreatorGUID(guid);
+ action.Event.SetType(type);
+ action.Event.SetFlags(flags);
+ action.Event.SetTime(eventPackedTime);
+ action.Event.SetTimeZoneTime(unkPackedTime);
+ action.Event.SetRepeatable(repeatable);
+ action.Event.SetMaxInvites(maxInvites);
+ action.Event.SetDungeonId(dungeonId);
+ action.Event.SetGuildId((flags & CALENDAR_FLAG_GUILD_ONLY) ? GetPlayer()->GetGuildId() : 0);
+ action.Event.SetTitle(title);
+ action.Event.SetDescription(description);
+ action.Event.AddInvite(inviteId);
+ action.Invite.SetEventId(action.Event.GetEventId());
+ action.Invite.SetInviteId(inviteId);
+ action.Invite.SetInvitee(invitee);
+ action.Invite.SetStatus(status);
+ action.Invite.SetRank(rank);
+ action.Invite.SetSenderGUID(guid);
+
+ sCalendarMgr->AddAction(action);
}
void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recv_data)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_UPDATE_EVENT");
- recv_data.rfinish(); // set to end to avoid warnings spam
-
- //recv_data >> uint64
- //recv_data >> uint64
- //recv_data >> std::string
- //recv_data >> std::string
- //recv_data >> uint8
- //recv_data >> uint8
- //recv_data >> uint32
- //recv_data >> uint32
- //recv_data >> uint32
- //recv_data >> uint32
- //recv_data >> uint32
+ uint64 guid = _player->GetGUID();
+ uint64 eventId;
+ uint64 inviteId;
+ std::string title;
+ std::string description;
+ uint8 type;
+ bool repeatable;
+ uint32 maxInvites;
+ int32 dungeonId;
+ uint32 eventPackedTime;
+ uint32 timeZoneTime;
+ uint32 flags;
+
+ recv_data >> eventId >> inviteId >> title >> description >> type;
+ recv_data >> repeatable >> maxInvites >> dungeonId;
+ recv_data >> eventPackedTime >> timeZoneTime >> flags;
+
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_UPDATE_EVENT [" UI64FMTD "] EventId [" UI64FMTD
+ "], InviteId [" UI64FMTD "] Title %s, Description %s, type %u "
+ "Repeatable %u, MaxInvites %u, Dungeon ID %d, Time %u "
+ "Time2 %u, Flags %u", guid, eventId, inviteId, title.c_str(),
+ description.c_str(), type, repeatable, maxInvites, dungeonId,
+ eventPackedTime, timeZoneTime, flags);
+
+ CalendarAction action;
+ action.SetAction(CALENDAR_ACTION_MODIFY_EVENT);
+ action.SetGUID(guid);
+ action.SetInviteId(inviteId);
+ action.Event.SetEventId(eventId);
+ action.Event.SetType(type);
+ action.Event.SetFlags(flags);
+ action.Event.SetTime(eventPackedTime);
+ action.Event.SetTimeZoneTime(timeZoneTime);
+ action.Event.SetRepeatable(repeatable);
+ action.Event.SetDungeonId(dungeonId);
+ action.Event.SetTitle(title);
+ action.Event.SetDescription(description);
+ action.Event.SetMaxInvites(maxInvites);
+
+ sCalendarMgr->AddAction(action);
}
void WorldSession::HandleCalendarRemoveEvent(WorldPacket& recv_data)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_REMOVE_EVENT");
-
+ uint64 guid = _player->GetGUID();
uint64 eventId;
- uint64 creatorGuid;
- uint32 unk1;
+ uint64 inviteId;
+ uint32 flags;
- recv_data >> eventId;
- recv_data >> creatorGuid;
- recv_data >> unk1;
+ recv_data >> eventId >> inviteId >> flags;
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_REMOVE_EVENT [" UI64FMTD "], EventId [" UI64FMTD
+ "] inviteId [" UI64FMTD "] Flags?: %u", guid, eventId, inviteId, flags);
+
+ CalendarAction action;
+ action.SetAction(CALENDAR_ACTION_REMOVE_EVENT);
+ action.SetGUID(guid);
+ action.SetInviteId(inviteId);
+ action.Event.SetEventId(eventId);
+ action.Event.SetFlags(flags);
+
+ sCalendarMgr->AddAction(action);
}
void WorldSession::HandleCalendarCopyEvent(WorldPacket& recv_data)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_COPY_EVENT");
- recv_data.rfinish(); // set to end to avoid warnings spam
+ uint64 guid = _player->GetGUID();
+ uint64 eventId;
+ uint64 inviteId;
+ uint32 time;
+
+ recv_data >> eventId >> inviteId >> time;
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_COPY_EVENT [" UI64FMTD "], EventId [" UI64FMTD
+ "] inviteId [" UI64FMTD "] Time: %u", guid, eventId, inviteId, time);
- //recv_data >> uint64
- //recv_data >> uint64
- //recv_data >> uint32
+ CalendarAction action;
+ action.SetAction(CALENDAR_ACTION_COPY_EVENT);
+ action.SetGUID(guid);
+ action.SetInviteId(inviteId);
+ action.Event.SetEventId(eventId);
+ action.Event.SetTime(time);
+ sCalendarMgr->AddAction(action);
}
void WorldSession::HandleCalendarEventInvite(WorldPacket& recv_data)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_EVENT_INVITE");
-
+ uint64 guid = _player->GetGUID();
uint64 eventId;
uint64 inviteId;
std::string name;
uint8 status;
uint8 rank;
- recv_data >> eventId;
- recv_data >> inviteId;
- recv_data >> name;
- recv_data >> status;
- recv_data >> rank;
+ recv_data >> eventId >> inviteId >> name >> status >> rank;
+ uint64 invitee = 0;
+ if (Player* player = sObjectAccessor->FindPlayerByName(name.c_str()))
+ invitee = player->GetGUID();
+ else
+ invitee = sObjectMgr->GetPlayerGUIDByName(name.c_str());
+
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_INVITE [" UI64FMTD "], EventId ["
+ UI64FMTD "] InviteId [" UI64FMTD "] Name %s ([" UI64FMTD "]), status %u, "
+ "Rank %u", guid, eventId, inviteId, name.c_str(), invitee, status, rank);
+
+ CalendarAction action;
+ action.SetAction(CALENDAR_ACTION_ADD_EVENT_INVITE);
+ action.SetGUID(guid);
+ action.SetInviteId(inviteId);
+ action.Invite.SetEventId(eventId);
+ action.Invite.SetInviteId(sCalendarMgr->GetFreeInviteId());
+ action.Invite.SetSenderGUID(_player->GetGUID());
+ action.Invite.SetInvitee(invitee);
+ action.Invite.SetRank(rank);
+ action.Invite.SetStatus(status);
+
+ sCalendarMgr->AddAction(action);
+}
- //FIXME - Finish it
+void WorldSession::HandleCalendarEventSignup(WorldPacket& recv_data)
+{
+ uint64 guid = _player->GetGUID();
+ uint64 eventId;
+ uint8 status;
- recv_data.rfinish(); // set to end to avoid warnings spam
+ recv_data >> eventId >> status;
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_SIGNUP [" UI64FMTD "] EventId ["
+ UI64FMTD "] Status %u", guid, eventId, status);
+
+ CalendarAction action;
+ action.SetAction(CALENDAR_ACTION_SIGNUP_TO_EVENT);
+ action.SetGUID(guid);
+ action.SetExtraData(GetPlayer()->GetGuildId());
+ action.Event.SetEventId(eventId);
+ action.Invite.SetStatus(status);
+ sCalendarMgr->AddAction(action);
}
void WorldSession::HandleCalendarEventRsvp(WorldPacket& recv_data)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_EVENT_RSVP");
- recv_data.rfinish(); // set to end to avoid warnings spam
+ uint64 guid = _player->GetGUID();
+ uint64 eventId;
+ uint64 inviteId;
+ uint8 status;
+
+ recv_data >> eventId >> inviteId >> status;
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_RSVP [" UI64FMTD"] EventId ["
+ UI64FMTD "], InviteId [" UI64FMTD "], status %u", guid, eventId,
+ inviteId, status);
- //recv_data >> uint64
- //recv_data >> uint64
- //recv_data >> uint32
+ CalendarAction action;
+ action.SetAction(CALENDAR_ACTION_MODIFY_EVENT_INVITE);
+ action.SetGUID(guid);
+ action.SetInviteId(inviteId);
+ action.Invite.SetInviteId(inviteId);
+ action.Invite.SetEventId(eventId);
+ action.Invite.SetStatus(status);
+ sCalendarMgr->AddAction(action);
}
void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket& recv_data)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_EVENT_REMOVE_INVITE");
- recv_data.rfinish(); // set to end to avoid warnings spam
+ uint64 guid = _player->GetGUID();
+ uint64 invitee;
+ uint64 eventId;
+ uint64 owninviteId;
+ uint64 inviteId;
+
+ recv_data.readPackGUID(invitee);
+ recv_data >> inviteId >> owninviteId >> eventId;
+
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_REMOVE_INVITE ["
+ UI64FMTD "] EventId [" UI64FMTD "], OwnInviteId ["
+ UI64FMTD "], Invitee ([" UI64FMTD "] id: [" UI64FMTD "])",
+ guid, eventId, owninviteId, invitee, inviteId);
+
+ CalendarAction action;
+ action.SetAction(CALENDAR_ACTION_REMOVE_EVENT_INVITE);
+ action.SetGUID(guid);
+ action.SetInviteId(owninviteId);
+ action.Invite.SetInviteId(inviteId);
+ action.Invite.SetEventId(eventId);
+ action.Invite.SetInvitee(invitee);
- //recv_data.readPackGUID(guid)
- //recv_data >> uint64
- //recv_data >> uint64
- //recv_data >> uint64
+ sCalendarMgr->AddAction(action);
}
void WorldSession::HandleCalendarEventStatus(WorldPacket& recv_data)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_EVENT_STATUS");
- recv_data.rfinish(); // set to end to avoid warnings spam
-
- //recv_data.readPackGUID(guid)
- //recv_data >> uint64
- //recv_data >> uint64
- //recv_data >> uint64
- //recv_data >> uint32
+ uint64 guid = _player->GetGUID();
+ uint64 invitee;
+ uint64 eventId;
+ uint64 inviteId;
+ uint64 owninviteId;
+ uint8 status;
+
+ recv_data.readPackGUID(invitee);
+ recv_data >> eventId >> inviteId >> owninviteId >> status;
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_STATUS [" UI64FMTD"] EventId ["
+ UI64FMTD "] OwnInviteId [" UI64FMTD "], Invitee ([" UI64FMTD "] id: ["
+ UI64FMTD "], status %u", guid, eventId, owninviteId, invitee, inviteId, status);
+
+ CalendarAction action;
+ action.SetAction(CALENDAR_ACTION_MODIFY_EVENT_INVITE);
+ action.SetGUID(guid);
+ action.SetInviteId(owninviteId);
+ action.Invite.SetInviteId(inviteId);
+ action.Invite.SetEventId(eventId);
+ action.Invite.SetInvitee(invitee);
+ action.Invite.SetStatus(status);
+
+ sCalendarMgr->AddAction(action);
}
void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket& recv_data)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_EVENT_MODERATOR_STATUS");
- recv_data.rfinish(); // set to end to avoid warnings spam
-
- //recv_data.readPackGUID(guid)
- //recv_data >> uint64
- //recv_data >> uint64
- //recv_data >> uint64
- //recv_data >> uint32
+ uint64 guid = _player->GetGUID();
+ uint64 invitee;
+ uint64 eventId;
+ uint64 inviteId;
+ uint64 owninviteId;
+ uint8 status;
+
+ recv_data.readPackGUID(invitee);
+ recv_data >> eventId >> inviteId >> owninviteId >> status;
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_MODERATOR_STATUS [" UI64FMTD "] EventId ["
+ UI64FMTD "] OwnInviteId [" UI64FMTD "], Invitee ([" UI64FMTD "] id: ["
+ UI64FMTD "], status %u", guid, eventId, owninviteId, invitee, inviteId, status);
+
+ CalendarAction action;
+ action.SetAction(CALENDAR_ACTION_MODIFY_MODERATOR_EVENT_INVITE);
+ action.SetGUID(guid);
+ action.SetInviteId(owninviteId);
+ action.Invite.SetInviteId(inviteId);
+ action.Invite.SetEventId(eventId);
+ action.Invite.SetInvitee(invitee);
+ action.Invite.SetStatus(status);
+
+ sCalendarMgr->AddAction(action);
}
void WorldSession::HandleCalendarComplain(WorldPacket& recv_data)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_COMPLAIN");
- recv_data.rfinish(); // set to end to avoid warnings spam
+ uint64 guid = _player->GetGUID();
+ uint64 eventId;
+ uint64 complainGUID;
- //recv_data >> uint64
- //recv_data >> uint64
- //recv_data >> uint64
+ recv_data >> eventId >> complainGUID;
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_COMPLAIN [" UI64FMTD "] EventId ["
+ UI64FMTD "] guid [" UI64FMTD "]", guid, eventId, complainGUID);
}
void WorldSession::HandleCalendarGetNumPending(WorldPacket& /*recv_data*/)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_GET_NUM_PENDING"); // empty
+ uint64 guid = _player->GetGUID();
+ uint32 pending = sCalendarMgr->GetPlayerNumPending(guid);
+
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GET_NUM_PENDING: [" UI64FMTD
+ "] Pending: %u", guid, pending);
WorldPacket data(SMSG_CALENDAR_SEND_NUM_PENDING, 4);
- data << uint32(0); // number of pending invites
+ data << uint32(pending);
SendPacket(&data);
}
-void WorldSession::SendCalendarEvent(uint64 eventId, bool added)
+// ----------------------------------- SEND ------------------------------------
+
+void WorldSession::SendCalendarEvent(CalendarEvent const& calendarEvent, uint8 sendEventType)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_SEND_EVENT");
+ uint64 guid = _player->GetGUID();
+ uint64 eventId = calendarEvent.GetEventId();
+
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_SEND_EVENT [" UI64FMTD "] EventId ["
+ UI64FMTD "] SendType %u", guid, eventId, sendEventType);
+
WorldPacket data(SMSG_CALENDAR_SEND_EVENT);
- data << uint8(added); // from add_event
- data.appendPackGUID(0); // creator GUID
- data << uint64(0); // event ID
- data << uint8(0); // event name
- data << uint8(0); // event description
- data << uint8(0); // event type
- data << uint8(0); // unk
- data << uint32(100); // Max invites
- data << int32(0); // dungeon ID
- data << uint32(0); // unk time
- data << uint32(0); // event time
- data << uint32(0); // event flags
- data << uint32(0); // event guild id
-
- if (false) // invites exist
+ data << uint8(sendEventType);
+ data.appendPackGUID(calendarEvent.GetCreatorGUID());
+ data << uint64(eventId);
+ data << calendarEvent.GetTitle().c_str();
+ data << calendarEvent.GetDescription().c_str();
+ data << uint8(calendarEvent.GetType());
+ data << uint8(calendarEvent.GetRepeatable());
+ data << uint32(calendarEvent.GetMaxInvites());
+ data << int32(calendarEvent.GetDungeonId());
+ data << uint32(calendarEvent.GetFlags());
+ data << uint32(calendarEvent.GetTime());
+ data << uint32(calendarEvent.GetTimeZoneTime());
+ data << uint32(calendarEvent.GetGuildId());
+
+ CalendarinviteIdList const& invites = calendarEvent.GetInviteIdList();
+ data << uint32(invites.size());
+ for (CalendarinviteIdList::const_iterator it = invites.begin(); it != invites.end(); ++it)
{
- data << uint32(0); // invite count
- for (uint8 i = 0; i < 0; ++i)
+ if (CalendarInvite* invite = sCalendarMgr->GetInvite(*it))
+ {
+ uint64 guid = invite->GetInvitee();
+ Player* player = ObjectAccessor::FindPlayer(guid);
+ uint8 level = player ? player->getLevel() : Player::GetLevelFromDB(guid);
+
+ data.appendPackGUID(guid);
+ data << uint8(level);
+ data << uint8(invite->GetStatus());
+ data << uint8(invite->GetRank());
+ data << uint8(calendarEvent.GetGuildId() != 0);
+ data << uint64(invite->GetInviteId());
+ data << uint32(invite->GetStatusTime());
+ data << invite->GetText().c_str();
+ }
+ else
{
- data << uint64(0); // invite played guid
- data << uint8(0); // unk
- data << uint8(0); // status
- data << uint8(0); // rank
- data << uint8(0); // unk
- data << uint64(0); // invite ID
- data << uint32(0); // unk
- data << uint8(0); // text
+ data.appendPackGUID(guid);
+ data << uint8(0) << uint8(0) << uint8(0) << uint8(0)
+ << uint64(0) << uint32(0) << uint8(0);
+
+ sLog->outError("SendCalendarEvent: No Invite found with id [" UI64FMTD "]", *it);
}
}
SendPacket(&data);
}
-void WorldSession::SendCalendarEventInviteAlert(uint64 eventId, uint64 inviteId)
+void WorldSession::SendCalendarEventInvite(CalendarInvite const& invite, bool pending)
+{
+ uint64 guid = _player->GetGUID();
+ uint64 eventId = invite.GetEventId();
+ uint64 inviteId = invite.GetInviteId();
+ uint64 invitee = invite.GetInvitee();
+ uint8 status = invite.GetStatus();
+ uint32 statusTime = invite.GetStatusTime();
+ Player* player = ObjectAccessor::FindPlayer(invitee);
+ uint8 level = player ? player->getLevel() : Player::GetLevelFromDB(invitee);
+
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_INVITE [" UI64FMTD "] EventId ["
+ UI64FMTD "] InviteId [" UI64FMTD "] Invitee [" UI64FMTD "] "
+ " Level %u, Status %u, StatusTime %u" , guid, eventId, inviteId,
+ invitee, level, status, statusTime);
+
+ WorldPacket data(SMSG_CALENDAR_EVENT_INVITE, 8 + 8 + 8 + 1 + 1 + 1 + (statusTime ? 4 : 0) + 1);
+ data.appendPackGUID(invitee);
+ data << uint64(eventId);
+ data << uint64(inviteId);
+ data << uint8(level);
+ data << uint8(status);
+ if (statusTime)
+ data << uint8(1) << uint32(statusTime);
+ else
+ data << uint8(0);
+ data << uint8(pending);
+
+ SendPacket(&data);
+}
+
+void WorldSession::SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_INVITE_ALERT");
+ uint64 guid = _player->GetGUID();
+ uint64 eventId = calendarEvent.GetEventId();
+ uint64 inviteId = invite.GetInviteId();
+
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_INVITE_ALERT [" UI64FMTD "] EventId ["
+ UI64FMTD "] InviteId [" UI64FMTD "]", guid, eventId, inviteId);
+
WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_ALERT);
- data << uint64(0); // event ID
- data << uint8(0); // event title
- data << uint32(0); // event time
- uint32 unknum = 1;
- data << uint32(unknum);
- data << uint8(0); // event type
- data << uint32(0); // dungeon id
- data << uint64(0); // invite id
- data << uint8(0); // invite status
- data << uint8(0); // invite rank
- data.appendPackGUID(0); // event creator
- data.appendPackGUID(0); // invite sender
+ data << uint64(eventId);
+ data << calendarEvent.GetTitle().c_str();
+ data << uint32(calendarEvent.GetTime());
+ data << uint32(calendarEvent.GetFlags());
+ data << uint32(calendarEvent.GetType());
+ data << uint32(calendarEvent.GetDungeonId());
+ data << uint64(inviteId);
+ data << uint8(invite.GetStatus());
+ data << uint8(invite.GetRank());
+ data.appendPackGUID(calendarEvent.GetCreatorGUID());
+ data.appendPackGUID(invite.GetSenderGUID());
+ SendPacket(&data);
+}
+
+void WorldSession::SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, uint8 sendEventType)
+{
+ uint64 guid = _player->GetGUID();
+ uint64 eventId = calendarEvent.GetEventId();
+
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_UPDATED_ALERT ["
+ UI64FMTD "] EventId [" UI64FMTD "]", guid, eventId);
+
+
+ WorldPacket data(SMSG_CALENDAR_EVENT_UPDATED_ALERT, 1 + 8 + 4 + 4 + 4 + 1 + 4 +
+ calendarEvent.GetTitle().size() + calendarEvent.GetDescription().size() + 1 + 4 + 4);
+ data << uint8(sendEventType);
+ data << uint64(eventId);
+ data << uint32(calendarEvent.GetTime());
+ data << uint32(calendarEvent.GetFlags());
+ data << uint32(calendarEvent.GetTime());
+ data << uint8(calendarEvent.GetType());
+ data << uint32(calendarEvent.GetDungeonId());
+ data << calendarEvent.GetTitle().c_str();
+ data << calendarEvent.GetDescription().c_str();
+ data << uint8(calendarEvent.GetRepeatable());
+ data << uint32(calendarEvent.GetMaxInvites());
+ data << uint32(0); // FIXME
+ SendPacket(&data);
+}
+
+void WorldSession::SendCalendarEventRemovedAlert(CalendarEvent const& calendarEvent)
+{
+ uint64 guid = _player->GetGUID();
+ uint64 eventId = calendarEvent.GetEventId();
+ uint32 eventTime = (calendarEvent.GetTime());
+
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_REMOVED_ALERT [" UI64FMTD "] EventId ["
+ UI64FMTD "] Time %u", guid, eventId, eventTime);
+
+ WorldPacket data(SMSG_CALENDAR_EVENT_REMOVED_ALERT, 1 + 8 + 1);
+ data << uint8(0); // FIXME
+ data << uint64(eventId);
+ data << uint32(eventTime);
+ SendPacket(&data);
+}
+
+void WorldSession::SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite)
+{
+ uint64 guid = _player->GetGUID();
+ uint64 eventId = calendarEvent.GetEventId();
+ uint64 inviteId = invite.GetInviteId();
+ uint64 invitee = invite.GetInvitee();
+ uint32 eventTime = (calendarEvent.GetTime());
+ uint32 flags = calendarEvent.GetFlags();
+ uint8 status = invite.GetStatus();
+ uint8 rank = invite.GetRank();
+ uint32 statusTime = secsToTimeBitFields(invite.GetStatusTime());
+
+
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_STATUS [" UI64FMTD "] EventId ["
+ UI64FMTD "] InviteId [" UI64FMTD "] Invitee [" UI64FMTD "] Time %u "
+ "Flags %u, Status %u, Rank %u, StatusTime %u",
+ guid, eventId, inviteId, invitee, eventTime, flags, status, rank,
+ statusTime);
+
+ WorldPacket data(SMSG_CALENDAR_EVENT_STATUS, 8 + 8 + 4 + 4 + 1 + 1 + 4);
+ data.appendPackGUID(invitee);
+ data << uint64(eventId);
+ data << uint32(eventTime);
+ data << uint32(flags);
+ data << uint8(status);
+ data << uint8(rank);
+ data << uint32(statusTime);
+ SendPacket(&data);
+}
+
+void WorldSession::SendCalendarEventModeratorStatusAlert(CalendarInvite const& invite)
+{
+ uint64 guid = _player->GetGUID();
+ uint64 eventId = invite.GetEventId();
+ uint64 invitee = invite.GetInvitee();
+ uint8 status = invite.GetStatus();
+
+
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_MODERATOR_STATUS_ALERT [" UI64FMTD
+ "] Invitee [" UI64FMTD "] EventId [" UI64FMTD "] Status %u ", guid,
+ invitee, eventId, status);
+
+
+ WorldPacket data(SMSG_CALENDAR_EVENT_MODERATOR_STATUS_ALERT, 8 + 8 + 1 + 1);
+ data.appendPackGUID(invitee);
+ data << uint64(eventId);
+ data << uint8(status);
+ data << uint8(1); // FIXME
+ SendPacket(&data);
+}
+
+void WorldSession::SendCalendarEventInviteRemoveAlert(CalendarEvent const& calendarEvent, uint8 status)
+{
+ uint64 guid = _player->GetGUID();
+ uint64 eventId = calendarEvent.GetEventId();
+ uint32 eventTime = (calendarEvent.GetTime());
+ uint32 flags = calendarEvent.GetFlags();
+
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_INVITE_REMOVED_ALERT ["
+ UI64FMTD "] EventId [" UI64FMTD "] Time %u, Flags %u, Status %u",
+ guid, eventId, eventTime, flags, status);
+
+ WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_REMOVED_ALERT, 8 + 4 + 4 + 1);
+ data << uint64(eventId);
+ data << uint32(eventTime);
+ data << uint32(flags);
+ data << uint8(status);
SendPacket(&data);
}
-void WorldSession::SendCalendarEventRemovedAlert(uint64 eventId)
+void WorldSession::SendCalendarEventInviteRemove(CalendarInvite const& invite, uint32 flags)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_REMOVED_ALERT");
- WorldPacket data(SMSG_CALENDAR_EVENT_REMOVED_ALERT);
- data << uint8(0); // unk
- data << uint64(0); // invite id
- data << uint32(0); // invite time
+ uint64 guid = _player->GetGUID();
+ uint64 eventId = invite.GetEventId();
+ uint64 invitee = invite.GetInvitee();
+
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_EVENT_INVITE_REMOVED ["
+ UI64FMTD "] Invitee [" UI64FMTD "] EventId [" UI64FMTD
+ "] Flags %u", guid, invitee, eventId, flags);
+
+ WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_REMOVED, 8 + 4 + 4 + 1);
+ data.appendPackGUID(invitee);
+ data << uint32(eventId);
+ data << uint32(flags);
+ data << uint8(1); // FIXME
+ SendPacket(&data);
+}
+
+void WorldSession::SendCalendarClearPendingAction()
+{
+ uint64 guid = _player->GetGUID();
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_CLEAR_PENDING_ACTION [" UI64FMTD "]", guid);
+
+ WorldPacket data(SMSG_CALENDAR_CLEAR_PENDING_ACTION, 0);
+ SendPacket(&data);
+}
+
+void WorldSession::SendCalendarRaildLockoutUpdated(InstanceSave const* save)
+{
+ if (!save)
+ return;
+
+ uint64 guid = _player->GetGUID();
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_RAID_LOCKOUT_UPDATED [" UI64FMTD
+ "] Map: %u, Difficulty %u", guid, save->GetMapId(), save->GetDifficulty());
+
+ time_t cur_time = time_t(time(NULL));
+
+ 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());
+ SendPacket(&data);
+}
+
+void WorldSession::SendCalendarCommandResult(uint32 value)
+{
+ uint64 guid = _player->GetGUID();
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_COMMAND_RESULT [" UI64FMTD "] Value: %u", guid, value);
+
+ WorldPacket data(SMSG_CALENDAR_COMMAND_RESULT, 0);
+ data << uint16(0) << uint32(0) << 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);
}
@@ -432,4 +882,4 @@ void WorldSession::SendCalendarRaidLockout(InstanceSave* save, bool add)
data << uint32(save->GetResetTime() - currTime);
data << uint64(save->GetInstanceId());
SendPacket(&data);
-}
+} \ No newline at end of file
diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp
index 4335452635b..e2e6772f230 100755
--- a/src/server/game/Server/Protocol/Opcodes.cpp
+++ b/src/server/game/Server/Protocol/Opcodes.cpp
@@ -1236,7 +1236,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
/*0x4B7*/ { "SMSG_CORPSE_MAP_POSITION_QUERY_RESPONSE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
/*0x4B8*/ { "CMSG_UNUSED5", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::Handle_NULL },
/*0x4B9*/ { "CMSG_UNUSED6", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL },
- /*0x4BA*/ { "CMSG_CALENDAR_EVENT_SIGNUP", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL },
+ /*0x4BA*/ { "CMSG_CALENDAR_EVENT_SIGNUP", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleCalendarEventSignup },
/*0x4BB*/ { "SMSG_CALENDAR_CLEAR_PENDING_ACTION", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
/*0x4BC*/ { "SMSG_EQUIPMENT_SET_LIST", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
/*0x4BD*/ { "CMSG_EQUIPMENT_SET_SAVE", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleEquipmentSetSave },
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index a12470b842b..4f9880d3257 100755
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -56,6 +56,8 @@ struct LfgProposal;
struct LfgReward;
struct LfgRoleCheck;
struct LfgUpdateData;
+class CalendarEvent;
+class CalendarInvite;
enum AccountDataType
{
@@ -878,9 +880,22 @@ class WorldSession
void HandleCalendarEventModeratorStatus(WorldPacket& recv_data);
void HandleCalendarComplain(WorldPacket& recv_data);
void HandleCalendarGetNumPending(WorldPacket& recv_data);
- void SendCalendarEvent(uint64 eventId, bool added = false);
- void SendCalendarEventInviteAlert(uint64 eventId, uint64 inviteId);
- void SendCalendarEventRemovedAlert(uint64 eventId);
+ void HandleCalendarEventSignup(WorldPacket& recv_data);
+
+ void SendCalendarEvent(CalendarEvent const& calendarEvent, uint8 sendEventType);
+ void SendCalendarEventInvite(CalendarInvite const& invite, bool pending);
+ void SendCalendarEventInviteAlert(CalendarEvent const& calendarEvent, CalendarInvite const& calendarInvite);
+ void SendCalendarEventInviteRemove(CalendarInvite const& invite, uint32 flags);
+ void SendCalendarEventInviteRemoveAlert(CalendarEvent const& calendarEvent, uint8 status);
+ void SendCalendarEventRemovedAlert(CalendarEvent const& calendarEvent);
+ void SendCalendarEventUpdateAlert(CalendarEvent const& calendarEvent, uint8 sendEventType);
+ void SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite);
+ void SendCalendarEventModeratorStatusAlert(CalendarInvite const& invite);
+ void SendCalendarClearPendingAction();
+ void SendCalendarRaildLockoutAdded(InstanceSave const* save);
+ void SendCalendarRaildLockoutRemoved(InstanceSave const* save);
+ void SendCalendarRaildLockoutUpdated(InstanceSave const* save);
+ void SendCalendarCommandResult(uint32 value);
void SendCalendarRaidLockout(InstanceSave* save, bool add);
void HandleSpellClick(WorldPacket& recv_data);
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 59f5508149d..61757b4fab2 100755
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -76,6 +76,7 @@
#include "Channel.h"
#include "WardenCheckMgr.h"
#include "Warden.h"
+#include "CalendarMgr.h"
volatile bool World::m_stopEvent = false;
uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE;
@@ -1659,6 +1660,9 @@ void World::SetInitialWorldSettings()
sLog->outString("Loading SmartAI scripts...");
sSmartScriptMgr->LoadSmartAIFromDB();
+ sLog->outString("Loading Calendar data...");
+ sCalendarMgr->LoadFromDB();
+
///- Initialize game time and timers
sLog->outString("Initialize game time and timers");
m_gameTime = time(NULL);