Beispiel #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);
            }
        }
Beispiel #2
0
        public override bool Start()
        {
            bool result;

            try
            {
                LogProvider.Default = new LogProvider(new LogConfig {
                    FilePath = "./log/fight/", UseConsole = true, UseFile = true
                });
                this.m_running = true;
                Thread.CurrentThread.Priority = ThreadPriority.Normal;
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.CurrentDomain_UnhandledException);

                CrossFightServer.log.Warn("正在初始化…………");
                if (!Sql_DbObject.TryConnection())
                {
                    result = false;
                    CrossFightServer.log.Error("数据库连接失败,请检查!");
                    return(result);
                }
                CrossFightServer.log.Info("数据库连接成功!");

                if (!this.InitSocket(IPAddress.Parse(this.m_config.IP), this.m_config.Port))
                {
                    result = false;
                    CrossFightServer.log.Error("初始化监听端口失败,请检查!");
                    return(result);
                }
                CrossFightServer.log.Info("初始化监听端口成功!");



                if (!MapMgr.Init())
                {
                    result = false;
                    CrossFightServer.log.Error("初始化地图失败,请检查!");
                    return(result);
                }
                CrossFightServer.log.Info("初始化地图成功!");

                if (!ItemMgr.Init())
                {
                    result = false;
                    CrossFightServer.log.Error("初始化物品失败,请检查!");
                    return(result);
                }
                CrossFightServer.log.Info("初始化物品成功!");

                if (!PropItemMgr.Init())
                {
                    result = false;
                    CrossFightServer.log.Error("初始化道具失败,请检查!");
                    return(result);
                }
                CrossFightServer.log.Info("初始化道具成功!");

                if (!BallMgr.Init())
                {
                    result = false;
                    CrossFightServer.log.Error("初始化炸弹失败,请检查!");
                    return(result);
                }
                CrossFightServer.log.Info("初始化炸弹成功!");

                if (!DropMgr.Init())
                {
                    result = false;
                    CrossFightServer.log.Error("初始化掉落失败,请检查!");
                    return(result);
                }
                CrossFightServer.log.Info("初始化掉落成功!");

                if (!NPCInfoMgr.Init())
                {
                    result = false;
                    CrossFightServer.log.Error("初始化npc失败,请检查!");
                    return(result);
                }
                CrossFightServer.log.Info("初始化npc成功!");

                if (!LanguageMgr.Load())
                {
                    result = false;
                    CrossFightServer.log.Error("初始化语言包失败,请检查!");
                    return(result);
                }
                CrossFightServer.log.Info("初始化语言包成功!");



                if (!base.Start())
                {
                    result = false;
                    CrossFightServer.log.Error("基础服务启动失败,请检查!");
                    return(result);
                }
                CrossFightServer.log.Info("基础服务启动成功!");


                if (!ProxyRoomMgr.Setup())
                {
                    result = false;
                    CrossFightServer.log.Error("启动房间管理服务失败,请检查!");
                    return(result);
                }
                ProxyRoomMgr.Start();
                CrossFightServer.log.Info("启动房间管理服务成功!");

                if (!GameMgr.Setup(0, 4))
                {
                    result = false;
                    CrossFightServer.log.Error("启动游戏管理服务失败,请检查!");
                    return(result);
                }
                GameMgr.Start();
                StartScriptComponents();
                GameEventMgr.Notify(ScriptEvent.Loaded);
                CrossFightServer.log.Info("启动游戏管理服务成功!");
                GC.Collect(GC.MaxGeneration);
                CrossFightServer.log.Warn("战斗服务器已启动!");
                result = true;
            }

            catch (Exception e)
            {
                CrossFightServer.log.Error("Failed to start the server", e);
                result = false;
            }

            return(result);
        }
Beispiel #3
0
        public override bool Start()
        {
            if (this.m_running)
            {
                return(false);
            }
            bool result;

            try
            {
                this.m_running = true;
                Thread.CurrentThread.Priority = ThreadPriority.Normal;
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.CurrentDomain_UnhandledException);
                if (!this.InitComponent(this.InitSocket(this.m_config.Ip, this.m_config.Port), "InitSocket Port:" + this.m_config.Port))
                {
                    result = false;
                }
                else
                {
                    if (!this.InitComponent(this.StartScriptComponents(), "Script components"))
                    {
                        result = false;
                    }
                    else
                    {
                        if (!this.InitComponent(ProxyRoomMgr.Setup(), "RoomMgr.Setup"))
                        {
                            result = false;
                        }
                        else
                        {
                            if (!this.InitComponent(GameMgr.Setup(0, 4), "GameMgr.Setup"))
                            {
                                result = false;
                            }
                            else
                            {
                                if (!this.InitComponent(MapMgr.Init(), "MapMgr Init"))
                                {
                                    result = false;
                                }
                                else
                                {
                                    if (!this.InitComponent(ItemMgr.Init(), "ItemMgr Init"))
                                    {
                                        result = false;
                                    }
                                    else
                                    {
                                        if (!this.InitComponent(PropItemMgr.Init(), "PropItemMgr Init"))
                                        {
                                            result = false;
                                        }
                                        else
                                        {
                                            if (!this.InitComponent(BallMgr.Init(), "BallMgr Init"))
                                            {
                                                result = false;
                                            }
                                            else
                                            {
                                                if (!this.InitComponent(BallConfigMgr.Init(), "BallConfigMgr Init"))
                                                {
                                                    result = false;
                                                }
                                                else
                                                {
                                                    if (!this.InitComponent(DropMgr.Init(), "DropMgr Init"))
                                                    {
                                                        result = false;
                                                    }
                                                    else
                                                    {
                                                        if (!this.InitComponent(NPCInfoMgr.Init(), "NPCInfoMgr Init"))
                                                        {
                                                            result = false;
                                                        }
                                                        else
                                                        {
                                                            if (!this.InitComponent(WindMgr.Init(), "WindMgr Init"))
                                                            {
                                                                result = false;
                                                            }
                                                            else
                                                            {
                                                                if (!this.InitComponent(GoldEquipMgr.Init(), "GoldEquipMgr Init"))
                                                                {
                                                                    result = false;
                                                                }
                                                                else
                                                                {
                                                                    if (!this.InitComponent(LanguageMgr.Setup(""), "LanguageMgr Init"))
                                                                    {
                                                                        result = false;
                                                                    }
                                                                    else
                                                                    {
                                                                        GameEventMgr.Notify(ScriptEvent.Loaded);
                                                                        if (!this.InitComponent(base.Start(), "base.Start()"))
                                                                        {
                                                                            result = false;
                                                                        }
                                                                        else
                                                                        {
                                                                            ProxyRoomMgr.Start();
                                                                            GameMgr.Start();
                                                                            GameEventMgr.Notify(GameServerEvent.Started, this);
                                                                            GC.Collect(GC.MaxGeneration);
                                                                            FightServer.log.Info("GameServer is now open for connections!");
                                                                            result = true;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                FightServer.log.Error("Failed to start the server", exception);
                result = false;
            }
            return(result);
        }
Beispiel #4
0
        public override bool Start()
        {
            if (m_running)
            {
                return(false);
            }
            try
            {
                m_running = true;

                Thread.CurrentThread.Priority = ThreadPriority.Normal;

                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                //初始化监听端口
                if (!InitComponent(InitSocket(m_config.Ip, m_config.Port), "InitSocket Port:" + m_config.Port))
                {
                    return(false);
                }

                //初始化脚本
                if (!InitComponent(StartScriptComponents(), "Script components"))
                {
                    return(false);
                }

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

                if (!InitComponent(GameMgr.Setup(0, 4), "GameMgr.Setup"))
                {
                    return(false);
                }

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

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

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

                //if (!InitComponent(VaneMgr.ByteAray(), "VaneMgr ByteAray"))
                //   return false;

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

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

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

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

                //发布脚本已加载事件
                GameEventMgr.Notify(ScriptEvent.Loaded);

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

                ProxyRoomMgr.Start();
                GameMgr.Start();

                //发布服务器开始事件
                GameEventMgr.Notify(GameServerEvent.Started, this);

                GC.Collect(GC.MaxGeneration);

                log.Info("GameServer is now open for connections!");

                return(true);
            }
            catch (Exception e)
            {
                log.Error("Failed to start the server", e);
                return(false);
            }
        }
Beispiel #5
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();
        }