Esempio n. 1
0
    public async ValueTask WriteAsync(ChannelWriter <byte> writer, AUTH_LOGON_PROOF packet)
    {
        await writer.WriteAsync((byte)AuthCMD.CMD_AUTH_LOGON_PROOF);

        await writer.WriteAsync((byte)packet.AccountState);

        if (packet.M2 != null)
        {
            await writer.WriteEnumerableAsync(packet.M2);

            await writer.WriteZeroNCountAsync(4);
        }
    }
Esempio n. 2
0
    public async ValueTask WriteAsync(ChannelWriter <byte> writer, AUTH_LOGON_CHALLENGE packet)
    {
        await writer.WriteAsync((byte)AuthCMD.CMD_AUTH_LOGON_CHALLENGE);

        await writer.WriteAsync((byte)AccountState.LOGIN_OK);

        await writer.WriteAsync(0);

        await writer.WriteEnumerableAsync(packet.PublicB);

        await writer.WriteAsync((byte)packet.G.Length);

        await writer.WriteAsync(packet.G[0]);

        await writer.WriteAsync(32);

        await writer.WriteEnumerableAsync(packet.N);

        await writer.WriteEnumerableAsync(packet.Salt);

        await writer.WriteEnumerableAsync(packet.CrcSalt);

        await writer.WriteAsync(0);
    }
Esempio n. 3
0
 public static async ValueTask WriteFloatAsync(this ChannelWriter <byte> writer, float data)
 {
     await writer.WriteEnumerableAsync(BitConverter.GetBytes(data));
 }
Esempio n. 4
0
        public async ValueTask WriteAsync(ChannelWriter <byte> writer, AUTH_REALMLIST packet)
        {
            var t = Channel.CreateUnbounded <byte>();
            //writer = t.Writer;

            var responseBodyLength = packet.Realms.Sum(x =>
                                                       5
                                                       + x.Name.Length + 1
                                                       + x.Address.Length + 1 + x.Port.Length + 1
                                                       + 7) + 7;

            await writer.WriteAsync((byte)AuthCMD.CMD_AUTH_REALMLIST);

            await writer.WriteAsync((byte)(responseBodyLength % 256));

            await writer.WriteAsync((byte)(responseBodyLength / 256));

            await writer.WriteEnumerableAsync(packet.Unk);

            await writer.WriteAsync((byte)packet.Realms.Length);

            foreach (var realmListItem in packet.Realms)
            {
                // (uint8) Realm Icon
                // 0 -> Normal; 1 -> PvP; 6 -> RP; 8 -> RPPvP;
                await writer.WriteAsync(realmListItem.Icon);

                // (uint8) IsLocked
                // 0 -> none; 1 -> locked
                await writer.WriteAsync(0);

                // (uint8) unk
                await writer.WriteAsync(0);

                // (uint8) unk
                await writer.WriteAsync(0);

                // (uint8) Realm Color
                // 0 -> Green; 1 -> Red; 2 -> Offline;
                await writer.WriteAsync(realmListItem.Realmflags);

                // (string) Realm Name (zero terminated)
                await writer.WriteEnumerableAsync(Encoding.UTF8.GetBytes(realmListItem.Name));

                await writer.WriteAsync(0);

                // (string) Realm Address ("ip:port", zero terminated)
                await writer.WriteEnumerableAsync(Encoding.UTF8.GetBytes($"{realmListItem.Address}:{realmListItem.Port}"));

                await writer.WriteAsync(0);

                // (float) Population
                // 400F -> Full; 5F -> Medium; 1.6F -> Low; 200F -> New; 2F -> High
                // 00 00 48 43 -> Recommended
                // 00 00 C8 43 -> Full
                // 9C C4 C0 3F -> Low
                // BC 74 B3 3F -> Low
                await writer.WriteFloatAsync(realmListItem.Population);

                // (byte) Number of character at this realm for this account
                await writer.WriteAsync((byte)realmListItem.CharacterCount);

                // (byte) Timezone
                // 0x01 - Development
                // 0x02 - USA
                // 0x03 - Oceania
                // 0x04 - LatinAmerica
                // 0x05 - Tournament
                // 0x06 - Korea
                // 0x07 - Tournament
                // 0x08 - UnitedKingdom
                // 0x09 - Germany
                // 0x0A - France
                // 0x0B - Spain
                // 0x0C - Russian
                // 0x0D - Tournament
                // 0x0E - Taiwan
                // 0x0F - Tournament
                // 0x10 - China
                // 0x11 - CN1
                // 0x12 - CN2
                // 0x13 - CN3
                // 0x14 - CN4
                // 0x15 - CN5
                // 0x16 - CN6
                // 0x17 - CN7
                // 0x18 - CN8
                // 0x19 - Tournament
                // 0x1A - Test Server
                // 0x1B - Tournament
                // 0x1C - QA Server
                // 0x1D - CN9
                // 0x1E - Test Server 2
                await writer.WriteAsync(realmListItem.Timezone);

                // (byte) Unknown (may be 2 -> TestRealm, / 6 -> ?)
                await writer.WriteAsync(0);
            }

            await writer.WriteAsync(2); // 2=list of realms 0=wizard

            await writer.WriteAsync(0);
        }