コード例 #1
0
ファイル: Rights.cs プロジェクト: habb0/Snowlight
        public bool GiveUserRights(uint UserId)
        {
            lock (mActorSyncRoot)
            {
                if (mUsersWithRights.Contains(UserId))
                {
                    return(false);
                }

                mUsersWithRights.Add(UserId);

                using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                {
                    MySqlClient.SetParameter("roomid", RoomId);
                    MySqlClient.SetParameter("userid", UserId);
                    MySqlClient.ExecuteNonQuery("INSERT INTO room_rights (room_id,user_id) VALUES (@roomid,@userid)");
                }

                RoomActor Actor = GetActorByReferenceId(UserId);

                if (Actor != null)
                {
                    Actor.SetStatus("flatctrl");
                    Actor.UpdateNeeded = true;

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

                    if (ActorSession != null)
                    {
                        ActorSession.SendData(RoomRightsComposer.Compose());
                    }
                }
            }

            return(true);
        }
コード例 #2
0
        public bool AddUserToRoom(Session Session)
        {
            if (Session.AbsoluteRoomId != RoomId || !Session.Authenticated)
            {
                return(false);
            }

            uint ActorId = GenerateActorId();

            if (ActorId == 0)
            {
                return(false);
            }

            Vector3 StartPosition = new Vector3(Model.DoorPosition.X, Model.DoorPosition.Y, Model.DoorPosition.Z);
            int     StartRotation = Model.DoorRotation;

            RoomActor NewActor = RoomActor.TryCreateActor(ActorId, RoomActorType.UserCharacter, Session.CharacterId,
                                                          Session.CharacterInfo, StartPosition, StartRotation, this);

            Item TargetTeleporter = null;

            if (Session.IsTeleporting)
            {
                TargetTeleporter = GetItem(Session.TargetTeleporterId);

                if (TargetTeleporter != null && !TargetTeleporter.TemporaryInteractionReferenceIds.ContainsKey(2))
                {
                    NewActor.Position = new Vector3(TargetTeleporter.RoomPosition.X, TargetTeleporter.RoomPosition.Y,
                                                    TargetTeleporter.RoomPosition.Z);
                    NewActor.HeadRotation = TargetTeleporter.RoomRotation;
                    NewActor.BodyRotation = TargetTeleporter.RoomRotation;
                    NewActor.UpdateNeeded = true;

                    TargetTeleporter.TemporaryInteractionReferenceIds.Add(2, NewActor.Id);
                    TargetTeleporter.DisplayFlags = "2";
                    TargetTeleporter.RequestUpdate(3);
                }

                Session.TargetTeleporterId = 0;
                Session.IsTeleporting      = false;
            }

            if (NewActor == null)
            {
                return(false);
            }

            AddActorToRoom(NewActor);

            if (TargetTeleporter != null)
            {
                TargetTeleporter.BroadcastStateUpdate(this);
            }

            if (CheckUserRights(Session, true))
            {
                NewActor.SetStatus("flatctrl", "useradmin");
                Session.SendData(RoomOwnerRightsComposer.Compose());
                Session.SendData(RoomRightsComposer.Compose());
            }
            else if (CheckUserRights(Session))
            {
                NewActor.SetStatus("flatctrl");
                Session.SendData(RoomRightsComposer.Compose());
            }

            if (Session.CurrentEffect > 0)
            {
                NewActor.ApplyEffect(Session.CurrentEffect);
            }

            WiredManager.HandleEnterRoom(NewActor);

            NewActor.UpdateNeeded = true;
            return(true);
        }