void WorldSession::SendPetNameQuery(ObjectGuid petguid, uint32 petnumber) const { Creature* pet = _player->GetMap()->GetAnyTypeCreature(petguid); // When replying to a query, verify input against public field info only (where it comes from) if (!pet || !pet->GetCharmInfo() || (pet->GetUInt32Value(UNIT_FIELD_PETNUMBER) && pet->GetUInt32Value(UNIT_FIELD_PETNUMBER) != petnumber)) { WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4 + 1 + 4 + 1)); data << uint32(petnumber); data << uint8(0); data << uint32(0); data << uint8(0); _player->GetSession()->SendPacket(data); return; } char const* name = pet->GetName(); // creature pets have localization like other creatures if (!pet->GetOwnerGuid().IsPlayer()) { int loc_idx = GetSessionDbLocaleIndex(); sObjectMgr.GetCreatureLocaleStrings(pet->GetEntry(), loc_idx, &name); } WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4 + 4 + strlen(name) + 1)); data << uint32(petnumber); data << name; data << uint32(pet->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP)); _player->GetSession()->SendPacket(data); }
void WorldSession::SendPetNameQuery(ObjectGuid petguid, uint32 petnumber) { Creature* pet = _player->GetMap()->GetAnyTypeCreature(petguid); if (!pet || !pet->GetCharmInfo() || pet->GetCharmInfo()->GetPetNumber() != petnumber) return; char const* name = pet->GetName(); // creature pets have localization like other creatures if (!pet->GetOwnerGuid().IsPlayer()) { int loc_idx = GetSessionDbLocaleIndex(); sObjectMgr.GetCreatureLocaleStrings(pet->GetEntry(), loc_idx, &name); } WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4 + 4 + strlen(name) + 1)); data << uint32(petnumber); data << name; 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); }
bool WorldSession::CheckMailBox(ObjectGuid guid) { // GM case if (guid == GetPlayer()->GetObjectGuid()) { // command case will return only if player have real access to command if (!ChatHandler(GetPlayer()).FindCommand("mailbox")) { DEBUG_LOG("%s attempt open mailbox in cheating way.", guid.GetString().c_str()); return false; } } // mailbox case else if (guid.IsGameObject()) { if (!GetPlayer()->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_MAILBOX)) { DEBUG_LOG("Mailbox %s not found or %s can't interact with him.", guid.GetString().c_str(), GetPlayer()->GetGuidStr().c_str()); return false; } } // squire case else if (guid.IsAnyTypeCreature()) { Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); if (!creature) { DEBUG_LOG("%s not found or %s can't interact with him.", creature->GetGuidStr().c_str(), GetPlayer()->GetGuidStr().c_str()); return false; } if (!(creature->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_SQUIRE)) { DEBUG_LOG("%s not have access to mailbox.", creature->GetGuidStr().c_str()); return false; } if (creature->GetOwnerGuid() != GetPlayer()->GetObjectGuid()) { DEBUG_LOG("%s not owned by %s for access to mailbox.", creature->GetGuidStr().c_str(), GetPlayer()->GetGuidStr().c_str()); return false; } } else return false; return true; }
void WorldSession::SendPetNameQuery(ObjectGuid petguid, uint32 petnumber) { Creature* pet = _player->GetMap()->GetAnyTypeCreature(petguid); if (!pet || !pet->GetCharmInfo() || pet->GetCharmInfo()->GetPetNumber() != petnumber) { return; } char const* name = pet->GetName(); // creature pets have localization like other creatures if (!pet->GetOwnerGuid().IsPlayer()) { int loc_idx = GetSessionDbLocaleIndex(); sObjectMgr.GetCreatureLocaleStrings(pet->GetEntry(), loc_idx, &name); } WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4 + 4 + strlen(name) + 1)); data << uint32(petnumber); data << name; data << uint32(pet->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP)); _player->GetSession()->SendPacket(&data); }
void FollowMovementGenerator<Creature>::_updateSpeed(Creature& u) { // pet only sync speed with owner if (!((Creature&)u).IsPet() || !i_target.isValid() || i_target->GetObjectGuid() != u.GetOwnerGuid()) return; u.UpdateSpeed(MOVE_RUN, true); u.UpdateSpeed(MOVE_WALK, true); u.UpdateSpeed(MOVE_SWIM, true); }