internal void GetInventory() { QueuedServerMessage response = new QueuedServerMessage(Session.GetConnection()); response.appendResponse(Session.GetHabbo().GetInventoryComponent().SerializeFloorItemInventory()); //response.appendResponse(Session.GetHabbo().GetInventoryComponent().SerializeWallItemInventory()); response.sendResponse(); }
internal void GetRoomData2() { try { QueuedServerMessage message = new QueuedServerMessage(Session.GetConnection()); if (Session.GetHabbo().LoadingRoom <= 0 || CurrentLoadingRoom == null) return; RoomData Data = CurrentLoadingRoom.RoomData;//SilverwaveEnvironment.GetGame().GetRoomManager().GenerateRoomData(Session.GetHabbo().LoadingRoom); if (Data == null) { return; } if (Data.Model == null) { Session.SendNotif(LanguageLocale.GetValue("room.missingmodeldata")); Session.SendMessage(new ServerMessage(Outgoing.OutOfRoom)); ClearRoomLoading(); return; } //CurrentLoadingRoom = SilverwaveEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().LoadingRoom); message.appendResponse(CurrentLoadingRoom.GetGameMap().Model.SerializeRelativeHeightmap()); message.appendResponse(CurrentLoadingRoom.GetGameMap().Model.GetHeightmap()); message.sendResponse(); GetRoomData3(); } catch (Exception e) { Logging.LogException("Unable to load room ID [" + Session.GetHabbo().LoadingRoom + "] " + e.ToString()); //Session.SendNotif(LanguageLocale.GetValue("room.roomdataloaderror")); } }
internal void OnRoomUserAdd() { if (Session == null || GetResponse() == null) return; QueuedServerMessage response = new QueuedServerMessage(Session.GetConnection()); List<RoomUser> UsersToDisplay = new List<RoomUser>(); if (CurrentLoadingRoom == null || CurrentLoadingRoom.GetRoomUserManager() == null || CurrentLoadingRoom.GetRoomUserManager().UserList == null) return; foreach (RoomUser User in CurrentLoadingRoom.GetRoomUserManager().UserList.Values) { if (User == null || User.IsSpectator) continue; UsersToDisplay.Add(User); } Response.Init(Outgoing.SetRoomUser); Response.AppendInt32(UsersToDisplay.Count); foreach (RoomUser User in UsersToDisplay) { User.Serialize(Response, CurrentLoadingRoom.GetGameMap().gotPublicPool); } response.appendResponse(GetResponse()); response.appendResponse(RoomFloorAndWallComposer(CurrentLoadingRoom)); response.appendResponse(GetResponse()); Response.Init(Outgoing.ValidRoom); Response.AppendBoolean(true); Response.AppendInt32(CurrentLoadingRoom.RoomId); Response.AppendBoolean(CurrentLoadingRoom.CheckRights(Session, true)); response.appendResponse(GetResponse()); //DataTable Table; //using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor()) //{ //dbClient.setQuery("SELECT user_id FROM room_rights WHERE room_id=" + CurrentLoadingRoom.RoomData.Id); //Table = dbClient.getTable(); //} /*GetResponse().Init(Outgoing.GetPowerList); GetResponse().AppendUInt(CurrentLoadingRoom.RoomData.Id); GetResponse().AppendInt32(Table.Rows.Count); foreach (DataRow i in Table.Rows) { Habbo xUser = SilverwaveEnvironment.getHabboForId((uint)i[0]); GetResponse().AppendUInt(xUser.Id); GetResponse().AppendString(xUser.Username); } //response.appendResponse(GetResponse());*/ foreach (uint i in CurrentLoadingRoom.UsersWithRights) { Habbo xUser = SilverwaveEnvironment.getHabboForId(i); if (xUser != null) { GetResponse().Init(Outgoing.GivePowers); GetResponse().AppendInt32(CurrentLoadingRoom.RoomId); GetResponse().AppendInt32(xUser.Id); GetResponse().AppendString(xUser.Username); response.appendResponse(GetResponse()); } } ServerMessage Updates = CurrentLoadingRoom.GetRoomUserManager().SerializeStatusUpdates(true); if (Updates != null) response.appendResponse(Updates); if (CurrentLoadingRoom.Event != null) { SilverwaveEnvironment.GetGame().GetRoomEvents().SerializeEventInfo(CurrentLoadingRoom.RoomId); } foreach (RoomUser User in CurrentLoadingRoom.GetRoomUserManager().UserList.Values) { if (User == null || User.IsSpectator) continue; if (User.IsBot) { if (User.BotData.DanceId > 0) { Response.Init(Outgoing.Dance); Response.AppendInt32(User.VirtualId); Response.AppendInt32(User.BotData.DanceId); response.appendResponse(GetResponse()); } } else { if (User.IsDancing) { Response.Init(Outgoing.Dance); Response.AppendInt32(User.VirtualId); Response.AppendInt32(User.DanceId); response.appendResponse(GetResponse()); } } if (User.IsAsleep) { response.appendResponse(new SleepComposer(User, true)); } if (User.CarryItemID > 0 && User.CarryTimer > 0) { Response.Init(Outgoing.ApplyCarryItem); Response.AppendInt32(User.VirtualId); Response.AppendInt32(User.CarryTimer); response.appendResponse(GetResponse()); } if (!User.IsBot) { try { if (User != null && User.GetClient() != null && User.GetClient().GetHabbo() != null) { if (User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent() != null && User.CurrentEffect >= 1) { Response.Init(Outgoing.ApplyEffects); Response.AppendInt32(User.VirtualId); Response.AppendInt32(User.CurrentEffect); Response.AppendInt32(0); response.appendResponse(GetResponse()); } ServerMessage RoomUpdate = new ServerMessage(Outgoing.UpdateUserInformation); RoomUpdate.AppendInt32(User.VirtualId); RoomUpdate.AppendString(User.GetClient().GetHabbo().Look); RoomUpdate.AppendString(User.GetClient().GetHabbo().Gender.ToLower()); RoomUpdate.AppendString(User.GetClient().GetHabbo().Motto); RoomUpdate.AppendInt32(User.GetClient().GetHabbo().AchievementPoints); if (CurrentLoadingRoom != null) CurrentLoadingRoom.SendMessage(RoomUpdate); } } catch (Exception e) { Logging.HandleException(e, "Rooms.SendRoomData3"); } } } response.sendResponse(); CurrentLoadingRoom = null; }
internal void PrepareRoomForUser(uint Id, string Password) { ClearRoomLoading(); QueuedServerMessage response = new QueuedServerMessage(Session.GetConnection()); if (Session == null) return; if (SilverwaveEnvironment.ShutdownStarted) { Session.SendNotif(LanguageLocale.GetValue("shutdown.alert")); return; } if (Session.GetHabbo().InRoom) { Room OldRoom = SilverwaveEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (OldRoom != null) { if (OldRoom.GetRoomUserManager() != null) OldRoom.GetRoomUserManager().RemoveUserFromRoom(Session, false, false); } } Room Room = SilverwaveEnvironment.GetGame().GetRoomManager().LoadRoom(Id); if (Room == null) return; if (Room.UserCount >= Room.UsersMax && !Session.GetHabbo().HasFuse("fuse_enter_full_rooms")) { if (Session.GetHabbo().Id != Room.OwnerId) { // This rom is full!! ServerMessage msg = new ServerMessage(Outgoing.RoomErrorToEnter); msg.AppendInt32(1); //Session.SendMessage(msg); ServerMessage msg2 = new ServerMessage(Outgoing.OutOfRoom); Session.SendMessage(msg2); return; } } if (Room == null || Session == null || Session.GetHabbo() == null) return; if (Session.GetHabbo().IsTeleporting && Session.GetHabbo().TeleportingRoomID != Id) return; Session.GetHabbo().LoadingRoom = Id; CurrentLoadingRoom = Room; if (!Session.GetHabbo().HasFuse("fuse_enter_any_room") && Room.UserIsBanned(Session.GetHabbo().Id)) { if (Room.HasBanExpired(Session.GetHabbo().Id)) { Room.RemoveBan(Session.GetHabbo().Id); } else { // You are banned of this room! // C`PA // Response.Init(Outgoing.RoomErrorToEnter); //Response.AppendInt32(4); //response.appendResponse(GetResponse()); Session.SendNotif("You are banned from this room"); Response.Init(Outgoing.OutOfRoom); response.appendResponse(GetResponse()); response.sendResponse(); return; } } Response.Init(Outgoing.PrepareRoomForUsers); response.appendResponse(GetResponse()); if (!Session.GetHabbo().HasFuse("fuse_enter_any_room") && !Room.CheckRights(Session, true, true) && !Session.GetHabbo().IsTeleporting && !Session.GetHabbo().IsHopping) { if (Room.State == 1) { if (Room.UserCount == 0) { Response.Init(Outgoing.DoorBellNoPerson); response.appendResponse(GetResponse()); } else { Response.Init(Outgoing.Doorbell); Response.AppendString(""); response.appendResponse(GetResponse()); ServerMessage RingMessage = new ServerMessage(Outgoing.Doorbell); RingMessage.AppendString(Session.GetHabbo().Username); Room.SendMessageToUsersWithRights(RingMessage); } response.sendResponse(); return; } else if (Room.State == 2) { if (Password.ToLower() != Room.Password.ToLower()) { Response.Init(Outgoing.OutOfRoom); response.appendResponse(GetResponse()); response.sendResponse(); return; } } } Session.GetHabbo().LoadingChecksPassed = true; response.addBytes(LoadRoomForUser().getPacket); //LoadRoomForUser(); response.sendResponse(); using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor()) dbClient.runFastQuery("INSERT INTO user_roomvisits (user_id,room_id,entry_timestamp,exit_timestamp,hour,minute) VALUES ('" + Session.GetHabbo().Id + "','" + Id + "','" + SilverwaveEnvironment.GetUnixTimestamp() + "','0','" + DateTime.Now.Hour + "','" + DateTime.Now.Minute + "');" + "UPDATE user_stats SET RoomVisits = RoomVisits + 1 WHERE id = " + Session.GetHabbo().Id); }
internal QueuedServerMessage LoadRoomForUser() { Room Room = CurrentLoadingRoom; QueuedServerMessage response = new QueuedServerMessage(Session.GetConnection()); if (Room == null || !Session.GetHabbo().LoadingChecksPassed) return response; if (Session.GetHabbo().FavouriteGroup > 0) { if (CurrentLoadingRoom.Group != null && !(CurrentLoadingRoom.LoadedGroups.ContainsKey(CurrentLoadingRoom.Group.Id))) CurrentLoadingRoom.LoadedGroups.Add(CurrentLoadingRoom.Group.Id, CurrentLoadingRoom.Group.Badge); if (!CurrentLoadingRoom.LoadedGroups.ContainsKey(Session.GetHabbo().FavouriteGroup)) { if (SilverwaveEnvironment.GetGame().GetGroupManager().GetGroup(Session.GetHabbo().FavouriteGroup) != null) CurrentLoadingRoom.LoadedGroups.Add(Session.GetHabbo().FavouriteGroup, SilverwaveEnvironment.GetGame().GetGroupManager().GetGroup(Session.GetHabbo().FavouriteGroup).Badge); } } Response.Init(Outgoing.SerializeRoomBadges); Response.AppendInt32(CurrentLoadingRoom.LoadedGroups.Count); foreach (KeyValuePair<uint, string> Group in CurrentLoadingRoom.LoadedGroups) { Response.AppendInt32(Group.Key); Response.AppendString(Group.Value); } response.appendResponse(GetResponse()); Response.Init(Outgoing.InitialRoomInformation); Response.AppendString(Room.ModelName); Response.AppendInt32(Room.RoomId); response.appendResponse(GetResponse()); if (Session.GetHabbo().SpectatorMode) { Response.Init(Outgoing.SpectatorMode); response.appendResponse(GetResponse()); } if (Room.Wallpaper != "0.0") { Response.Init(Outgoing.RoomDecoration); Response.AppendString("wallpaper"); Response.AppendString(Room.Wallpaper); response.appendResponse(GetResponse()); } if (Room.Floor != "0.0") { Response.Init(Outgoing.RoomDecoration); Response.AppendString("floor"); Response.AppendString(Room.Floor); response.appendResponse(GetResponse()); } Response.Init(Outgoing.RoomDecoration); Response.AppendString("landscape"); Response.AppendString(Room.Landscape); response.appendResponse(GetResponse()); if (Room.CheckRights(Session, true)) { Response.Init(Outgoing.RoomRightsLevel); Response.AppendInt32(4); response.appendResponse(GetResponse()); Response.Init(Outgoing.HasOwnerRights); response.appendResponse(GetResponse()); } else if (Room.CheckRights(Session)) { Response.Init(Outgoing.RoomRightsLevel); Response.AppendInt32(1); response.appendResponse(GetResponse()); } else { Response.Init(Outgoing.RoomRightsLevel); Response.AppendInt32(0); response.appendResponse(GetResponse()); } Response.Init(Outgoing.RateRoom); Response.AppendInt32(Room.Score); Response.AppendBoolean(!(Session.GetHabbo().RatedRooms.Contains(Room.RoomId) || Room.CheckRights(Session, true))); response.appendResponse(GetResponse()); return response; }
internal void GetRoomData3() { if (Session.GetHabbo().LoadingRoom <= 0 || !Session.GetHabbo().LoadingChecksPassed || CurrentLoadingRoom == null || Session == null) { return; } if (CurrentLoadingRoom.UsersNow + 1 > CurrentLoadingRoom.UsersMax && !Session.GetHabbo().HasFuse("fuse_enter_full_rooms")) { Session.SendNotif(LanguageLocale.GetValue("room.fullerror")); return; } ClearRoomLoading(); QueuedServerMessage response = new QueuedServerMessage(Session.GetConnection()); RoomItem[] floorItems = CurrentLoadingRoom.GetRoomItemHandler().mFloorItems.Values.ToArray(); RoomItem[] wallItems = CurrentLoadingRoom.GetRoomItemHandler().mWallItems.Values.ToArray(); Response.Init(Outgoing.SerializeFloorItems); if (CurrentLoadingRoom.Group != null) { if (CurrentLoadingRoom.Group.AdminOnlyDeco == 1) { Response.AppendInt32(CurrentLoadingRoom.Group.Admins.Count + 1); // count of owners foreach (GroupUser User in CurrentLoadingRoom.Group.Admins.Values) { Response.AppendInt32(User.Id); Response.AppendString(SilverwaveEnvironment.getHabboForId(User.Id).Username); } } else { Response.AppendInt32(CurrentLoadingRoom.Group.Members.Count + 1); // count of owners foreach (GroupUser User in CurrentLoadingRoom.Group.Members.Values) { Response.AppendInt32(User.Id); Response.AppendString(SilverwaveEnvironment.getHabboForId(User.Id).Username); } } Response.AppendInt32(CurrentLoadingRoom.OwnerId); Response.AppendString(CurrentLoadingRoom.Owner); } else { Response.AppendInt32(1); // count of owners // serialize all owners Response.AppendInt32(CurrentLoadingRoom.OwnerId); Response.AppendString(CurrentLoadingRoom.Owner); } Response.AppendInt32(floorItems.Length); foreach (RoomItem Item in floorItems) Item.Serialize(Response); response.appendResponse(GetResponse()); Response.Init(Outgoing.SerializeWallItems); if (CurrentLoadingRoom.Group != null) { if (CurrentLoadingRoom.Group.AdminOnlyDeco == 1) { Response.AppendInt32(CurrentLoadingRoom.Group.Admins.Count + 1); // count of owners foreach (GroupUser User in CurrentLoadingRoom.Group.Admins.Values) { Response.AppendInt32(User.Id); Response.AppendString(SilverwaveEnvironment.getHabboForId(User.Id).Username); } } else { Response.AppendInt32(CurrentLoadingRoom.Group.Members.Count + 1); // count of owners foreach (GroupUser User in CurrentLoadingRoom.Group.Members.Values) { Response.AppendInt32(User.Id); Response.AppendString(SilverwaveEnvironment.getHabboForId(User.Id).Username); } } Response.AppendInt32(CurrentLoadingRoom.OwnerId); Response.AppendString(CurrentLoadingRoom.Owner); } else { Response.AppendInt32(1); // count of owners // serialize all owners Response.AppendInt32(CurrentLoadingRoom.OwnerId); Response.AppendString(CurrentLoadingRoom.Owner); } // serialize items Response.AppendInt32(wallItems.Length); foreach (RoomItem Item in wallItems) Item.Serialize(Response); response.appendResponse(GetResponse()); Array.Clear(floorItems, 0, floorItems.Length); Array.Clear(wallItems, 0, wallItems.Length); floorItems = null; wallItems = null; CurrentLoadingRoom.GetRoomUserManager().AddUserToRoom(Session, false); //this.SerializeRoomInformation(CurrentLoadingRoom); response.sendResponse(); if (SilverwaveEnvironment.GetUnixTimestamp() < Session.GetHabbo().FloodTime && Session.GetHabbo().FloodTime != 0) { ServerMessage Packet = new ServerMessage(Outgoing.FloodFilter); Packet.AppendInt32(Session.GetHabbo().FloodTime - SilverwaveEnvironment.GetUnixTimestamp()); Session.SendMessage(Packet); } }
internal bool tryLogin(string AuthTicket) { try { string ip = GetConnection().getIp(); byte errorCode = 0; UserData userData = UserDataFactory.GetUserData(AuthTicket, ip, out errorCode); if (errorCode == 1) { SendNotifWithScroll(LanguageLocale.GetValue("login.invalidsso")); return false; } else if (errorCode == 2) { SendNotifWithScroll(LanguageLocale.GetValue("login.loggedin")); return false; } SilverwaveEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username); this.Habbo = userData.user; this.Habbo.SSOTicket = AuthTicket; userData.user.LoadData(userData); string banReason = SilverwaveEnvironment.GetGame().GetBanManager().GetBanReason(userData.user.Username, ip, MachineId); if (!string.IsNullOrEmpty(banReason) || userData.user.Username == null) { SendNotifWithScroll(banReason); Logging.WriteLine("Banned access from " + MachineId, ConsoleColor.Red); using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT ip_last FROM users WHERE id=" + this.GetHabbo().Id + " LIMIT 1"); string IP = dbClient.getString(); dbClient.setQuery("SELECT COUNT(0) FROM bans_access WHERE user_id=" + this.Habbo.Id + " LIMIT 1"); int Count = dbClient.getInteger(); if (Count > 0) { dbClient.runFastQuery("UPDATE bans_access SET attempts = attempts + 1, ip='" + IP + "' WHERE user_id=" + this.GetHabbo().Id + " LIMIT 1"); } else { dbClient.runFastQuery("INSERT INTO bans_access (user_id, ip) VALUES (" + this.GetHabbo().Id + ", '" + IP + "')"); } } return false; } userData.user.Init(this, userData); QueuedServerMessage response = new QueuedServerMessage(Connection); ServerMessage UniqueId = new ServerMessage(Outgoing.UniqueID); UniqueId.AppendString(this.MachineId); response.appendResponse(UniqueId); response.appendResponse(new AuthenticationOKComposer()); if (this.Habbo != null) { ServerMessage HomeRoom1 = new ServerMessage(Outgoing.HomeRoom); HomeRoom1.AppendInt32(this.Habbo.HomeRoom); // first home HomeRoom1.AppendInt32(this.Habbo.HomeRoom); // current home response.appendResponse(HomeRoom1); } ServerMessage MiniMail = new ServerMessage(Outgoing.SerializeMiniMailCount); MiniMail.AppendInt32(0); response.appendResponse(MiniMail); ServerMessage FavouriteRooms = new ServerMessage(Outgoing.FavouriteRooms); FavouriteRooms.AppendInt32(30); // max rooms FavouriteRooms.AppendInt32(userData.user.FavoriteRooms.Count); foreach (uint Id in userData.user.FavoriteRooms.ToArray()) { FavouriteRooms.AppendInt32(Id); } response.appendResponse(FavouriteRooms); if (this.GetHabbo().GetAvatarEffectsInventoryComponent() != null) SendMessage(this.GetHabbo().GetAvatarEffectsInventoryComponent().Serialize()); response.appendResponse(new UserRightsComposer((this.Habbo == null) ? 1 : this.Habbo.Rank)); ServerMessage bools1 = new ServerMessage(Outgoing.bools1); bools1.AppendBoolean(true); bools1.AppendBoolean(false); response.appendResponse(bools1); ServerMessage StartConsole = new ServerMessage(Outgoing.EnableConsole); StartConsole.AppendBoolean(true); response.appendResponse(StartConsole); //PixelManager.GivePixels(this, 0); ServerMessage mClient = new ServerMessage(Outgoing.ActivityPoints); mClient.AppendInt32(11); // ? mClient.AppendInt32(0); mClient.AppendInt32(Habbo.ActivityPoints); mClient.AppendInt32(1); mClient.AppendInt32(0); mClient.AppendInt32(2); mClient.AppendInt32(0); mClient.AppendInt32(3); mClient.AppendInt32(0); mClient.AppendInt32(4); mClient.AppendInt32(0); // Pixels mClient.AppendInt32(5); mClient.AppendInt32(Habbo.BelCredits); //seasonal currency mClient.AppendInt32(101); mClient.AppendInt32(0); mClient.AppendInt32(102); mClient.AppendInt32(0); mClient.AppendInt32(103); mClient.AppendInt32(0); mClient.AppendInt32(104); mClient.AppendInt32(0); mClient.AppendInt32(105); mClient.AppendInt32(Habbo.BelCredits); response.appendResponse(mClient); userData.user.UpdateCreditsBalance(); ServerMessage fuserights = new ServerMessage(Outgoing.Fuserights); fuserights.AppendInt32(2); if (Habbo.GetSubscriptionManager().HasSubscription) { fuserights.AppendInt32(1); //suscription } else { fuserights.AppendInt32(0); //no-suscription } //fuserights.AppendInt32(userData.user.Rank); fuserights.AppendInt32(0); response.appendResponse(fuserights); ServerMessage Constructors = new ServerMessage(Outgoing.ConstructorsClubLimits); Constructors.AppendInt32(0); //current used furni Constructors.AppendInt32(100); //max furni Constructors.AppendInt32(20000); // club timestamp ? ye response.appendResponse(Constructors); ServerMessage KeysEvent = new ServerMessage(Outgoing.HabboColoredKeysEvent); KeysEvent.AppendString(""); KeysEvent.AppendString(""); response.appendResponse(KeysEvent); if (userData.user.HasFuse("fuse_mod")) { response.appendResponse(SilverwaveEnvironment.GetGame().GetModerationTool().SerializeTool()); } response.sendResponse(); if (!string.IsNullOrWhiteSpace(SilverwaveEnvironment.GetDBConfig().DBData["welcome_message"])) { this.SendBroadcastMessage(SilverwaveEnvironment.GetDBConfig().DBData["welcome_message"]); } return true; } catch (UserDataNotFoundException) { SendNotifWithScroll("User not found or already logged in."); } catch (Exception e) { Logging.LogCriticalException("Bug duing user login: " + e.ToString()); } return false; }
internal void SerializeOpenTickets(ref QueuedServerMessage serverMessages, uint userID) { ServerMessage Response = new ServerMessage(Outgoing.SerializeIssue); foreach (SupportTicket ticket in Tickets) { if (ticket.Status == TicketStatus.OPEN || (ticket.Status == TicketStatus.PICKED && ticket.ModeratorId == userID) || (ticket.Status == TicketStatus.PICKED && ticket.ModeratorId == 0)) { Response = ticket.Serialize(Response); serverMessages.appendResponse(Response); } } }
internal void SerializeQuests(ref QueuedServerMessage response) { SilverwaveEnvironment.GetGame().GetQuestManager().GetList(mClient, null); }