Esempio n. 1
0
        /// <summary>
        /// 
        /// </summary>
        public Word_CharEnumResponse( WowCharEnumCharacterInfo[] characterInfoArray )
            : base( (long)WordOpCode.SMSG_CHAR_ENUM, 0 )
        {
            WriterStream.Write( (ushort)0 /* 2 + ? */ );              // Size
            WriterStream.Write( (ushort)WordOpCode.SMSG_CHAR_ENUM );  // ID
            //////////////////////////////////////////////////////////////////////////

            WriterStream.Write( (byte)characterInfoArray.Length );

            if ( characterInfoArray.Length > 0 )
            {
                foreach ( WowCharEnumCharacterInfo wowCharacterInfo in characterInfoArray )
                {
                    WriterStream.Write( (ulong)wowCharacterInfo.CharacterGuid );
                    WriterStream.WriteUTF8Null( (string)wowCharacterInfo.Name );

                    WriterStream.Write( (byte)wowCharacterInfo.Race );
                    WriterStream.Write( (byte)wowCharacterInfo.Class );
                    WriterStream.Write( (byte)wowCharacterInfo.Gender );

                    WriterStream.Write( (byte)wowCharacterInfo.Skin );
                    WriterStream.Write( (byte)wowCharacterInfo.Face );
                    WriterStream.Write( (byte)wowCharacterInfo.HairStyle );
                    WriterStream.Write( (byte)wowCharacterInfo.HairColor );
                    WriterStream.Write( (byte)wowCharacterInfo.FacialHair );

                    WriterStream.Write( (byte)wowCharacterInfo.Level );

                    WriterStream.Write( (uint)wowCharacterInfo.ZoneId );
                    WriterStream.Write( (uint)wowCharacterInfo.MapId );

                    WriterStream.Write( (float)wowCharacterInfo.PositionX );
                    WriterStream.Write( (float)wowCharacterInfo.PositionY );
                    WriterStream.Write( (float)wowCharacterInfo.PositionZ );

                    WriterStream.Write( (uint)wowCharacterInfo.GuildGuid );

                    WriterStream.Write( (byte)0 );
                    // 0x01
                    // 0x02
                    // 0x04 - CHAR_LOGIN_LOCKED_FOR_TRANSFER
                    // 0x08
                    // 0x10
                    // 0x20
                    // 0x40

                    byte iFlags = 0;
                    if ( wowCharacterInfo.IsHideHelm == true )
                        iFlags |= 0x04;
                    if ( wowCharacterInfo.IsHideCloak == true )
                        iFlags |= 0x08;
                    if ( wowCharacterInfo.IsGhost == true )
                        iFlags |= 0x20;
                    if ( wowCharacterInfo.IsNeedRename == true )
                        iFlags |= 0x40;
                    WriterStream.Write( (byte)iFlags );

                    WriterStream.Write( (byte)0xA0 ); // unknown

                    WriterStream.Write( (byte)0 ); // unknown
                    // 0x01 - CHAR_LOGIN_LOCKED_BY_BILLING

                    WriterStream.Write( (byte)1 ); // unknown

                    if ( wowCharacterInfo.PetInfo!= null )
                    {
                        WriterStream.Write( (uint)wowCharacterInfo.PetInfo.PetModelId );
                        WriterStream.Write( (uint)wowCharacterInfo.PetInfo.PetLevel );
                        WriterStream.Write( (uint)wowCharacterInfo.PetInfo.PetFamily );
                    }
                    else
                    {
                        WriterStream.Write( (uint)0 );
                        WriterStream.Write( (uint)0 );
                        WriterStream.Write( (uint)0 );
                    }

                    for ( int iIndex = 0; iIndex < wowCharacterInfo.Equipment.Length; iIndex++ )
                    {
                        if ( wowCharacterInfo.Equipment[iIndex] != null )
                        {
                            WriterStream.Write( (uint)wowCharacterInfo.Equipment[iIndex].ModelID );
                            WriterStream.Write( (byte)wowCharacterInfo.Equipment[iIndex].InventoryType );
                        }
                        else
                        {
                            WriterStream.Write( (uint)0 );
                            WriterStream.Write( (byte)0 );
                        }
                    }

                    WriterStream.Write( (uint)0 ); // first bag display id
                    WriterStream.Write( (byte)0 ); // first bag inventory type
                }
            }

            //byte[] nnn = new byte[] { 
            //     0xD0, 0xF0, 0x4C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x61, 0x69, 0x68, 0x75, 0x61, 0x6E, 0x71, 0x69, 0x6E, 0x67, 0x00, 0x0A, 0x02, 0x01, 0x00, 0x03, 0x09, 0x05, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x02, 0x00, 0x00, 0x66, 0xB6, 0x21, 0x46, 0x52, 0xAA, 0xC6, 0xC5, 0x43, 0x9C, 0x05, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB5, 0x8F, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB6, 0x8F, 0x00, 0x00, 0x07, 0xB9, 0x8F, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x09, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
            //};

            //WriterStream.Write( nnn, 0, nnn.Length );

            //////////////////////////////////////////////////////////////////////////
            WriterStream.Seek( 0, SeekOrigin.Begin );
            WriterStream.Write( (ushort)ByteOrder.NetToHost( (ushort)( WriterStream.Length - 2/*Size本身的大小*/ ) ) );
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        private static void SQL_HandleCharEnum(CharEnumSQL sqlInfo)
        {
            XPQuery <Account> accounts = new XPQuery <Account>(OneDatabase.Session);

            var accountList = from account in accounts
                              where account.Oid == sqlInfo.WorldExtendData.CommonData.AccountsGuid
                              select account;


            XPCollection <CharacterBase> characterCollection = null;

            foreach (Account character in accountList)
            {
                characterCollection = character.Characters;
                break;
            }

            if (characterCollection == null)
            {
                Debug.WriteLine("World_PacketHandlers.SQL_HandleCharEnum(...) - characterCollection == null error!");
                return;
            }

            List <WowCharEnumCharacterInfo> characterInfoList = new List <WowCharEnumCharacterInfo>((int)WowCharacter.WOW_MAX_CHARACTER_COUNT);

            foreach (CharacterBase character in characterCollection)
            {
                WowCharEnumCharacterInfo characterInfo = new WowCharEnumCharacterInfo();

                characterInfo.CharacterGuid = (ulong)character.Oid;
                characterInfo.GuildGuid     = (uint)character.Account.Oid;
                characterInfo.Name          = character.CharacterName;
                characterInfo.Level         = (uint)character.Level;
                characterInfo.Race          = (uint)character.Race;
                characterInfo.Class         = (uint)character.Class;
                characterInfo.ZoneId        = (uint)character.ZoneId;
                characterInfo.MapId         = (uint)character.MapId;
                characterInfo.PositionX     = (uint)character.PositionX;
                characterInfo.PositionY     = (uint)character.PositionY;
                characterInfo.PositionZ     = (uint)character.PositionZ;
                characterInfo.Gender        = (uint)character.Gender;
                characterInfo.Face          = (uint)character.Face;
                characterInfo.HairStyle     = (uint)character.HairStyle;
                characterInfo.HairColor     = (uint)character.HairColor;
                characterInfo.FacialHair    = (uint)character.FacialHair;
                characterInfo.IsHideHelm    = false;
                characterInfo.IsHideCloak   = false;
                characterInfo.IsGhost       = character.IsGhost;
                characterInfo.IsNeedRename  = character.IsNeedRename;



                XPQuery <CharacterPet> creaturePets = new XPQuery <CharacterPet>(OneDatabase.Session);

                var creaturePetList = from creaturePet in creaturePets
                                      where creaturePet.Owner == character
                                      select creaturePet;

                foreach (CharacterPet creaturePet in creaturePetList)
                {
                    WowCreatureTemplate creatureTemplate = ProcessServer.WowZoneCluster.World.CreatureTemplateManager.GetCreatureTemplate((Serial)creaturePet.CreatureTemplateGuid) as WowCreatureTemplate;
                    if (creatureTemplate != null)
                    {
                        characterInfo.PetInfo.PetLevel   = (uint)creaturePet.Level;
                        characterInfo.PetInfo.PetModelId = creatureTemplate.ModelId;
                        characterInfo.PetInfo.PetFamily  = creatureTemplate.Family;
                    }

                    break;
                }



                XPQuery <CharacterItem> characterItems = new XPQuery <CharacterItem>(OneDatabase.Session);

                var characterItemList = from characterItem in characterItems
                                        where characterItem.Owner == character && characterItem.SlotId > EquipmentSlot.EquipmentSlotEnd && characterItem.BagId == InventorySlotBag.InventorySlotEquipmentBag
                                        select characterItem;

                foreach (CharacterItem characterItem in characterItemList)
                {
                    WowItemTemplate itemTemplate = ProcessServer.WowZoneCluster.World.ItemTemplateManager.GetItemTemplate((Serial)characterItem.ItemTemplateGuid) as WowItemTemplate;
                    if (itemTemplate == null)
                    {
                        continue;
                    }

                    characterInfo.Equipment[characterItem.SlotId] = itemTemplate;
                }


                characterInfoList.Add(characterInfo);
            }

            sqlInfo.NetState.Send(new Word_CharEnumResponse(characterInfoList.ToArray()));
        }