Пример #1
0
        public override bool Start()
        {
            if (m_isRunning)
            {
                return(false);
            }
            try
            {
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                Thread.CurrentThread.Priority = ThreadPriority.Normal;

                GameProperties.Refresh();


                if (!InitComponent(RecompileScripts(), "Recompile Scripts"))
                {
                    return(false);
                }

                if (!InitComponent(StartScriptComponents(), "Script components"))
                {
                    return(false);
                }

                if (!InitComponent((GameProperties.EDITION == Edition), "Edition:" + Edition))
                {
                    return(false);
                }

                if (!InitComponent(InitSocket(IPAddress.Parse(Configuration.Ip), Configuration.Port), "InitSocket Port:" + Configuration.Port))
                {
                    return(false);
                }

                if (!InitComponent(AllocatePacketBuffers(), "AllocatePacketBuffers()"))
                {
                    return(false);
                }

                if (!InitComponent(LogMgr.Setup(Configuration.GAME_TYPE, Configuration.ServerID, Configuration.AreaID), "LogMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(WorldMgr.Init(), "WorldMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(MapMgr.Init(), "MapMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(ItemMgr.Init(), "ItemMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(ItemBoxMgr.Init(), "ItemBox Init"))
                {
                    return(false);
                }

                if (!InitComponent(BallMgr.Init(), "BallMgr Init"))
                {
                    return(false);
                }
                if (!InitComponent(BallConfigMgr.Init(), "BallConfigMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(FusionMgr.Init(), "FusionMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(AwardMgr.Init(), "AwardMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(NPCInfoMgr.Init(), "NPCInfoMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(MissionInfoMgr.Init(), "MissionInfoMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(PveInfoMgr.Init(), "PveInfoMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(DropMgr.Init(), "Drop Init"))
                {
                    return(false);
                }

                if (!InitComponent(FightRateMgr.Init(), "FightRateMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(ConsortiaLevelMgr.Init(), "ConsortiaLevelMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(RefineryMgr.Init(), "RefineryMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(StrengthenMgr.Init(), "StrengthenMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(PropItemMgr.Init(), "PropItemMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(ShopMgr.Init(), "ShopMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(QuestMgr.Init(), "QuestMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(RoomMgr.Setup(Configuration.MaxRoomCount), "RoomMgr.Setup"))
                {
                    return(false);
                }

                if (!InitComponent(GameMgr.Setup(Configuration.ServerID, GameProperties.BOX_APPEAR_CONDITION), "GameMgr.Start()"))
                {
                    return(false);
                }

                if (!InitComponent(ConsortiaMgr.Init(), "ConsortiaMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(LanguageMgr.Setup(@""), "LanguageMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(RateMgr.Init(Configuration), "ExperienceRateMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(MacroDropMgr.Init(), "MacroDropMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(BattleMgr.Setup(), "BattleMgr Setup"))
                {
                    return(false);
                }

                if (!InitComponent(InitGlobalTimer(), "Init Global Timers"))
                {
                    return(false);
                }

                if (!InitComponent(MarryRoomMgr.Init(), "MarryRoomMgr Init"))
                {
                    return(false);
                }
                if (!InitComponent(LogMgr.Setup(1, 4, 4), "LogMgr Setup"))
                {
                    return(false);
                }
                GameEventMgr.Notify(ScriptEvent.Loaded);

                if (!InitComponent(InitLoginServer(), "Login To CenterServer"))
                {
                    return(false);
                }

                RoomMgr.Start();
                GameMgr.Start();
                BattleMgr.Start();
                MacroDropMgr.Start();

                if (!InitComponent(base.Start(), "base.Start()"))
                {
                    return(false);
                }



                GameEventMgr.Notify(GameServerEvent.Started, this);

                GC.Collect(GC.MaxGeneration);

                if (log.IsInfoEnabled)
                {
                    log.Info("GameServer is now open for connections!");
                }

                m_isRunning = true;
                return(true);
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Failed to start the server", e);
                }

                return(false);
            }
        }
Пример #2
0
        private void Init(Object sender, EventArgs e)
        {
            LogProvider.Default = new LogProvider(new LogConfig
            {
                UseMessageBox = true,
                LogView       = LogView,
                UseLogView    = true,
                FilePath      = @".\log\",
                UseFile       = true
            });
            var log = LogProvider.Default;

            this.runmgr = new RunMgr();
            Web.Server.WebServer.Runmgr = this.runmgr;

            new Thread(() =>
            {
                if (!Sql_DbObject.TryConnection())
                {
                    log.Error("Fail to connect to SQL!");
                    WinForm.Notice("初始化失败,请查看日志。");
                    return;
                }
                else
                {
                    log.Info("Succeed to to connect to SQL!");
                }
                if (!LanguageMgr.Load())
                {
                    log.Error("Fail to load language");
                    WinForm.Notice("初始化失败,请查看日志。");
                    return;
                }
                else
                {
                    log.Info("Succeed to load language");
                }
                if (!MapMgr.Init())
                {
                    log.Error("Fail to load map");
                    WinForm.Notice("初始化失败,请查看日志。");
                    return;
                }
                else
                {
                    log.Info("Succeed to load map");
                }
                if (!ItemMgr.Init())
                {
                    log.Error("Fail to load item");
                    WinForm.Notice("初始化失败,请查看日志。");
                    return;
                }
                else
                {
                    log.Info("Succeed to load item");
                }
                if (!PropItemMgr.Init())
                {
                    log.Error("Fail to load propitem");
                    WinForm.Notice("初始化失败,请查看日志。");
                    return;
                }
                else
                {
                    log.Info("Succeed to load propitem");
                }
                if (!BallMgr.Init())
                {
                    log.Error("Fail to load ball");
                    WinForm.Notice("初始化失败,请查看日志。");
                    return;
                }
                else
                {
                    log.Info("Succeed to load ball");
                }
                if (!DropMgr.Init())
                {
                    log.Error("Fail to load drop");
                    WinForm.Notice("初始化失败,请查看日志。");
                    return;
                }
                else
                {
                    log.Info("Succeed to load drop");
                }
                if (!NPCInfoMgr.Init())
                {
                    log.Error("Fail to load npc");
                    WinForm.Notice("初始化失败,请查看日志。");
                    return;
                }
                else
                {
                    log.Info("Succeed to load npc");
                }

                if (!ItemBoxMgr.Init())
                {
                    log.Error("Fail to load itembox");
                    WinForm.Notice("初始化失败,请查看日志。");
                    return;
                }
                else
                {
                    log.Info("Succeed to load itembox");
                }
                flag = true;
            }).Start();

            Thread thread = new Thread(run);

            thread.Start();
        }