Exemple #1
0
        private void CharacterList()
        {
            var packet = new Packet(Opcode.PLAYERLIST);

            packet.WriteInt32(DateTime.UtcNow.GetUnixTimestamp());
            packet.WriteByte((byte) (User.AcceptedAgreement ? 0 : 1));

            var characters = User.Characters.Where(c => !c.Deleted && !c.Blocked).ToList();
            packet.WriteByte((byte) characters.Count);
            foreach (var character in characters)
            {
                packet.WriteInt32(character.Slot);

                packet.WriteString(character.Name);
                packet.WriteInt32(character.Id);

                packet.WriteInt32(character.WorldId);
                packet.WriteByte(character.Gender);
                packet.WritePosition(character.Position);

                packet.WriteInt32(character.Level);
                packet.WriteInt32(character.Job);

                packet.WriteInt32(character.Stats.STR);
                packet.WriteInt32(character.Stats.STA);
                packet.WriteInt32(character.Stats.DEX);
                packet.WriteInt32(character.Stats.INT);
                packet.WriteInt32(character.Stats.SPI);

                packet.WriteInt32(character.Appearance.HairMesh);
                packet.WriteUInt32((uint) character.Appearance.HairColor);
                packet.WriteInt32(character.Appearance.HeadMesh);

                packet.WriteInt32(character.Blocked ? 1 : 0);
                packet.WriteInt32(character.BlockTime);

                //TODO: Clean this up.

                var container = new ItemContainer<InventoryItem>(character, character.InventoryItems, (byte) Define.MAX_INVENTORY, (byte) Define.MAX_HUMAN_PARTS, Constants.InventorySlots);

                var equipmentItems = container.EquippedItems.ToList();

                packet.WriteInt32(equipmentItems.Count); //TODO: Implement non-fashion items.

                //  for i = 1, count do
                //    parts = LAr:ReadByte(ar)
                //    item_id = LAr:ReadDword(ar)
                //    flag = LAr:ReadDword(ar)
                //    attr = LAr:ReadInt(ar)
                //  end

                for(var i = 1; i <= 5; i++)
                {
                    var item = character.Closet.Items.FirstOrDefault(c => c.Equipped && c.Index == i);

                    packet.WriteInt32(item != null ? item.ItemId : 0);
                }
            }

            packet.WriteInt32(User.Characters.Count(c => c.Deleted));

            //TODO: Implement city/province.
            packet.WriteInt32(0); //City Id
            packet.WriteInt32(0); //Province Id

            packet.WriteSByte(20); //TODO: Find out what this is.

            Send(packet);
        }
        private void CharacterList()
        {
            var packet = new Packet(Opcode.PLAYERLIST);

            packet.WriteInt32(DateTime.UtcNow.GetUnixTimestamp());
            packet.WriteByte((byte)(User.AcceptedAgreement ? 0 : 1));

            var characters = User.Characters.Where(c => !c.Deleted && !c.Blocked).ToList();

            packet.WriteByte((byte)characters.Count);
            foreach (var character in characters)
            {
                packet.WriteInt32(character.Slot);

                packet.WriteString(character.Name);
                packet.WriteInt32(character.Id);

                packet.WriteInt32(character.WorldId);
                packet.WriteByte(character.Gender);
                packet.WritePosition(character.Position);

                packet.WriteInt32(character.Level);
                packet.WriteInt32(character.Job);

                packet.WriteInt32(character.Stats.STR);
                packet.WriteInt32(character.Stats.STA);
                packet.WriteInt32(character.Stats.DEX);
                packet.WriteInt32(character.Stats.INT);
                packet.WriteInt32(character.Stats.SPI);

                packet.WriteInt32(character.Appearance.HairMesh);
                packet.WriteUInt32((uint)character.Appearance.HairColor);
                packet.WriteInt32(character.Appearance.HeadMesh);

                packet.WriteInt32(character.Blocked ? 1 : 0);
                packet.WriteInt32(character.BlockTime);

                //TODO: Clean this up.

                var container = new ItemContainer <InventoryItem>(character, character.InventoryItems, (byte)Define.MAX_INVENTORY, (byte)Define.MAX_HUMAN_PARTS, Constants.InventorySlots);

                var equipmentItems = container.EquippedItems.ToList();

                packet.WriteInt32(equipmentItems.Count);                 //TODO: Implement non-fashion items.

                //  for i = 1, count do
                //    parts = LAr:ReadByte(ar)
                //    item_id = LAr:ReadDword(ar)
                //    flag = LAr:ReadDword(ar)
                //    attr = LAr:ReadInt(ar)
                //  end

                for (var i = 1; i <= 5; i++)
                {
                    var item = character.Closet.Items.FirstOrDefault(c => c.Equipped && c.Index == i);

                    packet.WriteInt32(item != null ? item.ItemId : 0);
                }
            }

            packet.WriteInt32(User.Characters.Count(c => c.Deleted));

            //TODO: Implement city/province.
            packet.WriteInt32(0);             //City Id
            packet.WriteInt32(0);             //Province Id

            packet.WriteSByte(20);            //TODO: Find out what this is.

            Send(packet);
        }