Esempio n. 1
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            GSPacketIn pkg = packet.Clone();

            if (WorldMgr.SpaScene.AddPlayer(player))
            {
                pkg.WriteBoolean(true);
            }
            else
            {
                pkg.WriteBoolean(false);
            }
            player.Out.SendTCP(pkg);
            DateTime lastTimeLeaveSpaRoom = player.PlayerCharacter.LastSpaDate;

            //bool flag = 1 == 0;
            if (lastTimeLeaveSpaRoom.Year != DateTime.Now.Year || lastTimeLeaveSpaRoom.Month != DateTime.Now.Month || lastTimeLeaveSpaRoom.Day != DateTime.Now.Day)
            {
                player.UpdateSpaPubGoldRoomLimit(SpaRoomMgr.pubGoldRoom_MinLimit);
                player.UpdateSpaPubMoneyRoomLimit(SpaRoomMgr.pubMoneyRoom_MinLimit);
                player.UpdateIsInSpaPubGoldToday(false);
                player.UpdateIsInSpaPubMoneyToday(false);
            }
            if (player.CurrentSpaRoom != null)
            {
                player.CurrentSpaRoom.RemovePlayer(player);
            }
            SpaRoom[] list = SpaRoomMgr.GetAllSpaRoom();
            player.Out.SendSpaRoomList(player, list);
            return(0);
        }
Esempio n. 2
0
 public override void OnTick(SpaRoom room)
 {
     try
     {
         if (room != null)
         {
             room.KickAllPlayer();
             using (PlayerBussiness db = new PlayerBussiness())
             {
                 db.DisposeSpaRoomInfo(room.Spa_Room_Info.RoomID);
             }
             SpaRoomMgr.RemoveSpaRoom(room);
             GSPacketIn pkg = new GSPacketIn(174);
             pkg.WriteInt(room.Spa_Room_Info.RoomID);
             WorldMgr.SpaScene.SendToALL(pkg);
             room.StopTimer();
         }
     }
     catch (Exception ex)
     {
         //if (SpaLogicProcessor.log.IsErrorEnabled)
         {
             SpaLogicProcessor.log.Error("OnTick", ex);
         }
     }
 }
Esempio n. 3
0
 public override void Stop()
 {
     if (this.IsRunning == 1)
     {
         this.IsRunning = -1;
         if (!MarryRoomMgr.UpdateBreakTimeWhereServerStop())
         {
             Console.WriteLine("Update Marry BreakTime failed");
         }
         if (!SpaRoomMgr.UpdateBreakTimeWhereSpaServerStop())
         {
             Console.WriteLine("Update Spa BreakTime failed");
         }
         RoomMgr.Stop();
         GameMgr.Stop();
         BattleMgr.Stop();
         if (this._loginServer != null)
         {
             this._loginServer.Disconnected -= new ClientEventHandle(this.loginServer_Disconnected);
             this._loginServer.Disconnect();
         }
         if (this.m_pingCheckTimer != null)
         {
             this.m_pingCheckTimer.Change(-1, -1);
             this.m_pingCheckTimer.Dispose();
             this.m_pingCheckTimer = null;
         }
         if (this.m_saveDbTimer != null)
         {
             this.m_saveDbTimer.Change(-1, -1);
             this.m_saveDbTimer.Dispose();
             this.m_saveDbTimer = null;
         }
         if (this.m_saveRecordTimer != null)
         {
             this.m_saveRecordTimer.Change(-1, -1);
             this.m_saveRecordTimer.Dispose();
             this.m_saveRecordTimer = null;
             this.SaveRecordProc(null);
         }
         if (this.m_buffScanTimer != null)
         {
             this.m_buffScanTimer.Change(-1, -1);
             this.m_buffScanTimer.Dispose();
             this.m_buffScanTimer = null;
         }
         if (this.m_limitItemRefreshTimer != null)
         {
             this.m_limitItemRefreshTimer.Change(-1, -1);
             this.m_limitItemRefreshTimer.Dispose();
             this.m_limitItemRefreshTimer = null;
         }
         this.SaveTimerProc(null);
         base.Stop();
         Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
         GameServer.log.Warn("Server Stopped!");
     }
 }
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int result;

            if (SpaRoomMgr.QuickLoginSpaRoom(player))
            {
                result = 1;
            }
            else
            {
                result = 0;
            }
            return(result);
        }
Esempio n. 5
0
        public bool HandleCommand(GamePlayer player, GSPacketIn packet)
        {
            bool result;

            if (player.CurrentSpaRoom == null)
            {
                result = false;
            }
            else
            {
                SpaRoom room = player.CurrentSpaRoom;
                player.Spa_Day_Alter_Continue = packet.ReadBoolean();
                if (player.Spa_Day_Alter_Continue)
                {
                    if (SpaRoomMgr.SpaPubRoomPay(player, room))
                    {
                        if (room.Spa_Room_Info.RoomType == 1)
                        {
                            player.UpdateIsInSpaPubGoldToday(true);
                        }
                        if (room.Spa_Room_Info.RoomType == 2)
                        {
                            player.UpdateIsInSpaPubMoneyToday(true);
                        }
                        result = true;
                    }
                    else
                    {
                        result = false;
                    }
                }
                else
                {
                    player.CurrentSpaRoom.RemovePlayerSpecial(player);
                    result = true;
                }
            }
            return(result);
        }
Esempio n. 6
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            SpaRoom room = null;
            string  msg  = "";
            int     id   = packet.ReadInt();
            string  pwd  = packet.ReadString();

            if (id != 0)
            {
                room = SpaRoomMgr.GetSpaRoombyID(id, (pwd == null) ? "" : pwd, ref msg);
            }
            int result;

            if (room != null)
            {
                if (room.Spa_Room_Info.RoomType == 1 && player.PlayerCharacter.SpaPubGoldRoomLimit <= 0)
                {
                    player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("SpaRoomLoginHandler.Failed", new object[0]));
                    result = 0;
                    return(result);
                }
                if (room.Spa_Room_Info.RoomType == 2 && player.PlayerCharacter.SpaPubMoneyRoomLimit <= 0)
                {
                    player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("SpaRoomLoginHandler.Failed", new object[0]));
                    result = 0;
                    return(result);
                }
            }
            if (SpaRoomMgr.LoginSpaRoom(player, room, msg))
            {
                result = 1;
            }
            else
            {
                result = 0;
            }
            return(result);
        }
Esempio n. 7
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int result;

            if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked)
            {
                player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                result = 0;
            }
            else
            {
                if (player.CurrentRoom != null)
                {
                    player.CurrentRoom.RemovePlayerUnsafe(player);
                }
                if (player.CurrentSpaRoom != null)
                {
                    player.CurrentSpaRoom.RemovePlayer(player);
                }
                SpaRoom[] rooms = SpaRoomMgr.GetAllSpaRoom();
                if (rooms != null)
                {
                    if (rooms.Count <SpaRoom>() > 2000)
                    {
                        result = 0;
                        return(result);
                    }
                }
                SpaRoomInfo info = new SpaRoomInfo();
                info.RoomName         = packet.ReadString().Replace(";", "");
                info.Pwd              = packet.ReadString();
                info.RoomIntroduction = packet.ReadString();
                info.MaxCount         = packet.ReadInt();
                info.ServerID         = GameServer.Instance.Config.ServerID;
                info.AvailTime        = SpaRoomMgr.priRoomInit_MinLimit;
                info.RoomType         = 3;
                string[] array = new string[]
                {
                    "1",
                    "2"
                };
                string[] money = "800,1600".Split(new char[]
                {
                    ','
                });
                if (money.Length < 2)
                {
                    SpaRoomCreateHandler.log.Error("SpaRoomCreateMoney node in configuration file is wrong");

                    result = 0;
                }
                else
                {
                    int needMoney;
                    if (info.MaxCount == 4)
                    {
                        needMoney = int.Parse(money[0]);
                    }
                    else
                    {
                        if (info.MaxCount == 8)
                        {
                            needMoney = int.Parse(money[1]);
                        }
                        else
                        {
                            needMoney     = int.Parse(money[1]);
                            info.MaxCount = 8;
                        }
                    }
                    if (player.PlayerCharacter.Money >= needMoney)
                    {
                        SpaRoom room = SpaRoomMgr.CreateSpaRoom(player, info);
                        if (room != null)
                        {
                            player.RemoveMoney(needMoney, LogMoneyType.Spa, LogMoneyType.Spa_Room_Creat);
                            player.Out.SendSpaRoomInfo(player, room);
                            player.Out.SendSpaRoomLogin(player);
                            room.SendSpaRoomInfoUpdateToSpaScenePlayers(room);
                            CountBussiness.InsertSystemPayCount(player.PlayerCharacter.ID, needMoney, 0, 3, 6);
                        }
                        result = 0;
                    }
                    else
                    {
                        player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough", new object[0]));
                        result = 1;
                    }
                }
            }
            return(result);
        }
Esempio n. 8
0
        public override bool Start()
        {
            bool result = true;

            try
            {
                IsRunning = 0;
                Thread.CurrentThread.Priority = ThreadPriority.Normal;
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.CurrentDomain_UnhandledException);


                if (!this.StartScriptComponents())
                {
                    result = false;
                    GameServer.log.Error("初始化脚本失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化脚本成功!");

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

                if (!this.AllocatePacketBuffers())
                {
                    result = false;
                    GameServer.log.Error("分配数据包缓冲区失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("分配数据包缓冲区成功!");

                //LogMgr.Setup

                if (!WorldMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化世界场景失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化世界场景成功!");



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

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


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

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



                if (!FightRateMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化战斗倍率失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化战斗倍率成功!");

                if (!ConsortiaLevelMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化公会等级失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化公会等级成功!");

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

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

                if (!BoxMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化时间宝箱失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化时间宝箱成功!");

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

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

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

                if (!RoomMgr.Setup(this.Config.MaxRoomCount))
                {
                    result = false;
                    GameServer.log.Error("初始化房间管理服务失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化房间管理服务成功!");

                if (!GameMgr.Setup(1, 4))
                {
                    result = false;
                    GameServer.log.Error("初始化游戏管理服务失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化游戏管理服务成功!");

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


                if (!Game.Server.Managers.RateMgr.Init(this.Config))
                {
                    result = false;
                    GameServer.log.Error("初始化经验倍率管理服务失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化经验倍率管理服务成功!");

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


                if (!BattleMgr.Setup(this.Config))
                {
                    result = false;
                    GameServer.log.Error("加载战斗管理服务失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("加载战斗管理服务成功!");

                if (!this.InitGlobalTimer())
                {
                    result = false;
                    GameServer.log.Error("初始化全局Timers失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化全局Timers成功!");

                if (!this.InitLoginServer())
                {
                    result = false;
                    GameServer.log.Error("登陆到中心服务器失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("登陆到中心服务器成功!");

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

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

                if (!ActiveMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化活动失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化活动成功!");
                if (!VIPMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化VIP失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化VIP成功!");
                if (!LevelMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化等级失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化等级成功!");

                /*  if (!WorldBossMgr.Init())
                 * {
                 *    result = false;
                 *    GameServer.log.Error("初始化世界Boss失败,请检查!");
                 *    return result;
                 * }
                 * GameServer.log.Info("初始化世界Boss成功!");
                 */
                RoomMgr.Start();
                GameMgr.Start();
                BattleMgr.Start();
                MacroDropMgr.Start();

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

                GameEventMgr.Notify(ScriptEvent.Loaded);
                GC.Collect(GC.MaxGeneration);
                //LogMgr.Setup(1, 1, 1);
                GameServer.log.Warn("游戏服务器启动成功!");
                IsRunning = 1;
            }
            catch (Exception e)
            {
                GameServer.log.Error("Failed to start the server", e);
                // throw e;
                result = false;
            }
            return(result);
        }