Exemple #1
0
        public AsyncMapLoader(string fileName) : base()
        {
            this.WorkerReportsProgress = true;

            this.DoWork += new DoWorkEventHandler((o, e) =>
            {
                CMapObj Map = new CMapObj(fileName, this);
                Map.LoadData();
                e.Result = Map;
            });

            this.ProgressChanged += new ProgressChangedEventHandler((o, e) =>
            {
                Program.UpdateLoadingStatus();
            });

            this.RunWorkerCompleted += new RunWorkerCompletedEventHandler((o, e) =>
            {
                if (e.Result is CMapObj map)
                {
                    OnMapLoaded?.Invoke(this, new AsyncMapLoaderEventArgs(map));
                }

                OnMapLoaded = null;
            });
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Version = Assembly.GetExecutingAssembly().GetName().Version;
            SetDefaultTitle();
            PrintHeader();

            if (!DBCExtractor.ExtractDBC())
            {
                Console.WriteLine("Unable to extract DBC files, exiting...");
                Console.ReadLine();
                Environment.Exit(0);
            }

            if (!DBCStorage.Initialize())
            {
                Console.WriteLine("Unable to initialize DBC Storage, exiting...");
                Console.ReadLine();
                Environment.Exit(0);
            }

            List <string> WDTFiles;

            if (!WDTExtractor.ExtractWDTFiles(out WDTFiles))
            {
                Console.WriteLine("Unable to extract WDT files, exiting...");
                Console.ReadLine();
                Environment.Exit(0);
            }

            // For test only, extract only Azeroth.
            // TODO: We need to process, build map files, and release memory ASAP.
            // Right now, loading all data we are parsing would result in around 10gb.

            //Begin loading all wdt information.
            if (!Globals.LoadAsync)
            {
                foreach (var wdt in WDTFiles)
                {
                    var map = new CMapObj(wdt, null);
                    map.LoadData();
                    LoadedMaps.Add(map);
                    break;
                }
            }
            else
            {
                foreach (var wdt in WDTFiles)
                {
                    AsyncMapLoader loadMapTask = new AsyncMapLoader(wdt);
                    loadMapTask.OnMapLoaded += OnMapLoaded;
                    loadMapTask.RunWorkerAsync();
                    break;
                }
            }

            Console.ReadLine();
        }