本文整理汇总了C++中ObjectGuid::IsPet方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectGuid::IsPet方法的具体用法?C++ ObjectGuid::IsPet怎么用?C++ ObjectGuid::IsPet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectGuid
的用法示例。
在下文中一共展示了ObjectGuid::IsPet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendPetNameQuery
void WorldSession::SendPetNameQuery( ObjectGuid petguid, uint32 petnumber)
{
//Client asks for data before add to map (or we have wrong teleport sequence), so we cant use GetCreatureOrPetOrVehicle()
Creature* pet = NULL;
if(_player->IsBeingTeleported())
{
Map *map = sMapMgr.FindMap(_player->GetTeleportDest().mapid);
if(map)
{
if (petguid.IsPet())
pet = map->GetPet(petguid);
else if(petguid.IsVehicle())
pet = (Creature*)map->GetVehicle(petguid);
else
pet = map->GetCreature(petguid);
}
}
else
pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, petguid);
if (!pet || !pet->GetCharmInfo() || pet->GetCharmInfo()->GetPetNumber() != petnumber)
{
std::string name = "NoPetName";
WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4+4+name.size()+1));
data << uint32(petnumber);
data << name.c_str();
data << uint32(time(0));
data << uint8(0);
_player->GetSession()->SendPacket(&data);
// looking for errors
/* if (!pet)
sLog.outError("SendPetNameQuery:: Pet not found, not exist or not in world"); <-------
else if (!pet->GetCharmInfo())
sLog.outError("SendPetNameQuery:: Pet CharmInfo() not found");
else if (pet->GetCharmInfo()->GetPetNumber() != petnumber)
sLog.outError("SendPetNameQuery:: Pet number is not equal to requested petnumber"); */
return;
}
std::string name = pet->GetName();
WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4+4+name.size()+1));
data << uint32(petnumber);
data << name.c_str();
data << uint32(pet->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP));
if ( pet->isPet() && ((Pet*)pet)->GetDeclinedNames() )
{
data << uint8(1);
for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
data << ((Pet*)pet)->GetDeclinedNames()->name[i];
}
else
data << uint8(0);
_player->GetSession()->SendPacket(&data);
}
示例2: BuildChatPacket
size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string const& message, uint8 chatTag,
std::string const& senderName /*= ""*/, std::string const& receiverName /*= ""*/,
uint32 achievementId /*= 0*/, bool gmMessage /*= false*/, std::string const& channelName /*= ""*/)
{
size_t receiverGUIDPos = 0;
data.Initialize(!gmMessage ? SMSG_MESSAGECHAT : SMSG_GM_MESSAGECHAT);
data << uint8(chatType);
data << int32(language);
data << uint64(senderGUID);
data << uint32(0); // some flags
switch (chatType)
{
case CHAT_MSG_MONSTER_SAY:
case CHAT_MSG_MONSTER_PARTY:
case CHAT_MSG_MONSTER_YELL:
case CHAT_MSG_MONSTER_WHISPER:
case CHAT_MSG_MONSTER_EMOTE:
case CHAT_MSG_RAID_BOSS_EMOTE:
case CHAT_MSG_RAID_BOSS_WHISPER:
case CHAT_MSG_BATTLENET:
data << uint32(senderName.length() + 1);
data << senderName;
receiverGUIDPos = data.wpos();
data << uint64(receiverGUID);
if (receiverGUID && !receiverGUID.IsPlayer() && !receiverGUID.IsPet())
{
data << uint32(receiverName.length() + 1);
data << receiverName;
}
break;
case CHAT_MSG_WHISPER_FOREIGN:
data << uint32(senderName.length() + 1);
data << senderName;
receiverGUIDPos = data.wpos();
data << uint64(receiverGUID);
break;
case CHAT_MSG_BG_SYSTEM_NEUTRAL:
case CHAT_MSG_BG_SYSTEM_ALLIANCE:
case CHAT_MSG_BG_SYSTEM_HORDE:
receiverGUIDPos = data.wpos();
data << uint64(receiverGUID);
if (receiverGUID && !receiverGUID.IsPlayer())
{
data << uint32(receiverName.length() + 1);
data << receiverName;
}
break;
case CHAT_MSG_ACHIEVEMENT:
case CHAT_MSG_GUILD_ACHIEVEMENT:
receiverGUIDPos = data.wpos();
data << uint64(receiverGUID);
break;
default:
if (gmMessage)
{
data << uint32(senderName.length() + 1);
data << senderName;
}
if (chatType == CHAT_MSG_CHANNEL)
{
ASSERT(channelName.length() > 0);
data << channelName;
}
receiverGUIDPos = data.wpos();
data << uint64(receiverGUID);
break;
}
data << uint32(message.length() + 1);
data << message;
data << uint8(chatTag);
if (chatType == CHAT_MSG_ACHIEVEMENT || chatType == CHAT_MSG_GUILD_ACHIEVEMENT)
data << uint32(achievementId);
return receiverGUIDPos;
}
示例3: BuildChatPacket
size_t ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string const& message, uint8 chatTag,
std::string const& senderName /*= ""*/, std::string const& receiverName /*= ""*/,
uint32 achievementId /*= 0*/, bool gmMessage /*= false*/, std::string const& channelName /*= ""*/,
std::string const& addonPrefix /*= ""*/)
{
size_t receiverGUIDPos = 0;
data.Initialize(!gmMessage ? SMSG_MESSAGECHAT : SMSG_GM_MESSAGECHAT);
data << uint8(chatType);
data << int32(language);
data << uint64(senderGUID);
data << uint32(0); // some flags
switch (chatType)
{
case CHAT_MSG_MONSTER_SAY:
case CHAT_MSG_MONSTER_PARTY:
case CHAT_MSG_MONSTER_YELL:
case CHAT_MSG_MONSTER_WHISPER:
case CHAT_MSG_MONSTER_EMOTE:
case CHAT_MSG_RAID_BOSS_EMOTE:
case CHAT_MSG_RAID_BOSS_WHISPER:
case CHAT_MSG_BATTLENET:
data << uint32(senderName.length() + 1);
data << senderName;
receiverGUIDPos = data.wpos();
data << uint64(receiverGUID);
if (receiverGUID && !receiverGUID.IsPlayer() && !receiverGUID.IsPet())
{
data << uint32(receiverName.length() + 1);
data << receiverName;
}
if (language == LANG_ADDON)
data << addonPrefix;
break;
case CHAT_MSG_WHISPER_FOREIGN:
data << uint32(senderName.length() + 1);
data << senderName;
receiverGUIDPos = data.wpos();
data << uint64(receiverGUID);
if (language == LANG_ADDON)
data << addonPrefix;
break;
case CHAT_MSG_BG_SYSTEM_NEUTRAL:
case CHAT_MSG_BG_SYSTEM_ALLIANCE:
case CHAT_MSG_BG_SYSTEM_HORDE:
receiverGUIDPos = data.wpos();
data << uint64(receiverGUID);
if (receiverGUID && !receiverGUID.IsPlayer())
{
data << uint32(receiverName.length() + 1);
data << receiverName;
}
if (language == LANG_ADDON)
data << addonPrefix;
break;
case CHAT_MSG_ACHIEVEMENT:
case CHAT_MSG_GUILD_ACHIEVEMENT:
receiverGUIDPos = data.wpos();
data << uint64(receiverGUID);
if (language == LANG_ADDON)
data << addonPrefix;
break;
default:
if (gmMessage)
{
data << uint32(senderName.length() + 1);
data << senderName;
}
if (chatType == CHAT_MSG_CHANNEL)
{
ASSERT(channelName.length() > 0);
data << channelName;
}
receiverGUIDPos = data.wpos();
data << uint64(receiverGUID);
if (language == LANG_ADDON)
data << addonPrefix;
break;
}
data << uint32(message.length() + 1);
data << message;
data << uint8(chatTag);
if (chatType == CHAT_MSG_ACHIEVEMENT || chatType == CHAT_MSG_GUILD_ACHIEVEMENT)
data << uint32(achievementId);
else if (chatType == CHAT_MSG_RAID_BOSS_WHISPER || chatType == CHAT_MSG_RAID_BOSS_EMOTE)
{
data << float(0.0f); // Display time in middle of the screen (in seconds), defaults to 10 if not set (cannot be below 1)
data << uint8(0); // Hide in chat frame (only shows in middle of the screen)
}
return receiverGUIDPos;
}