public static void WriteRoom(ServerPacket Packet, RoomData Data, RoomPromotion Promotion, bool NewNavigator = false) { Packet.WriteInteger(Data.Id); Packet.WriteString(Data.Name); Packet.WriteInteger(Data.OwnerId); Packet.WriteString(Data.OwnerName); Packet.WriteInteger(RoomAccessUtility.GetRoomAccessPacketNum(Data.Access)); Packet.WriteInteger(Data.UsersNow); Packet.WriteInteger(Data.UsersMax); Packet.WriteString(Data.Description); Packet.WriteInteger(Data.TradeSettings); Packet.WriteInteger(Data.Score); Packet.WriteInteger(0);//Top rated room rank. Packet.WriteInteger(Data.Category); Packet.WriteInteger(Data.Tags.Count); foreach (string tag in Data.Tags) { Packet.WriteString(tag); } int RoomType = 0; if (Data.Group != null) { RoomType += 2; } if (Data.Promotion != null) { RoomType += 4; } if (Data.Type == "private") { RoomType += 8; } if (Data.AllowPets == 1) { RoomType += 16; } FeaturedRoom Item = null; if (BiosEmuThiago.GetGame().GetNavigator().TryGetFeaturedRoom(Data.Id, out Item)) { RoomType += 1; } Packet.WriteInteger(RoomType); if (Item != null) { Packet.WriteString(Item.Image); } if (Data.Group != null) { Packet.WriteInteger(Data.Group == null ? 0 : Data.Group.Id); Packet.WriteString(Data.Group == null ? "" : Data.Group.Name); Packet.WriteString(Data.Group == null ? "" : Data.Group.Badge); } if (Data.Promotion != null) { Packet.WriteString(Promotion != null ? Promotion.Name : ""); Packet.WriteString(Promotion != null ? Promotion.Description : ""); Packet.WriteInteger(Promotion != null ? Promotion.MinutesLeft : 0); } }
public void Fill(DataRow Row) { Id = Convert.ToInt32(Row["id"]); Name = Convert.ToString(Row["caption"]); Description = Convert.ToString(Row["description"]); Type = Convert.ToString(Row["roomtype"]); OwnerId = Convert.ToInt32(Row["owner"]); OwnerName = ""; using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `username` FROM `users` WHERE `id` = @owner LIMIT 1"); dbClient.AddParameter("owner", OwnerId); string result = dbClient.getString(); if (!String.IsNullOrEmpty(result)) { OwnerName = result; } } this.Access = RoomAccessUtility.ToRoomAccess(Row["state"].ToString().ToLower()); Category = Convert.ToInt32(Row["category"]); if (!string.IsNullOrEmpty(Row["users_now"].ToString())) { UsersNow = Convert.ToInt32(Row["users_now"]); } else { UsersNow = 0; } UsersMax = Convert.ToInt32(Row["users_max"]); ModelName = Convert.ToString(Row["model_name"]); Score = Convert.ToInt32(Row["score"]); Tags = new List <string>(); AllowPets = Convert.ToInt32(Row["allow_pets"].ToString()); AllowPetsEating = Convert.ToInt32(Row["allow_pets_eat"].ToString()); RoomBlockingEnabled = Convert.ToInt32(Row["room_blocking_disabled"].ToString()); Hidewall = Convert.ToInt32(Row["allow_hidewall"].ToString()); Password = Convert.ToString(Row["password"]); Wallpaper = Convert.ToString(Row["wallpaper"]); Floor = Convert.ToString(Row["floor"]); Landscape = Convert.ToString(Row["landscape"]); FloorThickness = Convert.ToInt32(Row["floorthick"]); WallThickness = Convert.ToInt32(Row["wallthick"]); WhoCanMute = Convert.ToInt32(Row["mute_settings"]); WhoCanKick = Convert.ToInt32(Row["kick_settings"]); WhoCanBan = Convert.ToInt32(Row["ban_settings"]); chatMode = Convert.ToInt32(Row["chat_mode"]); chatSpeed = Convert.ToInt32(Row["chat_speed"]); chatSize = Convert.ToInt32(Row["chat_size"]); TradeSettings = Convert.ToInt32(Row["trade_settings"]); Group G = null; if (BiosEmuThiago.GetGame().GetGroupManager().TryGetGroup(Convert.ToInt32(Row["group_id"]), out G)) { Group = G; } else { Group = null; } foreach (string Tag in Row["tags"].ToString().Split(',')) { Tags.Add(Tag); } mModel = BiosEmuThiago.GetGame().GetRoomManager().GetModel(ModelName); this.PushEnabled = BiosEmuThiago.EnumToBool(Row["push_enabled"].ToString()); this.PullEnabled = BiosEmuThiago.EnumToBool(Row["pull_enabled"].ToString()); this.SPushEnabled = BiosEmuThiago.EnumToBool(Row["spush_enabled"].ToString()); this.SPullEnabled = BiosEmuThiago.EnumToBool(Row["spull_enabled"].ToString()); this.EnablesEnabled = BiosEmuThiago.EnumToBool(Row["enables_enabled"].ToString()); this.RespectNotificationsEnabled = BiosEmuThiago.EnumToBool(Row["respect_notifications_enabled"].ToString()); this.PetMorphsAllowed = BiosEmuThiago.EnumToBool(Row["pet_morphs_allowed"].ToString()); WiredScoreBordDay = new Dictionary <int, KeyValuePair <int, string> >(); WiredScoreBordWeek = new Dictionary <int, KeyValuePair <int, string> >(); WiredScoreBordMonth = new Dictionary <int, KeyValuePair <int, string> >(); using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { List <bool> SuperCheck = new List <bool>() { false, false, false }; DateTime now = DateTime.Now; int getdaytoday = Convert.ToInt32(now.ToString("MMddyyyy")); int getmonthtoday = Convert.ToInt32(now.ToString("MM")); int getweektoday = CultureInfo.GetCultureInfo("Nl-nl").Calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday); this.WiredScoreFirstBordInformation = new List <int>() { getdaytoday, getmonthtoday, getweektoday }; dbClient.SetQuery("SELECT * FROM wired_scorebord WHERE roomid = @id ORDER BY `punten` DESC "); dbClient.AddParameter("id", this.Id); foreach (DataRow row in dbClient.getTable().Rows) { int userid = Convert.ToInt32(row["userid"]); string username = Convert.ToString(row["username"]); int Punten = Convert.ToInt32(row["punten"]); string soort = Convert.ToString(row["soort"]); int timestamp = Convert.ToInt32(row["timestamp"]); if ((!(soort == "day") || this.WiredScoreBordDay.ContainsKey(userid) ? false : !SuperCheck[0])) { if (timestamp != getdaytoday) { SuperCheck[0] = false; } if (!SuperCheck[0]) { this.WiredScoreBordDay.Add(userid, new KeyValuePair <int, string>(Punten, username)); } } if ((!(soort == "month") || this.WiredScoreBordMonth.ContainsKey(userid) ? false : !SuperCheck[1])) { if (timestamp != getmonthtoday) { SuperCheck[1] = false; } this.WiredScoreBordMonth.Add(userid, new KeyValuePair <int, string>(Punten, username)); } if ((!(soort == "week") || this.WiredScoreBordWeek.ContainsKey(userid) ? false : !SuperCheck[2])) { if (timestamp != getweektoday) { SuperCheck[2] = false; } this.WiredScoreBordWeek.Add(userid, new KeyValuePair <int, string>(Punten, username)); } } if (SuperCheck[0]) { dbClient.RunQuery(string.Concat("DELETE FROM `wired_scorebord` WHERE `roomid`='", this.Id, "' AND `soort`='day'")); this.WiredScoreBordDay.Clear(); } if (SuperCheck[1]) { dbClient.RunQuery(string.Concat("DELETE FROM `wired_scorebord` WHERE `roomid`='", this.Id, "' AND `soort`='month'")); this.WiredScoreBordMonth.Clear(); } if (SuperCheck[2]) { dbClient.RunQuery(string.Concat("DELETE FROM `wired_scorebord` WHERE `roomid`='", this.Id, "' AND `soort`='week'")); this.WiredScoreBordDay.Clear(); } } }