Core/Calendar: Initial work for calendar
Original author: Silinoron (from calendar branch)
This commit is contained in:
@@ -15,3 +15,5 @@
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Calendar.h"
|
||||
|
||||
@@ -19,8 +19,61 @@
|
||||
#ifndef TRINITY_CALENDAR_H
|
||||
#define TRINITY_CALENDAR_H
|
||||
|
||||
class Calendar
|
||||
{
|
||||
#include "Common.h"
|
||||
|
||||
// TODO - Get correct values
|
||||
enum CalendarEventType
|
||||
{
|
||||
CALENDARTYPE_RAID = 0,
|
||||
CALENDARTYPE_DUNGEON,
|
||||
CALENDARTYPE_PVP,
|
||||
CALENDARTYPE_MEETING,
|
||||
CALENDARTYPE_OTHER,
|
||||
};
|
||||
|
||||
// TODO - Get correct values
|
||||
enum CalendarInviteStatus
|
||||
{
|
||||
CALENDARSTATUS_INVITED = 0,
|
||||
CALENDARSTATUS_ACCEPTED,
|
||||
CALENDARSTATUS_DECLINED,
|
||||
CALENDARSTATUS_TENTATIVE,
|
||||
CALENDARSTATUS_OUT,
|
||||
CALENDARSTATUS_STANDBY,
|
||||
CALENDARSTATUS_CONFIRMED,
|
||||
};
|
||||
|
||||
struct CalendarEvent
|
||||
{
|
||||
uint64 Id;
|
||||
uint64 CreatorGuid;
|
||||
std::string Name;
|
||||
std::string Description;
|
||||
uint8 Type;
|
||||
uint8 Unk;
|
||||
uint32 DungeonId;
|
||||
uint32 UnkTime;
|
||||
uint32 Time;
|
||||
uint32 Flags;
|
||||
uint32 GuildId;
|
||||
};
|
||||
|
||||
struct CalendarInvite
|
||||
{
|
||||
uint64 Id;
|
||||
uint64 Event;
|
||||
uint8 Status;
|
||||
uint8 Rank;
|
||||
uint8 Unk1;
|
||||
uint8 Unk2;
|
||||
uint8 Unk3;
|
||||
std::string Text;
|
||||
uint64 CreatorGuid;
|
||||
uint32 Time;
|
||||
uint64 TargetGuid;
|
||||
};
|
||||
|
||||
typedef UNORDERED_MAP<uint64, CalendarInvite> CalendarInviteMap;
|
||||
typedef UNORDERED_MAP<uint64, CalendarEvent> CalendarEventMap;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2012 Trinity <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "CalendarMgr.h"
|
||||
#include "QueryResult.h"
|
||||
|
||||
CalendarMgr::CalendarMgr() : _currentEventId(0), _currentInviteId(0)
|
||||
{
|
||||
}
|
||||
|
||||
CalendarMgr::~CalendarMgr()
|
||||
{
|
||||
}
|
||||
|
||||
void CalendarMgr::AppendInvitesToCalendarPacketForPlayer(WorldPacket& data, Player* player)
|
||||
{
|
||||
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())
|
||||
{
|
||||
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++;
|
||||
}
|
||||
}
|
||||
data.put<uint32>(pCounter, counter); // update number of invites
|
||||
}
|
||||
|
||||
void CalendarMgr::AppendEventsToCalendarPacketForPlayer(WorldPacket& data, Player* player)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
CalendarInvite invite = itr->second;
|
||||
if (invite.TargetGuid == player->GetGUID())
|
||||
{
|
||||
if (alreadyAdded.find(invite.Event) == alreadyAdded.end())
|
||||
{
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
data.put<uint32>(pCounter, counter); // update number of invites
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2012 Trinity <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef TRINITY_CALENDARMGR_H
|
||||
#define TRINITY_CALENDARMGR_H
|
||||
|
||||
#include <ace/Singleton.h>
|
||||
#include "Calendar.h"
|
||||
#include "Player.h"
|
||||
|
||||
class CalendarMgr
|
||||
{
|
||||
friend class ACE_Singleton<CalendarMgr, ACE_Null_Mutex>;
|
||||
|
||||
public:
|
||||
CalendarMgr();
|
||||
~CalendarMgr();
|
||||
|
||||
CalendarInvite const* GetInvite(uint64 inviteId)
|
||||
{
|
||||
CalendarInviteMap::const_iterator itr = _inviteMap.find(inviteId);
|
||||
if(itr != _inviteMap.end())
|
||||
return &itr->second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void AddInvite(CalendarInvite invite) { _inviteMap[invite.Id] = invite; }
|
||||
void RemoveInvite(uint64 inviteId) { _inviteMap.erase(inviteId); }
|
||||
|
||||
CalendarEvent const* GetEvent(uint64 eventId)
|
||||
{
|
||||
CalendarEventMap::const_iterator itr = _eventMap.find(eventId);
|
||||
if(itr != _eventMap.end())
|
||||
return &itr->second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void AddEvent(CalendarEvent event) { _eventMap[event.Id] = event; }
|
||||
void RemoveEvent(uint64 eventId) { _eventMap.erase(eventId); }
|
||||
|
||||
void AppendInvitesToCalendarPacketForPlayer(WorldPacket& data, Player* player);
|
||||
void AppendEventsToCalendarPacketForPlayer(WorldPacket& data, Player* player);
|
||||
|
||||
uint64 GetNextEventId() { return ++_currentEventId; }
|
||||
uint64 GetNextInviteId() { return ++_currentInviteId; }
|
||||
|
||||
private:
|
||||
CalendarInviteMap _inviteMap;
|
||||
CalendarEventMap _eventMap;
|
||||
uint64 _currentEventId;
|
||||
uint64 _currentInviteId;
|
||||
};
|
||||
|
||||
#define sCalendarMgr ACE_Singleton<CalendarMgr, ACE_Null_Mutex>::instance()
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user