GetMaxTypeId() public static method

public static GetMaxTypeId ( ) : uint
return uint
Ejemplo n.º 1
0
        static void Main(String[] args)
        {
            Console.Clear();
            Console.Title = "Wowhead Ripper";
            DBC.LoadDBCs();
            DB2.LoadDB2s();
            List <String> files = new List <String>();


            foreach (String fileName in args)
            {
                if (!File.Exists(fileName))
                {
                    Console.WriteLine("File {0} doesnt exist, skipping", fileName);
                    continue;
                }

                if (File.ReadAllLines(fileName).Length == 0)
                {
                    Console.WriteLine("File {0} is empty, skipping", fileName);
                    continue;
                }

                files.Add(fileName);
            }

            foreach (String fileName in files)
            {
                Console.WriteLine("Loading file {0}...", fileName);
                var file = File.ReadAllText(fileName);

                Regex regex = new Regex(@"([0-9]+) +([0-9]+) +([0-9]+) *[,\r\n]+");

                foreach (Match result in regex.Matches(file))
                {
                    UInt32 typeId        = uint.Parse(result.Groups[1].ToString());
                    Int32  subTypeIdFlag = int.Parse(result.Groups[2].ToString());
                    UInt32 entry         = uint.Parse(result.Groups[3].ToString());

                    if (typeId >= Defines.GetMaxTypeId())
                    {
                        Console.WriteLine("Incorrect typeId for command \"{0} {1} {2}\"", typeId, subTypeIdFlag, entry);
                        continue;
                    }

                    if (subTypeIdFlag >= (1 << (int)Defines.GetMaxTypeId()))
                    {
                        Console.WriteLine("Incorrect flags for command \"{0} {1} {2}\"", typeId, subTypeIdFlag, entry);
                        continue;
                    }

                    if (!commandList.Keys.Contains(new KeyValuePair <uint, uint>(typeId, entry)))
                    {
                        commandList.Add(new KeyValuePair <uint, uint>(typeId, entry), subTypeIdFlag);
                    }
                    else
                    {
                        commandList[new KeyValuePair <uint, uint>(typeId, entry)] |= subTypeIdFlag;
                    }
                }
            }

            Console.WriteLine("Got {0} records to parse.", commandList.Count);
            Console.WriteLine("Starting Parsing, please Stand by.");

            if (configFileName != "")
            {
                singleFileStream           = new StreamWriter(configFileName, true);
                count                      = commandList.Count;
                singleFileStream.AutoFlush = true;
            }

            foreach (KeyValuePair <uint, uint> key in commandList.Keys)
            {
                new Thread(new ThreadStart(delegate { ParseData(key.Key, commandList[key], key.Value); })).Start();
                if (usePreCached)
                {
                    Thread.Sleep(20);
                }
                else
                {
                    Thread.Sleep(700); // Needs to be done because Wowhead will think that you are a bot
                }
            }

            while (count != dataDone)
            {
                // Wait till all threads close
            }

            if (singleFileStream != null)
            {
                singleFileStream.Flush();
                singleFileStream.Close();
            }

            Console.Beep();
            Console.WriteLine("Parsing done!");
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
Ejemplo n.º 2
0
        static void Main(String[] args)
        {
            Console.Clear();
            Console.Title = "Wowhead Ripper";
            List <String> files = new List <String>();

            DBC.LoadDBCs();
            DB2.LoadDB2s();

            foreach (String fileName in args)
            {
                if (!File.Exists(fileName))
                {
                    Console.WriteLine("File {0} doesnt exist, skipping", fileName);
                    continue;
                }
                if (File.ReadAllLines(fileName).Length == 0)
                {
                    Console.WriteLine("File {0} is empty, skipping", fileName);
                    continue;
                }
                files.Add(fileName);
            }

            foreach (String fileName in files)
            {
                Console.WriteLine("Loading file {0}...", fileName);
                StreamReader file = new StreamReader(fileName);

                while (file.Peek() >= 0)
                {
                    String      Line     = file.ReadLine();
                    List <uint> lineData = Def.GetAllNumbersOfString(Line);

                    if (lineData.Count != 3)
                    {
                        Console.WriteLine("Incorrect format for line \"{0}\"", Line);
                        continue;
                    }

                    UInt32 typeId        = lineData.ToArray()[0];
                    Int32  subTypeIdFlag = (int)lineData.ToArray()[1];
                    UInt32 entry         = lineData.ToArray()[2];

                    if (typeId >= Def.GetMaxTypeId())
                    {
                        Console.WriteLine("Incorrect typeId for line \"{0}\"", Line);
                        continue;
                    }

                    if (subTypeIdFlag >= (1 << (int)Def.GetMaxTypeId()))
                    {
                        Console.WriteLine("Incorrect flags for line \"{0}\"", Line);
                        continue;
                    }

                    if (!commandList.Keys.Contains(new KeyValuePair <uint, uint>(typeId, entry)))
                    {
                        commandList.Add(new KeyValuePair <uint, uint>(typeId, entry), subTypeIdFlag);
                    }
                    else
                    {
                        commandList[new KeyValuePair <uint, uint>(typeId, entry)] |= subTypeIdFlag;
                    }
                }
            }

            Console.WriteLine("Got {0} records to parse", commandList.Count);
            Console.WriteLine("Starting Parsing, please stand by");

            if (configFileName != "")
            {
                stream           = new StreamWriter(configFileName, true);
                count            = commandList.Count;
                stream.AutoFlush = true;
            }

            foreach (KeyValuePair <uint, uint> key in commandList.Keys)
            {
                new Thread(new ThreadStart(delegate { ParseData(key.Key, commandList[key], key.Value); })).Start();
                if (usePreCached)
                {
                    Thread.Sleep(20);
                }
                else
                {
                    Thread.Sleep(700); // Needs to be done because Wowhead will think that you are a bot
                }
            }

            while (count != datad)
            {
            }

            if (configFileName != "")
            {
                stream.Flush();
                stream.Close();
            }

            Console.Beep();
            Console.WriteLine("Parsing done!");
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }