コード例 #1
0
        private void HandleFriendMoved(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            byte index = dr.ReadByte();
            byte newIndex = dr.ReadByte();

            FriendUser friend = m_friendsList[index];
            friend.Index = newIndex;
            m_friendsList.Insert(newIndex, friend);

            if (newIndex < index)
            {
                for (int i = newIndex + 1; i <= index; i++)
                {
                    m_friendsList[i].Index += 1;
                }
            }
            else if (newIndex > index)
            {
                for (int i = index; i < newIndex; i++)
                {
                    m_friendsList[i].Index -= 1;
                }
            }

            FriendMovedEventArgs args = new FriendMovedEventArgs(friend, newIndex) { EventData = pd };
            OnFriendMoved(args);
        }
コード例 #2
0
        private void HandleFriendUpdate(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            byte entry = dr.ReadByte();
            if (m_friendsList.Count <= entry)
            {
                return;
            }
            FriendUser friend = m_friendsList[entry];
            friend.Status = (FriendStatus)dr.ReadByte();
            friend.LocationType = (FriendLocation)dr.ReadByte();
            string prodID = dr.ReadDwordString(0);
            friend.Location = dr.ReadCString();

            if (friend.LocationType != FriendLocation.Offline)
            {
                friend.Product = Product.GetByProductCode(prodID);
            }
            else
            {
                friend.Product = null;
            }

            FriendUpdatedEventArgs args = new FriendUpdatedEventArgs(friend) { EventData = pd };
            OnFriendUpdated(args);
        }
コード例 #3
0
        private void HandleClanMemberInformation(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            int cookie = dr.ReadInt32();
            if (!m_warcraftProfileRequests.ContainsKey(cookie))
            {
                Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Unable to locate profile request with cookie {0:x2}", cookie));
                return;
            }
            WarcraftProfileEventArgs args = m_warcraftProfileRequests[cookie];

            byte success = dr.ReadByte();
            if (success != 0)
            {
                m_warcraftProfileRequests.Remove(cookie);
                ProfileLookupFailedEventArgs profileFailed = new ProfileLookupFailedEventArgs(args.Username, args.Product) { EventData = pd };
                OnProfileLookupFailed(profileFailed);
                return;
            }

            string clanName = dr.ReadCString();
            ClanRank rank = (ClanRank)dr.ReadByte();
            DateTime joined = DateTime.FromFileTime(dr.ReadInt64());

            args.Clan = new ClanProfile(clanName, rank, joined);

            BncsPacket pck = new BncsPacket((byte)BncsPacketId.WarcraftGeneral);
            pck.InsertByte((byte)WarcraftCommands.ClanInfoRequest);
            pck.InsertInt32(cookie);
            pck.InsertDwordString(args.Profile.ClanTag, 0);
            pck.InsertDwordString(args.Product.ProductCode);
            Send(pck);

            BattleNetClientResources.IncomingBufferPool.FreeBuffer(pd.Data);
        }
コード例 #4
0
        private void HandleAuthInfo(PD data)
        {
            DataReader dr = new DataReader(data.Data);
            dr.Seek(4);
            m_serverToken = dr.ReadInt32();

            m_oldAuthInfo(data);
        }
コード例 #5
0
        private void HandleFriendAdded(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            int nextIndex = m_friendsList.Count;
            FriendUser newFriend = __ParseNewFriend(dr, nextIndex);
            m_friendsList.Add(newFriend);

            FriendAddedEventArgs args = new FriendAddedEventArgs(newFriend) { EventData = pd };
            OnFriendAdded(args);
        }
コード例 #6
0
ファイル: BattleNetClient.Clan.cs プロジェクト: Mofsy/jinxbot
        private void HandleClanInfo(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            dr.Seek(1);
            string clanTag = dr.ReadDwordString(0);
            ClanRank rank = (ClanRank)dr.ReadByte();

            ClanMembershipEventArgs args = new ClanMembershipEventArgs(clanTag, rank);
            args.EventData = pd;
            OnClanMembershipReceived(args);

            BncsPacket pck = new BncsPacket((byte)BncsPacketId.ClanMemberList);
            pck.InsertInt32(Interlocked.Increment(ref m_clanCookie));
            Send(pck);
        }
コード例 #7
0
        private void HandleLogonResponse2(PD data)
        {
            DataReader dr = new DataReader(data.Data);
            int success = dr.ReadInt32();
            if (success == 0)
            {
                m_events.OnLoginSucceeded(BaseEventArgs.GetEmpty(data));

                BncsPacket pck = new BncsPacket((byte)BncsPacketId.QueryRealms2);
            }
            else
            {
                m_events.OnLoginFailed(new LoginFailedEventArgs(LoginFailureReason.AccountDoesNotExist, success));
            }
        }
コード例 #8
0
        private void HandleFriendRemoved(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            byte index = dr.ReadByte();

            FriendUser removed = m_friendsList[index];
            m_friendsList.RemoveAt(index);

            for (int i = index; i < m_friendsList.Count; i++)
            {
                m_friendsList[i].Index -= 1;
            }

            FriendRemovedEventArgs args = new FriendRemovedEventArgs(removed) { EventData = pd };
            OnFriendRemoved(args);
        }
コード例 #9
0
        private void HandleQueryRealms2(PD data)
        {
            DataReader dr = new DataReader(data.Data);
            dr.Seek(4);
            int count = dr.ReadInt32();
            RealmServer[] realms = new RealmServer[count];
            for (int i = 0; i < count; i++)
            {
                dr.Seek(4);
                string title = dr.ReadCString();
                string desc = dr.ReadCString();

                realms[i] = new RealmServer(title, desc);
            }

            AvailableRealmsEventArgs args = new AvailableRealmsEventArgs(realms) { EventData = data };
            OnRealmsRetrieved(args);
        }
コード例 #10
0
        private void HandleFriendsList(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            int numEntries = dr.ReadByte();
            FriendUser[] list = new FriendUser[numEntries];
            for (int i = 0; i < numEntries; i++)
            {
                FriendUser friend = __ParseNewFriend(dr, i);
                list[i] = friend;
            }

            m_friendsList.AddRange(list);

            Debug.WriteLine("Received friends list; " + list.Length + " user on it.");

            FriendListReceivedEventArgs args = new FriendListReceivedEventArgs(list) { EventData = pd };
            OnFriendListReceived(args);
        }
コード例 #11
0
ファイル: StarcraftStats.cs プロジェクト: Mofsy/jinxbot
        internal StarcraftStats(byte[] stats)
        {
            m_literal = Encoding.ASCII.GetString(stats);

            // RATS 0 0 200 0 0 0 0 0 RATS
            // pcode rating rank wins spawn unknown hirating unkn unkn icon
            DataReader dr = new DataReader(stats);
            string productCode = dr.ReadDwordString(0);
            m_prod = Product.GetByProductCode(productCode);
            if (m_prod == null)
                m_prod = Product.UnknownProduct;

            if (stats.Length > 4)
            {
                try
                {
                    dr.ReadTerminatedString(' ', Encoding.ASCII);
                    string sRating = dr.ReadTerminatedString(' ', Encoding.ASCII);
                    int.TryParse(sRating, out m_ladderRating);
                    string sRank = dr.ReadTerminatedString(' ', Encoding.ASCII);
                    int.TryParse(sRank, out m_ladderRank);
                    string sWins = dr.ReadTerminatedString(' ', Encoding.ASCII);
                    int.TryParse(sWins, out m_wins);
                    int nSpawn;
                    string sSpawn = dr.ReadTerminatedString(' ', Encoding.ASCII);
                    int.TryParse(sSpawn, out nSpawn);
                    m_isSpawned = (nSpawn == 1);
                    dr.ReadTerminatedString(' ', Encoding.ASCII);
                    string sHighRating = dr.ReadTerminatedString(' ', Encoding.ASCII);
                    int.TryParse(sHighRating, out m_highestLadderRating);
                    dr.ReadTerminatedString(' ', Encoding.ASCII);
                    if (dr.Length > dr.Position)
                    {
                        dr.ReadTerminatedString(' ', Encoding.ASCII);
                        m_iconCode = dr.ReadDwordString(0);
                    }
                    else
                    {
                        m_iconCode = productCode;
                    }
                }
                catch (ArgumentOutOfRangeException) { }
            }
        }
コード例 #12
0
        private static FriendUser __ParseNewFriend(DataReader dr, int i)
        {
            string acct = dr.ReadCString();
            FriendStatus status = (FriendStatus)dr.ReadByte();
            FriendLocation location = (FriendLocation)dr.ReadByte();
            string productID = dr.ReadDwordString(0);
            Product prod = null;
            string locationName = string.Empty;
            if (location == FriendLocation.Offline)
            {
                dr.Seek(1);
            }
            else
            {
                prod = Product.GetByProductCode(productID);
                locationName = dr.ReadCString();
            }

            FriendUser friend = new FriendUser(i, acct, status, location, prod, locationName);
            return friend;
        }
コード例 #13
0
ファイル: Warcraft3Stats.cs プロジェクト: MusicDemon/BNSharp
        internal Warcraft3Stats(byte[] stats)
        {
            m_literal = Encoding.ASCII.GetString(stats);

            DataReader dr = new DataReader(stats);
            string productCode = dr.ReadDwordString(0);
            m_prod = Product.GetByProductCode(productCode);
            if (m_prod == null)
                m_prod = Product.UnknownProduct;

            if (stats.Length > 4)
            {
                dr.Seek(1);
                string iconInfo = dr.ReadDwordString((byte)' ');
                char raceID = iconInfo[2];
                if (RaceMap.ContainsKey(raceID))
                {
                    m_race = RaceMap[raceID];
                }
                else
                    m_race = Warcraft3IconRace.Unknown;

                m_iconTier = (int)(iconInfo[3] - '0');

                dr.Seek(1);
                string sLevel = dr.ReadTerminatedString(' ', Encoding.ASCII);
                int.TryParse(sLevel, out m_level);
                if (m_level == 0)
                    m_level = 1;

                try
                {
                    if (dr.Position < dr.Length)
                        m_clanTag = dr.ReadDwordString((byte)' ');
                }
                catch { }
            }
        }
コード例 #14
0
        private void HandleLogonRealmEx(PD data)
        {
            DataReader dr = new DataReader(data.Data);
            m_mcpCookie = dr.ReadInt32();
            int status = dr.ReadInt32();
            m_mcpStatus = status;

            if (data.Length > 8)
            {
                m_mcpChunk1 = dr.ReadByteArray(8);
                byte[] ipAddress = dr.ReadByteArray(4);
                m_ip = new IPAddress(ipAddress);
                m_port = dr.ReadInt32();
                m_mcpChunk2 = dr.ReadByteArray(48);
                m_uniqueBnetName = dr.ReadCString();

                BattleNetClientResources.IncomingBufferPool.FreeBuffer(data.Data);
            }
            else
            {
                RealmFailedEventArgs args = new RealmFailedEventArgs((RealmFailureReason)status) { EventData = data };
                OnRealmConnectionFailed(args);
            }
        }
コード例 #15
0
ファイル: BattleNetClient.Clan.cs プロジェクト: Mofsy/jinxbot
        private void HandleClanInvitation(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            int cookie = dr.ReadInt32();
            ClanInvitationResponse response = (ClanInvitationResponse)dr.ReadByte();

            ClanInvitationResponseEventArgs args = new ClanInvitationResponseEventArgs(cookie, response) { EventData = pd };
            OnClanInvitationResponseReceived(args);
        }
コード例 #16
0
ファイル: UserStats.cs プロジェクト: MusicDemon/BNSharp
        /// <summary>
        /// Parses a user statstring and returns an object representing the stats in a meaningful way.
        /// </summary>
        /// <param name="userName">The name of the user whose stats are being examined.</param>
        /// <param name="statsData">The stats of the user.</param>
        /// <returns>An instance of a class derived from <see>UserStats</see> based on the user's 
        /// <see cref="BNSharp.BattleNet.Product">Product</see>.  To check the product, check the 
        /// <see cref="UserStats.Product">Product property</see>.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="userName"/> or <paramref name="statsData"/>
        /// are <see langword="null" />.</exception>
        /// <remarks>
        /// <para>More specific information is available from most users by casting an object of this class to one of the 
        /// derived classes.  Products and their relevant classes are provided in the following table:</para>
        /// <list type="table">
        ///     <listheader>
        ///         <item>
        ///             <term>Product</term>
        ///             <description>Stats subclass type</description>
        ///         </item>
        ///     </listheader>
        ///     <item>
        ///         <term>Starcraft Retail, Starcraft: Brood War, Starcraft Shareware, Japan Starcraft,
        ///         Warcraft II: Battle.net Edition, Diablo Retail, Diablo Shareware</term>
        ///         <description><see>StarcraftStats</see></description>
        ///     </item>
        ///     <item>
        ///         <term>Diablo II Retail, Diablo II: Lord of Destruction</term>
        ///         <description><see>Diablo2Stats</see></description>
        ///     </item>
        ///     <item>
        ///         <term>Warcraft III: The Reign of Chaos, Warcraft III: The Frozen Throne</term>
        ///         <description><see>Warcraft3Stats</see></description>
        ///     </item>
        ///     <item>
        ///         <term>Others (unknown clients)</term>
        ///         <description><see>DefaultStats</see></description>
        ///     </item>
        /// </list>
        /// </remarks>
        public static UserStats Parse(string userName, byte[] statsData)
        {
            DataReader dr = new DataReader(statsData);
            string productCode = dr.ReadDwordString(0);
            UserStats result = null;
            switch (productCode)
            {
                case "STAR":
                case "SEXP":
                case "SSHR":
                case "JSTR":
                case "W2BN":
                case "DSHR":
                case "DRTL":
                    result = new StarcraftStats(statsData);
                    break;
                case "D2DV":
                case "D2XP":
                    result = new Diablo2Stats(userName, statsData);
                    break;
                case "WAR3":
                case "W3XP":
                    result = new Warcraft3Stats(statsData);
                    break;
                default:
                    result = new DefaultStats(productCode, statsData);
                    break;
            }

            return result;
        }
コード例 #17
0
        /// <summary>
        /// Executes the BnFTP request, downloading the file to where <see cref="BnFtpRequestBase.LocalFileName">LocalFileName</see>
        /// specifies, and closes the connection.
        /// </summary>
        /// <remarks>
        /// <para>By default, <c>LocalFileName</c> is the same name as the remote file, which will cause the file
        /// to be saved in the local application path.  The desired location of the file must be set before 
        /// <b>ExecuteRequest</b> is called.</para>
        /// </remarks>
        /// <exception cref="IOException">Thrown if the local file cannot be written.</exception>
        /// <exception cref="SocketException">Thrown if the remote host closes the connection prematurely.</exception>
        public override void ExecuteRequest()
        {
            DataBuffer buffer = new DataBuffer();
            buffer.InsertInt16((short)(33 + FileName.Length));
            buffer.InsertInt16(0x0100);
            buffer.InsertDwordString("IX86");
            buffer.InsertDwordString(Product);
            if (m_ad)
            {
                buffer.InsertInt32(m_adId);
                buffer.InsertDwordString(m_adExt);
            }
            else
            {
                buffer.InsertInt64(0);
            }
            // currently resuming is not supported
            buffer.InsertInt32(0);
            if (FileTime.HasValue)
            {
                buffer.InsertInt64(FileTime.Value.ToFileTimeUtc());
            }
            else
            {
                buffer.InsertInt64(0);
            }
            buffer.InsertCString(FileName);

            Socket sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            sck.Connect(Server, 6112);
            sck.Send(new byte[] { 2 });
            sck.Send(buffer.UnderlyingBuffer, 0, buffer.Count, SocketFlags.None);

            BattleNetClientResources.OutgoingBufferPool.FreeBuffer(buffer.UnderlyingBuffer);

            byte[] hdrLengthBytes = new byte[2];
            sck.Receive(hdrLengthBytes, 2, SocketFlags.None);

            int hdrLen = BitConverter.ToInt16(hdrLengthBytes, 0);
            Debug.WriteLine(hdrLen, "Header Length");
            byte[] hdrBytes = new byte[hdrLen - 2];
            sck.Receive(hdrBytes, hdrLen - 2, SocketFlags.None);
            DataReader rdr = new DataReader(hdrBytes);
            rdr.Seek(2);
            int fileSize = rdr.ReadInt32();
            this.FileSize = fileSize;
            rdr.Seek(8);
            long fileTime = rdr.ReadInt64();
            string name = rdr.ReadCString();
            if (string.Compare(name, FileName, StringComparison.OrdinalIgnoreCase) != 0 || FileSize == 0)
            {
                throw new FileNotFoundException(Resources.bnftp_filenotfound);
            }
            Debug.WriteLine(fileSize, "File Size");

            byte[] data = ReceiveLoop(sck, fileSize);
            sck.Close();

            FileStream fs = new FileStream(LocalFileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
            fs.SetLength(fileSize);
            fs.Write(data, 0, fileSize);
            fs.Flush();
            fs.Close();
            DateTime time = DateTime.FromFileTimeUtc(fileTime);
            File.SetLastWriteTimeUtc(LocalFileName, time);
        }
コード例 #18
0
ファイル: BattleNetClient.Clan.cs プロジェクト: Mofsy/jinxbot
        private void HandleClanMemberRankChange(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            ClanRank old = (ClanRank)dr.ReadByte();
            ClanRank newRank = (ClanRank)dr.ReadByte();
            string memberName = dr.ReadCString();
            ClanMember member = null;
            if (m_clanList.ContainsKey(memberName))
                member = m_clanList[memberName];

            ClanMemberRankChangeEventArgs args = new ClanMemberRankChangeEventArgs(old, newRank, member);
            args.EventData = pd;
            OnClanMemberRankChanged(args);
        }
コード例 #19
0
ファイル: BattleNetClient.Clan.cs プロジェクト: Mofsy/jinxbot
        private void HandleClanMemberStatusChanged(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            string userName = dr.ReadCString();
            if (m_clanList.ContainsKey(userName))
            {
                ClanMember member = m_clanList[userName];
                ClanRank rank = (ClanRank)dr.ReadByte();
                ClanMemberStatus status = (ClanMemberStatus)dr.ReadByte();
                string location = dr.ReadCString();
                member.Rank = rank;
                member.CurrentStatus = status;
                member.Location = location;

                ClanMemberStatusEventArgs args = new ClanMemberStatusEventArgs(member);
                args.EventData = pd;
                OnClanMemberStatusChanged(args);
            }
        }
コード例 #20
0
ファイル: BattleNetClient.Clan.cs プロジェクト: Mofsy/jinxbot
        private void HandleClanMemberRemoved(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            string memberName = dr.ReadCString();
            ClanMember member = m_clanList[memberName];
            m_clanList.Remove(memberName);

            ClanMemberStatusEventArgs args = new ClanMemberStatusEventArgs(member) { EventData = pd };
            OnClanMemberRemoved(args);
        }
コード例 #21
0
ファイル: BattleNetClient.Clan.cs プロジェクト: Mofsy/jinxbot
        private void HandleClanMemberList(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            dr.Seek(4);
            byte memCount = dr.ReadByte();
            for (int i = 0; i < memCount; i++)
            {
                string userName = dr.ReadCString();
                ClanRank rank = (ClanRank)dr.ReadByte();
                ClanMemberStatus status = (ClanMemberStatus)dr.ReadByte();
                string location = dr.ReadCString();
                m_clanList.Add(userName, new ClanMember(userName, rank, status, location));

            }

            ClanMember[] members = new ClanMember[m_clanList.Count];
            m_clanList.Values.CopyTo(members, 0);

            ClanMemberListEventArgs args = new ClanMemberListEventArgs(members);
            args.EventData = pd;
            OnClanMemberListReceived(args);
        }
コード例 #22
0
ファイル: BattleNetClient.Clan.cs プロジェクト: Mofsy/jinxbot
 private void HandleClanMotd(ParseData pd)
 {
     DataReader dr = new DataReader(pd.Data);
     dr.Seek(8);
     string motd = dr.ReadCString();
     InformationEventArgs args = new InformationEventArgs(motd);
     args.EventData = pd;
     OnClanMessageOfTheDay(args);
 }
コード例 #23
0
ファイル: BattleNetClient.Clan.cs プロジェクト: Mofsy/jinxbot
        private void HandleClanRankChange(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            int cookie = dr.ReadInt32();
            string userName = m_clanRankChangeToMemberList[cookie];
            m_clanRankChangeToMemberList.Remove(cookie);
            ClanRankChangeStatus status = (ClanRankChangeStatus)dr.ReadByte();

            ClanRankChangeEventArgs args = new ClanRankChangeEventArgs(userName, status) { EventData = pd };
            OnClanRankChangeResponseReceived(args);
        }
コード例 #24
0
ファイル: BattleNetClient.Clan.cs プロジェクト: Mofsy/jinxbot
        private void HandleClanFindCandidates(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            dr.Seek(4); // skip the cookie
            ClanCandidatesSearchStatus status = (ClanCandidatesSearchStatus)dr.ReadByte();
            int numCandidates = dr.ReadByte();
            string[] usernames = new string[numCandidates];
            for (int i = 0; i < numCandidates; i++)
            {
                usernames[i] = dr.ReadCString();
            }

            ClanCandidatesSearchEventArgs args = new ClanCandidatesSearchEventArgs(status, usernames);
            args.EventData = pd;
            OnClanCandidatesSearchCompleted(args);
        }
コード例 #25
0
ファイル: BattleNetClient.Clan.cs プロジェクト: Mofsy/jinxbot
        private void HandleClanInvitationResponse(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            int cookie = dr.ReadInt32();
            string tag = dr.ReadDwordString(0);
            string name = dr.ReadCString();
            string inviter = dr.ReadCString();

            ClanInvitationEventArgs args = new ClanInvitationEventArgs(cookie, tag, name, inviter) { EventData = pd };
            OnClanInvitationReceived(args);
        }
コード例 #26
0
ファイル: BattleNetClient.Clan.cs プロジェクト: Mofsy/jinxbot
 // 0x73
 private void HandleDisbandClan(ParseData pd)
 {
     DataReader dr = new DataReader(pd.Data);
     dr.Seek(4);
     ClanResponseCode status = (ClanResponseCode)dr.ReadByte();
     ClanDisbandEventArgs args = new ClanDisbandEventArgs(status == ClanResponseCode.Success);
     args.EventData = pd;
     OnClanDisbandCompleted(args);
 }
コード例 #27
0
ファイル: Diablo2Stats.cs プロジェクト: Mofsy/jinxbot
        internal Diablo2Stats(string userName, byte[] statstring)
        {
            m_literal = Encoding.ASCII.GetString(statstring);

            DataReader dr = new DataReader(statstring);
            string productCode = dr.ReadDwordString(0);
            m_prod = Product.GetByProductCode(productCode);
            if (m_prod == null)
                m_prod = Product.UnknownProduct;

            Match m = RealmCharacterTest.Match(userName);
            if (m.Success)
            {
                m_userName = string.Concat("*", m.Groups["Username"].Value);
                try
                {
                    m_isRealm = true;
                    m_realm = dr.ReadTerminatedString(',', Encoding.ASCII);
                    m_charName = dr.ReadTerminatedString(',', Encoding.ASCII);

                    byte[] characterData = dr.ReadByteArray(33);
                    /*
    0000   ff 0f 74 00 01 00 00 00 00 00 00 00 8c 00 00 00  ..t.............
    0010   00 00 00 00 0d f0 ad ba 0d f0 ad ba 53 63 72 65  ............Scre
    0020   65 6e 53 68 6f 6f 74 40 55 53 45 61 73 74 2a 44  enShoot@USEast*D
    0030   72 2e 4d 61 72 73 68 61 6c 6c 00 50 58 32 44 55  r.Marshall.PX2DU
    0040   53 45 61 73 74 2c 53 63 72 65 65 6e 53 68 6f 6f  SEast,ScreenShoo
    0050   74 2c>84 80 39 ff ff ff ff 0f ff 5d ff ff ff*04  t,..9......]....
    0060   4d ff ff ff ff ff ff ff ff ff ff 56*a8*9a ff ff  M..........V....
    0070   ff ff ff<00                                      ....
                     * */
                    m_class = (Diablo2CharacterClass)characterData[13];
                    if (m_class < Diablo2CharacterClass.Amazon || m_class > Diablo2CharacterClass.Assassin)
                        m_class = Diablo2CharacterClass.Unknown;

                    m_isMale = !(m_class == Diablo2CharacterClass.Amazon || m_class == Diablo2CharacterClass.Assassin ||
                                    m_class == Diablo2CharacterClass.Sorceress);

                    m_level = characterData[25];

                    byte flags = characterData[26];
                    m_isHardcore = ((flags & 4) == 4);
                    m_isDead = ((flags & 8) == 8);
                    m_isExpCharacter = ((flags & 32) == 32);
                    m_isLadder = ((flags & 64) == 64);

                    byte completedActs = (byte)((characterData[27] & 0x3e) >> 2);
                    if (m_isExpCharacter)
                    {
                        m_difficulty = (Diablo2DifficultyLevel)(completedActs / 5);
                        m_numActsCompleted = (completedActs % 5);
                        m_hasCompletedGame = (m_numActsCompleted == 5);
                    }
                    else
                    {
                        m_difficulty = (Diablo2DifficultyLevel)(completedActs / 4);
                        m_numActsCompleted = (completedActs % 4);
                        m_hasCompletedGame = (m_numActsCompleted == 4);
                    }
                }
                catch (ArgumentOutOfRangeException) { }
            }
            else
            {
                m_userName = userName;
            }
        }
コード例 #28
0
ファイル: BattleNetClient.Clan.cs プロジェクト: Mofsy/jinxbot
 private void HandleClanMakeChieftan(ParseData pd)
 {
     DataReader dr = new DataReader(pd.Data);
     dr.Seek(4);
     ClanChieftanChangeResult result = (ClanChieftanChangeResult)dr.ReadByte();
     ClanChieftanChangeEventArgs args = new ClanChieftanChangeEventArgs(result);
     args.EventData = pd;
     OnClanChangeChieftanCompleted(args);
 }
コード例 #29
0
        public override void ExecuteRequest()
        {
            DataBuffer buf1 = new DataBuffer();
            buf1.InsertInt16(20);
            buf1.InsertInt16(0x0200);
            buf1.InsertDwordString("IX86");
            buf1.InsertDwordString(Product);
            if (m_ad)
            {
                buf1.InsertInt32(m_adId);
                buf1.InsertDwordString(m_adExt);
            }
            else
            {
                buf1.InsertInt64(0);
            }

            Socket sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            sck.Connect(Server, 6112);

            sck.Send(new byte[] { 2 });
            sck.Send(buf1.UnderlyingBuffer, 0, buf1.Count, SocketFlags.None);

            NetworkStream ns = new NetworkStream(sck, false);
            DataReader rdr = new DataReader(ns, 4);
            int serverToken = rdr.ReadInt32();

            DataBuffer buf2 = new DataBuffer();
            buf2.InsertInt32(0); // no resuming
            if (FileTime.HasValue)
            {
                buf2.InsertInt64(FileTime.Value.ToFileTimeUtc());
            }
            else
            {
                buf2.InsertInt64(0);
            }

            int clientToken = new Random().Next();
            buf2.InsertInt32(clientToken);

            buf2.InsertInt32(m_key.Key.Length);
            buf2.InsertInt32(m_key.Product);
            buf2.InsertInt32(m_key.Value1);
            buf2.InsertInt32(0);
            buf2.InsertByteArray(m_key.GetHash(clientToken, serverToken));
            buf2.InsertCString(FileName);

            sck.Send(buf2.UnderlyingBuffer, 0, buf2.Count, SocketFlags.None);

            rdr = new DataReader(ns, 4);
            int msg2Size = rdr.ReadInt32() - 4;
            rdr = new DataReader(ns, msg2Size);

            this.FileSize = rdr.ReadInt32();
            rdr.Seek(8);
            long fileTime = rdr.ReadInt64();
            DateTime time = DateTime.FromFileTimeUtc(fileTime);
            string name = rdr.ReadCString();
            if (string.Compare(name, FileName, StringComparison.OrdinalIgnoreCase) != 0 || FileSize == 0)
            {
                throw new FileNotFoundException(Resources.bnftp_filenotfound);
            }

            byte[] data = ReceiveLoop(sck, FileSize);
            sck.Close();

            FileStream fs = new FileStream(LocalFileName, FileMode.OpenOrCreate, FileAccess.Write);
            fs.Write(data, 0, FileSize);
            fs.Flush();
            fs.Close();
        }
コード例 #30
0
ファイル: BattleNetClient.Clan.cs プロジェクト: Mofsy/jinxbot
        private void HandleClanRemoveMember(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            int reqID = dr.ReadInt32();
            ClanMemberRemovalResponse response = (ClanMemberRemovalResponse)dr.ReadByte();

            ClanRemovalResponseEventArgs args = new ClanRemovalResponseEventArgs(reqID, response) { EventData = pd };
            OnClanRemovalResponse(args);
        }