本文整理汇总了C++中player::BoundInstancesMap类的典型用法代码示例。如果您正苦于以下问题:C++ BoundInstancesMap类的具体用法?C++ BoundInstancesMap怎么用?C++ BoundInstancesMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BoundInstancesMap类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleCalendarGetCalendar
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
std::vector<CalendarInvite*> invites = sCalendarMgr->GetPlayerInvites(guid);
data << uint32(invites.size());
for (std::vector<CalendarInvite*>::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());
Guild* guild = sGuildMgr->GetGuildById(calendarEvent->GetGuildId());
data << uint64(guild ? guild->GetGUID() : 0);
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)
{
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;
}
//.........这里部分代码省略.........
示例2: HandleCalendarGetCalendar
void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/)
{
ObjectGuid guid = _player->GetObjectGuid();
DEBUG_LOG("WORLD: Received opcode CMSG_CALENDAR_GET_CALENDAR [%s]", guid.GetString().c_str());
time_t currTime = time(nullptr);
WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR);
CalendarInvitesList invites;
sCalendarMgr.GetPlayerInvitesList(guid, invites);
data << uint32(invites.size());
DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "Sending > %u invites", uint32(invites.size()));
for (CalendarInvitesList::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
{
CalendarEvent const* event = (*itr)->GetCalendarEvent();
MANGOS_ASSERT(event); // TODO: be sure no way to have a null event
data << uint64(event->EventId);
data << uint64((*itr)->InviteId);
data << uint8((*itr)->Status);
data << uint8((*itr)->Rank);
data << uint8(event->IsGuildEvent());
data << event->CreatorGuid.WriteAsPacked();
DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "invite> EventId[" UI64FMTD "], InviteId[" UI64FMTD "], status[%u], rank[%u]",
event->EventId, (*itr)->InviteId, uint32((*itr)->Status), uint32((*itr)->Rank));
}
CalendarEventsList events;
sCalendarMgr.GetPlayerEventsList(guid, events);
data << uint32(events.size());
DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "Sending > %u events", uint32(events.size()));
for (CalendarEventsList::const_iterator itr = events.begin(); itr != events.end(); ++itr)
{
CalendarEvent const* event = *itr;
data << uint64(event->EventId);
data << event->Title;
data << uint32(event->Type);
data << secsToTimeBitFields(event->EventTime);
data << uint32(event->Flags);
data << int32(event->DungeonId);
data << event->CreatorGuid.WriteAsPacked();
std::string timeStr = TimeToTimestampStr(event->EventTime);
DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "Events> EventId[" UI64FMTD "], Title[%s], Time[%s], Type[%u], Flag[%u], DungeonId[%d], CreatorGuid[%s]",
event->EventId, event->Title.c_str(), timeStr.c_str(), uint32(event->Type),
uint32(event->Flags), event->DungeonId, event->CreatorGuid.GetString().c_str());
}
data << uint32(currTime); // server time
data << secsToTimeBitFields(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)
{
DungeonPersistentState const* state = itr->second.state;
dataBuffer << uint32(state->GetMapId());
dataBuffer << uint32(state->GetDifficulty());
dataBuffer << uint32(state->GetResetTime() - currTime);
dataBuffer << uint64(state->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();
for (MapDifficultyMap::const_iterator itr = sMapDifficultyMap.begin(); itr != sMapDifficultyMap.end(); ++itr)
{
uint32 map_diff_pair = itr->first;
uint32 mapId = PAIR32_LOPART(map_diff_pair);
MapDifficultyEntry const* mapDiff = itr->second;
// skip mapDiff without global reset time
if (!mapDiff->resetTime)
continue;
// skip non raid map
MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
if (!mapEntry || !mapEntry->IsRaid())
//.........这里部分代码省略.........
示例3: HandleCalendarGetCalendar
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 -> fuck 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]);
//.........这里部分代码省略.........