Core/Calendar: Corrected structure of SMSG_CALENDAR_COMMAND_RESULT

This commit is contained in:
Shauren
2012-02-24 23:40:06 +01:00
parent e5621dfd99
commit 0e86b3a578
3 changed files with 78 additions and 26 deletions
+15 -22
View File
@@ -99,7 +99,7 @@ CalendarInvite* CalendarMgr::GetInvite(uint64 inviteId)
if (it != _invites.end())
return &(it->second);
sLog->outError("SPP: CalendarMgr::GetInvite: [" UI64FMTD "] not found!", inviteId);
sLog->outError("CalendarMgr::GetInvite: [" UI64FMTD "] not found!", inviteId);
return NULL;
}
@@ -109,7 +109,7 @@ CalendarEvent* CalendarMgr::GetEvent(uint64 eventId)
if (it != _events.end())
return &(it->second);
sLog->outError("SPP: CalendarMgr::GetEvent: [" UI64FMTD "] not found!", eventId);
sLog->outError("CalendarMgr::GetEvent: [" UI64FMTD "] not found!", eventId);
return NULL;
}
@@ -209,8 +209,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
case CALENDAR_ACTION_MODIFY_EVENT:
{
uint64 eventId = action.Event.GetEventId();
CalendarEvent* calendarEvent = CheckPermisions(eventId,
action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_MODERATOR);
CalendarEvent* calendarEvent = CheckPermisions(eventId, action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_MODERATOR);
if (!calendarEvent)
return;
@@ -235,8 +234,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
}
case CALENDAR_ACTION_COPY_EVENT:
{
CalendarEvent* calendarEvent = CheckPermisions(action.Event.GetEventId(),
action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_OWNER);
CalendarEvent* calendarEvent = CheckPermisions(action.Event.GetEventId(), action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_OWNER);
if (!calendarEvent)
return;
@@ -257,6 +255,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
CalendarinviteIdList const invites = calendarEvent->GetInviteIdList();
for (CalendarinviteIdList::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
{
if (CalendarInvite* invite = GetInvite(*itr))
{
uint64 inviteId = GetFreeInviteId();
@@ -274,6 +273,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
newEvent.AddInvite(inviteId);
}
}
}
if (AddEvent(newEvent))
SendCalendarEvent(newEvent, CALENDAR_SENDTYPE_COPY);
@@ -284,11 +284,9 @@ void CalendarMgr::AddAction(CalendarAction const& action)
{
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);
CalendarEvent* calendarEvent = CheckPermisions(eventId, action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_OWNER);
if (!calendarEvent)
return;
@@ -304,9 +302,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
case CALENDAR_ACTION_ADD_EVENT_INVITE:
{
uint64 eventId = action.Invite.GetEventId();
CalendarEvent* calendarEvent = CheckPermisions(eventId,
action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_MODERATOR);
CalendarEvent* calendarEvent = CheckPermisions(eventId, action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_MODERATOR);
if (!calendarEvent)
return;
@@ -324,8 +320,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
{
uint64 eventId = action.Event.GetEventId();
CalendarEvent* calendarEvent = GetEvent(eventId);
CheckPermisions(eventId,
action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_MODERATOR);
CheckPermisions(eventId, action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_MODERATOR);
if (!calendarEvent || !(calendarEvent->GetFlags() & CALENDAR_FLAG_GUILD_ONLY)
|| !calendarEvent->GetGuildId() || calendarEvent->GetGuildId() != action.GetExtraData())
@@ -385,7 +380,6 @@ void CalendarMgr::AddAction(CalendarAction const& action)
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;
@@ -394,8 +388,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
{
uint64 eventId = action.Invite.GetEventId();
uint64 inviteId = action.Invite.GetInviteId();
CalendarEvent* calendarEvent = CheckPermisions(eventId,
action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_MODERATOR);
CalendarEvent* calendarEvent = CheckPermisions(eventId, action.GetGUID(), action.GetInviteId(), CALENDAR_RANK_MODERATOR);
if (!calendarEvent)
return;
@@ -418,7 +411,7 @@ bool CalendarMgr::AddEvent(CalendarEvent const& newEvent)
uint64 eventId = newEvent.GetEventId();
if (_events.find(eventId) != _events.end())
{
sLog->outError("CalendarMgr::addEvent: Event [" UI64FMTD "] exists", eventId);
sLog->outError("CalendarMgr::AddEvent: Event [" UI64FMTD "] exists", eventId);
return false;
}
@@ -431,7 +424,7 @@ 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);
sLog->outError("CalendarMgr::RemoveEvent: Event [" UI64FMTD "] does not exist", eventId);
return false;
}
@@ -467,13 +460,13 @@ bool CalendarMgr::AddInvite(CalendarInvite const& newInvite)
uint64 inviteId = newInvite.GetInviteId();
if (!inviteId)
{
sLog->outError("CalendarMgr::addInvite: Cant add Invite 0");
sLog->outError("CalendarMgr::AddInvite: Cant add Invite 0");
return false;
}
if (_invites.find(inviteId) != _invites.end())
{
sLog->outError("CalendarMgr::addInvite: Invite [" UI64FMTD "] exists", inviteId);
sLog->outError("CalendarMgr::AddInvite: Invite [" UI64FMTD "] exists", inviteId);
return false;
}
@@ -489,7 +482,7 @@ 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);
sLog->outError("CalendarMgr::RemoveInvite: Invite [" UI64FMTD "] does not exist", inviteId);
return 0;
}
+24 -3
View File
@@ -237,6 +237,7 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recv_data)
"] differs", guid, inviteCount, invitee);
return;
}
inviteId = sCalendarMgr->GetFreeInviteId();
}
else
@@ -386,6 +387,12 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recv_data)
UI64FMTD "] InviteId [" UI64FMTD "] Name %s ([" UI64FMTD "]), status %u, "
"Rank %u", guid, eventId, inviteId, name.c_str(), invitee, status, rank);
if (!invitee)
{
SendCalendarCommandResult(CALENDAR_ERROR_PLAYER_NOT_FOUND);
return;
}
CalendarAction action;
action.SetAction(CALENDAR_ACTION_ADD_EVENT_INVITE);
action.SetGUID(guid);
@@ -817,13 +824,27 @@ void WorldSession::SendCalendarRaidLockoutUpdated(InstanceSave const* save)
SendPacket(&data);
}
void WorldSession::SendCalendarCommandResult(uint32 value)
void WorldSession::SendCalendarCommandResult(CalendarError err, char const* param /*= NULL*/)
{
uint64 guid = _player->GetGUID();
sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_COMMAND_RESULT [" UI64FMTD "] Value: %u", guid, value);
sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_CALENDAR_COMMAND_RESULT [" UI64FMTD "] Value: %u", guid, err);
WorldPacket data(SMSG_CALENDAR_COMMAND_RESULT, 0);
data << uint16(0) << uint32(0) << uint32(value);
data << uint32(0);
data << uint8(0);
switch (err)
{
case CALENDAR_ERROR_OTHER_INVITES_EXCEEDED:
case CALENDAR_ERROR_ALREADY_INVITED_TO_EVENT_S:
case CALENDAR_ERROR_IGNORING_YOU_S:
data << param;
break;
default:
data << uint8(0);
break;
}
data << uint32(err);
SendPacket(&data);
}
+39 -1
View File
@@ -141,6 +141,44 @@ enum CharterTypes
ARENA_TEAM_CHARTER_5v5_TYPE = 5
};
enum CalendarError
{
CALENDAR_OK = 0,
CALENDAR_ERROR_GUILD_EVENTS_EXCEEDED = 1,
CALENDAR_ERROR_EVENTS_EXCEEDED = 2,
CALENDAR_ERROR_SELF_INVITES_EXCEEDED = 3,
CALENDAR_ERROR_OTHER_INVITES_EXCEEDED = 4,
CALENDAR_ERROR_PERMISSIONS = 5,
CALENDAR_ERROR_EVENT_INVALID = 6,
CALENDAR_ERROR_NOT_INVITED = 7,
CALENDAR_ERROR_INTERNAL = 8,
CALENDAR_ERROR_GUILD_PLAYER_NOT_IN_GUILD = 9,
CALENDAR_ERROR_ALREADY_INVITED_TO_EVENT_S = 10,
CALENDAR_ERROR_PLAYER_NOT_FOUND = 11,
CALENDAR_ERROR_NOT_ALLIED = 12,
CALENDAR_ERROR_IGNORING_YOU_S = 13,
CALENDAR_ERROR_INVITES_EXCEEDED = 14,
CALENDAR_ERROR_INVALID_DATE = 16,
CALENDAR_ERROR_INVALID_TIME = 17,
CALENDAR_ERROR_NEEDS_TITLE = 19,
CALENDAR_ERROR_EVENT_PASSED = 20,
CALENDAR_ERROR_EVENT_LOCKED = 21,
CALENDAR_ERROR_DELETE_CREATOR_FAILED = 22,
CALENDAR_ERROR_SYSTEM_DISABLED = 24,
CALENDAR_ERROR_RESTRICTED_ACCOUNT = 25,
CALENDAR_ERROR_ARENA_EVENTS_EXCEEDED = 26,
CALENDAR_ERROR_RESTRICTED_LEVEL = 27,
CALENDAR_ERROR_USER_SQUELCHED = 28,
CALENDAR_ERROR_NO_INVITE = 29,
CALENDAR_ERROR_EVENT_WRONG_SERVER = 36,
CALENDAR_ERROR_INVITE_WRONG_SERVER = 37,
CALENDAR_ERROR_NO_GUILD_INVITES = 38,
CALENDAR_ERROR_INVALID_SIGNUP = 39,
CALENDAR_ERROR_NO_MODERATOR = 40
};
//class to deal with packet processing
//allows to determine if next packet is safe to be processed
class PacketFilter
@@ -892,9 +930,9 @@ class WorldSession
void SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite);
void SendCalendarEventModeratorStatusAlert(CalendarInvite const& invite);
void SendCalendarClearPendingAction();
void SendCalendarCommandResult(uint32 value);
void SendCalendarRaidLockout(InstanceSave* save, bool add);
void SendCalendarRaidLockoutUpdated(InstanceSave const* save);
void SendCalendarCommandResult(CalendarError err, char const* param = NULL);
void HandleSpellClick(WorldPacket& recv_data);
void HandleMirrorImageDataRequest(WorldPacket& recv_data);