internal void SendInstantMessage(UInt32 ToId, string Message) { if (!FriendshipExists(ToId)) { DeliverInstantMessageError(6, ToId); return; } GameClient Client = PiciEnvironment.GetGame().GetClientManager().GetClientByUserID(ToId); if (Client == null || Client.GetHabbo().GetMessenger() == null) { DeliverInstantMessageError(5, ToId); return; } if (GetClient().GetHabbo().Muted) { DeliverInstantMessageError(4, ToId); return; } if (Client.GetHabbo().Muted) { DeliverInstantMessageError(3, ToId); // No return, as this is just a warning. } Client.GetHabbo().GetMessenger().DeliverInstantMessage(Message, UserId); }
internal void MarketplaceTakeBack() { uint ItemId = Request.PopWiredUInt(); DataRow Row = null; using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT item_id, user_id, extra_data, offer_id state FROM catalog_marketplace_offers WHERE offer_id = " + ItemId + " LIMIT 1"); Row = dbClient.getRow(); } if (Row == null || Convert.ToUInt32(Row["user_id"]) != Session.GetHabbo().Id || (UInt32)Row["state"] != 1) { return; } Item Item = PiciEnvironment.GetGame().GetItemManager().GetItem(Convert.ToUInt32(Row["item_id"])); if (Item == null) { return; } PiciEnvironment.GetGame().GetCatalog().DeliverItems(Session, Item, 1, (String)Row["extra_data"]); using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("DELETE FROM catalog_marketplace_offers WHERE offer_id = " + ItemId + ""); } GetResponse().Init(614); GetResponse().AppendUInt(Convert.ToUInt32(Row["offer_id"])); GetResponse().AppendBoolean(true); SendResponse(); }
internal void OnNewRequest(uint friendID) { if (!requests.ContainsKey(friendID)) { requests.Add(friendID, new MessengerRequest(UserId, friendID, PiciEnvironment.GetGame().GetClientManager().GetNameById(friendID))); } }
internal void GetCatalogPage() { CatalogPage Page = PiciEnvironment.GetGame().GetCatalog().GetPage(Request.PopWiredInt32()); if (Page == null || !Page.Enabled || !Page.Visible || Page.MinRank > Session.GetHabbo().Rank) { return; } if (Page.ClubOnly && !Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club")) { Session.SendNotif(LanguageLocale.GetValue("catalog.missingclubmembership")); return; } Session.SendMessage(Page.GetMessage); if (Page.Layout == "recycler") { GetResponse().Init(507); GetResponse().AppendBoolean(true); GetResponse().AppendBoolean(false); SendResponse(); } }
internal static void AlertUser(GameClient ModSession, uint UserId, String Message, Boolean Caution) { GameClient Client = PiciEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId); if (Client == null || Client.GetHabbo().Id == ModSession.GetHabbo().Id) { return; } if (Caution && Client.GetHabbo().Rank >= ModSession.GetHabbo().Rank) { ModSession.SendNotif(LanguageLocale.GetValue("moderation.caution.missingrank")); Caution = false; } Client.SendNotif(Message, Caution); if (Caution) { using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("UPDATE user_info SET cautions = cautions + 1 WHERE user_id = " + UserId + ""); } } }
internal static void KickUser(GameClient ModSession, uint UserId, String Message, Boolean Soft) { GameClient Client = PiciEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId); if (Client == null || Client.GetHabbo().CurrentRoomId < 1 || Client.GetHabbo().Id == ModSession.GetHabbo().Id) { return; } if (Client.GetHabbo().Rank >= ModSession.GetHabbo().Rank) { ModSession.SendNotif(LanguageLocale.GetValue("moderation.kick.missingrank")); return; } Room Room = PiciEnvironment.GetGame().GetRoomManager().GetRoom(Client.GetHabbo().CurrentRoomId); if (Room == null) { return; } Room.GetRoomUserManager().RemoveUserFromRoom(Client, true, false); Client.CurrentRoomUserID = -1; if (!Soft) { Client.SendNotif(Message); using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("UPDATE user_info SET cautions = cautions + 1 WHERE user_id = " + UserId + ""); } } }
internal void SendInstantInvite() { int count = Request.PopWiredInt32(); List <UInt32> UserIds = new List <uint>(); for (int i = 0; i < count; i++) { UserIds.Add(Request.PopWiredUInt()); } string message = PiciEnvironment.FilterInjectionChars(Request.PopFixedString(), true); ServerMessage Message = new ServerMessage(135); Message.AppendUInt(Session.GetHabbo().Id); Message.AppendStringWithBreak(message); foreach (UInt32 Id in UserIds) { if (!Session.GetHabbo().GetMessenger().FriendshipExists(Id)) { continue; } GameClient Client = PiciEnvironment.GetGame().GetClientManager().GetClientByUserID(Id); if (Client == null) { return; } Client.SendMessage(Message); } }
internal void OnNewFriendship(uint friendID) { GameClient friend = PiciEnvironment.GetGame().GetClientManager().GetClientByUserID(friendID); MessengerBuddy newFriend; if (friend == null || friend.GetHabbo() == null) { DataRow dRow; using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT username,motto,look,last_online FROM users WHERE id = " + friendID); dRow = dbClient.getRow(); } newFriend = new MessengerBuddy(friendID, (string)dRow["username"], (string)dRow["look"], (string)dRow["motto"], (string)dRow["last_online"]); } else { Habbo user = friend.GetHabbo(); newFriend = new MessengerBuddy(friendID, user.Username, user.Look, user.Motto, string.Empty); newFriend.UpdateUser(friend); } if (!friends.ContainsKey(friendID)) { friends.Add(friendID, newFriend); } GetClient().SendMessage(SerializeUpdate(newFriend)); }
internal void AddFavorite() { uint Id = Request.PopWiredUInt(); RoomData Data = PiciEnvironment.GetGame().GetRoomManager().GenerateRoomData(Id); if (Data == null || Session.GetHabbo().FavoriteRooms.Count >= 30 || Session.GetHabbo().FavoriteRooms.Contains(Id) || Data.Type == "public") { GetResponse().Init(33); GetResponse().AppendInt32(-9001); SendResponse(); return; } GetResponse().Init(459); GetResponse().AppendUInt(Id); GetResponse().AppendBoolean(true); SendResponse(); Session.GetHabbo().FavoriteRooms.Add(Id); using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("INSERT INTO user_favorites (user_id,room_id) VALUES (" + Session.GetHabbo().Id + "," + Id + ")"); } }
private void OnRoomCrash(Exception e) { Logging.LogThreadException(e.ToString(), "Room cycle task for room " + RoomId); try { if (System.Diagnostics.Debugger.IsAttached) { foreach (RoomUser user in roomUserManager.UserList.Values) { if (user.IsBot || user.IsPet) { continue; } user.GetClient().SendNotif("Unhandled exception in room: " + e.ToString()); try { GetRoomUserManager().RemoveUserFromRoom(user.GetClient(), true, false); user.GetClient().CurrentRoomUserID = -1; } catch { } } } } catch { } PiciEnvironment.GetGame().GetRoomManager().UnloadRoom(this); isCrashed = true; }
internal static ServerMessage SerializeRoomVisits(UInt32 UserId) { //using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { //dbClient.setQuery("SELECT room_id,hour,minute FROM user_roomvisits WHERE user_id = " + UserId + " ORDER BY entry_timestamp DESC LIMIT 50"); //DataTable Data = dbClient.getTable(); ServerMessage Message = new ServerMessage(537); Message.AppendUInt(UserId); Message.AppendStringWithBreak(PiciEnvironment.GetGame().GetClientManager().GetNameById(UserId)); //if (Data != null) //{ // Message.Append(Data.Rows.Count); // foreach (DataRow Row in Data.Rows) // { // RoomData RoomData = PiciEnvironment.GetGame().GetRoomManager().GenerateNullableRoomData(Convert.ToUInt32(Row["room_id"])); // Message.Append(RoomData.IsPublicRoom); // Message.Append(RoomData.Id); // Message.Append(RoomData.Name); // Message.Append((int)Row["hour"]); // Message.Append((int)Row["minute"]); // } //} //else //{ Message.AppendInt32(0); //} return(Message); } }
internal static void SerializeQuest(ServerMessage Message, GameClient Session, Quest Quest, string Category) { int AmountInCat = PiciEnvironment.GetGame().GetQuestManager().GetAmountOfQuestsInCategory(Category); int Number = Quest == null ? AmountInCat : Quest.Number - 1; int UserProgress = Quest == null ? 0 : Session.GetHabbo().GetQuestProgress(Quest.Id); if (Quest != null && Quest.IsCompleted(UserProgress)) { Number++; } Message.AppendStringWithBreak(Category); Message.AppendInt32(Number); // Quest progress in this cat Message.AppendInt32(AmountInCat); // Total quests in this cat Message.AppendInt32((int)QuestRewardType.Pixels); // Reward type (1 = Snowflakes, 2 = Love hearts, 3 = Pixels, 4 = Seashells, everything else is pixels Message.AppendUInt(Quest == null ? 0 : Quest.Id); // Quest id Message.AppendBoolean(Quest == null ? false : Session.GetHabbo().CurrentQuestId == Quest.Id); // Quest started Message.AppendStringWithBreak(Quest == null ? string.Empty : Quest.ActionName); Message.AppendStringWithBreak(Quest == null ? string.Empty : Quest.DataBit); Message.AppendInt32(Quest == null ? 0 : Quest.Reward); Message.AppendStringWithBreak(Quest == null ? string.Empty : Quest.Name); Message.AppendInt32(UserProgress); // Current progress Message.AppendUInt(Quest == null ? 0 : Quest.GoalData); // Target progress Message.AppendInt32(0); // "Next quest available countdown" in seconds }
internal void FillNull(UInt32 pId) { this.Id = pId; this.Name = "Unknown Room"; this.Description = "-"; this.Type = "private"; this.Owner = "-"; this.Category = 0; this.UsersNow = 0; this.UsersMax = 0; this.ModelName = "NO_MODEL"; this.CCTs = ""; this.Score = 0; this.Tags = new List <string>(); this.AllowPets = true; this.AllowPetsEating = false; this.AllowWalkthrough = true; this.Hidewall = false; this.Password = ""; this.Wallpaper = "0.0"; this.Floor = "0.0"; this.Landscape = "0.0"; this.WallThickness = 0; this.FloorThickness = 0; //this.Event = null; this.AllowRightsOverride = false; this.myIcon = new RoomIcon(1, 1, new Dictionary <int, int>()); mModel = PiciEnvironment.GetGame().GetRoomManager().GetModel(ModelName, pId); }
internal void Fill(Room Room) { this.Id = Room.RoomId; this.Name = Room.Name; this.Description = Room.Description; this.Type = Room.Type; this.Owner = Room.Owner; this.Category = Room.Category; this.State = Room.State; this.UsersNow = Room.UsersNow; this.UsersMax = Room.UsersMax; this.ModelName = Room.ModelName; this.CCTs = Room.CCTs; this.Score = Room.Score; this.Tags = new List <string>(); foreach (string tag in Room.Tags.ToArray()) { this.Tags.Add(tag); } this.AllowPets = Room.AllowPets; this.AllowPetsEating = Room.AllowPetsEating; this.AllowWalkthrough = Room.AllowWalkthrough; this.Hidewall = Room.Hidewall; this.myIcon = Room.Icon; this.Password = Room.Password; this.Event = Room.Event; this.Wallpaper = Room.Wallpaper; this.Floor = Room.Floor; this.Landscape = Room.Landscape; this.FloorThickness = Room.FloorThickness; this.WallThickness = Room.WallThickness; mModel = PiciEnvironment.GetGame().GetRoomManager().GetModel(ModelName, Id); }
internal RoomItem(UInt32 Id, UInt32 RoomId, UInt32 BaseItem, string ExtraData, WallCoordinate wallCoord, Room pRoom) { this.Id = Id; this.RoomId = RoomId; this.BaseItem = BaseItem; this.ExtraData = ExtraData; this.originalExtraData = ExtraData; this.mX = 0; this.mY = 0; this.mZ = 0.0; this.UpdateNeeded = false; this.UpdateCounter = 0; this.InteractingUser = 0; this.InteractingUser2 = 0; this.IsTrans = false; this.interactingBallUser = 0; this.interactionCount = 0; this.value = 0; this.placedPosition = new Point(0, 0); this.wallCoord = wallCoord; mBaseItem = PiciEnvironment.GetGame().GetItemManager().GetItem(BaseItem); mRoom = pRoom; if (GetBaseItem() == null) { Logging.LogException("Unknown baseID: " + BaseItem); } mIsWallItem = true; mIsFloorItem = false; mAffectedPoints = new Dictionary <int, ThreeDCoord>(); }
internal ServerMessage SerializeSearchResults(string SearchQuery) { DataTable Data = new DataTable(); using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { if (SearchQuery.Length > 0) { if (dbClient.dbType == Pici.Storage.Database.DatabaseType.MySQL) { dbClient.setQuery("SELECT rooms.*, room_active.active_users FROM rooms LEFT JOIN room_active ON (room_active.roomid = rooms.id) WHERE owner = @query AND roomtype = 'private' " + "UNION ALL " + "SELECT rooms.*, room_active.active_users FROM rooms LEFT JOIN room_active ON (room_active.roomid = rooms.id) WHERE caption = @query AND roomtype = 'private' " + "ORDER BY active_users DESC LIMIT 50"); } else { dbClient.setQuery("SELECT TOP 50 rooms.*, room_active.active_users FROM rooms LEFT JOIN room_active ON (room_active.roomid = rooms.id) WHERE owner = @query AND roomtype = 'private' " + "UNION ALL " + "SELECT rooms.*, room_active.active_users FROM rooms LEFT JOIN room_active ON (room_active.roomid = rooms.id) WHERE caption = @query AND roomtype = 'private' " + "ORDER BY active_users DESC"); } dbClient.addParameter("query", SearchQuery); Data = dbClient.getTable(); } } List <RoomData> Results = new List <RoomData>(); if (Data != null) { foreach (DataRow Row in Data.Rows) { RoomData RData = PiciEnvironment.GetGame().GetRoomManager().FetchRoomData(Convert.ToUInt32(Row["id"]), Row); Results.Add(RData); } } ServerMessage Message = new ServerMessage(451); Message.AppendInt32(1); Message.AppendInt32(9); Message.AppendStringWithBreak(SearchQuery); Message.AppendInt32(Results.Count); int i = 0; foreach (RoomData Room in Results) { if (i > 0) { Message.AppendInt32(0); } Room.Serialize(Message, false); i++; } return(Message); }
internal void ReloadSettings() { RoomData data = PiciEnvironment.GetGame().GetRoomManager().GenerateRoomData(this.RoomId); InitializeFromRoomData(data); InitBots(); InitPets(); }
internal Room GetRoom() { if (mRoom == null) { mRoom = PiciEnvironment.GetGame().GetRoomManager().GetRoom(RoomId); //Todo: rub my penis } return(mRoom); }
private Room GetRoom() { if (mRoom == null) { mRoom = PiciEnvironment.GetGame().GetRoomManager().GetRoom(RoomId); } return(mRoom); }
internal void MarketplaceRowchase() { uint ItemId = Request.PopWiredUInt(); DataRow Row = null; using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT state, timestamp, total_price, extra_data, item_id FROM catalog_marketplace_offers WHERE offer_id = " + ItemId + " "); Row = dbClient.getRow(); } if (Row == null || (string)Row["state"] != "1" || (double)Row["timestamp"] <= Marketplace.FormatTimestamp()) { Session.SendNotif(LanguageLocale.GetValue("catalog.offerexpired")); return; } Item Item = PiciEnvironment.GetGame().GetItemManager().GetItem(Convert.ToUInt32(Row["item_id"])); if (Item == null) { return; } int prize = (int)Row["total_price"]; if ((int)Row["total_price"] >= 1) { Session.GetHabbo().Credits -= prize; Session.GetHabbo().UpdateCreditsBalance(); } PiciEnvironment.GetGame().GetCatalog().DeliverItems(Session, Item, 1, (String)Row["extra_data"]); Session.GetHabbo().GetInventoryComponent().RunDBUpdate(); using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("UPDATE catalog_marketplace_offers SET state = 2 WHERE offer_id = " + ItemId + ""); } Session.GetMessageHandler().GetResponse().Init(67); Session.GetMessageHandler().GetResponse().AppendUInt(Item.ItemId); Session.GetMessageHandler().GetResponse().AppendStringWithBreak(Item.Name); Session.GetMessageHandler().GetResponse().AppendInt32(prize); Session.GetMessageHandler().GetResponse().AppendInt32(0); Session.GetMessageHandler().GetResponse().AppendInt32(0); Session.GetMessageHandler().GetResponse().AppendInt32(1); Session.GetMessageHandler().GetResponse().AppendStringWithBreak(Item.Type.ToString()); Session.GetMessageHandler().GetResponse().AppendInt32(Item.SpriteId); Session.GetMessageHandler().GetResponse().AppendStringWithBreak(""); Session.GetMessageHandler().GetResponse().AppendInt32(1); Session.GetMessageHandler().GetResponse().AppendInt32(0); Session.GetMessageHandler().SendResponse(); Session.SendMessage(Marketplace.SerializeOffers(-1, -1, "", 1)); }
internal void Serialize(int Rank, ServerMessage Message) { Message.AppendBoolean(Visible); Message.AppendInt32(IconColor); Message.AppendInt32(IconImage); Message.AppendInt32(Id); Message.AppendStringWithBreak(Caption); Message.AppendInt32(PiciEnvironment.GetGame().GetCatalog().GetTreeSize(Rank, Id)); }
internal Item GetBaseItem() { if (mBaseItem == null) { mBaseItem = PiciEnvironment.GetGame().GetItemManager().GetItem(BaseItem); } return(mBaseItem); }
internal void InitBots() { List <RoomBot> Bots = PiciEnvironment.GetGame().GetBotManager().GetBotsForRoom(RoomId); foreach (RoomBot Bot in Bots) { DeployBot(Bot); } }
internal void RowchaseGift() { int PageId = Request.PopWiredInt32(); uint ItemId = Request.PopWiredUInt(); string ExtraData = Request.PopFixedString(); string GiftUser = PiciEnvironment.FilterInjectionChars(Request.PopFixedString()); string GiftMessage = PiciEnvironment.FilterInjectionChars(Request.PopFixedString()); PiciEnvironment.GetGame().GetCatalog().HandleRowchase(Session, PageId, ItemId, ExtraData, true, GiftUser, GiftMessage); }
private void LoadBots() { List <RoomBot> bots = PiciEnvironment.GetGame().GetBotManager().GetBotsForRoom(this.RoomId); foreach (RoomBot bot in bots) { RoomUser NewUser = DeployBot(bot); NewUser.SetPos(bot.X, bot.Y, bot.Z); } }
internal static ServerMessage SerializeTicketChatlog(SupportTicket Ticket, RoomData RoomData, Double Timestamp) { Room currentRoom = PiciEnvironment.GetGame().GetRoomManager().GetRoom(RoomData.Id); ServerMessage Message = new ServerMessage(534); Message.AppendUInt(Ticket.TicketId); Message.AppendUInt(Ticket.SenderId); Message.AppendUInt(Ticket.ReportedId); Message.AppendBoolean(RoomData.IsPublicRoom); Message.AppendUInt(RoomData.Id); Message.AppendStringWithBreak(RoomData.Name); if (currentRoom == null) { Message.AppendInt32(0); return(Message); } else { using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT user_id,user_name,hour,minute,message FROM chatlogs WHERE room_id = " + RoomData.Id + " AND timestamp >= " + (Timestamp - 300) + " AND timestamp <= " + Timestamp + " ORDER BY timestamp DESC"); DataTable Data = dbClient.getTable(); Message = new ServerMessage(534); Message.AppendUInt(Ticket.TicketId); Message.AppendUInt(Ticket.SenderId); Message.AppendUInt(Ticket.ReportedId); Message.AppendBoolean(RoomData.IsPublicRoom); Message.AppendUInt(RoomData.Id); Message.AppendStringWithBreak(RoomData.Name); if (Data != null) { Message.AppendInt32(Data.Rows.Count); foreach (DataRow Row in Data.Rows) { Message.AppendInt32((int)Row["hour"]); Message.AppendInt32((int)Row["minute"]); Message.AppendUInt((UInt32)Row["user_id"]); Message.AppendStringWithBreak((String)Row["user_name"]); Message.AppendStringWithBreak((String)Row["message"]); } } else { Message.AppendInt32(0); } return(Message); } } }
internal static void RoomAlert(uint RoomId, Boolean Caution, String Message) { Room Room = PiciEnvironment.GetGame().GetRoomManager().GetRoom(RoomId); if (Room == null || Message.Length <= 1) { return; } RoomAlert alert = new RoomAlert(Message, 3); }
internal void HandleRowchase() { int PageId = Request.PopWiredInt32(); uint ItemId = Request.PopWiredUInt(); string ExtraData = Request.PopFixedString(); for (int i = 0; i < Session.GetHabbo().buyItemLoop; i++) { PiciEnvironment.GetGame().GetCatalog().HandleRowchase(Session, PageId, ItemId, ExtraData, false, "", ""); } }
internal RoomUser GetRoomUser() { Room Room = PiciEnvironment.GetGame().GetRoomManager().GetRoom(RoomId); if (Room == null) { return(null); } return(Room.GetRoomUserManager().GetRoomUserByHabbo(UserId)); }
internal Item GetBaseItem() { Item Return = PiciEnvironment.GetGame().GetItemManager().GetItem(ItemIds); if (Return == null) { Console.WriteLine("UNKNOWN ItemIds: " + ItemIds); } return(Return); }