Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
Stack Magic Tile problem
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="eemillundgren" data-source="post: 460373" data-attributes="member: 61105"><p>Hi, I have discovered this, someone who knows how to fix these 2 problems?</p><p><a href="https://imgur.com/a/m3WNerL" target="_blank">https://imgur.com/a/m3WNerL</a></p><p></p><p>[SPOILER="Code"]public bool SetFloorItem(GameClient Session, Item Item, int newX, int newY, int newRot, bool newItem, bool OnRoller, bool sendMessage, bool updateRoomUserStatuses = false) {</p><p> bool NeedsReAdd = false;</p><p></p><p> if (newItem)</p><p> if (Item.IsWired)</p><p> if (Item.IsWired)</p><p> if (_room.HideWired)</p><p> {</p><p> _room.HideWired = false;</p><p> Session.SendWhisper("El Wired está oculto.");</p><p> _room.SendMessage(_room.HideWiredMessages(false));</p><p> }</p><p> if (Item.GetBaseItem().WiredType == WiredBoxType.EffectRegenerateMaps && _room.GetRoomItemHandler().GetFloor.Where(x => x.GetBaseItem().WiredType == WiredBoxType.EffectRegenerateMaps).Count() > 0)</p><p> return false;</p><p></p><p> List<Item> ItemsOnTile = GetFurniObjects(newX, newY);</p><p> if (Item.GetBaseItem().InteractionType == InteractionType.ROLLER && ItemsOnTile.Where(x => x.GetBaseItem().InteractionType == InteractionType.ROLLER && x.Id != Item.Id).Count() > 0)</p><p> return false;</p><p></p><p> if (!newItem)</p><p> NeedsReAdd = _room.GetGameMap().RemoveFromMap(Item);</p><p></p><p> Dictionary<int, ThreeDCoord> AffectedTiles = Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, newRot);</p><p></p><p> if (!_room.GetGameMap().ValidTile(newX, newY) || _room.GetGameMap().SquareHasUsers(newX, newY) && !Item.GetBaseItem().IsSeat)</p><p> {</p><p> if (NeedsReAdd)</p><p> _room.GetGameMap().AddToMap(Item);</p><p> return false;</p><p> }</p><p></p><p> foreach (ThreeDCoord Tile in AffectedTiles.Values)</p><p> {</p><p> if (!_room.GetGameMap().ValidTile(Tile.X, Tile.Y) ||</p><p> (_room.GetGameMap().SquareHasUsers(Tile.X, Tile.Y) && !Item.GetBaseItem().IsSeat))</p><p> {</p><p> if (NeedsReAdd)</p><p> {</p><p> _room.GetGameMap().AddToMap(Item);</p><p> }</p><p> return false;</p><p> }</p><p> }</p><p></p><p> // Start calculating new Z coordinate</p><p> Double newZ = _room.GetGameMap().Model.SqFloorHeight[newX, newY];</p><p></p><p> if (!OnRoller)</p><p> {</p><p> // Make sure this tile is open and there are no users here</p><p> if (_room.GetGameMap().Model.SqState[newX, newY] != SquareState.OPEN && !Item.GetBaseItem().IsSeat)</p><p> {</p><p> return false;</p><p> }</p><p></p><p> foreach (ThreeDCoord Tile in AffectedTiles.Values)</p><p> {</p><p> if (_room.GetGameMap().Model.SqState[Tile.X, Tile.Y] != SquareState.OPEN &&</p><p> !Item.GetBaseItem().IsSeat)</p><p> {</p><p> if (NeedsReAdd)</p><p> {</p><p> //AddItem(Item);</p><p> _room.GetGameMap().AddToMap(Item);</p><p> }</p><p> return false;</p><p> }</p><p> }</p><p></p><p> // And that we have no users</p><p> if (!Item.GetBaseItem().IsSeat && !Item.IsRoller)</p><p> {</p><p> foreach (ThreeDCoord Tile in AffectedTiles.Values)</p><p> {</p><p> if (_room.GetGameMap().GetRoomUsers(new Point(Tile.X, Tile.Y)).Count > 0)</p><p> {</p><p> if (NeedsReAdd)</p><p> _room.GetGameMap().AddToMap(Item);</p><p> return false;</p><p> }</p><p> }</p><p> }</p><p> }</p><p></p><p> // Find affected objects</p><p> var ItemsAffected = new List<Item>();</p><p> var ItemsComplete = new List<Item>();</p><p></p><p> foreach (ThreeDCoord Tile in AffectedTiles.Values.ToList())</p><p> {</p><p> List<Item> Temp = GetFurniObjects(Tile.X, Tile.Y);</p><p></p><p> if (Temp != null)</p><p> {</p><p> ItemsAffected.AddRange(Temp);</p><p> }</p><p> }</p><p></p><p></p><p> ItemsComplete.AddRange(ItemsOnTile);</p><p> ItemsComplete.AddRange(ItemsAffected);</p><p></p><p> if (!OnRoller)</p><p> {</p><p> // Check for items in the stack that do not allow stacking on top of them</p><p> foreach (Item I in ItemsComplete.ToList())</p><p> {</p><p> if (I == null)</p><p> continue;</p><p></p><p> if (I.Id == Item.Id)</p><p> continue;</p><p></p><p> if (I.GetBaseItem() == null)</p><p> continue;</p><p></p><p> if (!I.GetBaseItem().Stackable)</p><p> {</p><p> if (NeedsReAdd)</p><p> {</p><p> //AddItem(Item);</p><p> _room.GetGameMap().AddToMap(Item);</p><p> }</p><p> return false;</p><p> }</p><p> }</p><p> }</p><p></p><p> //if (!Item.IsRoller)</p><p> {</p><p> // If this is a rotating action, maintain item at current height</p><p> if (Item.Rotation != newRot && Item.GetX == newX && Item.GetY == newY)</p><p> newZ = Item.GetZ;</p><p></p><p></p><p> Double StackingTile = 0;</p><p></p><p></p><p> // Are there any higher objects in the stack!?</p><p> foreach (Item I in ItemsComplete.ToList())</p><p> {</p><p> if (I == null)</p><p> continue;</p><p></p><p> if (I.Id == Item.Id)</p><p> continue; // cannot stack on self</p><p></p><p> if (I.GetBaseItem().InteractionType == InteractionType.STACKTOOL)</p><p> StackingTile = I.GetZ;</p><p></p><p> if (I.TotalHeight > newZ)</p><p> newZ = StackingTile != 0 ? StackingTile : I.TotalHeight;</p><p> }</p><p> }</p><p></p><p> // Verify the rotation is correct</p><p> if (newRot != 0 && newRot != 2 && newRot != 4 && newRot != 6 && newRot != 8 && !Item.GetBaseItem().ExtraRot)</p><p> newRot = 0;</p><p></p><p> Item.Rotation = newRot;</p><p> int oldX = Item.GetX;</p><p> int oldY = Item.GetY;</p><p> Item.SetState(newX, newY, newZ, AffectedTiles);</p><p></p><p> if (!OnRoller && Session != null)</p><p> Item.Interactor.OnPlace(Session, Item);</p><p></p><p></p><p> if (newItem)</p><p> {</p><p> if (_floorItems.ContainsKey(Item.Id))</p><p> {</p><p> if (Session != null)</p><p> Session.SendNotification(PlusEnvironment.GetGame().GetLanguageLocale().TryGetValue("room_item_placed"));</p><p> _room.GetGameMap().RemoveFromMap(Item);</p><p> return true;</p><p> }</p><p></p><p> if (Item.IsFloorItem && !_floorItems.ContainsKey(Item.Id))</p><p> _floorItems.TryAdd(Item.Id, Item);</p><p> else if (Item.IsWallItem && !_wallItems.ContainsKey(Item.Id))</p><p> _wallItems.TryAdd(Item.Id, Item);</p><p></p><p> if (sendMessage)</p><p> _room.SendMessage(new ObjectAddComposer(Item, _room));</p><p> }</p><p> else</p><p> {</p><p> UpdateItem(Item);</p><p> if (!OnRoller && sendMessage)</p><p> _room.SendMessage(new ObjectUpdateComposer(Item, _room.OwnerId));</p><p> }</p><p> _room.GetGameMap().AddToMap(Item);</p><p></p><p> if (Item.GetBaseItem().IsSeat)</p><p> updateRoomUserStatuses = true;</p><p></p><p> if (updateRoomUserStatuses)</p><p> _room.GetRoomUserManager().UpdateUserStatusses();</p><p></p><p> if (Item.GetBaseItem().InteractionType == InteractionType.TENT || Item.GetBaseItem().InteractionType == InteractionType.TENT_SMALL)</p><p> {</p><p> _room.RemoveTent(Item.Id, Item);</p><p> _room.AddTent(Item.Id);</p><p> }</p><p></p><p> using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())</p><p> {</p><p> 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");</p><p> }</p><p> return true;</p><p> }</p><p></p><p> public List<Item> GetFurniObjects(int X, int Y)</p><p> {</p><p> return _room.GetGameMap().GetCoordinatedItems(new Point(X, Y));</p><p> }</p><p></p><p> public bool SetFloorItem(Item Item, int newX, int newY, Double newZ)</p><p> {</p><p> if (_room == null)</p><p> return false;</p><p></p><p> _room.GetGameMap().RemoveFromMap(Item);</p><p></p><p> Item.SetState(newX, newY, newZ, Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, Item.Rotation));</p><p> if (Item.GetBaseItem().InteractionType == InteractionType.TONER)</p><p> {</p><p> if (_room.TonerData == null)</p><p> {</p><p> _room.TonerData = new TonerData(Item.Id);</p><p> }</p><p> }</p><p> UpdateItem(Item);</p><p> _room.GetGameMap().AddItemToMap(Item);</p><p> return true;</p><p> }</p><p></p><p> public bool SetWallItem(GameClient Session, Item Item)</p><p> {</p><p> if (!Item.IsWallItem || _wallItems.ContainsKey(Item.Id))</p><p> return false;</p><p></p><p> if (_floorItems.ContainsKey(Item.Id))</p><p> {</p><p> Session.SendNotification(PlusEnvironment.GetGame().GetLanguageLocale().TryGetValue("room_item_placed"));</p><p> return true;</p><p> }</p><p></p><p> Item.Interactor.OnPlace(Session, Item);</p><p> if (Item.GetBaseItem().InteractionType == InteractionType.MOODLIGHT)</p><p> {</p><p> if (_room.MoodlightData == null)</p><p> {</p><p> _room.MoodlightData = new MoodlightData(Item.Id);</p><p> Item.ExtraData = _room.MoodlightData.GenerateExtraData();</p><p> }</p><p> }</p><p></p><p> using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())</p><p> {</p><p> dbClient.SetQuery("UPDATE `items` SET `room_id` = '" + _room.RoomId + "', `x` = '" + Item.GetX + "', `y` = '" + Item.GetY + "', `z` = '" + Item.GetZ + "', `rot` = '" + Item.Rotation + "', `wall_pos` = @WallPos WHERE `id` = '" + Item.Id + "' LIMIT 1");</p><p> dbClient.AddParameter("WallPos", Item.wallCoord);</p><p> dbClient.RunQuery();</p><p> }</p><p></p><p> _wallItems.TryAdd(Item.Id, Item);</p><p></p><p> _room.SendMessage(new ItemAddComposer(Item));</p><p></p><p> return true;</p><p> }</p><p></p><p> public void UpdateItem(Item item)</p><p> {</p><p> if (item == null)</p><p> return;</p><p> if (!_movedItems.ContainsKey(item.Id))</p><p> _movedItems.TryAdd(item.Id, item);</p><p> }</p><p></p><p></p><p> public void RemoveItem(Item item)</p><p> {</p><p> if (item == null)</p><p> return;</p><p></p><p> if (_movedItems.ContainsKey(item.Id))</p><p> _movedItems.TryRemove(item.Id, out item);</p><p> if (_rollers.ContainsKey(item.Id))</p><p> _rollers.TryRemove(item.Id, out item);</p><p> }</p><p></p><p> public void OnCycle()</p><p> {</p><p> if (mGotRollers)</p><p> {</p><p> try</p><p> {</p><p> _room.SendMessage(CycleRollers());</p><p> }</p><p> catch //(Exception e)</p><p> {</p><p> // Logging.LogThreadException(e.ToString(), "rollers for room with ID " + room.RoomId);</p><p> mGotRollers = false;</p><p> }</p><p> }</p><p></p><p> if (_roomItemUpdateQueue.Count > 0)</p><p> {</p><p> List<Item> addItems = new List<Item>();</p><p> while (_roomItemUpdateQueue.Count > 0)</p><p> {</p><p> var item = (Item)null;</p><p> if (_roomItemUpdateQueue.TryDequeue(out item))</p><p> {</p><p> item.ProcessUpdates();</p><p></p><p> if (item.UpdateCounter > 0)</p><p> addItems.Add(item);</p><p> }</p><p> }</p><p></p><p> foreach (Item item in addItems.ToList())</p><p> {</p><p> if (item == null)</p><p> continue;</p><p></p><p> _roomItemUpdateQueue.Enqueue(item);</p><p> }</p><p> }</p><p></p><p> //mFloorItems.OnCycle();</p><p> //mWallItems.OnCycle();</p><p> }</p><p></p><p> public List<Item> RemoveItems(GameClient Session)</p><p> {</p><p> List<Item> Items = new List<Item>();</p><p></p><p> foreach (Item Item in this.GetWallAndFloor.ToList())</p><p> {</p><p> if (Item == null || Item.UserID != Session.GetHabbo().Id)</p><p> continue;</p><p></p><p> if (Item.IsFloorItem)</p><p> {</p><p> Item I = null;</p><p> this._floorItems.TryRemove(Item.Id, out I);</p><p> Session.GetHabbo().GetInventoryComponent()._floorItems.TryAdd(Item.Id, I);</p><p> this._room.SendMessage(new ObjectRemoveComposer(Item, Item.UserID));</p><p> }</p><p> else if (Item.IsWallItem)</p><p> {</p><p> Item I = null;</p><p> this._wallItems.TryRemove(Item.Id, out I);</p><p> Session.GetHabbo().GetInventoryComponent()._wallItems.TryAdd(Item.Id, I);</p><p> this._room.SendMessage(new ItemRemoveComposer(Item, Item.UserID));</p><p> }</p><p></p><p> this._room.GetGameMap().GenerateMaps();</p><p> Session.SendMessage(new FurniListAddComposer(Item));</p><p> }</p><p></p><p> return Items;</p><p> }</p><p></p><p> public ICollection<Item> GetFloor</p><p> {</p><p> get</p><p> {</p><p> return this._floorItems.Values;</p><p> }</p><p> }</p><p></p><p> public ICollection<Item> GetWall</p><p> {</p><p> get</p><p> {</p><p> return this._wallItems.Values;</p><p> }</p><p> }</p><p></p><p> public IEnumerable<Item> GetWallAndFloor</p><p> {</p><p> get</p><p> {</p><p> return this._floorItems.Values.Concat(this._wallItems.Values);</p><p> }</p><p> }</p><p></p><p></p><p> public bool CheckPosItem(GameClient Session, Item Item, int newX, int newY, int newRot, bool newItem, bool SendNotify = true)</p><p> {</p><p> try</p><p> {</p><p> Dictionary<int, ThreeDCoord> dictionary = Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, newRot);</p><p> if (!this._room.GetGameMap().ValidTile(newX, newY))</p><p> return false;</p><p></p><p></p><p> foreach (ThreeDCoord coord in dictionary.Values.ToList())</p><p> {</p><p> if ((this._room.GetGameMap().Model.DoorX == coord.X) && (this._room.GetGameMap().Model.DoorY == coord.Y))</p><p> return false;</p><p> }</p><p></p><p> if ((this._room.GetGameMap().Model.DoorX == newX) && (this._room.GetGameMap().Model.DoorY == newY))</p><p> return false;</p><p></p><p></p><p> foreach (ThreeDCoord coord in dictionary.Values.ToList())</p><p> {</p><p> if (!this._room.GetGameMap().ValidTile(coord.X, coord.Y))</p><p> return false;</p><p> }</p><p></p><p> double num = this._room.GetGameMap().Model.SqFloorHeight[newX, newY];</p><p> if ((((Item.Rotation == newRot) && (Item.GetX == newX)) && (Item.GetY == newY)) && (Item.GetZ != num))</p><p> return false;</p><p></p><p> if (this._room.GetGameMap().Model.SqState[newX, newY] != SquareState.OPEN)</p><p> return false;</p><p></p><p> foreach (ThreeDCoord coord in dictionary.Values.ToList())</p><p> {</p><p> if (this._room.GetGameMap().Model.SqState[coord.X, coord.Y] != SquareState.OPEN)</p><p> return false;</p><p> }</p><p> if (!Item.GetBaseItem().IsSeat)</p><p> {</p><p> if (this._room.GetGameMap().SquareHasUsers(newX, newY))</p><p> return false;</p><p></p><p> foreach (ThreeDCoord coord in dictionary.Values.ToList())</p><p> {</p><p> if (this._room.GetGameMap().SquareHasUsers(coord.X, coord.Y))</p><p> return false;</p><p> }</p><p> }</p><p></p><p> List<Item> furniObjects = this.GetFurniObjects(newX, newY);</p><p> List<Item> collection = new List<Item>();</p><p> List<Item> list3 = new List<Item>();</p><p> foreach (ThreeDCoord coord in dictionary.Values.ToList())</p><p> {</p><p> List<Item> list4 = this.GetFurniObjects(coord.X, coord.Y);</p><p> if (list4 != null)</p><p> collection.AddRange(list4);</p><p></p><p> }</p><p></p><p> if (furniObjects == null)</p><p> furniObjects = new List<Item>();</p><p></p><p> list3.AddRange(furniObjects);</p><p> list3.AddRange(collection);</p><p> foreach (Item item in list3.ToList())</p><p> {</p><p> if ((item.Id != Item.Id) && !item.GetBaseItem().Stackable)</p><p> return false;</p><p> }</p><p> return true;</p><p> }</p><p> catch</p><p> {</p><p> return false;</p><p> }</p><p> }</p><p></p><p></p><p> public ICollection<Item> GetRollers()</p><p> {</p><p> return this._rollers.Values;</p><p> }</p><p></p><p> public void Dispose()</p><p> {</p><p> foreach (Item Item in this.GetWallAndFloor.ToList())</p><p> {</p><p> if (Item == null)</p><p> continue;</p><p></p><p> Item.Destroy();</p><p> }</p><p></p><p> _floorItems.Clear();</p><p> _wallItems.Clear();</p><p> _movedItems.Clear();</p><p> this._roomItemUpdateQueue = null;</p><p></p><p> _room = null;</p><p> _floorItems = null;</p><p> _wallItems = null;</p><p> _movedItems = null;</p><p> _wallItems = null;</p><p> _roomItemUpdateQueue = null;</p><p> }</p><p> }</p><p>}[/SPOILER]</p></blockquote><p></p>
[QUOTE="eemillundgren, post: 460373, member: 61105"] Hi, I have discovered this, someone who knows how to fix these 2 problems? [URL]https://imgur.com/a/m3WNerL[/URL] [SPOILER="Code"]public bool SetFloorItem(GameClient Session, Item Item, int newX, int newY, int newRot, bool newItem, bool OnRoller, bool sendMessage, bool updateRoomUserStatuses = false) { bool NeedsReAdd = false; if (newItem) if (Item.IsWired) if (Item.IsWired) if (_room.HideWired) { _room.HideWired = false; Session.SendWhisper("El Wired está oculto."); _room.SendMessage(_room.HideWiredMessages(false)); } 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; } } // Start calculating new Z coordinate Double newZ = _room.GetGameMap().Model.SqFloorHeight[newX, newY]; 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; 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) 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; 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 List<Item> GetFurniObjects(int X, int Y) { return _room.GetGameMap().GetCoordinatedItems(new Point(X, Y)); } 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 SetWallItem(GameClient Session, Item Item) { if (!Item.IsWallItem || _wallItems.ContainsKey(Item.Id)) return false; if (_floorItems.ContainsKey(Item.Id)) { Session.SendNotification(PlusEnvironment.GetGame().GetLanguageLocale().TryGetValue("room_item_placed")); return true; } Item.Interactor.OnPlace(Session, Item); if (Item.GetBaseItem().InteractionType == InteractionType.MOODLIGHT) { if (_room.MoodlightData == null) { _room.MoodlightData = new MoodlightData(Item.Id); Item.ExtraData = _room.MoodlightData.GenerateExtraData(); } } using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `items` SET `room_id` = '" + _room.RoomId + "', `x` = '" + Item.GetX + "', `y` = '" + Item.GetY + "', `z` = '" + Item.GetZ + "', `rot` = '" + Item.Rotation + "', `wall_pos` = @WallPos WHERE `id` = '" + Item.Id + "' LIMIT 1"); dbClient.AddParameter("WallPos", Item.wallCoord); dbClient.RunQuery(); } _wallItems.TryAdd(Item.Id, Item); _room.SendMessage(new ItemAddComposer(Item)); return true; } public void UpdateItem(Item item) { if (item == null) return; if (!_movedItems.ContainsKey(item.Id)) _movedItems.TryAdd(item.Id, item); } public void RemoveItem(Item item) { if (item == null) return; if (_movedItems.ContainsKey(item.Id)) _movedItems.TryRemove(item.Id, out item); if (_rollers.ContainsKey(item.Id)) _rollers.TryRemove(item.Id, out item); } public void OnCycle() { if (mGotRollers) { try { _room.SendMessage(CycleRollers()); } catch //(Exception e) { // Logging.LogThreadException(e.ToString(), "rollers for room with ID " + room.RoomId); mGotRollers = false; } } if (_roomItemUpdateQueue.Count > 0) { List<Item> addItems = new List<Item>(); while (_roomItemUpdateQueue.Count > 0) { var item = (Item)null; if (_roomItemUpdateQueue.TryDequeue(out item)) { item.ProcessUpdates(); if (item.UpdateCounter > 0) addItems.Add(item); } } foreach (Item item in addItems.ToList()) { if (item == null) continue; _roomItemUpdateQueue.Enqueue(item); } } //mFloorItems.OnCycle(); //mWallItems.OnCycle(); } public List<Item> RemoveItems(GameClient Session) { List<Item> Items = new List<Item>(); foreach (Item Item in this.GetWallAndFloor.ToList()) { if (Item == null || Item.UserID != Session.GetHabbo().Id) continue; if (Item.IsFloorItem) { Item I = null; this._floorItems.TryRemove(Item.Id, out I); Session.GetHabbo().GetInventoryComponent()._floorItems.TryAdd(Item.Id, I); this._room.SendMessage(new ObjectRemoveComposer(Item, Item.UserID)); } else if (Item.IsWallItem) { Item I = null; this._wallItems.TryRemove(Item.Id, out I); Session.GetHabbo().GetInventoryComponent()._wallItems.TryAdd(Item.Id, I); this._room.SendMessage(new ItemRemoveComposer(Item, Item.UserID)); } this._room.GetGameMap().GenerateMaps(); Session.SendMessage(new FurniListAddComposer(Item)); } return Items; } public ICollection<Item> GetFloor { get { return this._floorItems.Values; } } public ICollection<Item> GetWall { get { return this._wallItems.Values; } } public IEnumerable<Item> GetWallAndFloor { get { return this._floorItems.Values.Concat(this._wallItems.Values); } } public bool CheckPosItem(GameClient Session, Item Item, int newX, int newY, int newRot, bool newItem, bool SendNotify = true) { try { Dictionary<int, ThreeDCoord> dictionary = Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, newRot); if (!this._room.GetGameMap().ValidTile(newX, newY)) return false; foreach (ThreeDCoord coord in dictionary.Values.ToList()) { if ((this._room.GetGameMap().Model.DoorX == coord.X) && (this._room.GetGameMap().Model.DoorY == coord.Y)) return false; } if ((this._room.GetGameMap().Model.DoorX == newX) && (this._room.GetGameMap().Model.DoorY == newY)) return false; foreach (ThreeDCoord coord in dictionary.Values.ToList()) { if (!this._room.GetGameMap().ValidTile(coord.X, coord.Y)) return false; } double num = this._room.GetGameMap().Model.SqFloorHeight[newX, newY]; if ((((Item.Rotation == newRot) && (Item.GetX == newX)) && (Item.GetY == newY)) && (Item.GetZ != num)) return false; if (this._room.GetGameMap().Model.SqState[newX, newY] != SquareState.OPEN) return false; foreach (ThreeDCoord coord in dictionary.Values.ToList()) { if (this._room.GetGameMap().Model.SqState[coord.X, coord.Y] != SquareState.OPEN) return false; } if (!Item.GetBaseItem().IsSeat) { if (this._room.GetGameMap().SquareHasUsers(newX, newY)) return false; foreach (ThreeDCoord coord in dictionary.Values.ToList()) { if (this._room.GetGameMap().SquareHasUsers(coord.X, coord.Y)) return false; } } List<Item> furniObjects = this.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 = this.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 item in list3.ToList()) { if ((item.Id != Item.Id) && !item.GetBaseItem().Stackable) return false; } return true; } catch { return false; } } public ICollection<Item> GetRollers() { return this._rollers.Values; } public void Dispose() { foreach (Item Item in this.GetWallAndFloor.ToList()) { if (Item == null) continue; Item.Destroy(); } _floorItems.Clear(); _wallItems.Clear(); _movedItems.Clear(); this._roomItemUpdateQueue = null; _room = null; _floorItems = null; _wallItems = null; _movedItems = null; _wallItems = null; _roomItemUpdateQueue = null; } } }[/SPOILER] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
Stack Magic Tile problem
Top