Ejemplo n.º 1
0
        public void RemoveUser(User user, bool free)
        {
            if (user == null)
            {
                return;
            }
            Msg_RL_UserQuit quitBuilder = new Msg_RL_UserQuit();

            quitBuilder.UserGuid = user.Guid;
            quitBuilder.RoomId   = RoomId;
            m_Connector.SendMsgToLobby(quitBuilder);

            foreach (User otheruser in m_RoomUsers)
            {
                if (null != otheruser && otheruser != user)
                {
                    otheruser.RemoveSameRoomUser(user);
                }
            }
            user.ClearSameRoomUser();
            if (null != m_ActiveScene)
            {
                Scene scene = m_ActiveScene;
                scene.LeaveScene(user);
            }

            LogSys.Log(LOG_TYPE.INFO, "FreeUser {0} for {1} {2}, [Room.RemoveUser]", user.LocalID, user.Guid, user.GetKey());
            m_RoomUsers.Remove(user);
            if (free)
            {
                m_UserPool.FreeUser(user.LocalID);
            }
        }
Ejemplo n.º 2
0
        internal void OnRoomUserQuit(int roomid, ulong guid, Msg_RL_UserQuit originalMsg)
        {
            UserInfo user = LobbyServer.Instance.UserProcessScheduler.GetUserInfo(guid);

            if (user != null)
            {
                RoomInfo room = user.Room;
                if (null != room)
                {
                    if (room.RoomId == roomid)
                    {
                        room.DelUsers(guid);
                        user.ResetRoomInfo();
                        user.CurrentRoomID = 0;
                        user.CurrentState  = UserState.Room == user.CurrentState ? UserState.Online : user.CurrentState;
                    }
                }
                else
                {
                    user.CurrentRoomID = 0;
                    user.CurrentState  = UserState.Room == user.CurrentState ? UserState.Online : user.CurrentState;
                }

                LobbyServer.Instance.ForwardToWorld(user.UserSvrName, originalMsg);

                LogSys.Log(LOG_TYPE.INFO, "RoomServer User Quit Guid {0} State {1}", guid, user.CurrentState);
            }
        }
Ejemplo n.º 3
0
        private void HandleUserQuit(Msg_LR_UserQuit msg, PBChannel channel, int handle, uint seq)
        {
            bool isFieldThread;
            int  ix = GetActiveRoomThreadIndex(msg.RoomID, out isFieldThread);

            if (ix >= 0)
            {
                if (isFieldThread)
                {
                    RoomThread roomThread = field_roomthread_list_[ix];
                    roomThread.QueueAction(roomThread.HandleUserQuit, msg, channel);
                }
                else
                {
                    RoomThread roomThread = roomthread_list_[ix];
                    roomThread.QueueAction(roomThread.HandleUserQuit, msg, channel);
                }
            }
            else
            {
                Msg_RL_UserQuit replyBuilder = new Msg_RL_UserQuit();
                replyBuilder.UserGuid = msg.UserGuid;
                replyBuilder.RoomID   = msg.RoomID;
                channel.Send(replyBuilder);
            }
        }
Ejemplo n.º 4
0
        //---------------------------------------------------------------------------------------------
        internal void HandleUserQuit(Msg_RL_UserQuit msg)
        {
            UserInfo user = GetUserInfo(msg.UserGuid);

            if (null != user)
            {
                user.CurrentState = UserState.Online;
                user.LeftLife     = UserInfo.LifeTimeOfNoHeartbeat;
            }
        }
Ejemplo n.º 5
0
 internal void MpveEndBattle(int kill_npc_ct)
 {
     if (this.CurrentState == RoomState.Finish || this.CurrentState == RoomState.Deactive)
     {
         return;
     }
     foreach (User user in room_users_)
     {
         if (user != null)
         {
             Msg_RL_UserQuit.Builder unqBuilder = Msg_RL_UserQuit.CreateBuilder();
             unqBuilder.SetRoomID(cur_room_id_);
             unqBuilder.SetUserGuid(user.Guid);
             unqBuilder.SetIsBattleEnd(true);
             connector_.SendMsgToLobby(unqBuilder.Build());
         }
     }
     //向Lobby发送战斗结束消息:RoomID,胜方阵营,开始时间,结束时间。。。
     Msg_RL_BattleEnd.Builder beBuilder = Msg_RL_BattleEnd.CreateBuilder();
     beBuilder.SetRoomID(RoomID);
     Msg_RL_BattleEnd.Types.WinnerCampEnum winCamp = Msg_RL_BattleEnd.Types.WinnerCampEnum.None;
     beBuilder.SetWinnerCamp(winCamp);
     //战斗数据
     foreach (User user in room_users_)
     {
         if (user != null)
         {
             var battleRecord = user.Info.GetCombatStatisticInfo();
             Msg_RL_UserBattleInfo.Builder ubrBuilder = Msg_RL_UserBattleInfo.CreateBuilder();
             ubrBuilder.SetUserGuid(user.Guid);
             Msg_RL_UserBattleInfo.Types.BattleResultEnum result = Msg_RL_UserBattleInfo.Types.BattleResultEnum.Unfinish;
             if (kill_npc_ct > 0)
             {
                 result = Msg_RL_UserBattleInfo.Types.BattleResultEnum.Win;
             }
             else
             {
                 result = Msg_RL_UserBattleInfo.Types.BattleResultEnum.Lost;
             }
             ubrBuilder.SetBattleResult(result);
             ubrBuilder.SetMoney(user.Info.Money);
             CombatStatisticInfo combatInfo = user.Info.GetCombatStatisticInfo();
             ubrBuilder.SetHitCount(combatInfo.HitCount);
             ubrBuilder.SetKillNpcCount(kill_npc_ct);
             ubrBuilder.SetMaxMultiHitCount(combatInfo.MaxMultiHitCount);
             ubrBuilder.SetTotalDamageToMyself(combatInfo.TotalDamageToMyself);
             ubrBuilder.SetTotalDamageFromMyself(combatInfo.TotalDamageFromMyself);
             beBuilder.AddUserBattleInfos(ubrBuilder.Build());
         }
     }
     connector_.SendMsgToLobby(beBuilder.Build());
     this.CurrentState = RoomState.Finish;
     m_FinishTime      = TimeUtility.GetServerMilliseconds();
     LogSys.Log(LOG_TYPE.DEBUG, "Room {0}({1}) MpveEndBattle.", RoomID, LocalID);
 }
Ejemplo n.º 6
0
        private void HandleUserQuit(Msg_RL_UserQuit msg_, PBChannel channel, int src, uint session)
        {
            UserProcessScheduler dataProcess = UserServer.Instance.UserProcessScheduler;
            UserThread           userThread  = dataProcess.GetUserThread(msg_.UserGuid);

            if (null != userThread)
            {
                userThread.QueueAction(userThread.HandleUserQuit, msg_);
            }
            else
            {
                dataProcess.DefaultUserThread.QueueAction(dataProcess.DefaultUserThread.HandleUserQuit, msg_);
            }
        }
Ejemplo n.º 7
0
 internal void NoticeRoomClosing()
 {
     foreach (User user in room_users_)
     {
         if (user != null && (int)UserControlState.UserDropped == user.UserControlState)
         {
             Msg_RL_UserQuit.Builder unqBuilder = Msg_RL_UserQuit.CreateBuilder();
             unqBuilder.SetRoomID(cur_room_id_);
             unqBuilder.SetUserGuid(user.Guid);
             unqBuilder.SetIsBattleEnd(true);
             connector_.SendMsgToLobby(unqBuilder.Build());
         }
     }
 }
Ejemplo n.º 8
0
        internal void HandleUserQuit(Msg_LR_UserQuit msg, PBChannel channel)
        {
            Room room = GetRoomByID(msg.RoomID);

            if (null != room)
            {
                User user = room.GetUserByGuid(msg.UserGuid);
                if (null != user)
                {
                    room.DeleteUser(user);
                }
            }
            Msg_RL_UserQuit replyBuilder = new Msg_RL_UserQuit();

            replyBuilder.UserGuid = msg.UserGuid;
            replyBuilder.RoomID   = msg.RoomID;
            channel.Send(replyBuilder);
        }
Ejemplo n.º 9
0
        internal void DropUser(User user)
        {
            //向游戏客户端广播玩家掉线消息
            Msg_CRC_Exit bd = new Msg_CRC_Exit();

            bd.role_id = user.RoleId;
            user.BroadCastMsgToRoom(bd);
            //向Lobby发送玩家掉线消息
            Msg_RL_UserQuit.Builder uaqBuilder = Msg_RL_UserQuit.CreateBuilder();
            uaqBuilder.SetRoomID(cur_room_id_);
            uaqBuilder.SetUserGuid(user.Guid);
            uaqBuilder.SetIsBattleEnd(false);
            connector_.SendMsgToLobby(uaqBuilder.Build());
            //控制状态改为掉线
            user.UserControlState = (int)UserControlState.UserDropped;
            if (null != user.Info)
            {
                // user.Info.Suicide();
            }
            LogSys.Log(LOG_TYPE.DEBUG, "Room {0} User {1}({2}) dropped.", RoomID, user.Guid, user.GetKey());
        }
 private void HandleUserQuit(Msg_RL_UserQuit msg, PBChannel channel, int src, uint session)
 {
     //响应RoomServer回复lobby Msg_LR_UserQuit的消息
     m_RoomProcessThread.OnRoomUserQuit(msg.RoomId, msg.UserGuid, msg);
 }
 private void HandleUserQuit(Msg_RL_UserQuit msg, PBChannel channel, int src, uint session)
 {
     //响应RoomServer游戏客户端退出消息
     m_RoomProcessThread.QueueAction(m_RoomProcessThread.OnRoomUserQuit, msg.RoomID, msg.UserGuid, msg.IsBattleEnd);
 }
 private void HandleUserQuit(Msg_RL_UserQuit msg_, PBChannel channel, int src, uint session)
 {
 }