private static void DeleteSticky(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null || !Instance.CheckUserRights(Session, true)) { return; } Item Item = Instance.GetItem(Message.PopWiredUInt32()); if (Item == null || Item.Definition.Behavior != ItemBehavior.StickyNote) { return; } if (Instance.TakeItem(Item.Id)) { Instance.RegenerateRelativeHeightmap(); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Item.RemovePermanently(MySqlClient); } } }
private static void BanUser(Session Session, ClientMessage Message) { if (!Session.HasRight("moderation_tool")) { return; } uint UserId = Message.PopWiredUInt32(); string MessageText = Message.PopString(); double Length = (Message.PopWiredInt32() * 3600); Session TargetSession = SessionManager.GetSessionByCharacterId(UserId); if (TargetSession == null || TargetSession.HasRight("moderation_tool")) { Session.SendData(NotificationMessageComposer.Compose("This user is not online or you do not have permission to ban them.\nPlease use housekeeping to ban users that are offline.")); return; } SessionManager.StopSession(TargetSession.Id); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationBanManager.BanUser(MySqlClient, UserId, MessageText, Session.CharacterId, Length); ModerationLogs.LogModerationAction(MySqlClient, Session, "Banned user", "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ") for " + Length + " hours: '" + MessageText + "'"); } }
private static void GetRoomInfo(Session Session, ClientMessage Message) { if (!Session.HasRight("moderation_tool")) { return; } RoomInfo Info = RoomInfoLoader.GetRoomInfo(Message.PopWiredUInt32()); if (Info == null) { Session.SendData(NotificationMessageComposer.Compose("Could not retrieve room information.")); return; } Session.SendData(ModerationRoomInfoComposer.Compose(Info, RoomManager.GetInstanceByRoomId(Info.Id))); }
private static void OnFriendRequestAccept(Session Session, ClientMessage Message) { int Amount = Message.PopWiredInt32(); // Precaution: limit queries to 50. if (Amount > 50) { Amount = 50; } List<Session> SessionsToUpdate = new List<Session>() { Session }; for (int i = 0; i < Amount; i++) { uint RequestId = Message.PopWiredUInt32(); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { MySqlClient.SetParameter("user1", Session.CharacterId); MySqlClient.SetParameter("user2", RequestId); MySqlClient.SetParameter("confirmed", 1); int Affected = MySqlClient.ExecuteNonQuery("UPDATE messenger_friendships SET confirmed = @confirmed WHERE user_1_id = @user1 AND user_2_id = @user2 LIMIT 1"); if (Affected > 0) { MySqlClient.SetParameter("user1", RequestId); MySqlClient.SetParameter("user2", Session.CharacterId); MySqlClient.SetParameter("confirmed", 1); MySqlClient.ExecuteNonQuery("INSERT INTO messenger_friendships (user_1_id,user_2_id,confirmed) VALUES (@user1,@user2,@confirmed)"); Session.MessengerFriendCache.AddToCache(RequestId); Session TargetSession = SessionManager.GetSessionByCharacterId(RequestId); if (TargetSession != null) { TargetSession.MessengerFriendCache.AddToCache(Session.CharacterId); SessionsToUpdate.Add(TargetSession); } } } } for (int i = 0; i < 2; i++) { foreach (Session SessionToUpdate in SessionsToUpdate) { ForceMessengerUpdateForSession(SessionToUpdate); } } }
private static void GetRoomChatlog(Session Session, ClientMessage Message) { if (!Session.HasRight("chatlogs")) { Session.SendData(NotificationMessageComposer.Compose("You are not allowed to use this!")); return; } int Unknown1 = Message.PopWiredInt32(); uint RoomId = Message.PopWiredUInt32(); RoomInfo Info = RoomInfoLoader.GetRoomInfo(RoomId); if (Info == null) { Session.SendData(NotificationMessageComposer.Compose("Room not found; could not load chatlogs.")); return; } Session.SendData(ModerationRoomChatlogsComposer.Compose(Info, ModerationLogs.GetLogsForRoom(RoomId, (UnixTimestamp.GetCurrent() - 3600), UnixTimestamp.GetCurrent()))); }
private static void OnInvite(Session Session, ClientMessage Message) { int Count = Message.PopWiredInt32(); List<uint> Targets = new List<uint>(); for (int i = 0; (i < Count && i < 50); i++) { Targets.Add(Message.PopWiredUInt32()); } string MessageText = UserInputFilter.FilterString(Message.PopString()); if (MessageText.Length > 121) { MessageText = MessageText.Substring(0, 121); } List<Session> Users = new List<Session>(); foreach (uint UserId in Targets) { if (!Session.MessengerFriendCache.Friends.Contains(UserId)) { continue; } Session TargetSession = SessionManager.GetSessionByCharacterId(UserId); if (TargetSession == null) { continue; } Users.Add(TargetSession); TargetSession.SendData(MessengerImInviteComposer.Compose(Session.CharacterId, Wordfilter.Filter(MessageText))); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { String to = ""; foreach (Session User in Users) { to += User.CharacterInfo.Username + " [" + User.CharacterId + "], "; } to = to.Substring(0, to.Length - 2); ModerationLogs.LogChatMessage(MySqlClient, Session.CharacterId, 0, "(INVITATION to " + to + ") " + MessageText); } }
private static void GetSongData(Session Session, ClientMessage Message) { int Amount = Message.PopWiredInt32(); List<SongData> Songs = new List<SongData>(); for (int i = 0; i < Amount; i++) { SongData Song = GetSong(Message.PopWiredUInt32()); if (Song == null) { continue; } Songs.Add(Song); } Session.SendData(SongDataComposer.Compose(Songs)); }
private static void GetUserInfo(Session Session, ClientMessage Message) { if (!Session.HasRight("moderation_tool")) { return; } CharacterInfo Info = null; using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Info = CharacterInfoLoader.GetCharacterInfo(MySqlClient, Message.PopWiredUInt32()); } if (Info == null) { Session.SendData(NotificationMessageComposer.Compose("Could not retrieve user information.")); return; } Session.SendData(ModerationUserInfoComposer.Compose(Info, SessionManager.GetSessionByCharacterId(Info.Id))); }
private static void KickUser(Session Session, ClientMessage Message) { if (!Session.HasRight("moderation_tool")) { return; } uint UserId = Message.PopWiredUInt32(); string MessageText = Message.PopString(); Session TargetSession = SessionManager.GetSessionByCharacterId(UserId); if (TargetSession == null || TargetSession.HasRight("moderation_tool")) { Session.SendData(NotificationMessageComposer.Compose("That user is not online or cannot be kicked at this point in time.")); return; } RoomInstance Instance = RoomManager.GetInstanceByRoomId(TargetSession.CurrentRoomId); if (Instance == null) { Session.SendData(NotificationMessageComposer.Compose("That user is not currently in any room.")); return; } TargetSession.CharacterInfo.ModerationCautions++; Instance.SoftKickUser(TargetSession.CharacterId, true, false, true); TargetSession.SendData(NotificationMessageComposer.Compose("A moderator has kicked you from the room for the following reason:\n\n" + MessageText)); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Kicked user from room", "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ") from '" + Instance.Info.Name + "' (ID " + Instance.RoomId + "): '" + MessageText + "'."); } }
private static void PlacePet(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null || (!Instance.CheckUserRights(Session, true) && !Instance.Info.AllowPets)) { return; } Pet Pet = Session.PetInventoryCache.GetPet(Message.PopWiredUInt32()); if (Pet == null) { return; } Vector2 DesiredPosition = new Vector2(Message.PopWiredInt32(), Message.PopWiredInt32()); if (!Instance.IsValidPosition(DesiredPosition)) { return; } Bot BotDefinition = BotManager.GetHandlerDefinitionForPetType(Pet.Type); if (BotDefinition == null) { Session.SendData(NotificationMessageComposer.Compose("This pet cannot be placed right now. Please try again later.")); return; } if (!Instance.CanPlacePet(Instance.CheckUserRights(Session, true))) { Session.SendData(RoomItemPlacementErrorComposer.Compose(RoomItemPlacementErrorCode.PetLimitReached)); return; } Vector3 Position = new Vector3(DesiredPosition.X, DesiredPosition.Y, Instance.GetUserStepHeight(DesiredPosition)); Pet.MoveToRoom(Instance.RoomId, Position); Instance.AddBotToRoom(BotManager.CreateNewInstance(BotDefinition, Instance.RoomId, Position, Pet)); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Pet.SynchronizeDatabase(MySqlClient); } Session.SendData(InventoryPetRemovedComposer.Compose(Pet.Id)); }
private static void RespectPet(Session Session, ClientMessage Message) { if (Session.CharacterInfo.RespectCreditPets <= 0) { return; } RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } RoomActor Actor = Instance.GetActorByReferenceId(Message.PopWiredUInt32(), RoomActorType.AiBot); if (Actor == null) { return; } Pet PetData = ((Bot)Actor.ReferenceObject).PetData; if (PetData == null) { return; } Session.CharacterInfo.RespectCreditPets = 500;/*--;*/ PetData.Score++; using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Session.CharacterInfo.SynchronizeRespectData(MySqlClient); PetData.SynchronizeDatabase(MySqlClient); } Instance.BroadcastMessage(RoomPetUpdateComposer.Compose(Actor.ReferenceId, PetData)); }
private static void OpenSticky(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } Item Item = Instance.GetItem(Message.PopWiredUInt32()); if (Item == null || Item.Definition.Behavior != ItemBehavior.StickyNote) { return; } Session.SendData(StickyDataComposer.Compose(Item)); }
private static void PlaceItem(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } uint ItemId = 0; string[] Data = null; if (Message.Id == OpcodesIn.ROOM_ITEM_PLACE_STICKY) { ItemId = Message.PopWiredUInt32(); string RawData = Message.PopString(); string[] TmpData = RawData.Split(' '); Data = new string[TmpData.Length + 1]; Data[0] = string.Empty; Data[1] = TmpData[0]; Data[2] = TmpData[1]; Data[3] = TmpData[2]; } else { string RawData = Message.PopString(); Data = RawData.Split(' '); uint.TryParse(Data[0], out ItemId); } Item Item = Session.InventoryCache.GetItem(ItemId); if (Item == null) { return; } bool HasPlacementRights = Instance.CheckUserRights(Session); bool IsPlacingGuestStickie = false; if (Item.Definition.Behavior == ItemBehavior.StickyNote && !HasPlacementRights && Instance.GuestsCanPlaceStickies) { IsPlacingGuestStickie = true; } else if (!HasPlacementRights) { Session.SendData(RoomItemPlacementErrorComposer.Compose(RoomItemPlacementErrorCode.InsufficientRights)); return; } if (Item.PendingExpiration && Item.ExpireTimeLeft <= 0) { using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Item.RemovePermanently(MySqlClient); } Session.InventoryCache.RemoveItem(Item.Id); Session.SendData(InventoryItemRemovedComposer.Compose(Item.Id)); return; } switch (Item.Definition.Type) { default: case ItemType.FloorItem: if (Data.Length != 4) { return; } int X = 0; int Y = 0; int Rotation = 0; int.TryParse(Data[1], out X); int.TryParse(Data[2], out Y); int.TryParse(Data[3], out Rotation); Vector3 FinalizedPosition = Instance.SetFloorItem(Session, Item, new Vector2(X, Y), Rotation); if (FinalizedPosition != null) { using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Item.MoveToRoom(MySqlClient, Instance.RoomId, FinalizedPosition, Rotation); } Instance.RegenerateRelativeHeightmap(); Session.InventoryCache.RemoveItem(Item.Id); Session.SendData(InventoryItemRemovedComposer.Compose(Item.Id)); ItemEventDispatcher.InvokeItemEventHandler(Session, Item, Instance, ItemEventType.Placed); Instance.BroadcastMessage(RoomFloorItemPlacedComposer.Compose(Item)); QuestManager.ProgressUserQuest(Session, QuestType.FURNI_PLACE); if (FinalizedPosition.Z > Instance.Model.Heightmap.FloorHeight[FinalizedPosition.X, FinalizedPosition.Y]) { QuestManager.ProgressUserQuest(Session, QuestType.FURNI_STACK); } } break; case ItemType.WallItem: string[] CorrectedData = new string[Data.Length - 1]; for (int i = 1; i < Data.Length; i++) { CorrectedData[i - 1] = Data[i]; } string WallPos = Instance.SetWallItem(Session, CorrectedData, Item); if (WallPos.Length > 0) { using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Item.MoveToRoom(MySqlClient, Instance.RoomId, new Vector3(0, 0, 0), 0, WallPos); } Session.InventoryCache.RemoveItem(Item.Id); Session.SendData(InventoryItemRemovedComposer.Compose(Item.Id)); ItemEventDispatcher.InvokeItemEventHandler(Session, Item, Instance, ItemEventType.Placed); Instance.BroadcastMessage(RoomWallItemPlacedComposer.Compose(Item)); if (IsPlacingGuestStickie) { Instance.GiveTemporaryStickieRights(Item.Id, Session.CharacterId); Session.SendData(StickyDataComposer.Compose(Item)); } } break; } }
private static void MoveWallItem(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null || !Instance.CheckUserRights(Session)) { return; } Item Item = Instance.GetItem(Message.PopWiredUInt32()); if (Item == null || Item.Definition.Type != ItemType.WallItem) { return; } string RawPlacementData = Message.PopString(); string WallPos = Instance.SetWallItem(Session, RawPlacementData, Item); if (WallPos.Length > 0) { Item.MoveToRoom(null, Instance.RoomId, new Vector3(0, 0, 0), 0, WallPos); RoomManager.MarkWriteback(Item, false); Instance.BroadcastMessage(RoomWallItemMovedComposer.Compose(Item)); ItemEventDispatcher.InvokeItemEventHandler(Session, Item, Instance, ItemEventType.Moved); } }
private static void MoveFloorItem(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null || !Instance.CheckUserRights(Session)) { return; } Item Item = Instance.GetItem(Message.PopWiredUInt32()); if (Item == null || Item.Definition.Type != ItemType.FloorItem) { return; } Vector2 NewPosition = new Vector2(Message.PopWiredInt32(), Message.PopWiredInt32()); int NewRotation = Message.PopWiredInt32(); bool IsRotationOnly = (Item.RoomId == Instance.RoomId && Item.RoomPosition.X == NewPosition.X && Item.RoomPosition.Y == NewPosition.Y && NewRotation != Item.RoomRotation); Vector3 FinalizedPosition = Instance.SetFloorItem(Session, Item, NewPosition, NewRotation); if (FinalizedPosition != null) { Item.MoveToRoom(null, Instance.RoomId, FinalizedPosition, NewRotation, string.Empty); RoomManager.MarkWriteback(Item, false); Instance.RegenerateRelativeHeightmap(); Instance.BroadcastMessage(RoomItemUpdatedComposer.Compose(Item)); ItemEventDispatcher.InvokeItemEventHandler(Session, Item, Instance, ItemEventType.Moved, IsRotationOnly ? 1 : 0); QuestManager.ProgressUserQuest(Session, IsRotationOnly ? QuestType.FURNI_ROTATE : QuestType.FURNI_MOVE); if (FinalizedPosition.Z > Instance.Model.Heightmap.FloorHeight[FinalizedPosition.X, FinalizedPosition.Y]) { QuestManager.ProgressUserQuest(Session, QuestType.FURNI_STACK); } } }
private static void OnSendIm(Session Session, ClientMessage Message) { uint UserId = Message.PopWiredUInt32(); string Text = UserInputFilter.FilterString(Message.PopString()).Trim(); if (UserId <= 0 || Text.Length < 1) { return; } if (Session.CharacterInfo.IsMuted) { Session.SendData(MessengerImErrorComposer.Compose(4, UserId)); return; } if (!Session.MessengerFriendCache.Friends.Contains(UserId)) { Session.SendData(MessengerImErrorComposer.Compose(6, UserId)); return; } Session TargetSession = SessionManager.GetSessionByCharacterId(UserId); if (TargetSession == null) { Session.SendData(MessengerImErrorComposer.Compose(5, UserId)); return; } if (TargetSession.CharacterInfo.IsMuted) { Session.SendData(MessengerImErrorComposer.Compose(3, UserId)); } TargetSession.SendData(MessengerImMessageComposer.Compose(Session.CharacterId, Wordfilter.Filter(Text))); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogChatMessage(MySqlClient, Session.CharacterId, 0, "(MESSAGE to " + TargetSession.CharacterInfo.Username + " [" + TargetSession.CharacterId+ "]) " + Text); } }
private static void GetTicketChatlog(Session Session, ClientMessage Message) { if (!Session.HasRight("chatlogs")) { Session.SendData(NotificationMessageComposer.Compose("You are not allowed to use this!")); return; } ModerationTicket Ticket = ModerationTicketManager.GetTicket(Message.PopWiredUInt32()); if (Ticket == null || Ticket.ModeratorUserId != Session.CharacterId) { Session.SendData(NotificationMessageComposer.Compose("Ticket not found or ticket is not assigned to you.")); return; } RoomInfo Info = null; if (Ticket.RoomId > 0) { Info = RoomInfoLoader.GetRoomInfo(Ticket.RoomId); } Session.SendData(ModerationTicketChatlogsComposer.Compose(Ticket, Info, ModerationLogs.GetLogsForRoom(Ticket.RoomId, (Ticket.CreatedTimestamp - 600), UnixTimestamp.GetCurrent()))); }
private static void SaveSticky(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } Item Item = Instance.GetItem(Message.PopWiredUInt32()); if (Item == null || Item.Definition.Behavior != ItemBehavior.StickyNote) { return; } StickieEditingRights Rights = Instance.GetStickieEditingRights(Session, Item); if (Rights == StickieEditingRights.ReadOnly) { return; } string RawData = Message.PopString(); string[] Bits = RawData.Split(' '); if (Bits.Length < 2) { return; } string Color = Bits[0].ToUpper().Trim(); string Text = UserInputFilter.FilterString(RawData.Substring(Color.Length + 1, RawData.Length - (Color.Length + 1))).Trim(); if (Color != "FFFF33" && Color != "FF9CFF" && Color != "9CCEFF" && Color != "9CFF9C" || Text.Length > 391) { return; } Item.Flags = RawData; Item.DisplayFlags = Color; if (Rights == StickieEditingRights.GuestEdit) { Item.Flags += "\n-----\n" + Session.CharacterInfo.Username + "\n" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); } Instance.RevokeTemporaryStickieRights(Item.Id); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Item.SynchronizeDatabase(MySqlClient, true); } Instance.BroadcastMessage(RoomWallItemMovedComposer.Compose(Item)); }
private static void GetUserChatlog(Session Session, ClientMessage Message) { if (!Session.HasRight("chatlogs")) { Session.SendData(NotificationMessageComposer.Compose("You are not allowed to use this!")); return; } uint UserId = Message.PopWiredUInt32(); Session.SendData(ModerationUserChatlogsComposer.Compose(UserId, ModerationLogs.GetLogsForUser(UserId, (UnixTimestamp.GetCurrent() - 3600)))); }
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()); } } }
private static void GetVisits(Session Session, ClientMessage Message) { if (!Session.HasRight("moderation_tool")) { return; } uint UserId = Message.PopWiredUInt32(); Session.SendData(ModerationUserVisitsComposer.Compose(UserId, ModerationLogs.GetRoomVistsForUser(UserId, UnixTimestamp.GetCurrent() - 3600))); }
private static void CautionUser(Session Session, ClientMessage Message) { if (!Session.HasRight("moderation_tool")) { return; } uint UserId = Message.PopWiredUInt32(); string MessageText = Message.PopString(); Session TargetSession = SessionManager.GetSessionByCharacterId(UserId); if (TargetSession != null) { TargetSession.SendData(HotelManagerNotificationComposer.Compose("Caution from moderator:\n\n" + MessageText)); ModerationTicketManager.MarkTicketRespondedToForUser(UserId); } else { Session.SendData(NotificationMessageComposer.Compose("That user is not online at this point in time.")); } CharacterInfo Info = (TargetSession != null ? TargetSession.CharacterInfo : null); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { if (Info == null) { Info = CharacterInfoLoader.GetCharacterInfo(MySqlClient, UserId); } if (Info != null) { Info.ModerationCautions++; } ModerationLogs.LogModerationAction(MySqlClient, Session, "Sent caution to user", "User " + TargetSession.CharacterInfo.Username + " (ID " + TargetSession.CharacterId + "): '" + MessageText + "'."); MySqlClient.SetParameter("userid", TargetSession.CharacterInfo.Id); MySqlClient.SetParameter("modid", Session.CharacterId); MySqlClient.SetParameter("timestamp", UnixTimestamp.GetCurrent()); MySqlClient.SetParameter("value", MessageText); MySqlClient.ExecuteNonQuery("INSERT INTO user_cautions (moderator_id,user_id,value,timestamp) VALUES (@modid,@userid,@value,@timestamp)"); } }
private static void MessageUser(Session Session, ClientMessage Message) { if (!Session.HasRight("moderation_tool")) { return; } uint UserId = Message.PopWiredUInt32(); string MessageText = Message.PopString(); Session TargetSession = SessionManager.GetSessionByCharacterId(UserId); if (TargetSession == null) { Session.SendData(NotificationMessageComposer.Compose("That user is not online at this point in time.")); return; } TargetSession.SendData(NotificationMessageComposer.Compose("Notification from staff:\n\n" + MessageText)); ModerationTicketManager.MarkTicketRespondedToForUser(UserId); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { ModerationLogs.LogModerationAction(MySqlClient, Session, "Sent message to user", "User " + TargetSession.CharacterInfo.Username + " (ID " + TargetSession.CharacterId + "): '" + MessageText + "'."); } }
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); } } } }
private static void TakeItem(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null || !Instance.CheckUserRights(Session, true)) { return; } int Unknown1 = Message.PopWiredInt32(); Item Item = Instance.GetItem(Message.PopWiredUInt32()); if (Item == null || Item.Definition.Behavior == ItemBehavior.StickyNote) { return; } if (Instance.TakeItem(Item.Id)) { ItemEventDispatcher.InvokeItemEventHandler(Session, Item, Instance, ItemEventType.Removing); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { Item.MoveToUserInventory(MySqlClient, Session.CharacterId); } Instance.RegenerateRelativeHeightmap(); Session.InventoryCache.Add(Item); Session.SendData(InventoryItemAddedComposer.Compose(Item)); QuestManager.ProgressUserQuest(Session, QuestType.FURNI_PICK); } }
private static void TakePet(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } RoomActor Actor = Instance.GetActorByReferenceId(Message.PopWiredUInt32(), RoomActorType.AiBot); if (Actor == null) { return; } Pet PetData = ((Bot)Actor.ReferenceObject).PetData; if (PetData == null || (PetData.OwnerId != Session.CharacterId && !Session.HasRight("hotel_admin"))) { return; } Instance.RemoveActorFromRoom(Actor.Id); Session.PetInventoryCache.Add(PetData); Session.SendData(InventoryPetAddedComposer.Compose(PetData)); }
private static void AddToPlaylist(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null || !Instance.CheckUserRights(Session, true) || Instance.MusicController == null || Instance.MusicController.PlaylistSize >= Instance.MusicController.PlaylistCapacity) { return; } Item DiskItem = Session.InventoryCache.GetItem(Message.PopWiredUInt32()); if (DiskItem == null || DiskItem.Definition.Behavior != ItemBehavior.MusicDisk) { return; } int NewOrder = Instance.MusicController.AddDisk(DiskItem); if (NewOrder < 0) { return; } Session.InventoryCache.RemoveItem(DiskItem.Id); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { DiskItem.MoveToSoundManager(MySqlClient, Instance.MusicController.LinkedItemId, NewOrder); } Session.SendData(InventoryItemRemovedComposer.Compose(DiskItem.Id)); Session.SendData(JukeboxPlaylistComposer.Compose(Instance.MusicController.PlaylistCapacity, Instance.MusicController.Playlist.Values.ToList())); }
private static void GetPetInfo(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } uint ActorRefId = Message.PopWiredUInt32(); RoomActor Actor = Instance.GetActorByReferenceId(ActorRefId, RoomActorType.AiBot); if (Actor == null) { return; } Pet PetData = ((Bot)Actor.ReferenceObject).PetData; if (PetData == null) { return; } Session.SendData(PetInfoComposer.Compose(Actor.ReferenceId, PetData)); }
private static void RemoveFavorite(Session Session, ClientMessage Message) { uint RoomId = Message.PopWiredUInt32(); if (Session.FavoriteRoomsCache.RemoveRoomFromFavorites(RoomId)) { Session.SendData(NavigatorFavoriteRoomsChanged.Compose(RoomId, false)); } ClearCacheGroup(Session.CharacterId); }
private static void OnFriendRemove(Session Session, ClientMessage Message) { int Amount = Message.PopWiredInt32(); // Precaution: limit queries to 50 if (Amount > 50) { Amount = 50; } List<MessengerUpdate> LocalUpdates = new List<MessengerUpdate>(); using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { for (int i = 0; i < Amount; i++) { uint FriendId = Message.PopWiredUInt32(); if (DestroyFriendship(MySqlClient, Session.CharacterId, FriendId)) { Session.MessengerFriendCache.RemoveFromCache(FriendId); LocalUpdates.Add(new MessengerUpdate(-1, CharacterInfoLoader.GenerateNullCharacter(FriendId))); Session TargetSession = SessionManager.GetSessionByCharacterId(FriendId); ; if (TargetSession != null) { TargetSession.MessengerFriendCache.RemoveFromCache(Session.CharacterId); TargetSession.SendData(MessengerUpdateListComposer.Compose(new List<MessengerUpdate>() { new MessengerUpdate(-1, CharacterInfoLoader.GenerateNullCharacter(Session.CharacterId)) })); } } } } Session.SendData(MessengerUpdateListComposer.Compose(LocalUpdates)); }