public Room(RoomData data) : base(data) { IsLagging = 0; Unloaded = false; IdleTime = 0; RoomMuted = false; MutedUsers = new Dictionary <int, double>(); Tents = new Dictionary <int, List <RoomUser> >(); _gamemap = new Gamemap(this, data.Model); _roomItemHandling = new RoomItemHandling(this); _roomUserManager = new RoomUserManager(this); _filterComponent = new FilterComponent(this); _wiredComponent = new WiredComponent(this); _bansComponent = new BansComponent(this); _tradingComponent = new TradingComponent(this); GetRoomItemHandler().LoadFurniture(); GetGameMap().GenerateMaps(); LoadPromotions(); LoadRights(); LoadFilter(); InitBots(); InitPets(); lastRegeneration = DateTime.Now; }
public bool ItemCanMove(Item Item, Point MoveTo) { List <ThreeDCoord> Points = Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, MoveTo.X, MoveTo.Y, Item.Rotation).Values.ToList(); if (Points == null || Points.Count == 0) { return(true); } foreach (ThreeDCoord Coord in Points) { if (Coord.X >= Model.MapSizeX || Coord.Y >= Model.MapSizeY) { return(false); } if (!SquareIsOpen(Coord.X, Coord.Y, false)) { return(false); } continue; } return(true); }
public static List<Vector2D> FindPath(RoomUser User, bool Diag, Gamemap Map, Vector2D Start, Vector2D End) { var Path = new List<Vector2D>(); PathFinderNode Nodes = FindPathReversed(User, Diag, Map, Start, End); if (Nodes != null) { Path.Add(End); while (Nodes.Next != null) { Path.Add(Nodes.Next.Position); Nodes = Nodes.Next; } } return Path; }
public bool SetFloorItem(Item item, int newX, int newY, Double newZ) { if (_room == null) { return(false); } _room.GetGameMap().RemoveFromMap(item); item.SetState(newX, newY, newZ, Gamemap.GetAffectedTiles(item.GetBaseItem().Length, item.GetBaseItem().Width, newX, newY, item.Rotation)); if (item.GetBaseItem().InteractionType == InteractionType.TONER) { if (_room.TonerData == null) { _room.TonerData = new TonerData(item.Id); } } UpdateItem(item); _room.GetGameMap().AddItemToMap(item); return(true); }
public bool SetFloorItem(GameClient Session, Item Item, int newX, int newY, int newRot, bool newItem, bool OnRoller, bool sendMessage, bool updateRoomUserStatuses = false, double height = -1) { bool NeedsReAdd = false; if (newItem) { if (Item.IsWired) { if (Item.GetBaseItem().WiredType == WiredBoxType.EffectRegenerateMaps && _room.GetRoomItemHandler().GetFloor.Count(x => x.GetBaseItem().WiredType == WiredBoxType.EffectRegenerateMaps) > 0) { return(false); } } } List <Item> ItemsOnTile = GetFurniObjects(newX, newY); if (Item.GetBaseItem().InteractionType == InteractionType.ROLLER && ItemsOnTile.Count(x => x.GetBaseItem().InteractionType == InteractionType.ROLLER && x.Id != Item.Id) > 0) { return(false); } if (!newItem) { NeedsReAdd = _room.GetGameMap().RemoveFromMap(Item); } Dictionary <int, ThreeDCoord> AffectedTiles = Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, newRot); if (!_room.GetGameMap().ValidTile(newX, newY) || _room.GetGameMap().SquareHasUsers(newX, newY) && !Item.GetBaseItem().IsSeat) { if (NeedsReAdd) { _room.GetGameMap().AddToMap(Item); } return(false); } foreach (ThreeDCoord Tile in AffectedTiles.Values) { if (!_room.GetGameMap().ValidTile(Tile.X, Tile.Y) || (_room.GetGameMap().SquareHasUsers(Tile.X, Tile.Y) && !Item.GetBaseItem().IsSeat)) { if (NeedsReAdd) { _room.GetGameMap().AddToMap(Item); } return(false); } } // Start calculating new Z coordinate double newZ = _room.GetGameMap().Model.SqFloorHeight[newX, newY]; if (height == -1) { if (!OnRoller) { // Make sure this tile is open and there are no users here if (_room.GetGameMap().Model.SqState[newX, newY] != SquareState.Open && !Item.GetBaseItem().IsSeat) { return(false); } foreach (ThreeDCoord Tile in AffectedTiles.Values) { if (_room.GetGameMap().Model.SqState[Tile.X, Tile.Y] != SquareState.Open && !Item.GetBaseItem().IsSeat) { if (NeedsReAdd) { //AddItem(Item); _room.GetGameMap().AddToMap(Item); } return(false); } } // And that we have no users if (!Item.GetBaseItem().IsSeat&& !Item.IsRoller) { foreach (ThreeDCoord Tile in AffectedTiles.Values) { if (_room.GetGameMap().GetRoomUsers(new Point(Tile.X, Tile.Y)).Count > 0) { if (NeedsReAdd) { _room.GetGameMap().AddToMap(Item); } return(false); } } } } // Find affected objects var ItemsAffected = new List <Item>(); var ItemsComplete = new List <Item>(); foreach (ThreeDCoord Tile in AffectedTiles.Values.ToList()) { List <Item> Temp = GetFurniObjects(Tile.X, Tile.Y); if (Temp != null) { ItemsAffected.AddRange(Temp); } } ItemsComplete.AddRange(ItemsOnTile); ItemsComplete.AddRange(ItemsAffected); if (!OnRoller) { // Check for items in the stack that do not allow stacking on top of them foreach (Item I in ItemsComplete.ToList()) { if (I == null) { continue; } if (I.Id == Item.Id) { continue; } if (I.GetBaseItem() == null) { continue; } if (!I.GetBaseItem().Stackable) { if (NeedsReAdd) { //AddItem(Item); _room.GetGameMap().AddToMap(Item); } return(false); } } } //if (!Item.IsRoller) { // If this is a rotating action, maintain item at current height if (Item.Rotation != newRot && Item.GetX == newX && Item.GetY == newY) { newZ = Item.GetZ; } // Are there any higher objects in the stack!? foreach (Item i in ItemsComplete.ToList()) { if (i == null) { continue; } if (i.Id == Item.Id) { continue; } if (i.GetBaseItem().InteractionType == InteractionType.STACKTOOL) { newZ = i.GetZ; break; } if (i.TotalHeight > newZ) { newZ = i.TotalHeight; } } } // Verify the rotation is correct if (newRot != 0 && newRot != 2 && newRot != 4 && newRot != 6 && newRot != 8 && !Item.GetBaseItem().ExtraRot) { newRot = 0; } } else { newZ = height; } Item.Rotation = newRot; int oldX = Item.GetX; int oldY = Item.GetY; Item.SetState(newX, newY, newZ, AffectedTiles); if (!OnRoller && Session != null) { Item.Interactor.OnPlace(Session, Item); } if (newItem) { if (_floorItems.ContainsKey(Item.Id)) { if (Session != null) { Session.SendNotification(PlusEnvironment.GetLanguageManager().TryGetValue("room.item.already_placed")); } _room.GetGameMap().RemoveFromMap(Item); return(true); } if (Item.IsFloorItem && !_floorItems.ContainsKey(Item.Id)) { _floorItems.TryAdd(Item.Id, Item); } else if (Item.IsWallItem && !_wallItems.ContainsKey(Item.Id)) { _wallItems.TryAdd(Item.Id, Item); } if (sendMessage) { _room.SendPacket(new ObjectAddComposer(Item)); } } else { UpdateItem(Item); if (!OnRoller && sendMessage) { _room.SendPacket(new ObjectUpdateComposer(Item, _room.OwnerId)); } } _room.GetGameMap().AddToMap(Item); if (Item.GetBaseItem().IsSeat) { updateRoomUserStatuses = true; } if (updateRoomUserStatuses) { _room.GetRoomUserManager().UpdateUserStatusses(); } if (Item.GetBaseItem().InteractionType == InteractionType.TENT || Item.GetBaseItem().InteractionType == InteractionType.TENT_SMALL) { _room.RemoveTent(Item.Id); _room.AddTent(Item.Id); } using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("UPDATE `items` SET `room_id` = '" + _room.RoomId + "', `x` = '" + Item.GetX + "', `y` = '" + Item.GetY + "', `z` = '" + Item.GetZ + "', `rot` = '" + Item.Rotation + "' WHERE `id` = '" + Item.Id + "' LIMIT 1"); } return(true); }
public bool CheckPosItem(Item Item, int newX, int newY, int newRot) { try { Dictionary <int, ThreeDCoord> dictionary = Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, newRot); if (!_room.GetGameMap().ValidTile(newX, newY)) { return(false); } foreach (ThreeDCoord coord in dictionary.Values.ToList()) { if ((_room.GetGameMap().Model.DoorX == coord.X) && (_room.GetGameMap().Model.DoorY == coord.Y)) { return(false); } } if ((_room.GetGameMap().Model.DoorX == newX) && (_room.GetGameMap().Model.DoorY == newY)) { return(false); } foreach (ThreeDCoord coord in dictionary.Values.ToList()) { if (!_room.GetGameMap().ValidTile(coord.X, coord.Y)) { return(false); } } double num = _room.GetGameMap().Model.SqFloorHeight[newX, newY]; if ((((Item.Rotation == newRot) && (Item.GetX == newX)) && (Item.GetY == newY)) && (Item.GetZ != num)) { return(false); } if (_room.GetGameMap().Model.SqState[newX, newY] != SquareState.Open) { return(false); } foreach (ThreeDCoord coord in dictionary.Values.ToList()) { if (_room.GetGameMap().Model.SqState[coord.X, coord.Y] != SquareState.Open) { return(false); } } if (!Item.GetBaseItem().IsSeat) { if (_room.GetGameMap().SquareHasUsers(newX, newY)) { return(false); } foreach (ThreeDCoord coord in dictionary.Values.ToList()) { if (_room.GetGameMap().SquareHasUsers(coord.X, coord.Y)) { return(false); } } } List <Item> furniObjects = GetFurniObjects(newX, newY); List <Item> collection = new List <Item>(); List <Item> list3 = new List <Item>(); foreach (ThreeDCoord coord in dictionary.Values.ToList()) { List <Item> list4 = GetFurniObjects(coord.X, coord.Y); if (list4 != null) { collection.AddRange(list4); } } if (furniObjects == null) { furniObjects = new List <Item>(); } list3.AddRange(furniObjects); list3.AddRange(collection); foreach (Item i in list3.ToList()) { if ((i.Id != Item.Id) && !i.GetBaseItem().Stackable) { return(false); } } return(true); } catch { return(false); } }
//private ProcessComponent _process = null; public Room(RoomData Data) { this.IsLagging = 0; this.IdleTime = 0; this._roomData = Data; RoomMuted = false; mDisposed = false; this.Id = Data.Id; this.Name = Data.Name; this.Description = Data.Description; this.OwnerName = Data.OwnerName; this.OwnerId = Data.OwnerId; this.Category = Data.Category; this.Type = Data.Type; this.Access = Data.Access; this.UsersNow = 0; this.UsersMax = Data.UsersMax; this.ModelName = Data.ModelName; this.Score = Data.Score; this.Tags = new List<string>(); foreach (string tag in Data.Tags) { Tags.Add(tag); } this.AllowPets = Data.AllowPets; this.AllowPetsEating = Data.AllowPetsEating; this.RoomBlockingEnabled = Data.RoomBlockingEnabled; this.Hidewall = Data.Hidewall; this.Group = Data.Group; this.Password = Data.Password; this.Wallpaper = Data.Wallpaper; this.Floor = Data.Floor; this.Landscape = Data.Landscape; this.WallThickness = Data.WallThickness; this.FloorThickness = Data.FloorThickness; this.chatMode = Data.chatMode; this.chatSize = Data.chatSize; this.chatSpeed = Data.chatSpeed; this.chatDistance = Data.chatDistance; this.extraFlood = Data.extraFlood; this.TradeSettings = Data.TradeSettings; this.WhoCanBan = Data.WhoCanBan; this.WhoCanKick = Data.WhoCanKick; this.WhoCanBan = Data.WhoCanBan; this.PushEnabled = Data.PushEnabled; this.PullEnabled = Data.PullEnabled; this.SPullEnabled = Data.SPullEnabled; this.SPushEnabled = Data.SPushEnabled; this.EnablesEnabled = Data.EnablesEnabled; this.RespectNotificationsEnabled = Data.RespectNotificationsEnabled; this.PetMorphsAllowed = Data.PetMorphsAllowed; this.ActiveTrades = new ArrayList(); this.Bans = new Dictionary<int, double>(); this.MutedUsers = new Dictionary<int, double>(); this.Tents = new Dictionary<int, List<RoomUser>>(); _gamemap = new Gamemap(this); if (_roomItemHandling == null) _roomItemHandling = new RoomItemHandling(this); _roomUserManager = new RoomUserManager(this); this._filterComponent = new FilterComponent(this); this._wiredComponent = new WiredComponent(this); GetRoomItemHandler().LoadFurniture(); GetGameMap().GenerateMaps(); this.LoadPromotions(); this.LoadRights(); this.LoadBans(); this.LoadFilter(); this.InitBots(); this.InitPets(); Data.UsersNow = 1; }
public void OnChat(int Colour, string Message, bool Shout) { if (GetClient() == null || GetClient().GetHabbo() == null || mRoom == null) { return; } if (mRoom.GetWired().TriggerEvent(Items.Wired.WiredBoxType.TriggerUserSays, GetClient().GetHabbo(), Message)) { return; } GetClient().GetHabbo().HasSpoken = true; if (mRoom.WordFilterList.Count > 0 && !GetClient().GetHabbo().GetPermissions().HasRight("word_filter_override")) { Message = mRoom.GetFilter().CheckMessage(Message); } ServerPacket Packet = null; if (Shout) { Packet = new ShoutComposer(VirtualId, Message, PlusEnvironment.GetGame().GetChatManager().GetEmotions().GetEmotionsForText(Message), Colour); } else { Packet = new ChatComposer(VirtualId, Message, PlusEnvironment.GetGame().GetChatManager().GetEmotions().GetEmotionsForText(Message), Colour); } if (GetClient().GetHabbo().TentId > 0) { mRoom.SendToTent(GetClient().GetHabbo().Id, GetClient().GetHabbo().TentId, Packet); Packet = new WhisperComposer(this.VirtualId, "[Tent Chat] " + Message, 0, Colour); List <RoomUser> ToNotify = mRoom.GetRoomUserManager().GetRoomUserByRank(2); if (ToNotify.Count > 0) { foreach (RoomUser user in ToNotify) { if (user == null || user.GetClient() == null || user.GetClient().GetHabbo() == null || user.GetClient().GetHabbo().TentId == GetClient().GetHabbo().TentId) { continue; } user.GetClient().SendPacket(Packet); } } } else { foreach (RoomUser User in mRoom.GetRoomUserManager().GetRoomUsers().ToList()) { if (User == null || User.GetClient() == null || User.GetClient().GetHabbo() == null || User.GetClient().GetHabbo().GetIgnores().IgnoredUserIds().Contains(mClient.GetHabbo().Id)) { continue; } if (mRoom.chatDistance > 0 && Gamemap.TileDistance(this.X, this.Y, User.X, User.Y) > mRoom.chatDistance) { continue; } User.GetClient().SendPacket(Packet); } } #region Pets/Bots responces if (Shout) { foreach (RoomUser User in mRoom.GetRoomUserManager().GetUserList().ToList()) { if (!User.IsBot) { continue; } if (User.IsBot) { User.BotAI.OnUserShout(this, Message); } } } else { foreach (RoomUser User in mRoom.GetRoomUserManager().GetUserList().ToList()) { if (!User.IsBot) { continue; } if (User.IsBot) { User.BotAI.OnUserSay(this, Message); } } } #endregion }
public void Dispose() { SendPacket(new CloseConnectionComposer()); if (!mDisposed) { isCrashed = false; mDisposed = true; /* TODO: Needs reviewing */ try { if (ProcessTask != null && ProcessTask.IsCompleted) { ProcessTask.Dispose(); } } catch { } if (ActiveTrades.Count > 0) { ActiveTrades.Clear(); } TonerData = null; MoodlightData = null; if (MutedUsers.Count > 0) { MutedUsers.Clear(); } if (Tents.Count > 0) { Tents.Clear(); } if (UsersWithRights.Count > 0) { UsersWithRights.Clear(); } if (_gameManager != null) { _gameManager.Dispose(); _gameManager = null; } if (_freeze != null) { _freeze.Dispose(); _freeze = null; } if (_soccer != null) { _soccer.Dispose(); _soccer = null; } if (_banzai != null) { _banzai.Dispose(); _banzai = null; } if (_gamemap != null) { _gamemap.Dispose(); _gamemap = null; } if (_gameItemHandler != null) { _gameItemHandler.Dispose(); _gameItemHandler = null; } // Room Data? if (teambanzai != null) { teambanzai.Dispose(); teambanzai = null; } if (teamfreeze != null) { teamfreeze.Dispose(); teamfreeze = null; } if (_roomUserManager != null) { _roomUserManager.Dispose(); _roomUserManager = null; } if (_roomItemHandling != null) { _roomItemHandling.Dispose(); _roomItemHandling = null; } if (_wordFilterList.Count > 0) { _wordFilterList.Clear(); } if (_filterComponent != null) { _filterComponent.Cleanup(); } if (_wiredComponent != null) { _wiredComponent.Cleanup(); } if (_bansComponent != null) { _bansComponent.Cleanup(); } if (_tradingComponent != null) { _tradingComponent.Cleanup(); } } }
public static PathFinderNode FindPathReversed(RoomUser User, bool Diag, Gamemap Map, Vector2D Start, Vector2D End) { var OpenList = new MinHeap<PathFinderNode>(256); var PfMap = new PathFinderNode[Map.Model.MapSizeX, Map.Model.MapSizeY]; PathFinderNode Node; Vector2D Tmp; int Cost; int Diff; var Current = new PathFinderNode(Start); Current.Cost = 0; var Finish = new PathFinderNode(End); PfMap[Current.Position.X, Current.Position.Y] = Current; OpenList.Add(Current); while (OpenList.Count > 0) { Current = OpenList.ExtractFirst(); Current.InClosed = true; for (int i = 0; Diag ? i < DiagMovePoints.Length : i < NoDiagMovePoints.Length; i++) { Tmp = Current.Position + (Diag ? DiagMovePoints[i] : NoDiagMovePoints[i]); bool IsFinalMove = (Tmp.X == End.X && Tmp.Y == End.Y); if (Map.IsValidStep(new Vector2D(Current.Position.X, Current.Position.Y), Tmp, IsFinalMove, User.AllowOverride)) { if (PfMap[Tmp.X, Tmp.Y] == null) { Node = new PathFinderNode(Tmp); PfMap[Tmp.X, Tmp.Y] = Node; } else { Node = PfMap[Tmp.X, Tmp.Y]; } if (!Node.InClosed) { Diff = 0; if (Current.Position.X != Node.Position.X) { Diff += 1; } if (Current.Position.Y != Node.Position.Y) { Diff += 1; } Cost = Current.Cost + Diff + Node.Position.GetDistanceSquared(End); if (Cost < Node.Cost) { Node.Cost = Cost; Node.Next = Current; } if (!Node.InOpen) { if (Node.Equals(Finish)) { Node.Next = Current; return Node; } Node.InOpen = true; OpenList.Add(Node); } } } } } return null; }
public bool SetFloorItem(GameClient Session, Item Item, int newX, int newY, int newRot, bool newItem, bool OnRoller, bool sendMessage, bool updateRoomUserStatuses = false) { // Questions -> Skype: keiz.er bool NeedsReAdd = false; if (newItem) { if (Item.IsWired) { if (Item.GetBaseItem().WiredType == WiredBoxType.EffectRegenerateMaps && _room.GetRoomItemHandler().GetFloor.Where(x => x.GetBaseItem().WiredType == WiredBoxType.EffectRegenerateMaps).Count() > 0) { return(false); } } } List <Item> ItemsOnTile = GetFurniObjects(newX, newY); if (Item.GetBaseItem().InteractionType == InteractionType.ROLLER && ItemsOnTile.Where(x => x.GetBaseItem().InteractionType == InteractionType.ROLLER && x.Id != Item.Id).Count() > 0) { return(false); } if (!newItem) { NeedsReAdd = _room.GetGameMap().RemoveFromMap(Item); } Dictionary <int, ThreeDCoord> AffectedTiles = Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, newRot); if (!_room.GetGameMap().ValidTile(newX, newY) || _room.GetGameMap().SquareHasUsers(newX, newY) && !Item.GetBaseItem().IsSeat) { if (NeedsReAdd) { _room.GetGameMap().AddToMap(Item); } return(false); } foreach (ThreeDCoord Tile in AffectedTiles.Values) { if (!_room.GetGameMap().ValidTile(Tile.X, Tile.Y) || (_room.GetGameMap().SquareHasUsers(Tile.X, Tile.Y) && !Item.GetBaseItem().IsSeat)) { if (NeedsReAdd) { _room.GetGameMap().AddToMap(Item); } return(false); } } Double newZ = _room.GetGameMap().Model.SqFloorHeight[newX, newY]; if (!OnRoller) { if (_room.GetGameMap().Model.SqState[newX, newY] != SquareState.OPEN && !Item.GetBaseItem().IsSeat) { return(false); } foreach (ThreeDCoord Tile in AffectedTiles.Values) { if (_room.GetGameMap().Model.SqState[Tile.X, Tile.Y] != SquareState.OPEN && !Item.GetBaseItem().IsSeat) { if (NeedsReAdd) { //AddItem(Item); _room.GetGameMap().AddToMap(Item); } return(false); } } if (!Item.GetBaseItem().IsSeat&& !Item.IsRoller) { foreach (ThreeDCoord Tile in AffectedTiles.Values) { if (_room.GetGameMap().GetRoomUsers(new Point(Tile.X, Tile.Y)).Count > 0) { if (NeedsReAdd) { _room.GetGameMap().AddToMap(Item); } return(false); } } } } // Find affected objects var ItemsAffected = new List <Item>(); var ItemsComplete = new List <Item>(); foreach (ThreeDCoord Tile in AffectedTiles.Values.ToList()) { List <Item> Temp = GetFurniObjects(Tile.X, Tile.Y); if (Temp != null) { ItemsAffected.AddRange(Temp); } } ItemsComplete.AddRange(ItemsOnTile); ItemsComplete.AddRange(ItemsAffected); if (!OnRoller) { foreach (Item I in ItemsComplete.ToList()) { if (I == null) { continue; } if (I.Id == Item.Id) { continue; } if (I.GetBaseItem() == null) { continue; } } } { if (Item.Rotation != newRot && Item.GetX == newX && Item.GetY == newY) { newZ = Item.GetZ; } foreach (Item I in ItemsComplete.ToList()) { if (I == null) { continue; } if (I.Id == Item.Id) { continue; } if (I.GetBaseItem().InteractionType == InteractionType.STACKTOOL) { // Basically the core of the fix // Questions -> Skype: keiz.er newZ = I.GetZ; break; } if (I.TotalHeight > newZ) { newZ = I.TotalHeight; } } } if (newRot != 0 && newRot != 2 && newRot != 4 && newRot != 6 && newRot != 8 && !Item.GetBaseItem().ExtraRot) { newRot = 0; } Item.Rotation = newRot; int oldX = Item.GetX; int oldY = Item.GetY; Item.SetState(newX, newY, newZ, AffectedTiles); if (!OnRoller && Session != null) { Item.Interactor.OnPlace(Session, Item); } if (newItem) { if (_floorItems.ContainsKey(Item.Id)) { if (Session != null) { Session.SendNotification(PlusEnvironment.GetGame().GetLanguageLocale().TryGetValue("room_item_placed")); } _room.GetGameMap().RemoveFromMap(Item); return(true); } if (Item.IsFloorItem && !_floorItems.ContainsKey(Item.Id)) { _floorItems.TryAdd(Item.Id, Item); } else if (Item.IsWallItem && !_wallItems.ContainsKey(Item.Id)) { _wallItems.TryAdd(Item.Id, Item); } if (sendMessage) { _room.SendMessage(new ObjectAddComposer(Item, _room)); } } else { UpdateItem(Item); if (!OnRoller && sendMessage) { _room.SendMessage(new ObjectUpdateComposer(Item, _room.OwnerId)); } } _room.GetGameMap().AddToMap(Item); if (Item.GetBaseItem().IsSeat) { updateRoomUserStatuses = true; } if (updateRoomUserStatuses) { _room.GetRoomUserManager().UpdateUserStatusses(); } if (Item.GetBaseItem().InteractionType == InteractionType.TENT || Item.GetBaseItem().InteractionType == InteractionType.TENT_SMALL) { _room.RemoveTent(Item.Id, Item); _room.AddTent(Item.Id); } using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("UPDATE `items` SET `room_id` = '" + _room.RoomId + "', `x` = '" + Item.GetX + "', `y` = '" + Item.GetY + "', `z` = '" + Item.GetZ + "', `rot` = '" + Item.Rotation + "' WHERE `id` = '" + Item.Id + "' LIMIT 1"); } return(true); }
public Room(RoomData Data) { IsLagging = 0; IdleTime = 0; RoomData = Data; RoomMuted = false; mDisposed = false; Id = Data.Id; Name = Data.Name; Description = Data.Description; OwnerName = Data.OwnerName; OwnerId = Data.OwnerId; Category = Data.Category; Type = Data.Type; Access = Data.Access; UsersNow = 0; UsersMax = Data.UsersMax; ModelName = Data.ModelName; Score = Data.Score; Tags = new List <string>(); foreach (var tag in Data.Tags) { Tags.Add(tag); } AllowPets = Data.AllowPets; AllowPetsEating = Data.AllowPetsEating; RoomBlockingEnabled = Data.RoomBlockingEnabled; Hidewall = Data.Hidewall; Group = Data.Group; Password = Data.Password; Wallpaper = Data.Wallpaper; Floor = Data.Floor; Landscape = Data.Landscape; WallThickness = Data.WallThickness; FloorThickness = Data.FloorThickness; chatMode = Data.chatMode; chatSize = Data.chatSize; chatSpeed = Data.chatSpeed; chatDistance = Data.chatDistance; extraFlood = Data.extraFlood; TradeSettings = Data.TradeSettings; WhoCanBan = Data.WhoCanBan; WhoCanKick = Data.WhoCanKick; WhoCanBan = Data.WhoCanBan; PushEnabled = Data.PushEnabled; PullEnabled = Data.PullEnabled; SPullEnabled = Data.SPullEnabled; SPushEnabled = Data.SPushEnabled; EnablesEnabled = Data.EnablesEnabled; RespectNotificationsEnabled = Data.RespectNotificationsEnabled; PetMorphsAllowed = Data.PetMorphsAllowed; ActiveTrades = new ArrayList(); MutedUsers = new Dictionary <int, double>(); Tents = new Dictionary <int, List <RoomUser> >(); _gamemap = new Gamemap(this); if (_roomItemHandling == null) { _roomItemHandling = new RoomItemHandling(this); } _roomUserManager = new RoomUserManager(this); _filterComponent = new FilterComponent(this); _wiredComponent = new WiredComponent(this); _bansComponent = new BansComponent(this); _tradingComponent = new TradingComponent(this); GetRoomItemHandler().LoadFurniture(); GetGameMap().GenerateMaps(); LoadPromotions(); LoadRights(); LoadFilter(); InitBots(); InitPets(); Data.UsersNow = 1; }
//private ProcessComponent _process = null; public Room(RoomData Data) { this.IsLagging = 0; this.IdleTime = 0; this._roomData = Data; RoomMuted = false; mDisposed = false; this.Id = Data.Id; this.Name = Data.Name; this.Description = Data.Description; this.OwnerName = Data.OwnerName; this.OwnerId = Data.OwnerId; this.Category = Data.Category; this.Type = Data.Type; this.Access = Data.Access; this.UsersNow = 0; this.UsersMax = Data.UsersMax; this.ModelName = Data.ModelName; this.Score = Data.Score; this.Tags = new List <string>(); foreach (string tag in Data.Tags) { Tags.Add(tag); } this.AllowPets = Data.AllowPets; this.AllowPetsEating = Data.AllowPetsEating; this.RoomBlockingEnabled = Data.RoomBlockingEnabled; this.Hidewall = Data.Hidewall; this.Group = Data.Group; this.Password = Data.Password; this.Wallpaper = Data.Wallpaper; this.Floor = Data.Floor; this.Landscape = Data.Landscape; this.WallThickness = Data.WallThickness; this.FloorThickness = Data.FloorThickness; this.chatMode = Data.chatMode; this.chatSize = Data.chatSize; this.chatSpeed = Data.chatSpeed; this.chatDistance = Data.chatDistance; this.extraFlood = Data.extraFlood; this.TradeSettings = Data.TradeSettings; this.WhoCanBan = Data.WhoCanBan; this.WhoCanKick = Data.WhoCanKick; this.WhoCanBan = Data.WhoCanBan; this.PushEnabled = Data.PushEnabled; this.PullEnabled = Data.PullEnabled; this.SPullEnabled = Data.SPullEnabled; this.SPushEnabled = Data.SPushEnabled; this.EnablesEnabled = Data.EnablesEnabled; this.RespectNotificationsEnabled = Data.RespectNotificationsEnabled; this.PetMorphsAllowed = Data.PetMorphsAllowed; this.BankEnabled = Data.BankEnabled; this.ShootEnabled = Data.ShootEnabled; this.HitEnabled = Data.HitEnabled; this.SafeZoneEnabled = Data.SafeZoneEnabled; this.SexCommandsEnabled = Data.SexCommandsEnabled; this.TurfEnabled = Data.TurfEnabled; this.RobEnabled = Data.RobEnabled; this.GymEnabled = Data.GymEnabled; this.DeliveryEnabled = Data.DeliveryEnabled; this.TutorialEnabled = Data.TutorialEnabled; this.DriveEnabled = Data.DriveEnabled; this.TaxiFromEnabled = Data.TaxiFromEnabled; this.TaxiToEnabled = Data.TaxiToEnabled; this.EnterRoomMessage = Data.EnterRoomMessage; this.RoleplayEvent = Data.RoleplayEvent; this.ActiveTrades = new ArrayList(); this.Bans = new Dictionary <int, double>(); this.MutedUsers = new Dictionary <int, double>(); this.Tents = new Dictionary <int, List <RoomUser> >(); _gamemap = new Gamemap(this); if (_roomItemHandling == null) { _roomItemHandling = new RoomItemHandling(this); } _roomUserManager = new RoomUserManager(this); this._filterComponent = new FilterComponent(this); this._wiredComponent = new WiredComponent(this); GetRoomItemHandler().LoadFurniture(); GetGameMap().GenerateMaps(); this.LoadPromotions(); this.LoadRights(); this.LoadBans(); this.LoadFilter(); this.InitBots(); this.InitPets(); if (this.GetRoomUserManager() != null && this.GetRoomUserManager().GetRoomUsers() != null && this.GetRoomUserManager().GetRoomUsers().Where(x => !x.IsBot) != null) { Data.UsersNow = this.GetRoomUserManager().GetRoomUsers().Where(x => !x.IsBot).ToList().Count; } else { Data.UsersNow = 0; } }
public bool SetFloorItem(GameClient Session, Item Item, int newX, int newY, int newRot, bool newItem, bool OnRoller, bool sendMessage, bool updateRoomUserStatuses = false, bool ToDB = true, Item SpaceItem = null, double newZ = 1000.0, bool PlacedByRoleplay = false) { double origZ = newZ; bool CheckHeight = newZ == 1000.0 ? true : false; bool NeedsReAdd = false; if (newItem && Item.ExtraData == "") { Item.ExtraData = "0"; } if (newItem) { if (Item.IsWired) { if (Item.GetBaseItem().WiredType == WiredBoxType.EffectRegenerateMaps && _room.GetRoomItemHandler().GetFloor.Where(x => x.GetBaseItem().WiredType == WiredBoxType.EffectRegenerateMaps).Count() > 0) { return(false); } } } List <Item> ItemsOnTile = GetFurniObjects(newX, newY); if (Item.GetBaseItem().InteractionType == InteractionType.ROLLER && ItemsOnTile.Where(x => x.GetBaseItem().InteractionType == InteractionType.ROLLER && x.Id != Item.Id).Count() > 0) { return(false); } if (!newItem) { NeedsReAdd = _room.GetGameMap().RemoveFromMap(Item); } Dictionary <int, ThreeDCoord> AffectedTiles = Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, newRot); if (!PlacedByRoleplay) { if (!_room.GetGameMap().ValidTile(newX, newY) || (_room.GetGameMap().SquareHasUsers(newX, newY) && !Item.GetBaseItem().Walkable&& !Item.GetBaseItem().IsSeat)) { if (NeedsReAdd) { _room.GetGameMap().AddToMap(Item); } return(false); } foreach (ThreeDCoord Tile in AffectedTiles.Values) { if (!_room.GetGameMap().ValidTile(Tile.X, Tile.Y) || (_room.GetGameMap().SquareHasUsers(newX, newY) && !Item.GetBaseItem().Walkable&& !Item.GetBaseItem().IsSeat)) { if (NeedsReAdd) { _room.GetGameMap().AddToMap(Item); } return(false); } } } if (SpaceItem != null && Session != null) { bool CanPlaceHere = true; if (AffectedTiles.Values.Select(x => new Point(x.X, x.Y)).Where(x => !SpaceItem.GetAffectedTiles.Contains(x)).ToList().Count > 0) { CanPlaceHere = false; } if (_room.OwnerId == Session.GetHabbo().Id || _room.CheckRights(Session) || Session.GetHabbo().GetPermissions().HasRight("room_item_place_exchange_anywhere")) { CanPlaceHere = true; } if (!CanPlaceHere) { return(false); } } // Start calculating new Z coordinate newZ = _room.GetGameMap().Model.SqFloorHeight[newX, newY]; if (Session != null) { if (Session.GetHabbo().DebugStacking == true) { newZ = Session.GetHabbo().StackHeight; } } if (!OnRoller && !PlacedByRoleplay) { // Make sure this tile is open and there are no users here if (_room.GetGameMap().Model.SqState[newX, newY] != SquareState.OPEN && !Item.GetBaseItem().IsSeat&& !Item.GetBaseItem().Walkable) { return(false); } foreach (ThreeDCoord Tile in AffectedTiles.Values) { if (_room.GetGameMap().Model.SqState[Tile.X, Tile.Y] != SquareState.OPEN && !Item.GetBaseItem().IsSeat&& !Item.GetBaseItem().Walkable) { if (NeedsReAdd) { _room.GetGameMap().AddToMap(Item); } return(false); } } // And that we have no users if (!Item.GetBaseItem().IsSeat&& !Item.IsRoller && !Item.GetBaseItem().Walkable) { foreach (ThreeDCoord Tile in AffectedTiles.Values) { if (_room.GetGameMap().GetRoomUsers(new Point(Tile.X, Tile.Y)).Count > 0) { if (NeedsReAdd) { _room.GetGameMap().AddToMap(Item); } return(false); } } } } // Find affected objects var ItemsAffected = new List <Item>(); var ItemsComplete = new List <Item>(); foreach (ThreeDCoord Tile in AffectedTiles.Values.ToList()) { List <Item> Temp = GetFurniObjects(Tile.X, Tile.Y); if (Temp != null) { ItemsAffected.AddRange(Temp); } } ItemsComplete.AddRange(ItemsOnTile); ItemsComplete.AddRange(ItemsAffected); if (!OnRoller) { // Check for items in the stack that do not allow stacking on top of them foreach (Item I in ItemsComplete.ToList()) { if (I == null) { continue; } if (I.Id == Item.Id) { continue; } if (I.GetBaseItem() == null) { continue; } if (!I.GetBaseItem().Stackable) { if (NeedsReAdd) { //AddItem(Item); _room.GetGameMap().AddToMap(Item); } return(false); } } } //if (!Item.IsRoller) { // If this is a rotating action, maintain item at current height if (Item.Rotation != newRot && Item.GetX == newX && Item.GetY == newY) { if (Session != null) { if (Session.GetHabbo().DebugStacking == true) { newZ = Session.GetHabbo().StackHeight; } else { newZ = Item.GetZ; } } else { newZ = Item.GetZ; } } Double StackingTile = 0; // Are there any higher objects in the stack!? foreach (Item I in ItemsComplete.ToList()) { if (I == null) { continue; } if (I.Id == Item.Id) { continue; // cannot stack on self } if (I.GetBaseItem().InteractionType == InteractionType.STACKTOOL) { StackingTile = I.GetZ; } if (I.TotalHeight > newZ) { if (Session != null) { if (Session.GetHabbo().DebugStacking == true) { newZ = Session.GetHabbo().StackHeight; } else { newZ = StackingTile != 0 ? StackingTile : I.TotalHeight; } } else { newZ = StackingTile != 0 ? StackingTile : I.TotalHeight; } } } } // Verify the rotation is correct if (newRot != 0 && newRot != 2 && newRot != 4 && newRot != 6 && newRot != 8 && !Item.GetBaseItem().ExtraRot) { newRot = 0; } Item.Rotation = newRot; int oldX = Item.GetX; int oldY = Item.GetY; if (!CheckHeight) { newZ = origZ; } Item.SetState(newX, newY, newZ, AffectedTiles); if (!OnRoller && Session != null) { Item.Interactor.OnPlace(Session, Item); } if (newItem) { if (_floorItems.ContainsKey(Item.Id)) { if (Session != null) { Session.SendNotification(PlusEnvironment.GetGame().GetLanguageLocale().TryGetValue("room_item_placed")); } _room.GetGameMap().RemoveFromMap(Item); return(true); } if (Item.IsFloorItem && !_floorItems.ContainsKey(Item.Id)) { _floorItems.TryAdd(Item.Id, Item); } else if (Item.IsWallItem && !_wallItems.ContainsKey(Item.Id)) { _wallItems.TryAdd(Item.Id, Item); } if (sendMessage) { _room.SendMessage(new ObjectAddComposer(Item, _room)); } } else { UpdateItem(Item); if (!OnRoller && sendMessage) { _room.SendMessage(new ObjectUpdateComposer(Item, Item.UserID)); } } _room.GetGameMap().AddToMap(Item); if (Item.GetBaseItem().IsSeat) { updateRoomUserStatuses = true; } if (updateRoomUserStatuses) { _room.GetRoomUserManager().UpdateUserStatusses(); } if (Item.GetBaseItem().InteractionType == InteractionType.TENT || Item.GetBaseItem().InteractionType == InteractionType.TENT_SMALL) { _room.RemoveTent(Item.Id, Item); _room.AddTent(Item.Id); } using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("UPDATE `items` SET `room_id` = '" + _room.RoomId + "', `x` = '" + Item.GetX + "', `y` = '" + Item.GetY + "', `z` = '" + Item.GetZ + "', `rot` = '" + Item.Rotation + "' WHERE `id` = '" + Item.Id + "' LIMIT 1"); } return(true); }
public bool CheckPosItem(GameClient Session, Item Item, int newX, int newY, int newRot, bool newItem, bool SendNotify = true) { try { var dictionary = Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, newRot); if (!_room.GetGameMap().ValidTile(newX, newY)) { return(false); } foreach (var coord in dictionary.Values.ToList()) { if (_room.GetGameMap().Model.DoorX == coord.X && _room.GetGameMap().Model.DoorY == coord.Y) { return(false); } } if (_room.GetGameMap().Model.DoorX == newX && _room.GetGameMap().Model.DoorY == newY) { return(false); } foreach (var coord in dictionary.Values.ToList()) { if (!_room.GetGameMap().ValidTile(coord.X, coord.Y)) { return(false); } } double num = _room.GetGameMap().Model.SqFloorHeight[newX, newY]; if (Item.Rotation == newRot && Item.GetX == newX && Item.GetY == newY && Item.GetZ != num) { return(false); } if (_room.GetGameMap().Model.SqState[newX, newY] != SquareState.OPEN) { return(false); } foreach (var coord in dictionary.Values.ToList()) { if (_room.GetGameMap().Model.SqState[coord.X, coord.Y] != SquareState.OPEN) { return(false); } } if (!Item.GetBaseItem().IsSeat) { if (_room.GetGameMap().SquareHasUsers(newX, newY)) { return(false); } foreach (var coord in dictionary.Values.ToList()) { if (_room.GetGameMap().SquareHasUsers(coord.X, coord.Y)) { return(false); } } } var furniObjects = GetFurniObjects(newX, newY); var collection = new List <Item>(); var list3 = new List <Item>(); foreach (var coord in dictionary.Values.ToList()) { var list4 = GetFurniObjects(coord.X, coord.Y); if (list4 != null) { collection.AddRange(list4); } } if (furniObjects == null) { furniObjects = new List <Item>(); } list3.AddRange(furniObjects); list3.AddRange(collection); foreach (var item in list3.ToList()) { if (item.Id != Item.Id && !item.GetBaseItem().Stackable) { return(false); } } return(true); } catch { return(false); } }