aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/CalendarHandler.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2012-02-25 00:14:39 +0100
committerShauren <shauren.trinity@gmail.com>2012-02-25 00:14:39 +0100
commit8945d115b2bf68f440f3b0ca68bff16a38d7541c (patch)
treeeae30ded7cffc3b3afc8d58309c982c900ac3a58 /src/server/game/Handlers/CalendarHandler.cpp
parent7a4d388e0467c8303137de543861b29d231e8a4f (diff)
Core/Calendar: Added some checks & error responses for calendar actions, many more to do still
Diffstat (limited to 'src/server/game/Handlers/CalendarHandler.cpp')
-rwxr-xr-xsrc/server/game/Handlers/CalendarHandler.cpp46
1 files changed, 34 insertions, 12 deletions
diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp
index b5a77dd52e0..01838f815fb 100755
--- a/src/server/game/Handlers/CalendarHandler.cpp
+++ b/src/server/game/Handlers/CalendarHandler.cpp
@@ -44,6 +44,7 @@ SMSG_CALENDAR_EVENT_INVITE_STATUS_ALERT [ Structure unkown ]
#include "CalendarMgr.h"
#include "ObjectMgr.h"
#include "ObjectAccessor.h"
+#include "DatabaseEnv.h"
void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/)
{
@@ -257,7 +258,7 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recv_data)
CalendarAction action;
action.SetAction(CALENDAR_ACTION_ADD_EVENT);
- action.SetGUID(guid);
+ action.SetPlayer(_player);
action.Event.SetEventId(sCalendarMgr->GetFreeEventId());
action.Event.SetCreatorGUID(guid);
action.Event.SetType(type);
@@ -309,7 +310,7 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recv_data)
CalendarAction action;
action.SetAction(CALENDAR_ACTION_MODIFY_EVENT);
- action.SetGUID(guid);
+ action.SetPlayer(_player);
action.SetInviteId(inviteId);
action.Event.SetEventId(eventId);
action.Event.SetType(type);
@@ -338,7 +339,7 @@ void WorldSession::HandleCalendarRemoveEvent(WorldPacket& recv_data)
CalendarAction action;
action.SetAction(CALENDAR_ACTION_REMOVE_EVENT);
- action.SetGUID(guid);
+ action.SetPlayer(_player);
action.SetInviteId(inviteId);
action.Event.SetEventId(eventId);
action.Event.SetFlags(flags);
@@ -359,7 +360,7 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket& recv_data)
CalendarAction action;
action.SetAction(CALENDAR_ACTION_COPY_EVENT);
- action.SetGUID(guid);
+ action.SetPlayer(_player);
action.SetInviteId(inviteId);
action.Event.SetEventId(eventId);
action.Event.SetTime(time);
@@ -375,13 +376,26 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recv_data)
std::string name;
uint8 status;
uint8 rank;
+ uint64 invitee = 0;
+ uint32 team = 0;
recv_data >> eventId >> inviteId >> name >> status >> rank;
- uint64 invitee = 0;
if (Player* player = sObjectAccessor->FindPlayerByName(name.c_str()))
+ {
invitee = player->GetGUID();
+ team = player->GetTeam();
+ }
else
- invitee = sObjectMgr->GetPlayerGUIDByName(name.c_str());
+ {
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUID_RACE_ACC_BY_NAME);
+ stmt->setString(0, name);
+ if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
+ {
+ Field* fields = result->Fetch();
+ invitee = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);
+ team = Player::TeamForRace(fields[1].GetUInt8());
+ }
+ }
sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_EVENT_INVITE [" UI64FMTD "], EventId ["
UI64FMTD "] InviteId [" UI64FMTD "] Name %s ([" UI64FMTD "]), status %u, "
@@ -393,9 +407,17 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recv_data)
return;
}
+ if (_player->GetTeam() != team)
+ {
+ SendCalendarCommandResult(CALENDAR_ERROR_NOT_ALLIED);
+ return;
+ }
+
+ // TODO: Check ignore, even if offline (db query)
+
CalendarAction action;
action.SetAction(CALENDAR_ACTION_ADD_EVENT_INVITE);
- action.SetGUID(guid);
+ action.SetPlayer(_player);
action.SetInviteId(inviteId);
action.Invite.SetEventId(eventId);
action.Invite.SetInviteId(sCalendarMgr->GetFreeInviteId());
@@ -419,7 +441,7 @@ void WorldSession::HandleCalendarEventSignup(WorldPacket& recv_data)
CalendarAction action;
action.SetAction(CALENDAR_ACTION_SIGNUP_TO_EVENT);
- action.SetGUID(guid);
+ action.SetPlayer(_player);
action.SetExtraData(GetPlayer()->GetGuildId());
action.Event.SetEventId(eventId);
action.Invite.SetStatus(status);
@@ -440,7 +462,7 @@ void WorldSession::HandleCalendarEventRsvp(WorldPacket& recv_data)
CalendarAction action;
action.SetAction(CALENDAR_ACTION_MODIFY_EVENT_INVITE);
- action.SetGUID(guid);
+ action.SetPlayer(_player);
action.SetInviteId(inviteId);
action.Invite.SetInviteId(inviteId);
action.Invite.SetEventId(eventId);
@@ -467,7 +489,7 @@ void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket& recv_data)
CalendarAction action;
action.SetAction(CALENDAR_ACTION_REMOVE_EVENT_INVITE);
- action.SetGUID(guid);
+ action.SetPlayer(_player);
action.SetInviteId(owninviteId);
action.Invite.SetInviteId(inviteId);
action.Invite.SetEventId(eventId);
@@ -493,7 +515,7 @@ void WorldSession::HandleCalendarEventStatus(WorldPacket& recv_data)
CalendarAction action;
action.SetAction(CALENDAR_ACTION_MODIFY_EVENT_INVITE);
- action.SetGUID(guid);
+ action.SetPlayer(_player);
action.SetInviteId(owninviteId);
action.Invite.SetInviteId(inviteId);
action.Invite.SetEventId(eventId);
@@ -520,7 +542,7 @@ void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket& recv_data)
CalendarAction action;
action.SetAction(CALENDAR_ACTION_MODIFY_MODERATOR_EVENT_INVITE);
- action.SetGUID(guid);
+ action.SetPlayer(_player);
action.SetInviteId(owninviteId);
action.Invite.SetInviteId(inviteId);
action.Invite.SetEventId(eventId);