/// <summary> /// Fills the specified row. /// </summary> /// <param name="row">The row.</param> internal void Fill(DataRow row) { try { Id = Convert.ToUInt32(row["id"]); Name = (string) row["caption"]; PassWord = (string) row["password"]; Description = (string) row["description"]; Type = (string) row["roomtype"]; Owner = (string) row["owner"]; OwnerId = 0; RoomChat = new ConcurrentStack<Chatlog>(); WordFilter = new List<string>(); using (var queryReactor = Azure.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery("SELECT id FROM users WHERE username = @name"); queryReactor.AddParameter("name", Owner); var integer = Convert.ToUInt32(queryReactor.GetInteger()); OwnerId = integer != uint.MinValue ? Convert.ToInt32(integer) : 0; queryReactor.SetQuery($"SELECT user_id, message, timestamp FROM users_chatlogs WHERE room_id = {Id} ORDER BY timestamp ASC LIMIT 150"); var table = queryReactor.GetTable(); foreach (DataRow dataRow in table.Rows) RoomChat.Push(new Chatlog((uint) dataRow[0], (string) dataRow[1], Azure.UnixToDateTime(int.Parse(dataRow[2].ToString())), false)); queryReactor.SetQuery($"SELECT word FROM rooms_wordfilter WHERE room_id = {Id}"); var tableFilter = queryReactor.GetTable(); foreach (DataRow dataRow in tableFilter.Rows) WordFilter.Add(dataRow["word"].ToString()); } var roomState = row["state"].ToString().ToLower(); switch (roomState) { case "locked": State = 1; break; case "password": State = 2; break; default: State = 0; break; } ModelName = (string) row["model_name"]; WallPaper = (string) row["wallpaper"]; Floor = (string) row["floor"]; LandScape = (string) row["landscape"]; CcTs = (string) row["public_ccts"]; int.TryParse(row["trade_state"].ToString(), out TradeState); int.TryParse(row["category"].ToString(), out Category); int.TryParse(row["walls_height"].ToString(), out WallHeight); int.TryParse(row["score"].ToString(), out Score); int.TryParse(row["floorthick"].ToString(), out FloorThickness); int.TryParse(row["wallthick"].ToString(), out WallThickness); int.TryParse(row["chat_type"].ToString(), out ChatType); int.TryParse(row["game_id"].ToString(), out GameId); int.TryParse(row["mute_settings"].ToString(), out WhoCanMute); int.TryParse(row["kick_settings"].ToString(), out WhoCanKick); int.TryParse(row["ban_settings"].ToString(), out WhoCanBan); uint.TryParse(row["users_now"].ToString(), out UsersNow); uint.TryParse(row["users_max"].ToString(), out UsersMax); uint.TryParse(row["group_id"].ToString(), out GroupId); uint.TryParse(row["chat_balloon"].ToString(), out ChatBalloon); uint.TryParse(row["chat_speed"].ToString(), out ChatSpeed); uint.TryParse(row["chat_max_distance"].ToString(), out ChatMaxDistance); uint.TryParse(row["chat_flood_protection"].ToString(), out ChatFloodProtection); AllowPets = Azure.EnumToBool(row["allow_pets"].ToString()); AllowPetsEating = Azure.EnumToBool(row["allow_pets_eat"].ToString()); AllowWalkThrough = Azure.EnumToBool(row["allow_walkthrough"].ToString()); HideWall = Azure.EnumToBool(row["hidewall"].ToString()); AllowRightsOverride = false; Group = Azure.GetGame().GetGroupManager().GetGroup(GroupId); Event = Azure.GetGame().GetRoomEvents().GetEvent(Id); _model = Azure.GetGame().GetRoomManager().GetModel(ModelName, Id); CompetitionStatus = 0; /* var dictionary = new Dictionary<int, int>(); if (!string.IsNullOrEmpty(row["icon_items"].ToString())) { string[] array = row["icon_items"].ToString().Split('|'); foreach (string text in array) { if (string.IsNullOrEmpty(text)) { continue; } string[] array2 = text.Replace('.', ',').Split(','); int key = 0; int value = 0; int.TryParse(array2[0], out key); if (array2.Length > 1) { int.TryParse(array2[1], out value); } try { if (!dictionary.ContainsKey(key)) { dictionary.Add(key, value); } } catch (Exception ex) { Logging.LogException("Exception: " + ex + "[" + text + "]"); } } } */ Tags = new List<string>(); //if (row.IsNull("tags") || !string.IsNullOrEmpty(row["tags"].ToString())) // @issue 96 if (row.IsNull("tags") || string.IsNullOrEmpty(row["tags"].ToString())) return; foreach (var item in row["tags"].ToString().Split(',')) Tags.Add(item); } catch (Exception ex) { Logging.LogException("Exception on RoomData Loading (Fill Void): " + ex); Logging.HandleException(ex, "Azure.HabboHotel.Rooms.RoomData"); } }
/// <summary> /// Fills the null. /// </summary> /// <param name="id">The identifier.</param> internal void FillNull(uint id) { Id = id; Name = "Unknown Room"; Description = "-"; Type = "private"; Owner = "-"; Category = 0; UsersNow = 0; UsersMax = 0; ModelName = "NO_MODEL"; CcTs = string.Empty; Score = 0; Tags = new List<string>(); AllowPets = true; AllowPetsEating = false; AllowWalkThrough = true; HideWall = false; PassWord = string.Empty; WallPaper = "0.0"; Floor = "0.0"; LandScape = "0.0"; WallThickness = 0; FloorThickness = 0; Group = null; AllowRightsOverride = false; Event = null; GameId = 0; WhoCanBan = 0; WhoCanKick = 0; WhoCanMute = 0; TradeState = 2; State = 0; RoomChat = new ConcurrentStack<Chatlog>(); WordFilter = new List<string>(); WallHeight = -1; _model = Azure.GetGame().GetRoomManager().GetModel(ModelName, Id); CompetitionStatus = 0; }