Esempio n. 1
0
        private string GetFlagsFromValues(string value)
        {
            string tmp, retur = string.Empty;

            if (headerFlags == null)
            {
                InitializeHeaderFlags();
            }

            for (int i = 0; i < headerFlags.Count; i++)
            {
                tmp = headerFlags[i].VariableValue.TrimStart('0');

                if (tmp.Length == 0)
                {
                    tmp = "0";
                }

                int curIdx = value.Length - tmp.Length;
                if (tmp[0] == value[curIdx] && tmp.Length > 1)
                {
                    retur += "|" + headerFlags[i].VariableName;
                }
                else if (value[curIdx] != '0')
                {
                    List <HeaderVariable> list = new List <HeaderVariable>();
                    ulong x_counter            = 0;
                    ulong x_tmp = ulong.Parse(HexConverter.Hex2Dec(value[curIdx].ToString()).ToString());
                    if (tmp.Length > 1)
                    {
                        foreach (HeaderVariable hVar in headerFlags)
                        {
                            if (hVar.VariableValue.TrimStart('0').Length == value.Substring(curIdx).Length)
                            {
                                list.Add(hVar);
                            }
                        }
                        list.Reverse();
                        foreach (HeaderVariable variable in list)
                        {
                            if (x_counter < x_tmp)
                            {
                                string valre = variable.VariableValue.Trim('0');
                                valre = HexConverter.Hex2Dec(valre).ToString();
                                ulong x_tmp2 = ulong.Parse(valre);
                                ulong ttttt  = x_tmp2 + x_counter;
                                if (x_tmp2 <= x_tmp && ttttt <= x_tmp)// vielleicht nochmal überprüfen irgendwanm
                                {
                                    x_counter += x_tmp2;
                                    if (!retur.Contains(variable.VariableName))
                                    {
                                        retur += "|" + variable.VariableName;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            tmp = value.Substring(value.Length - 1);
            if (!tmp.Equals("0"))
            {
                foreach (HeaderVariable troopFlag in headerFlags)
                {
                    string tmp2 = troopFlag.VariableValue.TrimStart('0').ToLower();
                    if (tmp2.Length < 2)
                    {
                        if (tmp.ToLower().Equals(tmp2))
                        {
                            retur += '|' + troopFlag.VariableName;
                        }
                    }
                }
            }

            if (retur.Length != 0)
            {
                retur = retur.Substring(1);
            }

            string[] tmpS = retur.Split('|');
            SkillHunter.RemoveItemDuplicatesFromArray(ref tmpS);
            retur = string.Empty;
            int minusOne = tmpS.Length - 1;

            for (int i = 0; i < tmpS.Length; i++)
            {
                retur += tmpS[i];
                if (i < minusOne)
                {
                    retur += '|';
                }
            }

            if (retur.Length == 0)
            {
                retur = "0";
            }

            return(retur);
        }
Esempio n. 2
0
        public static string GetItemCapabilityFlagsFromValue(string value)
        {
            string retur = string.Empty;

            if (HeaderItemCapabilityFlags.Count == 0)
            {
                InitializeHeaderItemCapabilityFlags();
                HeaderItemCapabilityFlags.Reverse();
            }

            int valueLength = 16;

            while (value.Length < valueLength)
            {
                value = "0" + value;
            }

            for (int i = 0; i < valueLength; i++)
            {
                if (value[i] == '0')
                {
                    continue;
                }

                List <HeaderVariable> list = new List <HeaderVariable>();

                int subLength = 1;
                if (i == 7)
                {
                    subLength++;
                }

                int curLength = valueLength - i;

                ulong x_counter = 0;
                ulong x_tmp     = HexConverter.Hex2Dec(value.Substring(i, subLength));

                for (int j = 0; j < HeaderItemCapabilityFlags.Count; j++)
                {
                    string varValue = HeaderItemCapabilityFlags[j].VariableValue.TrimStart('0');
                    if (varValue.Length == curLength)
                    {
                        list.Add(HeaderItemCapabilityFlags[j]);
                    }
                }

                foreach (HeaderVariable variable in list)
                {
                    if (x_counter < x_tmp)
                    {
                        HandleCFs(ref retur, ref x_tmp, ref x_counter, ref value, variable);
                    }
                }
            }

            if (!retur.Equals(string.Empty))
            {
                retur = retur.Substring(1);
            }

            string[] tmpS = retur.Split('|');
            SkillHunter.RemoveItemDuplicatesFromArray(ref tmpS);
            retur = string.Empty;
            for (int i = 0; i < tmpS.Length; i++)
            {
                retur += tmpS[i];
                if (i < tmpS.Length - 1)
                {
                    retur += "|";
                }
            }

            if (retur.Equals(string.Empty))
            {
                retur = "0";
            }

            return(retur);
        }
Esempio n. 3
0
        public static string GetItemModifiers_IMODBITS(string value /*, bool imodbits = false*/)
        {
            string retur = string.Empty;

            if (HeaderIModBits.Count == 0)
            {
                InitializeHeaderIModBits();
                HeaderIModBits.Reverse();
            }

            int valueLength = 16;

            while (value.Length < valueLength)
            {
                value = "0" + value;
            }

            for (int i = 0; i < valueLength; i++)
            {
                if (value[i] == '0')
                {
                    continue;
                }

                List <HeaderVariable> list = new List <HeaderVariable>();

                int curLength = valueLength - i;

                ulong x_counter = 0;
                ulong x_tmp     = HexConverter.Hex2Dec(value.Substring(i, 1));

                for (int j = 0; j < HeaderIModBits.Count; j++)
                {
                    string varValue = HeaderIModBits[j].VariableValue.TrimStart('0');
                    if (varValue.Length == curLength)
                    {
                        list.Add(HeaderIModBits[j]);
                    }
                }

                foreach (HeaderVariable variable in list)
                {
                    string varStart = variable.VariableValue.Replace("0", string.Empty);
                    ulong  xtert    = HexConverter.Hex2Dec(varStart);
                    ulong  ttttt    = xtert + x_counter;
                    if (xtert <= x_tmp && ttttt <= x_tmp)
                    {
                        x_counter = ttttt;
                        if (!IsValueInValueString(retur, variable.VariableName))
                        {
                            retur += "|" + variable.VariableName;
                        }
                    }
                }
            }

            if (retur.Length != 0)
            {
                retur = retur.Trim('|');
            }

            string[] tmpS = retur.Split('|');
            SkillHunter.RemoveItemDuplicatesFromArray(ref tmpS);
            retur = string.Empty;
            for (int i = 0; i < tmpS.Length; i++)
            {
                retur += tmpS[i];
                if (i < tmpS.Length - 1)
                {
                    retur += "|";
                }
            }

            if (retur.Equals(string.Empty))
            {
                retur = "imodbits_none";
            }

            return(retur);
        }
Esempio n. 4
0
        public static string GetItemPropertiesFromValue(string value)
        {
            string tmp = string.Empty, retur = string.Empty;

            if (HeaderItemProperties.Count == 0)
            {
                InitializeHeaderItemProperties();
            }

            for (int i = 0; i < HeaderItemProperties.Count; i++)
            {
                bool bbbb = false;
                tmp = HeaderItemProperties[i].VariableValue.TrimStart('0');
                int curIdx = value.Length - tmp.Length;
                if (value.Length >= tmp.Length)
                {
                    if (tmp[0] == value[curIdx] && tmp.Length > 2)
                    {
                        retur += "|" + HeaderItemProperties[i].VariableName;
                    }
                    else
                    {
                        bbbb = true;
                    }

                    if (value[curIdx] != '0' && bbbb)
                    {
                        List <HeaderVariable> list = new List <HeaderVariable>();
                        uint x_counter             = 0;
                        uint x_tmp = uint.Parse(HexConverter.Hex2Dec(value.Substring(curIdx, 1)).ToString());

                        if (tmp.Length > 2)
                        {
                            for (int j = 9; j < HeaderItemProperties.Count; j++)
                            {
                                if (HeaderItemProperties[j].VariableValue.TrimStart('0').Length == value.Substring(curIdx).Length)
                                {
                                    list.Add(HeaderItemProperties[j]);
                                }
                            }
                            list.Reverse();
                            foreach (HeaderVariable variable in list)
                            {
                                if (x_counter < x_tmp)
                                {
                                    uint x_tmp2 = uint.Parse(HexConverter.Hex2Dec(variable.VariableValue.Trim('0')).ToString());
                                    uint tttt   = x_tmp2 + x_counter;
                                    if (x_tmp2 <= x_tmp && tttt <= x_tmp)
                                    {
                                        x_counter += x_tmp2;
                                        if (!retur.Contains(variable.VariableName))
                                        {
                                            retur += "|" + variable.VariableName;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (value.Length > 2)
            {
                tmp = value.Substring(value.Length - 2);
            }

            tmp = tmp.TrimStart('0');

            foreach (HeaderVariable itype in HeaderItemProperties)
            {
                string tmp2 = itype.VariableValue.TrimStart('0').ToLower();
                if (tmp2.Length < 3)
                {
                    if (tmp.ToLower().Equals(tmp2))
                    {
                        retur += "|" + itype.VariableName;
                    }
                }
            }

            if (retur.Length != 0)
            {
                retur = retur.Substring(1);
            }

            string[] tmpS = retur.Split('|');
            SkillHunter.RemoveItemDuplicatesFromArray(ref tmpS);
            retur = string.Empty;
            for (int i = 0; i < tmpS.Length; i++)
            {
                retur += tmpS[i];
                if (i < tmpS.Length - 1)
                {
                    retur += '|';
                }
            }

            if (retur.Length == 0)
            {
                retur = "0";
            }

            return(retur);
        }