Beispiel #1
0
        private static void OnClientConfig(Session Session, ClientMessage Message)
        {
            int Volume = Message.PopWiredInt32();
            bool Something = Message.PopWiredBoolean();

            if (Volume < 0)
            {
                Volume = 0;
            }

            if (Volume > 100)
            {
                Volume = 100;
            }

            Session.CharacterInfo.ConfigVolume = Volume;
        }
Beispiel #2
0
        private static void PerformRoomAction(Session Session, ClientMessage Message)
        {
            if (!Session.HasRight("moderation_tool"))
            {
                return;
            }

            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Message.PopWiredUInt32());

            if (Instance == null)
            {
                Session.SendData(NotificationMessageComposer.Compose("Could not perform room action."));
                return;
            }

            bool SetLock = Message.PopWiredBoolean();
            bool SetName = Message.PopWiredBoolean();
            bool KickAll = Message.PopWiredBoolean();

            List<string> Tags = new List<string>();

            if (!SetName)
            {
                foreach (string Tag in Instance.Info.Tags)
                {
                    Tags.Add(Tag);
                }
            }

            Instance.Info.EditRoom(SetName ? "Inappropriate to hotel management" : Instance.Info.Name, SetName ?
                "Inappropriate to hotel management" : Instance.Info.Description, SetLock ? RoomAccessType.Locked :
                Instance.Info.AccessType, SetLock ? string.Empty : Instance.Info.Password, Instance.Info.MaxUsers,
                SetName ? 0 : Instance.Info.CategoryId, Tags, Instance.Info.AllowPets, Instance.Info.AllowPets,
                Instance.Info.DisableRoomBlocking, Instance.Info.HideWalls, Instance.Info.WallThickness,
                Instance.Info.FloorThickness);

            if (KickAll)
            {
                Instance.KickRoom(true);
            }

            if (KickAll || SetName || SetLock)
            {
                using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                {
                    StringBuilder Details = new StringBuilder();

                    Details.Append("Room '" + Instance.Info.Name + "' (ID " + Instance.Info.Id + "): ");
                    int i = 0;

                    if (SetName)
                    {
                        Details.Append("Name set to 'Inappropriate to hotel management'");
                        i++;
                    }

                    if (KickAll)
                    {
                        if (i > 0)
                        {
                            Details.Append(", ");
                        }

                        Details.Append("Kicked all users from room");
                        i++;
                    }

                    if (SetLock)
                    {
                        if (i > 0)
                        {
                            Details.Append(", ");
                        }

                        Details.Append("Locked room");
                        i++;
                    }

                    ModerationLogs.LogModerationAction(MySqlClient, Session, "Performed room moderation action",
                        Details.ToString());
                }
            }
        }
Beispiel #3
0
        private static void UpdateMoodlight(Session Session, ClientMessage Message)
        {
            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

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

            Item Item = Instance.MoodlightItem;

            if (Item == null)
            {
                return;
            }

            MoodlightData Data = MoodlightData.GenerateFromFlags(Item.Flags);
            int PresetId = Message.PopWiredInt32();
            MoodlightPreset Preset = null;

            if (Data.Presets.ContainsKey(PresetId))
            {
                Preset = Data.Presets[PresetId];
            }

            if (Preset == null)
            {
                return;
            }

            Preset.BackgroundOnly = !Message.PopWiredBoolean();
            Preset.ColorCode = UserInputFilter.FilterString(Message.PopString().Trim());
            Preset.ColorIntensity = Message.PopWiredInt32();

            if (!MoodlightData.IsValidColor(Preset.ColorCode))
            {
                return;
            }

            Item.Flags = Data.ToItemFlagData();
            Item.DisplayFlags = Data.ToDisplayData();

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                Item.SynchronizeDatabase(MySqlClient, true);
            }

            Item.BroadcastStateUpdate(Instance);
        }
Beispiel #4
0
        private static void OnFriendRequestDecline(Session Session, ClientMessage Message)
        {
            bool HandleAll = Message.PopWiredBoolean();
            int Amount = Message.PopWiredInt32();

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                if (HandleAll)
                {
                    MySqlClient.SetParameter("userid", Session.CharacterId);
                    MySqlClient.SetParameter("confirmed", 0);
                    MySqlClient.SetParameter("amount", Amount);
                    MySqlClient.ExecuteNonQuery("DELETE FROM messenger_friendships WHERE user_1_id = @userid AND confirmed = @confirmed");
                }
                else
                {
                    // Precaution: limit queries to 50
                    if (Amount > 50)
                    {
                        Amount = 50;
                    }

                    for (int i = 0; i < Amount; i++)
                    {
                        uint RequestId = Message.PopWiredUInt32();
                        DestroyFriendship(MySqlClient, Session.CharacterId, RequestId);
                    }
                }
            }
        }
Beispiel #5
0
        private static void OpenPublicConnection(Session Session, ClientMessage Message)
        {
            bool UnknownData1 = Message.PopWiredBoolean();
            uint RoomId = Message.PopWiredUInt32();
            bool UnknownData2 = Message.PopWiredBoolean();

            PrepareRoom(Session, RoomId, string.Empty);
        }
Beispiel #6
0
        private static void GetRoomInfo(Session Session, ClientMessage Message)
        {
            RoomInfo Info = RoomInfoLoader.GetRoomInfo(Message.PopWiredUInt32());

            if (Info == null)
            {
                return;
            }

            bool Bool1 = Message.PopWiredBoolean(); // true when entering a room, otherwise always false
            bool Bool2 = Message.PopWiredBoolean(); // true when requesting info before entering (stalking etc), otherwise always false??

            Session.SendData(RoomInfoComposer.Compose(Info, Bool1, Bool2));
        }