aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/CalendarHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Handlers/CalendarHandler.cpp')
-rw-r--r--src/server/game/Handlers/CalendarHandler.cpp50
1 files changed, 37 insertions, 13 deletions
diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp
index 2f1a726f9cf..0461d7290d1 100644
--- a/src/server/game/Handlers/CalendarHandler.cpp
+++ b/src/server/game/Handlers/CalendarHandler.cpp
@@ -239,20 +239,28 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData)
recvData.ReadPackedTime(unkPackedTime);
recvData >> flags;
- CalendarEvent calendarEvent(sCalendarMgr->GetFreeEventId(), guid, 0, CalendarEventType(type), dungeonId,
+ // prevent events in the past
+ // To Do: properly handle timezones and remove the "- time_t(86400L)" hack
+ if (time_t(eventPackedTime) < (time(NULL) - time_t(86400L)))
+ {
+ recvData.rfinish();
+ return;
+ }
+
+ CalendarEvent* calendarEvent = new CalendarEvent(sCalendarMgr->GetFreeEventId(), guid, 0, CalendarEventType(type), dungeonId,
time_t(eventPackedTime), flags, time_t(unkPackedTime), title, description);
- if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement())
+ if (calendarEvent->IsGuildEvent() || calendarEvent->IsGuildAnnouncement())
if (Player* creator = ObjectAccessor::FindPlayer(guid))
- calendarEvent.SetGuildId(creator->GetGuildId());
+ calendarEvent->SetGuildId(creator->GetGuildId());
- if (calendarEvent.IsGuildAnnouncement())
+ if (calendarEvent->IsGuildAnnouncement())
{
// 946684800 is 01/01/2000 00:00:00 - default response time
- CalendarInvite invite(0, calendarEvent.GetEventId(), 0, guid, 946684800, CALENDAR_STATUS_NOT_SIGNED_UP, CALENDAR_RANK_PLAYER, "");
+ CalendarInvite invite(0, calendarEvent->GetEventId(), 0, guid, 946684800, CALENDAR_STATUS_NOT_SIGNED_UP, CALENDAR_RANK_PLAYER, "");
// WARNING: By passing pointer to a local variable, the underlying method(s) must NOT perform any kind
// of storage of the pointer as it will lead to memory corruption
- sCalendarMgr->AddInvite(&calendarEvent, &invite);
+ sCalendarMgr->AddInvite(calendarEvent, &invite);
}
else
{
@@ -275,15 +283,15 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData)
recvData >> status >> rank;
// 946684800 is 01/01/2000 00:00:00 - default response time
- CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent.GetEventId(), invitee, guid, 946684800, CalendarInviteStatus(status), CalendarModerationRank(rank), "");
- sCalendarMgr->AddInvite(&calendarEvent, invite, trans);
+ CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent->GetEventId(), invitee, guid, 946684800, CalendarInviteStatus(status), CalendarModerationRank(rank), "");
+ sCalendarMgr->AddInvite(calendarEvent, invite, trans);
}
if (inviteCount > 1)
CharacterDatabase.CommitTransaction(trans);
}
- sCalendarMgr->AddEvent(new CalendarEvent(calendarEvent, calendarEvent.GetEventId()), CALENDAR_SENDTYPE_ADD);
+ sCalendarMgr->AddEvent(calendarEvent, CALENDAR_SENDTYPE_ADD);
}
void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData)
@@ -308,6 +316,14 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData)
recvData.ReadPackedTime(timeZoneTime);
recvData >> flags;
+ // prevent events in the past
+ // To Do: properly handle timezones and remove the "- time_t(86400L)" hack
+ if (time_t(eventPackedTime) < (time(NULL) - time_t(86400L)))
+ {
+ recvData.rfinish();
+ return;
+ }
+
TC_LOG_DEBUG("network", "CMSG_CALENDAR_UPDATE_EVENT [" UI64FMTD "] EventId [" UI64FMTD
"], InviteId [" UI64FMTD "] Title %s, Description %s, type %u "
"Repeatable %u, MaxInvites %u, Dungeon ID %d, Time %u "
@@ -350,17 +366,25 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData)
uint64 guid = _player->GetGUID();
uint64 eventId;
uint64 inviteId;
- uint32 time;
+ uint32 eventTime;
recvData >> eventId >> inviteId;
- recvData.ReadPackedTime(time);
+ recvData.ReadPackedTime(eventTime);
TC_LOG_DEBUG("network", "CMSG_CALENDAR_COPY_EVENT [" UI64FMTD "], EventId [" UI64FMTD
- "] inviteId [" UI64FMTD "] Time: %u", guid, eventId, inviteId, time);
+ "] inviteId [" UI64FMTD "] Time: %u", guid, eventId, inviteId, eventTime);
+
+ // prevent events in the past
+ // To Do: properly handle timezones and remove the "- time_t(86400L)" hack
+ if (time_t(eventTime) < (time(NULL) - time_t(86400L)))
+ {
+ recvData.rfinish();
+ return;
+ }
if (CalendarEvent* oldEvent = sCalendarMgr->GetEvent(eventId))
{
CalendarEvent* newEvent = new CalendarEvent(*oldEvent, sCalendarMgr->GetFreeEventId());
- newEvent->SetEventTime(time_t(time));
+ newEvent->SetEventTime(time_t(eventTime));
sCalendarMgr->AddEvent(newEvent, CALENDAR_SENDTYPE_COPY);
CalendarInviteStore invites = sCalendarMgr->GetEventInvites(eventId);