Skip to content

Commit

Permalink
Wasn't the issue so lets Revert the "Revert "Core/Calendar: use as ba…
Browse files Browse the repository at this point in the history
…se the calendar from Venugh and Bootz""

This reverts commit 83900fb.
  • Loading branch information
wazy committed Dec 28, 2012
1 parent 83900fb commit 288d939
Show file tree
Hide file tree
Showing 12 changed files with 1,916 additions and 275 deletions.
112 changes: 95 additions & 17 deletions src/server/game/Calendar/Calendar.cpp
@@ -1,25 +1,103 @@
/*
* Copyright (C) 2005 - 2012 MaNGOS <http://www.getmangos.com/>
*
* Copyright (C) 2008 - 2012 Trinity <http://www.trinitycore.org/>
* Copyright (C) 2011-2012 ArkCORE2 <http://www.arkania.net/>
* Copyright (C) 2010-2012 Project SkyFire <http://www.projectskyfire.org/>
*
* Copyright (C) 2010 - 2012 ProjectSkyfire <http://www.projectskyfire.org/>
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2011 - 2012 ArkCORE <http://www.arkania.net/>
* 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 3 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/>.
*/

#include "gamePCH.h"
#include "Player.h"
#include "Calendar.h"

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();
}

void CalendarInvite::Init()
{
_eventId = 0;
_invitee = 0;
_senderGUID = 0;
_statusTime = 0;
_status = CALENDAR_STATUS_INVITED; // default (0)?
_rank = CALENDAR_RANK_PLAYER;
_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;

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;

data << "CalendarAction::"
<< " Action: " << GetAction()
<< " Guid: " << GetPlayer()->GetGUID()
<< " Invite Id: " << GetInviteId()
<< " Extra data: " << GetExtraData()
<< " Event: " << Event.GetDebugString()
<< " Invite: " << Invite.GetDebugString();

return data.str();
}
197 changes: 180 additions & 17 deletions src/server/game/Calendar/Calendar.h
@@ -1,31 +1,194 @@
/*
* Copyright (C) 2005 - 2012 MaNGOS <http://www.getmangos.com/>
*
* Copyright (C) 2008 - 2012 Trinity <http://www.trinitycore.org/>
* Copyright (C) 2011-2012 ArkCORE2 <http://www.arkania.net/>
* Copyright (C) 2010-2012 Project SkyFire <http://www.projectskyfire.org/>
*
* Copyright (C) 2010 - 2012 ProjectSkyfire <http://www.projectskyfire.org/>
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2011 - 2012 ArkCORE <http://www.arkania.net/>
* 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 3 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 ARKCORE_CALENDAR_H
#define ARKCORE_CALENDAR_H

class Calendar
#include "Errors.h"
#include "SharedDefines.h"
#include <map>

class CalendarInvite
{
public:
CalendarInvite() : _inviteId(0) { Init(); }
explicit CalendarInvite(uint64 inviteId) : _inviteId(inviteId) { Init(); }

~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(CalendarInviteStatus status) { _status = status; }
CalendarInviteStatus GetStatus() const { return _status; }

void SetRank(CalendarModerationRank rank) { _rank = rank; }
CalendarModerationRank GetRank() const { return _rank; }

std::string GetDebugString() const;

private:
void Init();

uint64 _inviteId;
uint64 _eventId;
uint64 _invitee;
uint64 _senderGUID;
uint32 _statusTime;
CalendarInviteStatus _status;
CalendarModerationRank _rank;
std::string _text;
};

typedef std::set<uint64> CalendarInviteIdList;

class CalendarEvent
{
public:
CalendarEvent() : _eventId(0) { Init(); }
explicit CalendarEvent(uint64 eventId) : _eventId(eventId) { Init(); }

~CalendarEvent() { }

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(CalendarEventType type) { _type = type; }
CalendarEventType 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; }
bool 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:
void Init();

uint64 _eventId;
uint64 _creatorGUID;
uint32 _guildId;
CalendarEventType _type;
int32 _dungeonId;
uint32 _maxInvites;
uint32 _eventTime;
uint32 _flags;
bool _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;

class Player;

struct CalendarAction
{
CalendarAction(): _action(CALENDAR_ACTION_NONE), _player(NULL), _inviteId(0), _data(0)
{
}

void SetAction(CalendarActionData data) { _action = data; }
CalendarActionData GetAction() const { return _action; }

void SetPlayer(Player* player) { ASSERT(player); _player = player; }
Player* GetPlayer() const { return _player; }

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;

std::string GetDebugString() const;

private:
CalendarActionData _action;
Player* _player;
uint64 _inviteId;
uint32 _data;
};

#endif

0 comments on commit 288d939

Please sign in to comment.