Exemplo n.º 1
0
        private static void AnswerDoorbell(Session Session, ClientMessage Message)
        {
            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null || !Instance.CheckUserRights(Session))
            {
                return;
            }

            string Name   = Message.PopString();
            bool   Accept = (Message.ReadBytes(1)[0] == 65);

            Session TargetSession = SessionManager.GetSessionByCharacterId(CharacterResolverCache.GetUidFromName(Name));

            if (TargetSession == null || TargetSession.AbsoluteRoomId != Instance.RoomId || TargetSession.RoomAuthed)
            {
                return;
            }

            if (Accept)
            {
                TargetSession.RoomAuthed = true;
                TargetSession.SendData(RoomDoorbellAcceptedComposer.Compose());
                return;
            }

            TargetSession.SendData(RoomDoorbellNoResponseComposer.Compose());
            RoomManager.RemoveUserFromRoom(TargetSession, false);
        }
Exemplo n.º 2
0
        private static void GetRoomObjects(Session Session, ClientMessage Message)
        {
            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.AbsoluteRoomId);

            if (Instance == null || Session.RoomJoined || !Session.RoomAuthed) // if instance not found, or user already joined us, OR if the user isn't authed in the first place, let's gtfo
            {
                return;
            }

            Instance.SendObjects(Session);

            if (!Instance.AddUserToRoom(Session))
            {
                RoomManager.RemoveUserFromRoom(Session);
                return;
            }

            Session.RoomAuthed = true;
            Session.RoomJoined = true;

            ModerationLogs.LogRoomEntry(Session.CharacterId, Instance.RoomId);
            MessengerHandler.MarkUpdateNeeded(Session, 0, false);

            Session.SendData(RoomWallsStatusComposer.Compose(Instance.Info.HideWalls, Instance.Info.WallThickness, Instance.Info.FloorThickness));
            Session.SendData(RoomInfoRightsComposer.Compose(Instance.Info.Type == RoomType.Flat, Instance.RoomId,
                                                            (Instance.Info.Type == RoomType.Flat && Instance.CheckUserRights(Session, true)), Instance.Info.PubInternalName));

            /*if (Instance.Info.Type == RoomType.Flat)
             * {
             *  Session.SendData(RoomInfoComposer.Compose(Instance.Info, true));
             * }*/

            if (Session.CharacterInfo.IsMuted)
            {
                Session.SendData(RoomMutedComposer.Compose((int)Session.CharacterInfo.MutedSecondsLeft));
            }

            if (Instance.Info.OwnerId != Session.CharacterId)
            {
                QuestManager.ProgressUserQuest(Session, QuestType.SOCIAL_VISIT);
            }

            if (Session.QuestCache.CurrentQuestId > 0)
            {
                Quest Quest = QuestManager.GetQuest(Session.QuestCache.CurrentQuestId);

                if (Quest != null)
                {
                    Session.SendData(QuestStartedComposer.Compose(Session, Quest));
                }
            }
        }
Exemplo n.º 3
0
        public void HardKickUser(uint UserId)
        {
            RoomActor Actor = GetActorByReferenceId(UserId);

            if (Actor == null || Actor.Type != RoomActorType.UserCharacter)
            {
                return;
            }

            Session ActorSession = SessionManager.GetSessionByCharacterId(Actor.ReferenceId);

            RoomManager.RemoveUserFromRoom(ActorSession, true);
            RemoveCharacterFromRoom(UserId);
        }
Exemplo n.º 4
0
        public static void PrepareRoom(Session Session, uint RoomId, string Password = "", bool BypassAuthentication = false)
        {
            // Remove user from any previous room
            RoomManager.RemoveUserFromRoom(Session, false);

            // Try to retrieve room information
            RoomInfo Info = RoomInfoLoader.GetRoomInfo(RoomId);

            // Room not found, send kick notif and stop
            if (Info == null)
            {
                Session.SendData(RoomKickedComposer.Compose());
                return;
            }

            // Try to retrieve room model information
            RoomModel Model = Info.TryGetModel();

            // Model information not found, send kick notif and stop
            if (Model == null)
            {
                Session.SendData(RoomKickedComposer.Compose());
                return;
            }

            // Load room instance into the server memory if needed
            if (!RoomManager.InstanceIsLoadedForRoom(Info.Id))
            {
                RoomManager.TryLoadRoomInstance(Info.Id);
            }

            // Attempt to retrieve the instance from the server memory
            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Info.Id);

            // If the instance was not created or is unavailable, send kick notif and stop
            if (Instance == null)
            {
                Session.SendData(RoomKickedComposer.Compose());
                return;
            }

            // Check if the room capacity has been reached
            if (Info.CurrentUsers >= Info.MaxUsers && !Session.HasRight("enter_full_rooms"))
            {
                Session.SendData(RoomJoinErrorComposer.Compose(1));
                Session.SendData(RoomKickedComposer.Compose());
                return;
            }

            // Check if the user has been banned from this room
            if (Instance.IsUserBanned(Session.CharacterId))
            {
                Session.SendData(RoomJoinErrorComposer.Compose(4));
                Session.SendData(RoomKickedComposer.Compose());
                return;
            }

            // Mark room as loading and check for initial authorization
            Session.AbsoluteRoomId = Info.Id;
            Session.RoomAuthed     = (BypassAuthentication || Info.OwnerId == Session.CharacterId ||
                                      Session.HasRight("enter_locked_rooms"));
            Session.RoomJoined = false;

            // Send confirmation that the initial checks have been passed (if this is a flat)
            if (Info.Type == RoomType.Flat)
            {
                Session.SendData(RoomOpenFlatComposer.Compose());
            }

            // Try to accomplish authorization (if not already initially authorized by character rights)
            if (!Session.RoomAuthed)
            {
                // Check for valid password, if needed
                if (Info.AccessType == RoomAccessType.PasswordProtected)
                {
                    if (Info.Password != Password)
                    {
                        Session.SendData(GenericErrorComposer.Compose(-100002));
                        RoomManager.RemoveUserFromRoom(Session);
                        return;
                    }
                }
                // Send doorbell, if any users are in this room.
                else if (Info.AccessType == RoomAccessType.Locked)
                {
                    if (Instance.HumanActorCount > 0)
                    {
                        Session.SendData(RoomDoorbellComposer.Compose());
                        Instance.BroadcastMessage(RoomDoorbellComposer.Compose(Session.CharacterInfo.Username), true);
                        return;
                    }
                    else
                    {
                        Session.SendData(RoomDoorbellNoResponseComposer.Compose());
                        RoomManager.RemoveUserFromRoom(Session);
                        return;
                    }
                }
            }

            // If all these stages have been passed, mark auth as OK and continue loading
            Session.RoomAuthed = true;
            EnterRoom(Session, Instance);
        }