Exemplo n.º 1
0
        public void Marshal(Span <byte> span, int protocolVersion)
        {
            var writer = new SpanWriter(span);

            writer.WriteShortString(_user);
            writer.WriteShortString(_serverName);
            writer.WriteByte(_serverId);
            writer.WriteByte((byte)_pvpMode);
            writer.WriteByte((byte)(_trialAccount ? 1 : 0));
        }
Exemplo n.º 2
0
        => 1 + 4 + 4 + 4;     // Type + Page Offset + Date + Size

        public override void SerializeTypeMeta(ref SpanWriter writer)
        {
            writer.WriteByte((byte)EntryType);

            writer.WriteInt32(PageOffset);
            writer.WriteDateTimeT(ModifiedDate);
            writer.WriteInt32(Size);
        }
Exemplo n.º 3
0
        public void Marshal(Span <byte> span, int protocolVersion)
        {
            var writer = new SpanWriter(span);

            writer.WriteFixedString(_name, 30);
            writer.WriteFixedString(_user, 24);
            writer.WriteByte((byte)_status);
            // 3 unknown bytes
        }
Exemplo n.º 4
0
        public void Marshal(Span <byte> span, int protocolVersion)
        {
            var writer = new SpanWriter(span);

            writer.Skip(8);
            foreach (var c in _characters)
            {
                if (c == null)
                {
                    writer.WriteByte(0);
                }
                else
                {
                    writer.WriteByte(c.Level);
                    writer.WriteDaocString(c.Name);
                    writer.WriteUInt32LittleEndian(0x18);
                    writer.Write(c.Customization);
                    writer.Skip(13);
                    writer.WriteDaocString(c.LocationDescription);
                    writer.WriteDaocString(c.Classification.Class.DisplayName());
                    writer.WriteDaocString(c.Classification.Race.ToString());
                    writer.WriteUInt16LittleEndian(c.Model);
                    writer.WriteUInt16LittleEndian(c.Region);
                    writer.Write(c.Equipment);
                    writer.Write(c.Stats);
                    writer.Write(c.Classification);
                    // active weapon slots - see DoL's PacketLib1125.cs line 340
                    writer.WriteByte(0xFF);
                    writer.WriteByte(0xFF);
                    writer.WriteByte(0x01);                     // something about region
                    writer.WriteByte(c.Stats.Constitution);
                }
            }
            // TODO real stuff - see DoL's PacketLib1125.SendCharacterOverview
        }
Exemplo n.º 5
0
        public void Marshal(Span <byte> span, int protocolVersion)
        {
            var writer = new SpanWriter(span);
            var coords = _character.Coordinates;

            writer.WriteFloat(coords.X);
            writer.WriteFloat(coords.Y);
            writer.WriteFloat(coords.Z);
            writer.WriteUInt16LittleEndian(1);             // arbitrary object id
            writer.WriteUInt16LittleEndian(coords.Heading);
            // next two shorts have something to do with dungeons
            writer.WriteUInt16LittleEndian(0);
            writer.WriteUInt16LittleEndian(0);
            // unsure about byte order here
            // might have missed something in the DoL version
            //writer.WriteUInt16LittleEndian(_character.Region);
            writer.WriteUInt16BigEndian(_character.Region);
            writer.WriteByte(0x80);             // 0x80 = diving enabled - TODO get from region
            // DoL sends server name if current region is housing, otherwise 0x00
            writer.WriteByte(0);
            // 4 more 0x00 bytes
        }
Exemplo n.º 6
0
        public static void EncodeAndAdvance(ref SpanWriter sw, uint value)
        {
            uint        mask   = 0x80;
            Span <byte> buffer = Array.Empty <byte>();

            if (value <= 0x7F)
            {
                sw.WriteByte((byte)value);
                return;
            }
            else if (value <= 0x3FFF)
            {
                Span <byte> tempBuf = BitConverter.GetBytes(value).AsSpan();
                tempBuf.Reverse();
                buffer = tempBuf.Slice(2, 2);
            }
            else if (value <= 0x1FFFFF)
            {
                Span <byte> tempBuf = BitConverter.GetBytes(value).AsSpan();
                tempBuf.Reverse();
                buffer = tempBuf.Slice(1, 3);
            }
            else if (value <= 0xFFFFFFF)
            {
                buffer = BitConverter.GetBytes(value);
                buffer.Reverse();
            }
            else if (value <= 0xFFFFFFFF)
            {
                buffer = BitConverter.GetBytes(value);
                buffer.Reverse();
                buffer = new byte[] { 0, buffer[0], buffer[1], buffer[2], buffer[3] };
            }
            else
            {
                throw new Exception("????");
            }

            for (int i = 1; i < buffer.Length; i++)
            {
                buffer[0] += (byte)mask;
                mask     >>= 1;
            }

            sw.WriteBytes(buffer);
        }
Exemplo n.º 7
0
        public void Marshal(Span <byte> span, int protocolVersion)
        {
            var writer = new SpanWriter(span);
            var status = _character.Status;

            writer.WriteByte((byte)(status.Health * 100 / status.MaxHealth));
            writer.WriteByte((byte)(status.Mana * 100 / status.MaxMana));
            writer.WriteByte((byte)(_character.Sitting ? 0x02 : 0x00));
            writer.WriteByte((byte)(status.Endurance * 100 / status.MaxEndurance));
            writer.WriteByte((byte)(status.Concentration * 100 / status.MaxConcentration));
            // DoL represents "alive" as a separate property, but elsewhere uses health > 0
            // DoL hard codes 0x00 for alive - some doubt in comments about how to represent dead
            writer.WriteByte((byte)(status.Health > 0 ? 0x00 : 0x0F));
            writer.Write(status);
        }