Beispiel #1
0
        public static void Initialize()
        {
            if (Initialized)
                return;

            if (!Debugger.IsAttached) // the debugger handle the unhandled exceptions
                AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            AppDomain.CurrentDomain.ProcessExit += OnProcessExit;

            Config = new Config(ConfigPath);

            foreach (var assembly in m_hierarchy)
            {
                Config.BindAssembly(assembly);
                Config.RegisterAttributes(assembly);
            }

            Config.Load();

            logger.Info("{0} loaded", Path.GetFileName(Config.FilePath));

            var d2oSource = new D2OSource();
            d2oSource.AddReaders(DofusDataPath);
            DataProvider.Instance.AddSource(d2oSource);

            var maps = new D2PSource(new D2pFile(DofusMapsD2P));
            DataProvider.Instance.AddSource(maps);

            // todo : langs
            var d2iSource = new D2ISource(Languages.English);
            d2iSource.AddReaders(DofusI18NPath);
            DataProvider.Instance.AddSource(d2iSource);

            MITM = new MITM.MITM(new MITMConfiguration
                                     {
                                         FakeAuthHost = BotAuthHost,
                                         FakeAuthPort = BotAuthPort,
                                         FakeWorldHost = BotWorldHost,
                                         FakeWorldPort = BotWorldPort,
                                         RealAuthHost = RealAuthHost,
                                         RealAuthPort = RealAuthPort
                                     });

            MessageDispatcher.DefineHierarchy(m_hierarchy);

            foreach (var assembly in m_hierarchy)
            {
                MessageDispatcher.RegisterSharedAssembly(assembly);
            }

            PluginManager.Instance.LoadAllPlugins();

            DispatcherTask = new DispatcherTask(new MessageDispatcher(), MITM);
            DispatcherTask.Start(); // we have to start it now to dispatch the initialization msg

            var msg = new HostInitializationMessage();
            DispatcherTask.Dispatcher.Enqueue(msg, MITM);

            msg.Wait();

            Initialized = true;
        }
Beispiel #2
0
        public static void Initialize()
        {
            if (Initialized)
                return;

            UIManager.Instance.SetBusy(true);
            try
            {

                if (!Debugger.IsAttached) // the debugger handle the unhandled exceptions
                    AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

                AppDomain.CurrentDomain.ProcessExit += OnProcessExit;


                UIManager.Instance.BusyMessage = "Load config ...";
                Config = new Config(ConfigPath);

                foreach (Assembly assembly in m_hierarchy)
                {
                    Config.BindAssembly(assembly);
                    Config.RegisterAttributes(assembly);
                }

                Config.Load();

                logger.Info("{0} loaded", Path.GetFileName(Config.FilePath));


                UIManager.Instance.BusyMessage = "Loading D2O files ...";
                ObjectDataManager.Instance.AddReaders(Path.Combine(GetDofusPath(), DofusDataPath));
                I18NDataManager.Instance.DefaultLanguage = Languages.English;

                I18NDataManager.Instance.AddReaders(Path.Combine(GetDofusPath(), DofusI18NPath));
                IconsManager.Instance.Initialize(Path.Combine(GetDofusPath(), DofusItemIconPath));


                UIManager.Instance.BusyMessage = "Starting redis server ...";
                logger.Info("Starting redis server ...");
                RedisServerHost.Instance.ExecutablePath = RedisServerExe;
                RedisServerHost.Instance.StartOrFindProcess();

                UIManager.Instance.BusyMessage = string.Format("Loading {0}...", MapsManager.MapsDataFile);
                logger.Info("Loading {0}...", MapsManager.MapsDataFile);
                ProgressionCounter progression = MapsManager.Instance.Initialize(Path.Combine(GetDofusPath(), DofusMapsD2P));
                if (progression != null)
                    ExecuteProgress(progression);

                UIManager.Instance.BusyMessage = "Loading maps positions ...";
                logger.Info("Loading maps positions ...");
                progression = MapsPositionManager.Instance.Initialize();
                if (progression != null)
                    ExecuteProgress(progression);

                UIManager.Instance.BusyMessage = "Loading submaps ...";
                logger.Info("Loading submaps ...");
                progression = SubMapsManager.Instance.Initialize();
                if (progression != null)
                    ExecuteProgress(progression);


                MITM = new MITM.MITM(new MITMConfiguration
                    {
                        FakeAuthHost = BotAuthHost,
                        FakeAuthPort = BotAuthPort,
                        FakeWorldHost = BotWorldHost,
                        FakeWorldPort = BotWorldPort,
                        RealAuthHost = RealAuthHost,
                        RealAuthPort = RealAuthPort
                    });

                MessageDispatcher.DefineHierarchy(m_hierarchy);

                foreach (Assembly assembly in m_hierarchy)
                {
                    MessageDispatcher.RegisterSharedAssembly(assembly);
                }

                UIManager.Instance.BusyMessage = "Loading plugins ...";
                PluginManager.Instance.LoadAllPlugins();

                DispatcherTask = new DispatcherTask(new MessageDispatcher(), MITM);
                DispatcherTask.Start(); // we have to start it now to dispatch the initialization msg

                BotManager.Instance.Initialize();

                var msg = new HostInitializationMessage();
                DispatcherTask.Dispatcher.Enqueue(msg, MITM);

                msg.Wait();

            }
            finally
            {
                UIManager.Instance.SetBusy(false);
            }

            Initialized = true;
        }
Beispiel #3
-1
        private static void Initialize()
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
            AppDomain.CurrentDomain.ProcessExit += OnProcessExit;

            Config = new Config(ConfigPath);
            Config.Load();

            foreach (var assembly in m_hierarchy)
            {
                Config.BindAssembly(assembly);
            }

            var d2oSource = new D2OSource();
            d2oSource.AddReaders(Config.GetStatic("DofusDataPath", @"C:\Program Files (x86)\Dofus 2\app\data\common"));
            DataProvider.Instance.AddSource(d2oSource);

            var maps = new D2PSource(new D2pFile(Config.GetStatic("DofusMapsD2P", @"C:\Program Files (x86)\Dofus 2\app\content\maps\maps0.d2p")));
            DataProvider.Instance.AddSource(maps);

            var d2iSource = new D2ISource(Languages.English);
            d2iSource.AddReaders(Config.GetStatic("DofusI18NPath", @"C:\Program Files (x86)\Dofus 2\app\data\i18n"));
            DataProvider.Instance.AddSource(d2iSource);

            MITM = new MITM.MITM(new MITMConfiguration
                                     {
                                         FakeAuthHost = Config.GetStatic("BotAuthHost", "localhost"),
                                         FakeAuthPort = Config.GetStatic("BotAuthPort", 5555),
                                         FakeWorldHost = Config.GetStatic("BotWorldHost", "localhost"),
                                         FakeWorldPort = Config.GetStatic("BotWorldPort", 5556),
                                         RealAuthHost = Config.GetStatic("RealAuthHost", "213.248.126.180"),
                                         RealAuthPort = Config.GetStatic("RealAuthPort", 5555)
                                     });

            MessageDispatcher.DefineHierarchy(m_hierarchy);

            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                MessageDispatcher.RegisterAssembly(assembly);
            }

            PluginManager.Instance.LoadAllPlugins();

            DispatcherTask = new DispatcherTask(new MessageDispatcher(), MITM);
            DispatcherTask.Start(); // we have to start it now to dispatch the initialization msg

            var msg = new HostInitializationMessage();
            DispatcherTask.Dispatcher.Enqueue(msg, MITM);

            msg.Wait();
        }