コード例 #1
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) { }
            }
        }
コード例 #2
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 { }
            }
        }
コード例 #3
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;
            }
        }