Example #1
0
        void SendQueryPetNameResponse(ObjectGuid guid)
        {
            QueryPetNameResponse response = new QueryPetNameResponse();

            response.UnitGUID = guid;

            Creature unit = ObjectAccessor.GetCreatureOrPetOrVehicle(GetPlayer(), guid);

            if (unit)
            {
                response.Allow     = true;
                response.Timestamp = unit.GetUInt32Value(UnitFields.PetNameTimestamp);
                response.Name      = unit.GetName();

                Pet pet = unit.ToPet();
                if (pet)
                {
                    DeclinedName names = pet.GetDeclinedNames();
                    if (names != null)
                    {
                        response.HasDeclined   = true;
                        response.DeclinedNames = names;
                    }
                }
            }

            GetPlayer().SendPacket(response);
        }
Example #2
0
        void SendPetNameInvalid(PetNameInvalidReason error, string name, DeclinedName declinedName)
        {
            PetNameInvalid petNameInvalid = new PetNameInvalid();

            petNameInvalid.Result             = error;
            petNameInvalid.RenameData.NewName = name;
            for (int i = 0; i < SharedConst.MaxDeclinedNameCases; i++)
            {
                petNameInvalid.RenameData.DeclinedNames.name[i] = declinedName.name[i];
            }

            SendPacket(petNameInvalid);
        }
Example #3
0
        public bool Initialize(ObjectGuid guid, Player player = null)
        {
            CharacterInfo characterInfo = Global.WorldMgr.GetCharacterInfo(guid);

            if (characterInfo == null)
            {
                return(false);
            }

            if (player)
            {
                Contract.Assert(player.GetGUID() == guid);

                AccountID     = player.GetSession().GetAccountGUID();
                BnetAccountID = player.GetSession().GetBattlenetAccountGUID();
                Name          = player.GetName();
                RaceID        = player.GetRace();
                Sex           = (Gender)player.GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetGender);
                ClassID       = player.GetClass();
                Level         = (byte)player.getLevel();

                DeclinedName names = player.GetDeclinedNames();
                if (names != null)
                {
                    DeclinedNames = names;
                }
            }
            else
            {
                uint accountId     = ObjectManager.GetPlayerAccountIdByGUID(guid);
                uint bnetAccountId = Global.BNetAccountMgr.GetIdByGameAccount(accountId);

                AccountID     = ObjectGuid.Create(HighGuid.WowAccount, accountId);
                BnetAccountID = ObjectGuid.Create(HighGuid.BNetAccount, bnetAccountId);
                Name          = characterInfo.Name;
                RaceID        = characterInfo.RaceID;
                Sex           = characterInfo.Sex;
                ClassID       = characterInfo.ClassID;
                Level         = characterInfo.Level;
            }

            IsDeleted           = characterInfo.IsDeleted;
            GuidActual          = guid;
            VirtualRealmAddress = Global.WorldMgr.GetVirtualRealmAddress();

            return(true);
        }
Example #4
0
        public bool Initialize(ObjectGuid guid, Player player = null)
        {
            CharacterCacheEntry characterInfo = Global.CharacterCacheStorage.GetCharacterCacheByGuid(guid);

            if (characterInfo == null)
            {
                return(false);
            }

            if (player)
            {
                Cypher.Assert(player.GetGUID() == guid);

                AccountID     = player.GetSession().GetAccountGUID();
                BnetAccountID = player.GetSession().GetBattlenetAccountGUID();
                Name          = player.GetName();
                RaceID        = player.GetRace();
                Sex           = player.GetNativeSex();
                ClassID       = player.GetClass();
                Level         = (byte)player.GetLevel();

                DeclinedName names = player.GetDeclinedNames();
                if (names != null)
                {
                    DeclinedNames = names;
                }
            }
            else
            {
                uint accountId     = Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(guid);
                uint bnetAccountId = Global.BNetAccountMgr.GetIdByGameAccount(accountId);

                AccountID     = ObjectGuid.Create(HighGuid.WowAccount, accountId);
                BnetAccountID = ObjectGuid.Create(HighGuid.BNetAccount, bnetAccountId);
                Name          = characterInfo.Name;
                RaceID        = characterInfo.RaceId;
                Sex           = characterInfo.Sex;
                ClassID       = characterInfo.ClassId;
                Level         = characterInfo.Level;
            }

            IsDeleted           = characterInfo.IsDeleted;
            GuidActual          = guid;
            VirtualRealmAddress = Global.WorldMgr.GetVirtualRealmAddress();

            return(true);
        }
Example #5
0
        public void ModifyName(ObjectGuid guid, string name, DeclinedName declinedName)
        {
            if (!HasJournalLock())
            {
                return;
            }

            BattlePet pet = GetPet(guid);

            if (pet == null)
            {
                return;
            }

            pet.PacketInfo.Name = name;
            pet.NameTimestamp   = GameTime.GetGameTime();

            pet.DeclinedName = new DeclinedName();
            if (declinedName != null)
            {
                pet.DeclinedName = declinedName;
            }

            if (pet.SaveInfo != BattlePetSaveInfo.New)
            {
                pet.SaveInfo = BattlePetSaveInfo.Changed;
            }

            // Update the timestamp if the battle pet is summoned
            Player   player            = _owner.GetPlayer();
            Creature summonedBattlePet = ObjectAccessor.GetCreatureOrPetOrVehicle(player, player.GetCritterGUID());

            if (summonedBattlePet != null)
            {
                if (player.GetSummonedBattlePetGUID() == summonedBattlePet.GetBattlePetCompanionGUID())
                {
                    if (summonedBattlePet.GetBattlePetCompanionGUID() == guid)
                    {
                        summonedBattlePet.SetBattlePetCompanionNameTimestamp((uint)pet.NameTimestamp);
                    }
                }
            }
        }
Example #6
0
        public override void Read()
        {
            PetGuid = _worldPacket.ReadPackedGuid();
            uint nameLength = _worldPacket.ReadBits <uint>(7);

            if (_worldPacket.HasBit())
            {
                Declined = new DeclinedName();

                byte[] declinedNameLengths = new byte[SharedConst.MaxDeclinedNameCases];

                for (byte i = 0; i < SharedConst.MaxDeclinedNameCases; ++i)
                {
                    declinedNameLengths[i] = _worldPacket.ReadBits <byte>(7);
                }

                for (byte i = 0; i < SharedConst.MaxDeclinedNameCases; ++i)
                {
                    Declined.name[i] = _worldPacket.ReadString(declinedNameLengths[i]);
                }
            }

            Name = _worldPacket.ReadString(nameLength);
        }
 public SetPlayerDeclinedNames(WorldPacket packet) : base(packet)
 {
     DeclinedNames = new DeclinedName();
 }