Esempio n. 1
0
 private async void RequestChannelList()
 {
     BncsPacket pckChanReq = new BncsPacket(BncsPacketId.GetChannelList, _storage.Acquire());
     pckChanReq.InsertDwordString(_settings.Client.ProductCode);
     await pckChanReq.SendAsync(_connection);
 }
Esempio n. 2
0
        private async void HandleLogonResponse2(BncsReader dr)
        {
            int success = dr.ReadInt32();
            if (success == 0)
            {
                OnLoginSucceeded();
                ClassicProduct product = _settings.Client;
                if (product.UsesUdpPing)
                {
                    BncsPacket pck = new BncsPacket(BncsPacketId.UdpPingResponse, _storage.Acquire());
                    pck.InsertDwordString("bnet");
                    await pck.SendAsync(_connection);
                }

                EnterChat();
            }
            else
            {
                LoginFailureReason reason = LoginFailureReason.Unknown;
                switch (success)
                {
                    case 1: // account DNE
                        reason = LoginFailureReason.AccountDoesNotExist; break;
                    case 2: // invalid password
                        reason = LoginFailureReason.InvalidAccountOrPassword; break;
                    case 6: // account closed
                        reason = LoginFailureReason.AccountClosed; break;
                }
                LoginFailedEventArgs args = new LoginFailedEventArgs(reason, success, dr.ReadCString());
                OnLoginFailed(args);
            }
        }
Esempio n. 3
0
        private async void EnterChat()
        {
            // this does two things.
            // in War3 and W3xp both string fields are null, but in older clients, the first string field is 
            // the username.  And, War3 and W3xp send the SID_NETGAMEPORT packet before entering chat, so we
            // send that packet, then insert the empty string into the ENTERCHAT packet.  We of course go to 
            // the other branch that inserts the username into the packet for older clients.
            // new for War3: it also sends a packet that seems to be required, 0x44 subcommand 2 (get ladder map info)
            BncsPacket pck = new BncsPacket(BncsPacketId.EnterChat, _storage.Acquire());

            bool isClientWar3 = (_settings.Client.Equals(ClassicProduct.Warcraft3Retail) || _settings.Client.Equals(ClassicProduct.Warcraft3Expansion));
            bool isClientStar = (_settings.Client.Equals(ClassicProduct.StarcraftRetail) || _settings.Client.Equals(ClassicProduct.StarcraftBroodWar));
            if (isClientWar3)
            {
                BncsPacket pck0x45 = new BncsPacket(BncsPacketId.NetGamePort, _storage.Acquire());
                pck0x45.InsertInt16(6112);
                await pck0x45.SendAsync(_connection);

                BncsPacket pckGetLadder = new BncsPacket(BncsPacketId.WarcraftGeneral, _storage.Acquire());
                pckGetLadder.InsertByte((byte)WarcraftCommands.RequestLadderMap);
                pckGetLadder.InsertInt32(1); // cookie
                pckGetLadder.InsertByte(5); // number of types requested
                //pckGetLadder.InsertDwordString("URL");
                pckGetLadder.InsertInt32(0x004d4150);
                pckGetLadder.InsertInt32(0);
                //pckGetLadder.InsertDwordString("MAP");
                pckGetLadder.InsertInt32(0x0055524c);
                pckGetLadder.InsertInt32(0);
                pckGetLadder.InsertDwordString("TYPE");
                pckGetLadder.InsertInt32(0);
                pckGetLadder.InsertDwordString("DESC");
                pckGetLadder.InsertInt32(0);
                pckGetLadder.InsertDwordString("LADR");
                pckGetLadder.InsertInt32(0);
                await pckGetLadder.SendAsync(_connection);

                pck.InsertCString(string.Empty);
            }
            else
            {
                pck.InsertCString(_settings.Username);
            }
            pck.InsertCString(string.Empty);
            await pck.SendAsync(_connection);

            if (!isClientWar3)
            {
                RequestChannelList();

                //BncsPacket pckJoinChannel = new BncsPacket(BncsPacketId.JoinChannel, _storage.Acquire());
                //string client = "Starcraft";
                //switch (_settings.Client.ProductCode)
                //{
                //    case "SEXP":
                //        client = "Brood War";
                //        break;
                //    case "W2BN":
                //        client = "Warcraft II BNE";
                //        break;
                //    case "D2DV":
                //        client = "Diablo II";
                //        break;
                //    case "D2XP":
                //        client = "Lord of Destruction";
                //        break;
                //}
                //pckJoinChannel.InsertInt32((int)ChannelJoinFlags.FirstJoin);
                //pckJoinChannel.InsertCString(client);
                //await pckJoinChannel.SendAsync(_connection);
            }

            if (isClientWar3 || isClientStar)
            {
                pck = new BncsPacket(BncsPacketId.FriendsList, _storage.Acquire());
                await pck.SendAsync(_connection);
            }

            //m_tmr.Start();
        }
Esempio n. 4
0
        private async void HandleLogonResponse(BncsReader dr)
        {
            int status = dr.ReadInt32();
            if (status == 1)
            {
                OnLoginSucceeded();
                ClassicProduct product = _settings.Client;
                if (product.UsesUdpPing)
                {
                    BncsPacket pck = new BncsPacket(BncsPacketId.UdpPingResponse, _storage.Acquire());
                    pck.InsertDwordString("bnet");
                    await pck.SendAsync(_connection);
                }

                EnterChat();
            }
            else
            {
                LoginFailedEventArgs args = new LoginFailedEventArgs(LoginFailureReason.InvalidAccountOrPassword, status);
                OnLoginFailed(args);
            }
        }