void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData) { uint64 guid = _player->GetGUID(); uint64 eventId; uint64 inviteId; uint32 time; recvData >> eventId >> inviteId; recvData.ReadPackedTime(time); TC_LOG_DEBUG("network", "CMSG_CALENDAR_COPY_EVENT [" UI64FMTD "], EventId [" UI64FMTD "] inviteId [" UI64FMTD "] Time: %u", guid, eventId, inviteId, time); if (CalendarEvent* oldEvent = sCalendarMgr->GetEvent(eventId)) { CalendarEvent* newEvent = new CalendarEvent(*oldEvent, sCalendarMgr->GetFreeEventId()); newEvent->SetEventTime(time_t(time)); sCalendarMgr->AddEvent(newEvent, CALENDAR_SENDTYPE_COPY); CalendarInviteStore invites = sCalendarMgr->GetEventInvites(eventId); SQLTransaction trans; if (invites.size() > 1) trans = CharacterDatabase.BeginTransaction(); for (CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) sCalendarMgr->AddInvite(newEvent, new CalendarInvite(**itr, sCalendarMgr->GetFreeInviteId(), newEvent->GetEventId()), trans); if (invites.size() > 1) CharacterDatabase.CommitTransaction(trans); // should we change owner when somebody makes a copy of event owned by another person? } else sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); }
void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData) { uint64 guid = _player->GetGUID(); uint64 eventId; uint64 inviteId; uint32 time; recvData >> eventId >> inviteId; recvData.ReadPackedTime(time); sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_COPY_EVENT [" UI64FMTD "], EventId [" UI64FMTD "] inviteId [" UI64FMTD "] Time: %u", guid, eventId, inviteId, time); if(CalendarEvent* oldEvent = sCalendarMgr->GetEvent(eventId)) { CalendarEvent* newEvent = new CalendarEvent(*oldEvent, sCalendarMgr->GetFreeEventId()); newEvent->SetEventTime(time_t(time)); sCalendarMgr->AddEvent(newEvent, CALENDAR_SENDTYPE_COPY); CalendarInviteStore invites = sCalendarMgr->GetEventInvites(eventId); for(CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) sCalendarMgr->AddInvite(newEvent, new CalendarInvite(**itr, sCalendarMgr->GetFreeInviteId(), newEvent->GetEventId())); // should we change owner when somebody makes a copy of event owned by another person? } else sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); }
void WorldSession::HandleCalendarCopyEvent(WorldPackets::Calendar::CalendarCopyEvent& calendarCopyEvent) { ObjectGuid guid = _player->GetGUID(); // prevent events in the past // To Do: properly handle timezones and remove the "- time_t(86400L)" hack if (calendarCopyEvent.Date < (time(NULL) - time_t(86400L))) return; if (CalendarEvent* oldEvent = sCalendarMgr->GetEvent(calendarCopyEvent.EventID)) { CalendarEvent* newEvent = new CalendarEvent(*oldEvent, sCalendarMgr->GetFreeEventId()); newEvent->SetDate(calendarCopyEvent.Date); sCalendarMgr->AddEvent(newEvent, CALENDAR_SENDTYPE_COPY); CalendarInviteStore invites = sCalendarMgr->GetEventInvites(calendarCopyEvent.EventID); SQLTransaction trans; if (invites.size() > 1) trans = CharacterDatabase.BeginTransaction(); for (CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) sCalendarMgr->AddInvite(newEvent, new CalendarInvite(**itr, sCalendarMgr->GetFreeInviteId(), newEvent->GetEventId()), trans); if (invites.size() > 1) CharacterDatabase.CommitTransaction(trans); // Should we change owner when somebody makes a copy of event owned by another person? } else sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); }
void CalendarMgr::RemoveAllPlayerEventsAndInvites(ObjectGuid guid) { for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) if ((*itr)->GetCreatorGUID() == guid) RemoveEvent((*itr)->GetEventId(), ObjectGuid::Empty); // don't send mail if removing a character CalendarInviteStore playerInvites = GetPlayerInvites(guid); for (CalendarInviteStore::const_iterator itr = playerInvites.begin(); itr != playerInvites.end(); ++itr) RemoveInvite((*itr)->GetInviteId(), (*itr)->GetEventId(), guid); }
void CalendarMgr::RemovePlayerGuildEventsAndSignups(ObjectGuid guid, ObjectGuid::LowType guildId) { for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end(); ++itr) if ((*itr)->GetCreatorGUID() == guid && ((*itr)->IsGuildEvent() || (*itr)->IsGuildAnnouncement())) RemoveEvent((*itr)->GetEventId(), guid); CalendarInviteStore playerInvites = GetPlayerInvites(guid); for (CalendarInviteStore::const_iterator itr = playerInvites.begin(); itr != playerInvites.end(); ++itr) if (CalendarEvent* calendarEvent = GetEvent((*itr)->GetEventId())) if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == guildId) RemoveInvite((*itr)->GetInviteId(), (*itr)->GetEventId(), guid); }
void CalendarMgr::SendPacketToAllEventRelatives(WorldPacket& packet, CalendarEvent const& calendarEvent) { // Send packet to all guild members if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement()) if (Guild* guild = sGuildMgr->GetGuildById(calendarEvent.GetGuildId())) guild->BroadcastPacket(&packet); // Send packet to all invitees if event is non-guild, in other case only to non-guild invitees (packet was broadcasted for them) CalendarInviteStore invites = _invites[calendarEvent.GetEventId()]; for (CalendarInviteStore::iterator itr = invites.begin(); itr != invites.end(); ++itr) if (Player* player = ObjectAccessor::FindConnectedPlayer((*itr)->GetInviteeGUID())) if (!calendarEvent.IsGuildEvent() || player->GetGuildId() != calendarEvent.GetGuildId()) player->SendDirectMessage(&packet); }
void CalendarMgr::RemoveAllPlayerEventsAndInvites(uint64 guid) { for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end();) { if ((*itr)->GetCreatorGUID() == guid) { itr = RemoveEvent((*itr)->GetEventId(), 0); // don't send mail if removing a character continue; } ++itr; } CalendarInviteStore playerInvites = GetPlayerInvites(guid); for (CalendarInviteStore::const_iterator itr = playerInvites.begin(); itr != playerInvites.end(); ++itr) RemoveInvite((*itr)->GetInviteId(), (*itr)->GetEventId(), guid); }
void CalendarMgr::RemovePlayerGuildEventsAndSignups(uint64 guid, uint32 guildId) { for (CalendarEventStore::const_iterator itr = _events.begin(); itr != _events.end();) { if ((*itr)->GetCreatorGUID() == guid && ((*itr)->IsGuildEvent() || (*itr)->IsGuildAnnouncement())) { itr = RemoveEvent((*itr)->GetEventId(), guid); continue; } ++itr; } CalendarInviteStore playerInvites = GetPlayerInvites(guid); for (CalendarInviteStore::const_iterator itr = playerInvites.begin(); itr != playerInvites.end(); ++itr) if (CalendarEvent* calendarEvent = GetEvent((*itr)->GetEventId())) if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == guildId) RemoveInvite((*itr)->GetInviteId(), (*itr)->GetEventId(), guid); }
void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData) { ObjectGuid guid = _player->GetGUID(); uint64 eventId; uint64 inviteId; uint32 eventTime; recvData >> eventId >> inviteId; recvData.ReadPackedTime(eventTime); TC_LOG_DEBUG("network", "CMSG_CALENDAR_COPY_EVENT [%s], EventId [" UI64FMTD "] inviteId [" UI64FMTD "] Time: %u", guid.ToString().c_str(), 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(eventTime)); sCalendarMgr->AddEvent(newEvent, CALENDAR_SENDTYPE_COPY); CalendarInviteStore invites = sCalendarMgr->GetEventInvites(eventId); SQLTransaction trans; if (invites.size() > 1) trans = CharacterDatabase.BeginTransaction(); for (CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) sCalendarMgr->AddInvite(newEvent, new CalendarInvite(**itr, sCalendarMgr->GetFreeInviteId(), newEvent->GetEventId()), trans); if (invites.size() > 1) CharacterDatabase.CommitTransaction(trans); // should we change owner when somebody makes a copy of event owned by another person? } else sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID); }
void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) { ObjectGuid guid = _player->GetGUID(); TC_LOG_DEBUG("network", "CMSG_CALENDAR_GET_CALENDAR [%s]", guid.ToString().c_str()); time_t currTime = time(NULL); WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 1000); // Average size if no instance CalendarInviteStore invites = sCalendarMgr->GetPlayerInvites(guid); data << uint32(invites.size()); for (CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) { data << uint64((*itr)->GetEventId()); data << uint64((*itr)->GetInviteId()); data << uint8((*itr)->GetStatus()); data << uint8((*itr)->GetRank()); if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent((*itr)->GetEventId())) { data << uint8(calendarEvent->IsGuildEvent()); data << calendarEvent->GetCreatorGUID().WriteAsPacked(); } else { data << uint8(0); data << (*itr)->GetSenderGUID().WriteAsPacked(); } } CalendarEventStore playerEvents = sCalendarMgr->GetPlayerEvents(guid); data << uint32(playerEvents.size()); for (CalendarEventStore::const_iterator itr = playerEvents.begin(); itr != playerEvents.end(); ++itr) { CalendarEvent* calendarEvent = *itr; data << uint64(calendarEvent->GetEventId()); data << calendarEvent->GetTitle(); data << uint32(calendarEvent->GetType()); data.AppendPackedTime(calendarEvent->GetEventTime()); data << uint32(calendarEvent->GetFlags()); data << int32(calendarEvent->GetDungeonId()); data << calendarEvent->GetCreatorGUID().WriteAsPacked(); } data << uint32(currTime); // server time data.AppendPackedTime(currTime); // zone time ByteBuffer dataBuffer; uint32 boundCounter = 0; for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { Player::BoundInstancesMap boundInstances = _player->GetBoundInstances(Difficulty(i)); for (Player::BoundInstancesMap::const_iterator itr = boundInstances.begin(); itr != boundInstances.end(); ++itr) { if (itr->second.perm) { InstanceSave const* save = itr->second.save; dataBuffer << uint32(save->GetMapId()); dataBuffer << uint32(save->GetDifficulty()); dataBuffer << uint32(save->GetResetTime() - currTime); dataBuffer << uint64(save->GetInstanceId()); // instance save id as unique instance copy id ++boundCounter; } } } data << uint32(boundCounter); data.append(dataBuffer); data << uint32(1135753200); // Constant date, unk (28.12.2005 07:00) // Reuse variables boundCounter = 0; std::set<uint32> sentMaps; dataBuffer.clear(); ResetTimeByMapDifficultyMap const& resets = sInstanceSaveMgr->GetResetTimeMap(); for (ResetTimeByMapDifficultyMap::const_iterator itr = resets.begin(); itr != resets.end(); ++itr) { uint32 mapId = PAIR32_LOPART(itr->first); if (sentMaps.find(mapId) != sentMaps.end()) continue; MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); if (!mapEntry || !mapEntry->IsRaid()) continue; sentMaps.insert(mapId); dataBuffer << int32(mapId); dataBuffer << int32(itr->second - currTime); dataBuffer << int32(0); // Never seen anything else in sniffs - still unknown ++boundCounter; } data << uint32(boundCounter); data.append(dataBuffer); /// @todo Fix this, how we do know how many and what holidays to send? uint32 holidayCount = 0; data << uint32(holidayCount); for (uint32 i = 0; i < holidayCount; ++i) { HolidaysEntry const* holiday = sHolidaysStore.LookupEntry(666); data << uint32(holiday->Id); // m_ID data << uint32(holiday->Region); // m_region, might be looping data << uint32(holiday->Looping); // m_looping, might be region data << uint32(holiday->Priority); // m_priority data << uint32(holiday->CalendarFilterType); // m_calendarFilterType for (uint8 j = 0; j < MAX_HOLIDAY_DATES; ++j) data << uint32(holiday->Date[j]); // 26 * m_date -- WritePackedTime ? for (uint8 j = 0; j < MAX_HOLIDAY_DURATIONS; ++j) data << uint32(holiday->Duration[j]); // 10 * m_duration for (uint8 j = 0; j < MAX_HOLIDAY_FLAGS; ++j) data << uint32(holiday->CalendarFlags[j]); // 10 * m_calendarFlags data << holiday->TextureFilename; // m_textureFilename (holiday name) } SendPacket(&data); }
void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) { uint64 guid = _player->GetGUID(); TC_LOG_DEBUG("network", "CMSG_CALENDAR_GET_CALENDAR [" UI64FMTD "]", guid); time_t currTime = time(NULL); uint32 counter = 0; CalendarInviteStore invites = sCalendarMgr->GetPlayerInvites(guid); CalendarEventStore playerEvents = sCalendarMgr->GetPlayerEvents(guid); ResetTimeByMapDifficultyMap const& resets = sInstanceSaveMgr->GetResetTimeMap(); ByteBuffer lockoutInfoBuffer; ByteBuffer invitesInfoBuffer; ByteBuffer eventsInfoBuffer; WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 1000); // Average size if no instance size_t resetPos = data.bitwpos(); data.WriteBits(0, 20); // Reset placeholder data.WriteBits(0, 16); // Holidays -> f**k that shit... Necessary to find out when this should be sent size_t lockoutPos = data.bitwpos(); data.WriteBits(0, 20); // Lockout placeholder for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { Player::BoundInstancesMap boundInstances = _player->GetBoundInstances(Difficulty(i)); for (Player::BoundInstancesMap::const_iterator itr = boundInstances.begin(); itr != boundInstances.end(); ++itr) { if (itr->second.perm) { InstanceSave const* save = itr->second.save; ObjectGuid guid = save->GetInstanceId(); data.WriteBit(guid[6]); data.WriteBit(guid[7]); data.WriteBit(guid[2]); data.WriteBit(guid[1]); data.WriteBit(guid[5]); data.WriteBit(guid[4]); data.WriteBit(guid[0]); data.WriteBit(guid[3]); lockoutInfoBuffer << uint32(save->GetDifficulty()); lockoutInfoBuffer.WriteByteSeq(guid[3]); lockoutInfoBuffer.WriteByteSeq(guid[0]); lockoutInfoBuffer.WriteByteSeq(guid[1]); lockoutInfoBuffer.WriteByteSeq(guid[5]); lockoutInfoBuffer << uint32(save->GetResetTime() - currTime); lockoutInfoBuffer << uint32(save->GetMapId()); lockoutInfoBuffer.WriteByteSeq(guid[2]); lockoutInfoBuffer.WriteByteSeq(guid[7]); lockoutInfoBuffer.WriteByteSeq(guid[6]); lockoutInfoBuffer.WriteByteSeq(guid[4]); ++counter; } } } data.WriteBits(invites.size(), 19); for (CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) { CalendarEvent* calendarEvent = sCalendarMgr->GetEvent((*itr)->GetEventId()); ObjectGuid guid = (*itr)->GetSenderGUID(); data.WriteBit(guid[1]); data.WriteBit(guid[2]); data.WriteBit(guid[6]); data.WriteBit(guid[7]); data.WriteBit(guid[3]); data.WriteBit(guid[0]); data.WriteBit(guid[4]); data.WriteBit(guid[5]); invitesInfoBuffer.WriteByteSeq(guid[2]); invitesInfoBuffer << uint64((*itr)->GetInviteId()); invitesInfoBuffer << uint8((*itr)->GetStatus()); invitesInfoBuffer.WriteByteSeq(guid[6]); invitesInfoBuffer.WriteByteSeq(guid[3]); invitesInfoBuffer.WriteByteSeq(guid[4]); invitesInfoBuffer.WriteByteSeq(guid[1]); invitesInfoBuffer.WriteByteSeq(guid[0]); invitesInfoBuffer << uint64((*itr)->GetEventId()); invitesInfoBuffer.WriteByteSeq(guid[7]); invitesInfoBuffer.WriteByteSeq(guid[5]); invitesInfoBuffer << uint8((*itr)->GetRank()); invitesInfoBuffer << uint8((calendarEvent && calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == _player->GetGuildId()) ? 1 : 0); } data.WriteBits(playerEvents.size(), 19); for (CalendarEventStore::const_iterator itr = playerEvents.begin(); itr != playerEvents.end(); ++itr) { CalendarEvent* calendarEvent = *itr; Guild* guild = sGuildMgr->GetGuildById(calendarEvent->GetGuildId()); ObjectGuid guildGuid = guild ? guild->GetGUID() : 0; ObjectGuid creatorGuid = calendarEvent->GetCreatorGUID(); data.WriteBit(creatorGuid[2]); data.WriteBit(guildGuid[1]); data.WriteBit(guildGuid[7]); data.WriteBit(creatorGuid[4]); data.WriteBit(guildGuid[5]); data.WriteBit(guildGuid[6]); data.WriteBit(guildGuid[3]); data.WriteBit(guildGuid[4]); data.WriteBit(creatorGuid[7]); data.WriteBits(calendarEvent->GetTitle().size(), 8); data.WriteBit(creatorGuid[1]); data.WriteBit(guildGuid[2]); data.WriteBit(guildGuid[0]); data.WriteBit(creatorGuid[0]); data.WriteBit(creatorGuid[3]); data.WriteBit(creatorGuid[6]); data.WriteBit(creatorGuid[5]); eventsInfoBuffer.WriteByteSeq(creatorGuid[5]); eventsInfoBuffer.WriteByteSeq(guildGuid[3]); eventsInfoBuffer.WriteString(calendarEvent->GetTitle()); eventsInfoBuffer.WriteByteSeq(guildGuid[7]); eventsInfoBuffer << int32(calendarEvent->GetDungeonId()); eventsInfoBuffer.WriteByteSeq(creatorGuid[0]); eventsInfoBuffer.WriteByteSeq(creatorGuid[4]); eventsInfoBuffer.WriteByteSeq(guildGuid[2]); eventsInfoBuffer.WriteByteSeq(creatorGuid[7]); eventsInfoBuffer.WriteByteSeq(creatorGuid[2]); eventsInfoBuffer.AppendPackedTime(calendarEvent->GetEventTime()); eventsInfoBuffer.WriteByteSeq(creatorGuid[3]); eventsInfoBuffer.WriteByteSeq(creatorGuid[1]); eventsInfoBuffer.WriteByteSeq(guildGuid[6]); eventsInfoBuffer.WriteByteSeq(guildGuid[1]); eventsInfoBuffer.WriteByteSeq(creatorGuid[6]); eventsInfoBuffer << uint32(calendarEvent->GetFlags()); eventsInfoBuffer.WriteByteSeq(guildGuid[4]); eventsInfoBuffer.WriteByteSeq(guildGuid[5]); eventsInfoBuffer.WriteByteSeq(guildGuid[0]); eventsInfoBuffer << uint64(calendarEvent->GetEventId()); eventsInfoBuffer << uint8(calendarEvent->GetType()); } data.FlushBits(); data.PutBits(lockoutPos, counter, 20); data.append(eventsInfoBuffer); data.append(lockoutInfoBuffer); data.append(invitesInfoBuffer); data.AppendPackedTime(currTime); // zone time counter = 0; std::set<uint32> sentMaps; for (ResetTimeByMapDifficultyMap::const_iterator itr = resets.begin(); itr != resets.end(); ++itr) { uint32 mapId = PAIR32_LOPART(itr->first); if (sentMaps.find(mapId) != sentMaps.end()) continue; MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); if (!mapEntry || !mapEntry->IsRaid()) continue; sentMaps.insert(mapId); data << int32(mapId); data << int32(itr->second - currTime); data << int32(0); // offset => found it different only once counter++; } data.PutBits(resetPos, counter, 20); data << uint32(1135753200); // Constant date, unk (28.12.2005 07:00) data << uint32(currTime); // server time SendPacket(&data); }
void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) { uint64 guid = _player->GetGUID(); sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GET_CALENDAR [" UI64FMTD "]", guid); time_t currTime = time(NULL); WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 1000); // Average size if no instance CalendarInviteStore invites = sCalendarMgr->GetPlayerInvites(guid); data << uint32(invites.size()); for (CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) { data << uint64((*itr)->GetEventId()); data << uint64((*itr)->GetInviteId()); data << uint8((*itr)->GetStatus()); data << uint8((*itr)->GetRank()); if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent((*itr)->GetEventId())) { data << uint8(calendarEvent->IsGuildEvent()); data.appendPackGUID(calendarEvent->GetCreatorGUID()); } else { data << uint8(0); data.appendPackGUID((*itr)->GetSenderGUID()); } } CalendarEventStore playerEvents = sCalendarMgr->GetPlayerEvents(guid); data << uint32(playerEvents.size()); for (CalendarEventStore::const_iterator itr = playerEvents.begin(); itr != playerEvents.end(); ++itr) { CalendarEvent* calendarEvent = *itr; data << uint64(calendarEvent->GetEventId()); data << calendarEvent->GetTitle(); data << uint32(calendarEvent->GetType()); data.AppendPackedTime(calendarEvent->GetEventTime()); data << uint32(calendarEvent->GetFlags()); data << int32(calendarEvent->GetDungeonId()); data.appendPackGUID(calendarEvent->GetCreatorGUID()); } data << uint32(currTime); // server time data.AppendPackedTime(currTime); // zone time ByteBuffer dataBuffer; uint32 boundCounter = 0; for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { BoundInstancesMap const& m_boundInstances = sInstanceSaveMgr->PlayerGetBoundInstances(_player->GetGUIDLow(), Difficulty(i)); for (BoundInstancesMap::const_iterator itr = m_boundInstances.begin(); itr != m_boundInstances.end(); ++itr) { if (itr->second.perm) { InstanceSave const* save = itr->second.save; time_t resetTime = itr->second.extended ? save->GetExtendedResetTime() : save->GetResetTime(); dataBuffer << uint32(save->GetMapId()); dataBuffer << uint32(save->GetDifficulty()); dataBuffer << uint32(resetTime >= currTime ? resetTime-currTime : 0); dataBuffer << uint64(MAKE_NEW_GUID(save->GetInstanceId(), 0, HIGHGUID_INSTANCE)); // instance save id as unique instance copy id ++boundCounter; } } } data << uint32(boundCounter); data.append(dataBuffer); // pussywizard uint32 relationTime = sWorld->getIntConfig(CONFIG_INSTANCE_RESET_TIME_RELATIVE_TIMESTAMP) + sWorld->getIntConfig(CONFIG_INSTANCE_RESET_TIME_HOUR) * HOUR; // set point in time (default 29.12.2005) + X hours data << uint32(relationTime); // Reuse variables boundCounter = 0; std::set<uint32> sentMaps; dataBuffer.clear(); ResetTimeByMapDifficultyMap const& resets = sInstanceSaveMgr->GetResetTimeMap(); for (ResetTimeByMapDifficultyMap::const_iterator itr = resets.begin(); itr != resets.end(); ++itr) { uint32 mapId = PAIR32_LOPART(itr->first); if (sentMaps.find(mapId) != sentMaps.end()) continue; MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); if (!mapEntry || !mapEntry->IsRaid()) continue; sentMaps.insert(mapId); dataBuffer << int32(mapId); time_t period = sInstanceSaveMgr->GetExtendedResetTimeFor(mapId, (Difficulty)PAIR32_HIPART(itr->first)) - itr->second; dataBuffer << int32(period); // pussywizard: reset time period dataBuffer << int32(0); // pussywizard: reset time offset, needed for other than 7-day periods if not aligned with relationTime ++boundCounter; } data << uint32(boundCounter); data.append(dataBuffer); // TODO: Fix this, how we do know how many and what holidays to send? data << uint32(sGameEventMgr->modifiedHolidays.size()); for (uint32 entry : sGameEventMgr->modifiedHolidays) { HolidaysEntry const* holiday = sHolidaysStore.LookupEntry(entry); data << uint32(holiday->Id); // m_ID data << uint32(holiday->Region); // m_region, might be looping data << uint32(holiday->Looping); // m_looping, might be region data << uint32(holiday->Priority); // m_priority data << uint32(holiday->CalendarFilterType); // m_calendarFilterType for (uint8 j = 0; j < MAX_HOLIDAY_DATES; ++j) data << uint32(holiday->Date[j]); // 26 * m_date -- WritePackedTime ? for (uint8 j = 0; j < MAX_HOLIDAY_DURATIONS; ++j) data << uint32(holiday->Duration[j]); // 10 * m_duration for (uint8 j = 0; j < MAX_HOLIDAY_FLAGS; ++j) data << uint32(holiday->CalendarFlags[j]); // 10 * m_calendarFlags data << holiday->TextureFilename; // m_textureFilename (holiday name) } SendPacket(&data); }