public override void OnTick(MarryRoom room)
 {
     try
     {
         if (room != null)
         {
             room.KickAllPlayer();
             using (PlayerBussiness playerBussiness = new PlayerBussiness())
             {
                 playerBussiness.DisposeMarryRoomInfo(room.Info.ID);
             }
             GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(room.Info.GroomID);
             GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(room.Info.BrideID);
             GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(room.Info.GroomID, false, room.Info);
             GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(room.Info.BrideID, false, room.Info);
             MarryRoomMgr.RemoveMarryRoom(room);
             GSPacketIn gSPacketIn = new GSPacketIn(254);
             gSPacketIn.WriteInt(room.Info.ID);
             WorldMgr.MarryScene.SendToALL(gSPacketIn);
             room.StopTimer();
         }
     }
     catch (Exception exception)
     {
         if (TankMarryLogicProcessor.log.IsErrorEnabled)
         {
             TankMarryLogicProcessor.log.Error("OnTick", exception);
         }
     }
 }
Пример #2
0
        public void HandleMarryRoomDispose(GSPacketIn packet)
        {
            int roomId = packet.ReadInt();

            MarryRoom[] rooms = MarryRoomMgr.GetAllMarryRoom();
            MarryRoom[] array = rooms;
            for (int i = 0; i < array.Length; i++)
            {
                MarryRoom room = array[i];
                if (room.Info.ID == roomId)
                {
                    room.KillAllPlayer();
                    MarryRoomMgr.RemoveMarryRoom(room);
                    GSPacketIn pkg = new GSPacketIn(254);
                    pkg.WriteInt(roomId);
                    WorldMgr.MarryScene.SendToALL(pkg);
                    room.StopTimer();
                    GSPacketIn pkg2 = new GSPacketIn(249);
                    pkg2.WriteByte(9);
                    room.SendToAll(pkg2);
                    room.StopTimerForHymeneal();
                    room.SendUserRemoveLate();
                    room.SendMarryRoomInfoUpdateToScenePlayers(room);
                }
            }
        }
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            GSPacketIn gSPacketIn = new GSPacketIn(240, client.Player.PlayerCharacter.ID);

            if (WorldMgr.MarryScene.AddPlayer(client.Player))
            {
                gSPacketIn.WriteBoolean(true);
            }
            else
            {
                gSPacketIn.WriteBoolean(false);
            }
            client.Out.SendTCP(gSPacketIn);
            if (client.Player.CurrentMarryRoom == null)
            {
                MarryRoom[] allMarryRoom = MarryRoomMgr.GetAllMarryRoom();
                MarryRoom[] array        = allMarryRoom;
                for (int i = 0; i < array.Length; i++)
                {
                    MarryRoom room = array[i];
                    client.Player.Out.SendMarryRoomInfo(client.Player, room);
                }
            }
            return(0);
        }
Пример #4
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            GSPacketIn pkg = packet.Clone();

            if (WorldMgr.MarryScene.AddPlayer(player))
            {
                pkg.WriteBoolean(true);
            }
            else
            {
                pkg.WriteBoolean(false);
            }
            player.Out.SendTCP(pkg);
            if (player.CurrentMarryRoom == null)
            {
                MarryRoom[] list  = MarryRoomMgr.GetAllMarryRoom();
                MarryRoom[] array = list;
                for (int i = 0; i < array.Length; i++)
                {
                    MarryRoom g = array[i];
                    player.Out.SendMarryRoomInfo(player, g);
                }
            }
            return(0);
        }
Пример #5
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!");
     }
 }
Пример #6
0
        //修改:  Xiaov
        //时间:  2009-11-7
        //描述:  进入结婚场景<已测试>
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            GSPacketIn pkg = packet.Clone();

            if (WorldMgr.MarryScene.AddPlayer(client.Player))
            {
                pkg.WriteBoolean(true);
            }
            else
            {
                pkg.WriteBoolean(false);
            }
            client.Out.SendTCP(pkg);

            if (client.Player.CurrentMarryRoom == null)
            {
                MarryRoom[] list = MarryRoomMgr.GetAllMarryRoom();

                foreach (MarryRoom g in list)
                {
                    client.Player.Out.SendMarryRoomInfo(client.Player, g);
                }
            }
            return(0);

            //if (client.Player.CurrentScene == WorldMgr.MarryScene)
            //{
            //    MarryRoom[] list = MarryRoomMgr.GetAllMarryRoom();
            //    foreach (MarryRoom g in list)
            //    {
            //        client.Player.Out.SendMarryRoomInfo(client.Player, g);
            //    }

            //    client.Out.SendPingTime();
            //}
        }
Пример #7
0
        public override void OnTick(MarryRoom room)
        {
            try
            {
                if (room != null)
                {
                    room.KickAllPlayer();

                    using (PlayerBussiness db = new PlayerBussiness())
                    {
                        db.DisposeMarryRoomInfo(room.Info.ID);
                    }

                    GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(room.Info.GroomID);
                    GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(room.Info.BrideID);

                    GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(room.Info.GroomID, false, room.Info);
                    GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(room.Info.BrideID, false, room.Info);

                    MarryRoomMgr.RemoveMarryRoom(room);

                    GSPacketIn pkg = new GSPacketIn((short)ePackageType.MARRY_ROOM_DISPOSE);
                    pkg.WriteInt(room.Info.ID);
                    WorldMgr.MarryScene.SendToALL(pkg);

                    room.StopTimer();
                }
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("OnTick", ex);
                }
            }
        }
Пример #8
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (!client.Player.PlayerCharacter.IsMarried)
            {
                return(1);
            }

            if (client.Player.PlayerCharacter.IsCreatedMarryRoom)
            {
                //client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryRoomCreateHandler.Msg1"));
                return(1);
            }

            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked"));
                return(0);
            }

            if (client.Player.CurrentRoom != null)
            {
                client.Player.CurrentRoom.RemovePlayerUnsafe(client.Player);
            }

            if (client.Player.CurrentMarryRoom != null)
            {
                client.Player.CurrentMarryRoom.RemovePlayer(client.Player);
            }

            //GamePlayer tempPlayer = WorldMgr.GetPlayerById(client.Player.PlayerCharacter.SpouseID);
            //if(tempPlayer != null)
            //{
            //    if (tempPlayer.IsMarryRommCreating)
            //    {
            //        client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryRoomCreateHandler.IsCreating"));
            //        return 1;
            //    }
            //}

            //client.Player.IsMarryRommCreating = true;

            MarryRoomInfo info = new MarryRoomInfo();

            info.Name             = packet.ReadString().Replace(";", "");
            info.Pwd              = packet.ReadString();
            info.MapIndex         = packet.ReadInt();
            info.AvailTime        = packet.ReadInt();
            info.MaxCount         = packet.ReadInt();
            info.GuestInvite      = packet.ReadBoolean();
            info.RoomIntroduction = packet.ReadString();
            info.ServerID         = GameServer.Instance.Configuration.ServerID;
            info.IsHymeneal       = false;

            string[] money = GameProperties.PRICE_MARRY_ROOM.Split(',');
            if (money.Length < 3)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("MarryRoomCreateMoney node in configuration file is wrong");
                }

                return(1);
            }

            int needMoney = 0;

            switch (info.AvailTime)
            {
            case 2:
                needMoney = int.Parse(money[0]);
                break;

            case 3:
                needMoney = int.Parse(money[1]);
                break;

            case 4:
                needMoney = int.Parse(money[2]);
                break;

            default:
                needMoney      = int.Parse(money[2]);
                info.AvailTime = 4;
                break;
            }

            if (client.Player.PlayerCharacter.Money >= needMoney)
            {
                MarryRoom room = MarryRoomMgr.CreateMarryRoom(client.Player, info);

                if (room != null)
                {
                    client.Player.RemoveMoney(needMoney);
                    LogMgr.LogMoneyAdd(LogMoneyType.Marry, LogMoneyType.Marry_Room, client.Player.PlayerCharacter.ID, needMoney, client.Player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", "");
                    GSPacketIn pkg = client.Player.Out.SendMarryRoomInfo(client.Player, room);
                    client.Player.Out.SendMarryRoomLogin(client.Player, true);
                    room.SendToScenePlayer(pkg);

                    CountBussiness.InsertSystemPayCount(client.Player.PlayerCharacter.ID, needMoney, 0, (int)eConsumerType.Marry, (int)eSubConsumerType.Marry_MarryRoom);
                }

                return(0);
            }
            else
            {
                client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough"));
            }

            return(1);
        }
Пример #9
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            bool isInMovie = packet.ReadBoolean();
            int  result;

            if (!player.PlayerCharacter.IsMarried)
            {
                result = 1;
            }
            else
            {
                if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked)
                {
                    player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                    result = 0;
                }
                else
                {
                    int needMoney = AppConfig.AppSettings["DivorcedMoney"].ConvertToInt(5214);
                    if (player.PlayerCharacter.Money < needMoney)
                    {
                        player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("DivorceApplyHandler.Msg1", new object[0]));
                        result = 1;
                    }
                    else
                    {
                        if (player.PlayerCharacter.IsCreatedMarryRoom)
                        {
                            using (PlayerBussiness db = new PlayerBussiness())
                            {
                                db.DisposeMarryRoomInfo(player.PlayerCharacter.SelfMarryRoomID);
                                GameServer.Instance.LoginServer.SendMarryRoomDisposeToPlayer(player.PlayerCharacter.SelfMarryRoomID);
                            }
                            MarryRoom[] rooms = MarryRoomMgr.GetAllMarryRoom();
                            MarryRoom[] array = rooms;
                            for (int i = 0; i < array.Length; i++)
                            {
                                MarryRoom room = array[i];
                                if (room.Info.GroomID == player.PlayerCharacter.ID || room.Info.BrideID == player.PlayerCharacter.ID)
                                {
                                    room.KillAllPlayer();
                                    GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(room.Info.GroomID);
                                    GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(room.Info.BrideID);
                                    GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(room.Info.GroomID, false, room.Info);
                                    GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(room.Info.BrideID, false, room.Info);
                                    MarryRoomMgr.RemoveMarryRoom(room);
                                    GSPacketIn pkg = new GSPacketIn(254);
                                    pkg.WriteInt(room.Info.ID);
                                    WorldMgr.MarryScene.SendToALL(pkg);
                                    room.StopTimer();
                                    if (isInMovie)
                                    {
                                        GSPacketIn pkg2 = new GSPacketIn(249);
                                        pkg2.WriteByte(9);
                                        room.SendToAll(pkg2);
                                        room.StopTimerForHymeneal();
                                        room.SendUserRemoveLate();
                                    }
                                    break;
                                }
                            }
                        }
                        player.RemoveMoney(needMoney, LogMoneyType.Marry, LogMoneyType.Marry_Unmarry);
                        CountBussiness.InsertSystemPayCount(player.PlayerCharacter.ID, needMoney, 0, 0, 3);
                        using (PlayerBussiness db = new PlayerBussiness())
                        {
                            PlayerInfo tempSpouse = db.GetUserSingleAllUserID(player.PlayerCharacter.SpouseID);
                            if (tempSpouse == null || tempSpouse.Sex == player.PlayerCharacter.Sex)
                            {
                                result = 1;
                                return(result);
                            }
                            MarryApplyInfo info = new MarryApplyInfo();
                            info.UserID           = player.PlayerCharacter.SpouseID;
                            info.ApplyUserID      = player.PlayerCharacter.ID;
                            info.ApplyUserName    = player.PlayerCharacter.NickName;
                            info.ApplyType        = 3;
                            info.LoveProclamation = "";
                            info.ApplyResult      = false;
                            int id = 0;
                            if (db.SavePlayerMarryNotice(info, 0, ref id))
                            {
                                GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(tempSpouse.ID);
                                player.LoadMarryProp();
                            }
                        }
                        player.QuestInventory.ClearMarryQuest();
                        player.Out.SendPlayerDivorceApply(player, true, true);
                        result = 0;
                    }
                }
            }
            return(result);
        }
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            MarryRoom marryRoom = null;
            string    text      = "";
            int       num       = packet.ReadInt();
            string    text2     = packet.ReadString();
            int       marryMap  = packet.ReadInt();

            if (num != 0)
            {
                marryRoom = MarryRoomMgr.GetMarryRoombyID(num, (text2 == null) ? "" : text2, ref text);
            }
            else
            {
                if (client.Player.PlayerCharacter.IsCreatedMarryRoom)
                {
                    MarryRoom[] allMarryRoom = MarryRoomMgr.GetAllMarryRoom();
                    MarryRoom[] array        = allMarryRoom;
                    for (int i = 0; i < array.Length; i++)
                    {
                        MarryRoom marryRoom2 = array[i];
                        if (marryRoom2.Info.GroomID == client.Player.PlayerCharacter.ID || marryRoom2.Info.BrideID == client.Player.PlayerCharacter.ID)
                        {
                            marryRoom = marryRoom2;
                            break;
                        }
                    }
                }
                if (marryRoom == null && client.Player.PlayerCharacter.SelfMarryRoomID != 0)
                {
                    client.Player.Out.SendMarryRoomLogin(client.Player, false);
                    MarryRoomInfo marryRoomInfo = null;
                    using (PlayerBussiness playerBussiness = new PlayerBussiness())
                    {
                        marryRoomInfo = playerBussiness.GetMarryRoomInfoSingle(client.Player.PlayerCharacter.SelfMarryRoomID);
                    }
                    if (marryRoomInfo != null)
                    {
                        client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryRoomLoginHandler.RoomExist", new object[]
                        {
                            marryRoomInfo.ServerID,
                            client.Player.PlayerCharacter.SelfMarryRoomID
                        }));
                        return(0);
                    }
                }
            }
            if (marryRoom != null)
            {
                if (marryRoom.CheckUserForbid(client.Player.PlayerCharacter.ID))
                {
                    client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("MarryRoomLoginHandler.Forbid", new object[0]));
                    client.Player.Out.SendMarryRoomLogin(client.Player, false);
                    return(1);
                }
                if (marryRoom.RoomState == eRoomState.FREE)
                {
                    if (marryRoom.AddPlayer(client.Player))
                    {
                        client.Player.MarryMap = marryMap;
                        client.Player.Out.SendMarryRoomLogin(client.Player, true);
                        marryRoom.SendMarryRoomInfoUpdateToScenePlayers(marryRoom);
                        return(0);
                    }
                }
                else
                {
                    client.Player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryRoomLoginHandler.AlreadyBegin", new object[0]));
                }
                client.Player.Out.SendMarryRoomLogin(client.Player, false);
            }
            else
            {
                client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation(string.IsNullOrEmpty(text) ? "MarryRoomLoginHandler.Failed" : text, new object[0]));
                client.Player.Out.SendMarryRoomLogin(client.Player, false);
            }
            return(1);
        }
Пример #11
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            //if (client.Player.CurrentGame != null)
            //{
            //    client.Player.CurrentGame.RemovePlayer(client.Player);
            //}
            //if(client.Player.CurrentMarryRoom != null)
            //{
            //    client.Player.CurrentMarryRoom.RemovePlayer(client.Player);
            //}

            MarryRoom room = null;
            string    msg  = "";

            int    id      = packet.ReadInt();
            string pwd     = packet.ReadString();
            int    sceneID = packet.ReadInt();

            if (id != 0)
            {
                room = MarryRoomMgr.GetMarryRoombyID(id, pwd == null ? "" : pwd, ref msg);
            }
            else
            {
                if (client.Player.PlayerCharacter.IsCreatedMarryRoom)
                {
                    MarryRoom[] rooms = MarryRoomMgr.GetAllMarryRoom();

                    foreach (MarryRoom r in rooms)
                    {
                        if (r.Info.GroomID == client.Player.PlayerCharacter.ID || r.Info.BrideID == client.Player.PlayerCharacter.ID)
                        {
                            room = r;
                            break;
                        }
                    }
                }

                if (room == null && client.Player.PlayerCharacter.SelfMarryRoomID != 0)
                {
                    client.Player.Out.SendMarryRoomLogin(client.Player, false);
                    MarryRoomInfo info = null;
                    using (PlayerBussiness db = new PlayerBussiness())
                    {
                        info = db.GetMarryRoomInfoSingle(client.Player.PlayerCharacter.SelfMarryRoomID);
                    }

                    if (info != null)
                    {
                        client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryRoomLoginHandler.RoomExist", info.ServerID, client.Player.PlayerCharacter.SelfMarryRoomID));
                        return(0);
                    }
                }
            }

            if (room != null)
            {
                if (room.CheckUserForbid(client.Player.PlayerCharacter.ID))
                {
                    client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("MarryRoomLoginHandler.Forbid"));
                    client.Player.Out.SendMarryRoomLogin(client.Player, false);
                    return(1);
                }

                if (room.RoomState == eRoomState.FREE)
                {
                    if (room.AddPlayer(client.Player))
                    {
                        client.Player.MarryMap = sceneID;

                        GSPacketIn pkg = client.Player.Out.SendMarryRoomLogin(client.Player, true);

                        room.SendMarryRoomInfoUpdateToScenePlayers(room);

                        return(0);
                    }
                }
                else
                {
                    client.Player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryRoomLoginHandler.AlreadyBegin"));
                }

                client.Player.Out.SendMarryRoomLogin(client.Player, false);
            }
            else
            {
                client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation(string.IsNullOrEmpty(msg) ? "MarryRoomLoginHandler.Failed" : msg));
                client.Player.Out.SendMarryRoomLogin(client.Player, false);
            }

            return(1);
        }
Пример #12
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int result;

            if (!player.PlayerCharacter.IsMarried)
            {
                result = 1;
            }
            else
            {
                if (player.PlayerCharacter.IsCreatedMarryRoom)
                {
                    result = 1;
                }
                else
                {
                    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.CurrentMarryRoom != null)
                        {
                            player.CurrentMarryRoom.RemovePlayer(player);
                        }
                        MarryRoomInfo info = new MarryRoomInfo();
                        info.Name             = packet.ReadString().Replace(";", "");
                        info.Pwd              = packet.ReadString();
                        info.MapIndex         = packet.ReadInt();
                        info.AvailTime        = packet.ReadInt();
                        info.MaxCount         = packet.ReadInt();
                        info.GuestInvite      = packet.ReadBoolean();
                        info.RoomIntroduction = packet.ReadString();
                        info.ServerID         = GameServer.Instance.Config.ServerID;
                        info.IsHymeneal       = false;
                        string[] array = new string[]
                        {
                            "1",
                            "2",
                            "3"
                        };
                        string[] money = "2000,2700,3400".Split(new char[]
                        {
                            ','
                        });
                        if (money.Length < 3)
                        {
                            MarryRoomCreateHandler.log.Error("MarryRoomCreateMoney node in configuration file is wrong");

                            result = 1;
                        }
                        else
                        {
                            int needMoney;
                            switch (info.AvailTime)
                            {
                            case 2:
                                needMoney = int.Parse(money[0]);
                                break;

                            case 3:
                                needMoney = int.Parse(money[1]);
                                break;

                            case 4:
                                needMoney = int.Parse(money[2]);
                                break;

                            default:
                                needMoney      = int.Parse(money[2]);
                                info.AvailTime = 4;
                                break;
                            }
                            if (player.PlayerCharacter.Money >= needMoney)
                            {
                                MarryRoom room = MarryRoomMgr.CreateMarryRoom(player, info);
                                if (room != null)
                                {
                                    player.RemoveMoney(needMoney, LogMoneyType.Marry, LogMoneyType.Marry_Room);
                                    GSPacketIn pkg = player.Out.SendMarryRoomInfo(player, room);
                                    player.Out.SendMarryRoomLogin(player, true);
                                    room.SendToScenePlayer(pkg);
                                    CountBussiness.InsertSystemPayCount(player.PlayerCharacter.ID, needMoney, 0, 0, 0);
                                }
                                result = 0;
                            }
                            else
                            {
                                player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough", new object[0]));
                                result = 1;
                            }
                        }
                    }
                }
            }
            return(result);
        }
Пример #13
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            MarryRoom room    = null;
            string    msg     = "";
            int       id      = packet.ReadInt();
            string    pwd     = packet.ReadString();
            int       sceneID = packet.ReadInt();
            int       result;

            if (id != 0)
            {
                room = MarryRoomMgr.GetMarryRoombyID(id, (pwd == null) ? "" : pwd, ref msg);
            }
            else
            {
                if (player.PlayerCharacter.IsCreatedMarryRoom)
                {
                    MarryRoom[] rooms = MarryRoomMgr.GetAllMarryRoom();
                    MarryRoom[] array = rooms;
                    for (int i = 0; i < array.Length; i++)
                    {
                        MarryRoom r = array[i];
                        if (r.Info.GroomID == player.PlayerCharacter.ID || r.Info.BrideID == player.PlayerCharacter.ID)
                        {
                            room = r;
                            break;
                        }
                    }
                }
                if (room == null && player.PlayerCharacter.SelfMarryRoomID != 0)
                {
                    player.Out.SendMarryRoomLogin(player, false);
                    MarryRoomInfo info = null;
                    using (PlayerBussiness db = new PlayerBussiness())
                    {
                        info = db.GetMarryRoomInfoSingle(player.PlayerCharacter.SelfMarryRoomID);
                    }
                    if (info != null)
                    {
                        player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryRoomLoginHandler.RoomExist", new object[]
                        {
                            info.ServerID,
                            player.PlayerCharacter.SelfMarryRoomID
                        }));
                        result = 0;
                        return(result);
                    }
                }
            }
            if (room != null)
            {
                if (room.CheckUserForbid(player.PlayerCharacter.ID))
                {
                    player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("MarryRoomLoginHandler.Forbid", new object[0]));
                    player.Out.SendMarryRoomLogin(player, false);
                    result = 1;
                    return(result);
                }
                if (room.RoomState == eRoomState.FREE)
                {
                    if (room.AddPlayer(player))
                    {
                        player.MarryMap = sceneID;
                        GSPacketIn pkg = player.Out.SendMarryRoomLogin(player, true);
                        room.SendMarryRoomInfoUpdateToScenePlayers(room);
                        result = 0;
                        return(result);
                    }
                }
                else
                {
                    player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryRoomLoginHandler.AlreadyBegin", new object[0]));
                }
                player.Out.SendMarryRoomLogin(player, false);
            }
            else
            {
                player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation(string.IsNullOrEmpty(msg) ? "MarryRoomLoginHandler.Failed" : msg, new object[0]));
                player.Out.SendMarryRoomLogin(player, false);
            }
            result = 1;
            return(result);
        }
Пример #14
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (!client.Player.PlayerCharacter.IsMarried)
            {
                return(1);
            }
            if (client.Player.PlayerCharacter.IsCreatedMarryRoom)
            {
                return(1);
            }
            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                return(0);
            }
            if (client.Player.CurrentRoom != null)
            {
                client.Player.CurrentRoom.RemovePlayerUnsafe(client.Player);
            }
            if (client.Player.CurrentMarryRoom != null)
            {
                client.Player.CurrentMarryRoom.RemovePlayer(client.Player);
            }
            MarryRoomInfo marryRoomInfo = new MarryRoomInfo();

            marryRoomInfo.Name             = packet.ReadString().Replace(";", "");
            marryRoomInfo.Pwd              = packet.ReadString();
            marryRoomInfo.MapIndex         = packet.ReadInt();
            marryRoomInfo.AvailTime        = packet.ReadInt();
            marryRoomInfo.MaxCount         = packet.ReadInt();
            marryRoomInfo.GuestInvite      = packet.ReadBoolean();
            marryRoomInfo.RoomIntroduction = packet.ReadString();
            marryRoomInfo.ServerID         = GameServer.Instance.Configuration.ServerID;
            marryRoomInfo.IsHymeneal       = false;
            string[] array = GameProperties.PRICE_MARRY_ROOM.Split(new char[]
            {
                ','
            });
            if (array.Length < 3)
            {
                if (MarryRoomCreateHandler.log.IsErrorEnabled)
                {
                    MarryRoomCreateHandler.log.Error("MarryRoomCreateMoney node in configuration file is wrong");
                }
                return(1);
            }
            int num;

            switch (marryRoomInfo.AvailTime)
            {
            case 2:
                num = int.Parse(array[0]);
                break;

            case 3:
                num = int.Parse(array[1]);
                break;

            case 4:
                num = int.Parse(array[2]);
                break;

            default:
                num = int.Parse(array[2]);
                marryRoomInfo.AvailTime = 4;
                break;
            }
            if (client.Player.PlayerCharacter.Money >= num)
            {
                MarryRoom marryRoom = MarryRoomMgr.CreateMarryRoom(client.Player, marryRoomInfo);
                if (marryRoom != null)
                {
                    client.Player.RemoveMoney(num);
                    LogMgr.LogMoneyAdd(LogMoneyType.Marry, LogMoneyType.Marry_Room, client.Player.PlayerCharacter.ID, num, client.Player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", "");
                    GSPacketIn packet2 = client.Player.Out.SendMarryRoomInfo(client.Player, marryRoom);
                    client.Player.Out.SendMarryRoomLogin(client.Player, true);
                    marryRoom.SendToScenePlayer(packet2);
                    CountBussiness.InsertSystemPayCount(client.Player.PlayerCharacter.ID, num, 0, 0, 0);
                }
                return(0);
            }
            client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough", new object[0]));
            return(1);
        }
Пример #15
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);
            }
        }
Пример #16
0
        /// <summary>
        /// Stops the server, disconnects all clients, and writes the database to disk
        /// </summary>
        public override void Stop()
        {
            if (m_isRunning)
            {
                m_isRunning = false;

                //记录礼堂使用情况
                if (!MarryRoomMgr.UpdateBreakTimeWhereServerStop())
                {
                    Console.WriteLine("Update BreakTime failed");
                }

                RoomMgr.Stop();
                GameMgr.Stop();

                if (_loginServer != null)
                {
                    _loginServer.Disconnected -= new ClientEventHandle(loginServer_Disconnected);
                    _loginServer.Disconnect();
                }

                //ping check timer
                if (m_pingCheckTimer != null)
                {
                    m_pingCheckTimer.Change(Timeout.Infinite, Timeout.Infinite);
                    m_pingCheckTimer.Dispose();
                    m_pingCheckTimer = null;
                }

                //Stop the World Save timer
                if (m_saveDbTimer != null)
                {
                    m_saveDbTimer.Change(Timeout.Infinite, Timeout.Infinite);
                    m_saveDbTimer.Dispose();
                    m_saveDbTimer = null;
                }

                if (m_saveRecordTimer != null)
                {
                    m_saveRecordTimer.Change(Timeout.Infinite, Timeout.Infinite);
                    m_saveRecordTimer.Dispose();
                    m_saveRecordTimer = null;
                    SaveRecordProc(null);
                }

                if (m_buffScanTimer != null)
                {
                    m_buffScanTimer.Change(Timeout.Infinite, Timeout.Infinite);
                    m_buffScanTimer.Dispose();
                    m_buffScanTimer = null;
                }

                SaveTimerProc(null);

                //Stop the base server
                base.Stop();

                Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;

                log.Info("Server Stopped!");
                //LogManager.Shutdown();


                Console.WriteLine("Server Stopped!");
            }
        }
Пример #17
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);
        }