public Gamemap(Room room) { this._room = room; this.DiagonalEnabled = true; mStaticModel = PlusEnvironment.GetGame().GetRoomManager().GetModel(room.ModelName); if (mStaticModel == null) { PlusEnvironment.GetGame().GetRoomManager().LoadModel(room.ModelName); mStaticModel = PlusEnvironment.GetGame().GetRoomManager().GetModel(room.ModelName); } if (mStaticModel == null) return; mDynamicModel = new DynamicRoomModel(mStaticModel); mCoordinatedItems = new ConcurrentDictionary<Point, List<int>>(); gotPublicPool = room.RoomData.Model.gotPublicPool; mGameMap = new byte[Model.MapSizeX, Model.MapSizeY]; mItemHeightMap = new double[Model.MapSizeX, Model.MapSizeY]; userMap = new ConcurrentDictionary<Point, List<RoomUser>>(); }
public void Destroy() { Array.Clear(SqState, 0, SqState.Length); Array.Clear(SqFloorHeight, 0, SqFloorHeight.Length); Array.Clear(SqSeatRot, 0, SqSeatRot.Length); staticModel = null; Heightmap = null; SqState = null; SqFloorHeight = null; SqSeatRot = null; }
public DynamicRoomModel(RoomModel pModel) { staticModel = pModel; DoorX = staticModel.DoorX; DoorY = staticModel.DoorY; DoorZ = staticModel.DoorZ; DoorOrientation = staticModel.DoorOrientation; Heightmap = staticModel.Heightmap; MapSizeX = staticModel.MapSizeX; MapSizeY = staticModel.MapSizeY; ClubOnly = staticModel.ClubOnly; this.RelativeHeightmap = string.Empty; Generate(); }
public static bool TryGetData(int roomId, out RoomData data) { if (PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(roomId, out Room room)) { data = room; return(true); } using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `rooms`.*, `users`.`username` FROM `rooms` INNER JOIN `users` ON `users`.`id` = `rooms`.`owner` WHERE `rooms`.`id` = @id LIMIT 1"); dbClient.AddParameter("id", roomId); DataRow row = dbClient.GetRow(); if (row != null) { RoomModel model = null; if (!PlusEnvironment.GetGame().GetRoomManager().TryGetModel(Convert.ToString(row["model_name"]), out model)) { data = null; return(false); } // TODO: Revise this? string username = (!String.IsNullOrEmpty(Convert.ToString(row["username"])) ? Convert.ToString(row["username"]) : "Habboon"); data = new RoomData(Convert.ToInt32(row["id"]), Convert.ToString(row["caption"]), Convert.ToString(row["model_name"]), username, Convert.ToInt32(row["owner"]), Convert.ToString(row["password"]), Convert.ToInt32(row["score"]), Convert.ToString(row["roomtype"]), Convert.ToString(row["state"]), Convert.ToInt32(row["users_now"]), Convert.ToInt32(row["users_max"]), Convert.ToInt32(row["category"]), Convert.ToString(row["description"]), Convert.ToString(row["tags"]), Convert.ToString(row["floor"]), Convert.ToString(row["landscape"]), Convert.ToInt32(row["allow_pets"]), Convert.ToInt32(row["allow_pets_eat"]), Convert.ToInt32(row["room_blocking_disabled"]), Convert.ToInt32(row["allow_hidewall"]), Convert.ToInt32(row["wallthick"]), Convert.ToInt32(row["floorthick"]), Convert.ToString(row["wallpaper"]), Convert.ToInt32(row["mute_settings"]), Convert.ToInt32(row["ban_settings"]), Convert.ToInt32(row["kick_settings"]), Convert.ToInt32(row["chat_mode"]), Convert.ToInt32(row["chat_size"]), Convert.ToInt32(row["chat_speed"]), Convert.ToInt32(row["chat_extra_flood"]), Convert.ToInt32(row["chat_hearing_distance"]), Convert.ToInt32(row["trade_settings"]), Convert.ToString(row["push_enabled"]) == "1", Convert.ToString(row["pull_enabled"]) == "1", Convert.ToString(row["spush_enabled"]) == "1", Convert.ToString(row["spull_enabled"]) == "1", Convert.ToString(row["enables_enabled"]) == "1", Convert.ToString(row["respect_notifications_enabled"]) == "1", Convert.ToString(row["pet_morphs_allowed"]) == "1", Convert.ToInt32(row["group_id"]), Convert.ToInt32(row["sale_price"]), Convert.ToString(row["lay_enabled"]) == "1", model); return(true); } } data = null; return(false); }
public void Dispose() { _userMap.Clear(); _dynamicModel.Destroy(); _coordinatedItems.Clear(); Array.Clear(_gameMap, 0, _gameMap.Length); Array.Clear(_userItemEffect, 0, _userItemEffect.Length); Array.Clear(_itemHeightMap, 0, _itemHeightMap.Length); _userMap = null; _gameMap = null; _userItemEffect = null; _itemHeightMap = null; _coordinatedItems = null; _dynamicModel = null; _room = null; _model = null; }
public bool TryGetModel(string id, out RoomModel model) { if (_roomModels.ContainsKey(id)) { model = _roomModels[id]; return(true); } // Try to load this model. if (LoadModel(id)) { if (TryGetModel(id, out RoomModel customModel)) { model = customModel; return(true); } } model = null; return(false); }
/// <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 List <Chatlog>(); WordFilter = new List <string>(); WallHeight = -1; _model = Plus.GetGame().GetRoomManager().GetModel(ModelName, Id); CompetitionStatus = 0; }
/// <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 List <Chatlog>(); WordFilter = new List <string>(); using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery("SELECT id FROM users WHERE username = @name"); queryReactor.AddParameter("name", Owner); uint integer = Convert.ToUInt32(queryReactor.GetInteger()); OwnerId = integer != uint.MinValue ? Convert.ToInt32(integer) : 0; /*queryReactor.SetQuery(string.Format("SELECT user_id, message, timestamp FROM users_chatlogs WHERE room_id= '{0}' ORDER BY timestamp ASC LIMIT 350", Id)); * var table = queryReactor.GetTable(); * foreach (DataRow dataRow in table.Rows) * { * RoomChat.Add(new Chatlog((uint)dataRow[0], (string)dataRow[1], Plus.UnixToDateTime(int.Parse(dataRow[2].ToString())), false)); * }*/ queryReactor.SetQuery(string.Format("SELECT word FROM rooms_wordfilter WHERE room_id = '{0}'", 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; case "open": 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 = Plus.EnumToBool(row["allow_pets"].ToString()); AllowPetsEating = Plus.EnumToBool(row["allow_pets_eat"].ToString()); AllowWalkThrough = Plus.EnumToBool(row["allow_walkthrough"].ToString()); HideWall = Plus.EnumToBool(row["hidewall"].ToString()); AllowRightsOverride = false; Group = Plus.GetGame().GetGroupManager().GetGroup(GroupId); Event = Plus.GetGame().GetRoomEvents().GetEvent(Id); _model = Plus.GetGame().GetRoomManager().GetModel(ModelName, Id); CompetitionStatus = 0; Tags = new List <string>(); 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); } }
/// <summary> /// Resets the model. /// </summary> internal void ResetModel() { _model = Plus.GetGame().GetRoomManager().GetModel(ModelName, Id); }
public DynamicRoomModel(RoomModel model) { staticModel = model; DoorX = staticModel.DoorX; DoorY = staticModel.DoorY; DoorZ = staticModel.DoorZ; DoorOrientation = staticModel.DoorOrientation; Heightmap = staticModel.Heightmap; MapSizeX = staticModel.MapSizeX; MapSizeY = staticModel.MapSizeY; ClubOnly = staticModel.ClubOnly; this._relativeHeightmap = string.Empty; SqState = new SquareState[MapSizeX, MapSizeY]; SqFloorHeight = new short[MapSizeX, MapSizeY]; SqSeatRot = new byte[MapSizeX, MapSizeY]; for (int y = 0; y < MapSizeY; y++) { for (int x = 0; x < MapSizeX; x++) { if (x > (staticModel.MapSizeX - 1) || y > (staticModel.MapSizeY - 1)) { SqState[x, y] = SquareState.Blocked; } else { SqState[x, y] = staticModel.SqState[x, y]; SqFloorHeight[x, y] = staticModel.SqFloorHeight[x, y]; SqSeatRot[x, y] = staticModel.SqSeatRot[x, y]; } } } var FloorMap = new StringBuilder(); for (int y = 0; y < MapSizeY; y++) { for (int x = 0; x < MapSizeX; x++) { if (x == DoorX && y == DoorY) { FloorMap.Append(DoorZ > 9 ? ((char)(87 + DoorZ)).ToString() : DoorZ.ToString()); continue; } if (SqState[x, y] == SquareState.Blocked) { FloorMap.Append('x'); continue; } double Height = SqFloorHeight[x, y]; string Val = Height > 9 ? ((char)(87 + Height)).ToString() : Height.ToString(); FloorMap.Append(Val); } FloorMap.Append(Convert.ToChar(13)); } this._relativeHeightmap = FloorMap.ToString(); }
public RoomData(int id, string caption, string modelName, string ownerName, int ownerId, string password, int score, string type, string access, int usersNow, int usersMax, int category, string description, string tags, string floor, string landscape, int allowPets, int allowPetsEating, int roomBlockingEnabled, int hidewall, int wallThickness, int floorThickness, string wallpaper, int muteSettings, int banSettings, int kickSettings, int chatMode, int chatSize, int chatSpeed, int extraFlood, int chatDistance, int tradeSettings, bool pushEnabled, bool pullEnabled, bool superPushEnabled, bool superPullEnabled, bool enablesEnabled, bool respectedNotificationsEnabled, bool petMorphsAllowed, int groupId, int salePrice, bool layEnabled, RoomModel model) { this.Id = id; this.Name = caption; this.ModelName = modelName; this.OwnerName = ownerName; this.OwnerId = ownerId; this.Password = password; this.Score = score; this.Type = type; this.Access = RoomAccessUtility.ToRoomAccess(access); this.UsersNow = usersNow; this.UsersMax = usersMax; this.Category = category; this.Description = description; this.Tags = new List <string>(); foreach (string Tag in tags.ToString().Split(',')) { Tags.Add(Tag); } this.Floor = floor; this.Landscape = landscape; this.AllowPets = allowPets; this.AllowPetsEating = allowPetsEating; this.RoomBlockingEnabled = roomBlockingEnabled; this.Hidewall = hidewall; this.WallThickness = wallThickness; this.FloorThickness = floorThickness; this.Wallpaper = wallpaper; this.WhoCanMute = muteSettings; this.WhoCanBan = banSettings; this.WhoCanKick = kickSettings; this.ChatMode = chatMode; this.ChatSize = chatSize; this.ChatSpeed = chatSpeed; this.ExtraFlood = extraFlood; this.ChatDistance = chatDistance; this.TradeSettings = tradeSettings; this.PushEnabled = pushEnabled; this.PullEnabled = pullEnabled; this.SuperPushEnabled = superPushEnabled; this.SuperPullEnabled = superPullEnabled; this.EnablesEnabled = enablesEnabled; this.RespectNotificationsEnabled = respectedNotificationsEnabled; this.PetMorphsAllowed = petMorphsAllowed; this.SalePrice = salePrice; this.ReverseRollers = false; this.LayEnabled = layEnabled; if (groupId > 0) { PlusEnvironment.GetGame().GetGroupManager().TryGetGroup(groupId, out this._group); } LoadPromotions(); this._model = model; }
public RoomData CreateRoom(GameClient session, string name, string description, int category, int maxVisitors, int tradeSettings, RoomModel model, string wallpaper = "0.0", string floor = "0.0", string landscape = "0.0", int wallthick = 0, int floorthick = 0) { if (name.Length < 3) { session.SendNotification(PlusEnvironment.GetLanguageManager().TryGetValue("room.creation.name.too_short")); return(null); } int roomId = 0; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("INSERT INTO `rooms` (`roomtype`,`caption`,`description`,`owner`,`model_name`,`category`,`users_max`,`trade_settings`) VALUES ('private',@caption,@description,@UserId,@model,@category,@usersmax,@tradesettings)"); dbClient.AddParameter("caption", name); dbClient.AddParameter("description", description); dbClient.AddParameter("UserId", session.GetHabbo().Id); dbClient.AddParameter("model", model.Id); dbClient.AddParameter("category", category); dbClient.AddParameter("usersmax", maxVisitors); dbClient.AddParameter("tradesettings", tradeSettings); roomId = Convert.ToInt32(dbClient.InsertQuery()); } RoomData data = new RoomData(roomId, name, model.Id, session.GetHabbo().Username, session.GetHabbo().Id, "", 0, "public", "open", 0, maxVisitors, category, description, string.Empty, floor, landscape, 1, 1, 0, 0, wallthick, floorthick, wallpaper, 1, 1, 1, 1, 1, 1, 1, 8, tradeSettings, true, true, true, true, true, true, true, 0, 0, true, model); return(data); }
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 = PlusEnvironment.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 (PlusEnvironment.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 = PlusEnvironment.GetGame().GetRoomManager().GetModel(ModelName); this.PushEnabled = PlusEnvironment.EnumToBool(Row["push_enabled"].ToString()); this.PullEnabled = PlusEnvironment.EnumToBool(Row["pull_enabled"].ToString()); this.SPushEnabled = PlusEnvironment.EnumToBool(Row["spush_enabled"].ToString()); this.SPullEnabled = PlusEnvironment.EnumToBool(Row["spull_enabled"].ToString()); this.EnablesEnabled = PlusEnvironment.EnumToBool(Row["enables_enabled"].ToString()); this.RespectNotificationsEnabled = PlusEnvironment.EnumToBool(Row["respect_notifications_enabled"].ToString()); this.PetMorphsAllowed = PlusEnvironment.EnumToBool(Row["pet_morphs_allowed"].ToString()); }
public void Dispose() { userMap.Clear(); mDynamicModel.Destroy(); mCoordinatedItems.Clear(); Array.Clear(mGameMap, 0, mGameMap.Length); Array.Clear(mUserItemEffect, 0, mUserItemEffect.Length); Array.Clear(mItemHeightMap, 0, mItemHeightMap.Length); userMap = null; mGameMap = null; mUserItemEffect = null; mItemHeightMap = null; mCoordinatedItems = null; mDynamicModel = null; this._room = null; mStaticModel = null; }
public bool TryGetModel(string Id, out RoomModel Model) { return(this._roomModels.TryGetValue(Id, out Model)); }
public bool TryGetModel(string Id, out RoomModel Model) { return this._roomModels.TryGetValue(Id, out Model); }
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 = PlusEnvironment.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 (PlusEnvironment.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 = PlusEnvironment.GetGame().GetRoomManager().GetModel(ModelName); this.PushEnabled = PlusEnvironment.EnumToBool(Row["push_enabled"].ToString()); this.PullEnabled = PlusEnvironment.EnumToBool(Row["pull_enabled"].ToString()); this.SPushEnabled = PlusEnvironment.EnumToBool(Row["spush_enabled"].ToString()); this.SPullEnabled = PlusEnvironment.EnumToBool(Row["spull_enabled"].ToString()); this.EnablesEnabled = PlusEnvironment.EnumToBool(Row["enables_enabled"].ToString()); this.RespectNotificationsEnabled = PlusEnvironment.EnumToBool(Row["respect_notifications_enabled"].ToString()); this.PetMorphsAllowed = PlusEnvironment.EnumToBool(Row["pet_morphs_allowed"].ToString()); }
public bool TryGetModel(string Id, out RoomModel Model) => _roomModels.TryGetValue(Id, out Model);