Skip to content

Instantly share code, notes, and snippets.

@rsa
Created September 25, 2011 06:26
Show Gist options
  • Select an option

  • Save rsa/1240299 to your computer and use it in GitHub Desktop.

Select an option

Save rsa/1240299 to your computer and use it in GitHub Desktop.
diff --git a/src/game/Calendar.h b/src/game/Calendar.h
index 10b75b5..3f3b33b 100644
--- a/src/game/Calendar.h
+++ b/src/game/Calendar.h
@@ -19,8 +19,86 @@
#ifndef MANGOS_CALENDAR_H
#define MANGOS_CALENDAR_H
+#include "Common.h"
+#include "ObjectGuid.h"
+#include "Policies/Singleton.h"
+#include <ace/RW_Thread_Mutex.h>
+
+struct CalendarEventInvite
+{
+ std::string m_Name;
+ ObjectGuid m_eventGuid;
+ ObjectGuid m_inviterGuid;
+ ObjectGuid m_playerGuid;
+ uint8 unk12;
+ uint8 unk13;
+};
+
+typedef std::set<CalendarEventInvite*> EventInvitesList;
+
+struct CalendarEvent
+{
+ ObjectGuid m_guid;
+ ObjectGuid m_creatorGuid;
+ std::string m_eventName;
+ std::string m_eventDescription;
+ uint8 m_eventType;
+ uint8 unk4;
+ uint32 unk5;
+ uint32 m_instance;
+ uint32 m_time;
+ uint32 unk8;
+ uint32 m_flags;
+ EventInvitesList inviteList;
+};
+
+typedef std::multimap<ObjectGuid, CalendarEventInvite> CalendarEventInviteMap;
+typedef std::map<ObjectGuid, CalendarEvent> CalendarEventMap;
+typedef std::multimap<uint32, HolidaysEntry const*> HolidaysList;
+
+typedef std::queue<ObjectGuid> EventsQueue;
+typedef std::queue<CalendarEventInvite*> InviteQueue;
+
+typedef std::pair<HolidaysList::const_iterator,HolidaysList::const_iterator> HolidaysListBounds;
+typedef std::pair<CalendarEventInviteMap::const_iterator,CalendarEventInviteMap::const_iterator> CalendarEventInviteBounds;
+
class Calendar
{
+ public:
+ Calendar();
+ ~Calendar();
+ void Initialize();
+ void Update();
+
+ // searching
+ CalendarEvent* GetEvent(ObjectGuid eventGuid);
+ EventInvitesList GetInvitesForPlayer(ObjectGuid playerGuid);
+
+ // save/load operations
+ CalendarResponseResult AddEvent(CalendarEvent* event);
+ void SaveEvent(ObjectGuid guid);
+ CalendarResponseResult AddInvite(CalendarEventInvite* invite);
+ void SaveEvents();
+ void LoadEvents();
+ // DBC operations
+ HolidaysList GetHolidaysForRegion(uint32 region);
+
+ // multithread locking
+ typedef ACE_RW_Thread_Mutex LockType;
+ typedef ACE_Read_Guard<LockType> ReadGuard;
+ typedef ACE_Write_Guard<LockType> WriteGuard;
+ LockType& GetLock() { return i_lock; }
+
+ private:
+ LockType i_lock;
+ CalendarEventMap m_eventsMap; // Events storage
+ CalendarEventInviteMap m_invitesMap; // Invites storage
+ HolidaysList m_holidaysList; // Holidays, sorted by region
+ EventsQueue m_saveQueue; // Events save queue
+ EventsQueue m_deleteQueue; // Events delete queue
};
+
+#define sCalendar MaNGOS::Singleton<Calendar>::Instance()
+
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment