BattleNet.CheckRevision.DoCheck C# (CSharp) Метод

DoCheck() публичный статический Метод

public static DoCheck ( String formula, String mpq, String directory, uint &output ) : CheckRevisionResult
formula String
mpq String
directory String
output uint
Результат CheckRevisionResult
        public static CheckRevisionResult DoCheck(String formula, String mpq, String directory, ref uint output)
        {
            const uint variableCount = 3;
            const uint operatorCount = 4;

            uint[] values = new uint[variableCount];

            OperatorType[] operators = new OperatorType[operatorCount];

            String[] tokens = formula.Split(' ');

            uint offset;
            for (offset = 0; offset < tokens.Length; offset++)
            {
                String token = tokens[offset];
                if (token == "4")
                {
                    offset++;
                    break;
                }
                else if (token.Length < 3)
                    return CheckRevisionResult.CHECK_REVISION_FORMULA_ERROR;
                char variableLetter = token[0];
                String numberString = token.Substring(2);
                uint number;
                try
                {
                    number = UInt32.Parse(numberString);
                }
                catch
                {
                    return CheckRevisionResult.CHECK_REVISION_FORMULA_ERROR;
                }

                uint variableIndex = 0;
                if (!GetVariableIndex(variableLetter,ref  variableIndex))
                    return CheckRevisionResult.CHECK_REVISION_FORMULA_ERROR;
                values[variableIndex] = number;
            }

            for (uint i = 0; offset < tokens.Length; i++, offset++)
            {
                String token = tokens[offset];
                if (token.Length != 5)
                    return CheckRevisionResult.CHECK_REVISION_FORMULA_ERROR;
                OperatorType current_operator;

                switch (token[3])
                {
                    case '+':
                        current_operator = new OperatorType(operator_add);
                        break;
                    case '-':
                        current_operator = new OperatorType(operator_sub);
                        break;
                    case '^':
                        current_operator = new OperatorType(operator_xor);
                        break;
                    default:
                        return CheckRevisionResult.CHECK_REVISION_FORMULA_ERROR;
                }
                operators[i] = current_operator;
            }
            uint mpq_index = 0;
            if (!RetrieveMpqIndex(mpq,ref mpq_index))
                return CheckRevisionResult.CHECK_REVISION_MPQ_ERROR;

            uint mpq_hash = mpqHashCodes[mpq_index];

            ulong a = values[0];
            ulong b = values[1];
            ulong c = values[2];

            a ^= mpq_hash;

            for (uint i = 0; i < d2Files.Length; i++)
            {
                String file = directory + d2Files[i];

                byte[] contentBytes =  File.ReadAllBytes(file);
                for (int j = 0; j < contentBytes.Length; j += 4)
                {
                    ulong s = (ulong)BitConverter.ToUInt32(contentBytes, j);

                    a = operators[0](a, s);
                    b = operators[1](b, c);
                    c = operators[2](c, a);
                    a = operators[3](a, b);

                }
            }
            output = (uint)c;

            return CheckRevisionResult.CHECK_REVISION_SUCCESS;
        }