internal bool tryLogin(string AuthTicket) { try { string ip = this.GetConnection().getIp(); byte b = 0; UserData userData = UserDataFactory.GetUserData(AuthTicket, ip, out b); bool result; if (b == 1) { result = false; return result; } if (b == 2) { result = false; return result; } MercuryEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username); this.Habbo = userData.user; userData.user.LoadData(userData); string banReason = MercuryEnvironment.GetGame().GetBanManager().GetBanReason(userData.user.Username, ip, this.MachineId); if (!string.IsNullOrEmpty(banReason) || userData.user.Username == null) { this.SendNotifWithScroll(banReason); using (IQueryAdapter queryreactor = MercuryEnvironment.GetDatabaseManager().getQueryreactor()) { queryreactor.setQuery("SELECT ip_last FROM users WHERE id=" + this.GetHabbo().Id + " LIMIT 1"); string @string = queryreactor.getString(); queryreactor.setQuery("SELECT COUNT(0) FROM bans_access WHERE user_id=" + this.Habbo.Id + " LIMIT 1"); int integer = queryreactor.getInteger(); if (integer > 0) { queryreactor.runFastQuery(string.Concat(new object[] { "UPDATE bans_access SET attempts = attempts + 1, ip='", @string, "' WHERE user_id=", this.GetHabbo().Id, " LIMIT 1" })); } else { queryreactor.runFastQuery(string.Concat(new object[] { "INSERT INTO bans_access (user_id, ip) VALUES (", this.GetHabbo().Id, ", '", @string, "')" })); } } result = false; return result; } userData.user.Init(this, userData); QueuedServerMessage queuedServerMessage = new QueuedServerMessage(this.Connection); ServerMessage serverMessage = new ServerMessage(Outgoing.UniqueMachineIDMessageComposer); serverMessage.AppendString(this.MachineId); queuedServerMessage.appendResponse(serverMessage); queuedServerMessage.appendResponse(new ServerMessage(Outgoing.AuthenticationOKMessageComposer)); if (this.Habbo != null) { ServerMessage serverMessage2 = new ServerMessage(Outgoing.HomeRoomMessageComposer); serverMessage2.AppendUInt(this.Habbo.HomeRoom); serverMessage2.AppendUInt(this.Habbo.HomeRoom); queuedServerMessage.appendResponse(serverMessage2); } ServerMessage serverMessage3 = new ServerMessage(Outgoing.MinimailCountMessageComposer); serverMessage3.AppendInt32(this.Habbo.MinimailUnreadMessages); queuedServerMessage.appendResponse(serverMessage3); ServerMessage serverMessage4 = new ServerMessage(Outgoing.FavouriteRoomsMessageComposer); serverMessage4.AppendInt32(30); serverMessage4.AppendInt32(userData.user.FavoriteRooms.Count); object[] array = userData.user.FavoriteRooms.ToArray(); for (int i = 0; i < array.Length; i++) { uint i2 = (uint)array[i]; serverMessage4.AppendUInt(i2); } queuedServerMessage.appendResponse(serverMessage4); ServerMessage rightsMessage = new ServerMessage(Outgoing.UserClubRightsMessageComposer); rightsMessage.AppendInt32(userData.user.GetSubscriptionManager().HasSubscription ? 2 : 0); rightsMessage.AppendUInt(userData.user.Rank); rightsMessage.AppendInt32(0); queuedServerMessage.appendResponse(rightsMessage); ServerMessage serverMessage5 = new ServerMessage(Outgoing.EnableNotificationsMessageComposer); serverMessage5.AppendBoolean(true); serverMessage5.AppendBoolean(false); queuedServerMessage.appendResponse(serverMessage5); ServerMessage serverMessage6 = new ServerMessage(Outgoing.EnableTradingMessageComposer); serverMessage6.AppendBoolean(true); queuedServerMessage.appendResponse(serverMessage6); userData.user.UpdateCreditsBalance(); ServerMessage serverMessage7 = new ServerMessage(Outgoing.ActivityPointsMessageComposer); serverMessage7.AppendInt32(2); serverMessage7.AppendInt32(0); serverMessage7.AppendInt32(userData.user.ActivityPoints); serverMessage7.AppendInt32(5); serverMessage7.AppendInt32(userData.user.BelCredits); queuedServerMessage.appendResponse(serverMessage7); if (userData.user.HasFuse("fuse_mod")) { queuedServerMessage.appendResponse(MercuryEnvironment.GetGame().GetModerationTool().SerializeTool()); } if (!string.IsNullOrWhiteSpace(MercuryEnvironment.GetDBConfig().DBData["welcome_message"])) { this.SendBroadcastMessage(MercuryEnvironment.GetDBConfig().DBData["welcome_message"]); } queuedServerMessage.appendResponse(MercuryEnvironment.GetGame().GetAchievementManager().AchievementDataCached); if (!GetHabbo().NUXPassed && ExtraSettings.NEW_USER_GIFTS_ENABLED) { queuedServerMessage.appendResponse(new ServerMessage(Outgoing.NuxSuggestFreeGiftsMessageComposer)); } queuedServerMessage.appendResponse(this.GetHabbo().GetAvatarEffectsInventoryComponent().GetPacket()); queuedServerMessage.sendResponse(); MercuryEnvironment.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(this); MercuryEnvironment.GetGame().GetAchievementManager().TryProgressRegistrationAchievements(this); MercuryEnvironment.GetGame().GetAchievementManager().TryProgressLoginAchievements(this); result = true; return result; } catch (Exception ex) { Logging.LogCriticalException("Bug during user login: " + ex.ToString()); } return false; }
internal void PrepareRoomForUser(uint Id, string Password) { this.ClearRoomLoading(); QueuedServerMessage queuedServerMessage = new QueuedServerMessage(this.Session.GetConnection()); if (this.Session == null) { return; } if (MercuryEnvironment.ShutdownStarted) { this.Session.SendNotif("The server is shutting down. What are you doing?"); return; } if (this.Session.GetHabbo().InRoom) { Room room = MercuryEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId); if (room != null && room.GetRoomUserManager() != null) { room.GetRoomUserManager().RemoveUserFromRoom(this.Session, false, false); } } Room room2 = MercuryEnvironment.GetGame().GetRoomManager().LoadRoom(Id); if (room2 == null) { return; } if (room2.UserCount >= room2.UsersMax && !this.Session.GetHabbo().HasFuse("fuse_enter_full_rooms") && (ulong)this.Session.GetHabbo().Id != (ulong)((long)room2.OwnerId)) { ServerMessage serverMessage = new ServerMessage(Outgoing.RoomEnterErrorMessageComposer); serverMessage.AppendInt32(1); this.Session.SendMessage(serverMessage); ServerMessage message = new ServerMessage(Outgoing.OutOfRoomMessageComposer); this.Session.SendMessage(message); return; } if (room2 == null || this.Session == null || this.Session.GetHabbo() == null) { return; } if (this.Session.GetHabbo().IsTeleporting && this.Session.GetHabbo().TeleportingRoomID != Id) { return; } this.Session.GetHabbo().LoadingRoom = Id; this.CurrentLoadingRoom = room2; if (!this.Session.GetHabbo().HasFuse("fuse_enter_any_room") && room2.UserIsBanned(this.Session.GetHabbo().Id)) { if (!room2.HasBanExpired(this.Session.GetHabbo().Id)) { ServerMessage serverMessage2 = new ServerMessage(Outgoing.RoomEnterErrorMessageComposer); serverMessage2.AppendInt32(4); this.Session.SendMessage(serverMessage2); this.Response.Init(Outgoing.OutOfRoomMessageComposer); queuedServerMessage.appendResponse(this.GetResponse()); queuedServerMessage.sendResponse(); return; } room2.RemoveBan(this.Session.GetHabbo().Id); } this.Response.Init(Outgoing.PrepareRoomMessageComposer); queuedServerMessage.appendResponse(this.GetResponse()); if (!this.Session.GetHabbo().HasFuse("fuse_enter_any_room") && !room2.CheckRights(this.Session, true, false) && !this.Session.GetHabbo().IsTeleporting && !this.Session.GetHabbo().IsHopping) { if (room2.State == 1) { if (room2.UserCount == 0) { this.Response.Init(Outgoing.DoorbellNoOneMessageComposer); queuedServerMessage.appendResponse(this.GetResponse()); } else { this.Response.Init(Outgoing.DoorbellMessageComposer); this.Response.AppendString(""); queuedServerMessage.appendResponse(this.GetResponse()); ServerMessage serverMessage3 = new ServerMessage(Outgoing.DoorbellMessageComposer); serverMessage3.AppendString(this.Session.GetHabbo().Username); room2.SendMessageToUsersWithRights(serverMessage3); } queuedServerMessage.sendResponse(); return; } if (room2.State == 2 && Password.ToLower() != room2.Password.ToLower()) { this.Response.Init(Outgoing.OutOfRoomMessageComposer); queuedServerMessage.appendResponse(this.GetResponse()); queuedServerMessage.sendResponse(); return; } } this.Session.GetHabbo().LoadingChecksPassed = true; queuedServerMessage.addBytes(this.LoadRoomForUser().getPacket); queuedServerMessage.sendResponse(); if (this.Session.GetHabbo().RecentlyVisitedRooms.Contains(room2.RoomId)) { this.Session.GetHabbo().RecentlyVisitedRooms.Remove(room2.RoomId); } this.Session.GetHabbo().RecentlyVisitedRooms.Add(room2.RoomId); }
internal void OnRoomUserAdd() { if (this.Session == null || this.GetResponse() == null) { return; } QueuedServerMessage queuedServerMessage = new QueuedServerMessage(this.Session.GetConnection()); List<RoomUser> list = new List<RoomUser>(); if (this.CurrentLoadingRoom == null || this.CurrentLoadingRoom.GetRoomUserManager() == null || this.CurrentLoadingRoom.GetRoomUserManager().UserList == null) { return; } foreach (RoomUser current in this.CurrentLoadingRoom.GetRoomUserManager().UserList.Values) { if (current != null && !current.IsSpectator) { list.Add(current); } } this.Response.Init(Outgoing.SetRoomUserMessageComposer); this.Response.AppendInt32(list.Count); foreach (RoomUser current2 in list) { current2.Serialize(this.Response, this.CurrentLoadingRoom.GetGameMap().gotPublicPool); } queuedServerMessage.appendResponse(this.GetResponse()); queuedServerMessage.appendResponse(this.RoomFloorAndWallComposer(this.CurrentLoadingRoom)); queuedServerMessage.appendResponse(this.GetResponse()); this.Response.Init(Outgoing.RoomOwnershipMessageComposer); this.Response.AppendUInt(this.CurrentLoadingRoom.RoomId); this.Response.AppendBoolean(this.CurrentLoadingRoom.CheckRights(this.Session, true, false)); queuedServerMessage.appendResponse(this.GetResponse()); foreach (uint current3 in this.CurrentLoadingRoom.UsersWithRights) { Habbo habboForId = MercuryEnvironment.getHabboForId(current3); if (habboForId != null) { this.GetResponse().Init(Outgoing.GiveRoomRightsMessageComposer); this.GetResponse().AppendUInt(this.CurrentLoadingRoom.RoomId); this.GetResponse().AppendUInt(habboForId.Id); this.GetResponse().AppendString(habboForId.Username); queuedServerMessage.appendResponse(this.GetResponse()); } } ServerMessage serverMessage = this.CurrentLoadingRoom.GetRoomUserManager().SerializeStatusUpdates(true); if (serverMessage != null) { queuedServerMessage.appendResponse(serverMessage); } if (this.CurrentLoadingRoom.Event != null) { MercuryEnvironment.GetGame().GetRoomEvents().SerializeEventInfo(this.CurrentLoadingRoom.RoomId); } foreach (RoomUser current4 in this.CurrentLoadingRoom.GetRoomUserManager().UserList.Values) { if (current4 != null) { if (current4.IsBot) { if (current4.BotData.DanceId > 0) { this.Response.Init(Outgoing.DanceStatusMessageComposer); this.Response.AppendInt32(current4.VirtualId); this.Response.AppendInt32(current4.BotData.DanceId); queuedServerMessage.appendResponse(this.GetResponse()); } } else { if (current4.IsDancing) { this.Response.Init(Outgoing.DanceStatusMessageComposer); this.Response.AppendInt32(current4.VirtualId); this.Response.AppendInt32(current4.DanceId); queuedServerMessage.appendResponse(this.GetResponse()); } } if (current4.IsAsleep) { ServerMessage sleepMsg = new ServerMessage(Outgoing.RoomUserIdleMessageComposer); sleepMsg.AppendInt32(current4.VirtualId); sleepMsg.AppendBoolean(true); queuedServerMessage.appendResponse(sleepMsg); } if (current4.CarryItemID > 0 && current4.CarryTimer > 0) { this.Response.Init(Outgoing.ApplyHanditemMessageComposer); this.Response.AppendInt32(current4.VirtualId); this.Response.AppendInt32(current4.CarryTimer); queuedServerMessage.appendResponse(this.GetResponse()); } if (!current4.IsBot) { try { if (current4 != null && current4.GetClient() != null && current4.GetClient().GetHabbo() != null) { if (current4.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent() != null && current4.CurrentEffect >= 1) { this.Response.Init(Outgoing.ApplyEffectMessageComposer); this.Response.AppendInt32(current4.VirtualId); this.Response.AppendInt32(current4.CurrentEffect); this.Response.AppendInt32(0); queuedServerMessage.appendResponse(this.GetResponse()); } ServerMessage serverMessage2 = new ServerMessage(Outgoing.UpdateUserDataMessageComposer); serverMessage2.AppendInt32(current4.VirtualId); serverMessage2.AppendString(current4.GetClient().GetHabbo().Look); serverMessage2.AppendString(current4.GetClient().GetHabbo().Gender.ToLower()); serverMessage2.AppendString(current4.GetClient().GetHabbo().Motto); serverMessage2.AppendInt32(current4.GetClient().GetHabbo().AchievementPoints); if (this.CurrentLoadingRoom != null) { this.CurrentLoadingRoom.SendMessage(serverMessage2); } } } catch (Exception pException) { Logging.HandleException(pException, "Rooms.SendRoomData3"); } } } } queuedServerMessage.sendResponse(); }
internal void GetRoomData3() { if (this.Session.GetHabbo().LoadingRoom <= 0u || !this.Session.GetHabbo().LoadingChecksPassed || this.CurrentLoadingRoom == null || this.Session == null) { return; } QueuedServerMessage queuedServerMessage; RoomItem[] array; RoomItem[] array2; RoomItem[] array3; checked { if (this.CurrentLoadingRoom.UsersNow + 1 > this.CurrentLoadingRoom.UsersMax && !this.Session.GetHabbo().HasFuse("fuse_enter_full_rooms")) { this.Session.SendNotif("La Sala está llena."); return; } this.ClearRoomLoading(); queuedServerMessage = new QueuedServerMessage(this.Session.GetConnection()); array = this.CurrentLoadingRoom.GetRoomItemHandler().mFloorItems.Values.ToArray<RoomItem>(); array2 = this.CurrentLoadingRoom.GetRoomItemHandler().mWallItems.Values.ToArray<RoomItem>(); this.Response.Init(Outgoing.RoomFloorItemsMessageComposer); if (this.CurrentLoadingRoom.Group != null) { if (this.CurrentLoadingRoom.Group.AdminOnlyDeco == 1u) { this.Response.AppendInt32(this.CurrentLoadingRoom.Group.Admins.Count + 1); using (Dictionary<uint, GroupUser>.ValueCollection.Enumerator enumerator = this.CurrentLoadingRoom.Group.Admins.Values.GetEnumerator()) { while (enumerator.MoveNext()) { GroupUser current = enumerator.Current; this.Response.AppendUInt(current.Id); this.Response.AppendString(MercuryEnvironment.getHabboForId(current.Id).Username); } goto IL_220; } } this.Response.AppendInt32(this.CurrentLoadingRoom.Group.Members.Count + 1); foreach (GroupUser current2 in this.CurrentLoadingRoom.Group.Members.Values) { this.Response.AppendUInt(current2.Id); this.Response.AppendString(MercuryEnvironment.getHabboForId(current2.Id).Username); } IL_220: this.Response.AppendInt32(this.CurrentLoadingRoom.OwnerId); this.Response.AppendString(this.CurrentLoadingRoom.Owner); } else { this.Response.AppendInt32(1); this.Response.AppendInt32(this.CurrentLoadingRoom.OwnerId); this.Response.AppendString(this.CurrentLoadingRoom.Owner); } this.Response.AppendInt32(array.Length); array3 = array; } for (int i = 0; i < array3.Length; i++) { RoomItem roomItem = array3[i]; roomItem.Serialize(this.Response); } queuedServerMessage.appendResponse(this.GetResponse()); this.Response.Init(Outgoing.RoomWallItemsMessageComposer); RoomItem[] array4; checked { if (this.CurrentLoadingRoom.Group != null) { if (this.CurrentLoadingRoom.Group.AdminOnlyDeco == 1u) { this.Response.AppendInt32(this.CurrentLoadingRoom.Group.Admins.Count + 1); using (Dictionary<uint, GroupUser>.ValueCollection.Enumerator enumerator3 = this.CurrentLoadingRoom.Group.Admins.Values.GetEnumerator()) { while (enumerator3.MoveNext()) { GroupUser current3 = enumerator3.Current; this.Response.AppendUInt(current3.Id); this.Response.AppendString(MercuryEnvironment.getHabboForId(current3.Id).Username); } goto IL_423; } } this.Response.AppendInt32(this.CurrentLoadingRoom.Group.Members.Count + 1); foreach (GroupUser current4 in this.CurrentLoadingRoom.Group.Members.Values) { this.Response.AppendUInt(current4.Id); this.Response.AppendString(MercuryEnvironment.getHabboForId(current4.Id).Username); } IL_423: this.Response.AppendInt32(this.CurrentLoadingRoom.OwnerId); this.Response.AppendString(this.CurrentLoadingRoom.Owner); } else { this.Response.AppendInt32(1); this.Response.AppendInt32(this.CurrentLoadingRoom.OwnerId); this.Response.AppendString(this.CurrentLoadingRoom.Owner); } this.Response.AppendInt32(array2.Length); array4 = array2; } for (int j = 0; j < array4.Length; j++) { RoomItem roomItem2 = array4[j]; roomItem2.Serialize(this.Response); } queuedServerMessage.appendResponse(this.GetResponse()); Array.Clear(array, 0, array.Length); Array.Clear(array2, 0, array2.Length); array = null; array2 = null; this.CurrentLoadingRoom.GetRoomUserManager().AddUserToRoom(this.Session, this.Session.GetHabbo().SpectatorMode, false); queuedServerMessage.sendResponse(); if (MercuryEnvironment.GetUnixTimestamp() < this.Session.GetHabbo().FloodTime && this.Session.GetHabbo().FloodTime != 0) { ServerMessage serverMessage = new ServerMessage(Outgoing.FloodFilterMessageComposer); serverMessage.AppendInt32(checked(this.Session.GetHabbo().FloodTime - MercuryEnvironment.GetUnixTimestamp())); this.Session.SendMessage(serverMessage); } Poll poll = null; if (MercuryEnvironment.GetGame().GetPollManager().TryGetPoll(this.CurrentLoadingRoom.RoomId, out poll) && !this.Session.GetHabbo().GotPollData(poll.Id)) { this.Response.Init(Outgoing.SuggestPollMessageComposer); poll.Serialize(this.Response); this.SendResponse(); } }
internal void GetRoomData2() { try { QueuedServerMessage queuedServerMessage = new QueuedServerMessage(this.Session.GetConnection()); if (this.Session.GetHabbo().LoadingRoom > 0u && this.CurrentLoadingRoom != null) { RoomData roomData = this.CurrentLoadingRoom.RoomData; if (roomData != null) { if (roomData.Model == null) { this.Session.SendNotif("Go To F**k Off You Stupid Damn AssHOLE ! F**k You !!"); this.Session.SendMessage(new ServerMessage(Outgoing.OutOfRoomMessageComposer)); this.ClearRoomLoading(); } else { queuedServerMessage.appendResponse(this.CurrentLoadingRoom.GetGameMap().GetNewHeightmap()); queuedServerMessage.appendResponse(this.CurrentLoadingRoom.GetGameMap().Model.GetHeightmap()); queuedServerMessage.sendResponse(); this.GetRoomData3(); } } } } catch (Exception ex) { Logging.LogException(string.Concat(new object[] { "Unable to load room ID [", this.Session.GetHabbo().LoadingRoom, "] ", ex.ToString() })); } }
internal void GetInventory() { QueuedServerMessage queuedServerMessage = new QueuedServerMessage(this.Session.GetConnection()); queuedServerMessage.appendResponse(this.Session.GetHabbo().GetInventoryComponent().SerializeFloorItemInventory()); queuedServerMessage.sendResponse(); }