Пример #1
0
        /// <summary>
        /// Informs the server that an ad has been displayed.  This should be sent whenever an ad 
        /// is updated on the client.
        /// </summary>
        /// <param name="adID">The ID of the ad assigned by the server.</param>
        public virtual void DisplayAd(int adID)
        {
            BncsPacket pck = new BncsPacket((byte)BncsPacketId.DisplayAd);
            pck.InsertDwordString(PLATFORM_TYPE);
            pck.InsertDwordString(Settings.Client);
            pck.InsertInt32(adID);
            pck.InsertInt16(0); // NULL strings for filename and URL.

            Send(pck);
        }
Пример #2
0
        private 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((byte)BncsPacketId.EnterChat);

            bool isClientWar3 = (m_settings.Client.Equals("WAR3", StringComparison.Ordinal) || m_settings.Client.Equals("W3XP", StringComparison.Ordinal));
            bool isClientStar = (m_settings.Client.Equals("STAR", StringComparison.Ordinal) || m_settings.Client.Equals("SEXP", StringComparison.Ordinal));
            if (isClientWar3)
            {
                BncsPacket pck0x45 = new BncsPacket((byte)BncsPacketId.NetGamePort);
                pck0x45.InsertInt16(6112);
                Send(pck0x45);

                BncsPacket pckGetLadder = new BncsPacket((byte)BncsPacketId.WarcraftGeneral);
                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);
                Send(pckGetLadder);

                pck.InsertCString(string.Empty);
            }
            else
            {
                pck.InsertCString(m_settings.Username);
            }
            pck.InsertCString(string.Empty);
            Send(pck);

            if (!isClientWar3)
            {
                RequestChannelList();

                BncsPacket pckJoinChannel = new BncsPacket((byte)BncsPacketId.JoinChannel);
                string client = "Starcraft";
                switch (m_settings.Client)
                {
                    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);
                Send(pckJoinChannel);
            }

            if (isClientWar3 || isClientStar)
            {
                pck = new BncsPacket((byte)BncsPacketId.FriendsList);
                Send(pck);
            }

            m_tmr.Start();
        }