private void RemoveRoomItem(RoomItem Item) { //Logging.WriteLine("HALLO?? TRYING TO REMOVE???"); if (Item.IsWallItem) { ServerMessage Message = new ServerMessage(Outgoing.PickUpWallItem); Message.AppendString(Item.Id + String.Empty); Message.AppendInt32(room.OwnerId); room.SendMessage(Message); } else if (Item.IsFloorItem) { //Logging.WriteLine("YEEEEEAH?????"); ServerMessage Message = new ServerMessage(Outgoing.ObjectRemove); Message.AppendString(Item.Id + String.Empty); Message.AppendInt32(0); Message.AppendInt32(room.OwnerId); room.SendMessage(Message); } if (Item.IsWallItem) { mWallItems.Remove(Item.Id); } else { //Logging.WriteLine("REMOVE FLOOR Item wtf?" + mFloorItems.ContainsKey(Item.Id)); this.mFloorItems.Remove(Item.Id); this.mFloorItems.OnCycle(); room.GetGameMap().RemoveFromMap(Item); } //Logging.WriteLine("removed?? = " + mFloorItems.ContainsKey(Item.Id)); RemoveItem(Item); room.GetRoomUserManager().UpdateUserStatuses(); if (WiredHandler.TypeIsWire(Item.GetBaseItem().InteractionType)) { room.GetWiredHandler().RemoveWiredItem(Item.Coordinate); } }
private void RemoveRoomItem(RoomItem Item) { if (Item.IsWallItem) { ServerMessage Message = new ServerMessage(84); Message.AppendRawUInt(Item.Id); Message.AppendStringWithBreak(""); Message.AppendBoolean(false); room.SendMessage(Message); } else if (Item.IsFloorItem) { ServerMessage Message = new ServerMessage(94); Message.AppendRawUInt(Item.Id); Message.AppendStringWithBreak(""); Message.AppendBoolean(false); room.SendMessage(Message); } if (Item.IsWallItem) { mWallItems.Remove(Item.Id); } else { room.GetGameMap().RemoveFromMap(Item); mFloorItems.Remove(Item.Id); } RemoveItem(Item); room.GetRoomUserManager().UpdateUserStatusses(); if (WiredHandler.TypeIsWire(Item.GetBaseItem().InteractionType)) { room.GetWiredHandler().RemoveWiredItem(Item.Coordinate); } }
internal bool SetFloorItem(GameClient Session, RoomItem Item, int newX, int newY, int newRot, bool newItem, bool OnRoller, bool sendMessage, bool updateRoomUserStatuses) { bool NeedsReAdd = 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) { AddItem(Item); 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) { AddItem(Item); room.GetGameMap().AddToMap(Item); } return(false); } } // Start calculating new Z coordinate Double newZ = room.GetGameMap().Model.SqFloorHeight[newX, newY]; if (!OnRoller) { // Is the item trying to stack on itself!? //if (Item.Rot == newRot && Item.GetX == newX && Item.GetY == newY && Item.GetZ != newZ) //{ // if (NeedsReAdd) // AddItem(Item); // return false; //} // Make sure this tile is open and there are no users here if (room.GetGameMap().Model.SqState[newX, newY] != SquareState.OPEN && !Item.GetBaseItem().IsSeat) { if (NeedsReAdd) { AddItem(Item); room.GetGameMap().AddToMap(Item); } 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().GetRoomUnits(new Point(Tile.X, Tile.Y)).Count > 0) { if (NeedsReAdd) { AddItem(Item); room.GetGameMap().AddToMap(Item); } return(false); } } } } // Find affected objects List <RoomItem> ItemsOnTile = GetFurniObjects(newX, newY); List <RoomItem> ItemsAffected = new List <RoomItem>(); List <RoomItem> ItemsComplete = new List <RoomItem>(); foreach (ThreeDCoord Tile in AffectedTiles.Values) { List <RoomItem> 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 (RoomItem I in ItemsComplete) { 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.Rot != newRot && Item.GetX == newX && Item.GetY == newY) { newZ = Item.GetZ; } // Are there any higher objects in the stack!? foreach (RoomItem I in ItemsComplete) { if (I.Id == Item.Id) { continue; // cannot stack on self } if (I.TotalHeight > newZ) { newZ = I.TotalHeight; } } } // Verify the rotation is correct //if (newRot != 0 && newRot != 2 && newRot != 4 && newRot != 6 && newRot != 8) //{ // newRot = 0; //} //Item.GetX = newX; //Item.GetY = newY; //Item.GetZ = newZ; Item.Rot = 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 (mFloorItems.ContainsKey(Item.Id)) { if (Session != null) { Session.SendNotif(LanguageLocale.GetValue("room.itemplaced")); } //Remove from map!!! return(true); } /*else if (mFloorItems.ContainsKey(Item.Id) && Item.MagicRemove) * { * RemoveFurniture(Session, Item.Id); * if (mFloorItems.ContainsKey(Item.Id)) * { * Logging.WriteLine("lul?"); * mFloorItems.Remove(Item.Id); * } * }*/ //using (DatabaseClient dbClient = FirewindEnvironment.GetDatabase().GetClient()) //{ // dbClient.addParameter("extra_data", ((StringData)Item.data).Data); // dbClient.runFastQuery("INSERT INTO room_items (id,room_id,base_item,extra_data,x,y,z,rot,wall_pos) VALUES ('" + Item.Id + "','" + RoomId + "','" + Item.BaseItem + "',@extra_data,'" + Item.GetX + "','" + Item.GetY + "','" + Item.GetZ + "','" + Item.Rot + "','')"); //} //if (mRemovedItems.ContainsKey(Item.Id)) // mRemovedItems.Remove(Item.Id); //if (mAddedItems.ContainsKey(Item.Id)) // return false; //mAddedItems.Add(Item.Id, Item); if (Item.IsFloorItem && !mFloorItems.ContainsKey(Item.Id)) { mFloorItems.Add(Item.Id, Item); } else if (Item.IsWallItem && !mWallItems.ContainsKey(Item.Id)) { mWallItems.Add(Item.Id, Item); } AddItem(Item); if (sendMessage) { ServerMessage Message = new ServerMessage(Outgoing.ObjectAdd); Item.Serialize(Message, room.OwnerId); Message.AppendString(room.Owner); room.SendMessage(Message); } } else { //using (DatabaseClient dbClient = FirewindEnvironment.GetDatabase().GetClient()) //{ // dbClient.runFastQuery("UPDATE room_items SET x = '" + Item.GetX + "', y = '" + Item.GetY + "', z = '" + Item.GetZ + "', rot = '" + Item.Rot + "', wall_pos = '' WHERE id = '" + Item.Id + "' LIMIT 1"); //} UpdateItem(Item); if (!OnRoller && sendMessage) { ServerMessage Message = new ServerMessage(Outgoing.ObjectUpdate); Item.Serialize(Message, room.OwnerId); //Message.AppendString(room.Owner); room.SendMessage(Message); } } if (!newItem) { room.GetWiredHandler().RemoveWiredItem(new System.Drawing.Point(oldX, oldY)); if (WiredHandler.TypeIsWire(Item.GetBaseItem().InteractionType)) { room.GetWiredHandler().AddWire(Item, new System.Drawing.Point(newX, newY), newRot, Item.GetBaseItem().InteractionType); } } else { if (WiredHandler.TypeIsWire(Item.GetBaseItem().InteractionType)) { room.GetWiredHandler().AddWire(Item, Item.Coordinate, newRot, Item.GetBaseItem().InteractionType); } } //GenerateMaps(false); room.GetGameMap().AddToMap(Item); if (Item.GetBaseItem().IsSeat) { updateRoomUserStatuses = true; } if (updateRoomUserStatuses) { room.GetRoomUserManager().UpdateUserStatuses(); } return(true); }
internal void LoadFurniture() { //this.Items.Clear(); this.mFloorItems.Clear(); this.mWallItems.Clear(); DataTable Data; using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor()) { if (dbClient.dbType == Pici.Storage.Database.DatabaseType.MySQL) { dbClient.setQuery("CALL getroomitems(@roomid)"); dbClient.addParameter("roomid", room.RoomId); } else { dbClient.setQuery("EXECUTE getroomitems " + room.RoomId); } Data = dbClient.getTable(); uint itemID; decimal x; decimal y; sbyte n; uint baseID; string extradata; WallCoordinate wallCoord; foreach (DataRow dRow in Data.Rows) { itemID = Convert.ToUInt32(dRow[0]); x = Convert.ToDecimal(dRow[1]); y = Convert.ToDecimal(dRow[2]); n = Convert.ToSByte(dRow[3]); baseID = Convert.ToUInt32(dRow[4]); if (DBNull.Value.Equals(dRow[5])) { extradata = string.Empty; } else { extradata = (string)dRow[5]; } if (n > 6) // Is wallitem { wallCoord = new WallCoordinate((double)x, (double)y, n); RoomItem item = new RoomItem(itemID, room.RoomId, baseID, extradata, wallCoord, room); if (!mWallItems.ContainsKey(itemID)) { mWallItems.Inner.Add(itemID, item); } } else //Is flooritem { int coordX, coordY; TextHandling.Split((double)x, out coordX, out coordY); RoomItem item = new RoomItem(itemID, room.RoomId, baseID, extradata, coordX, coordY, (double)y, n, room); if (!mFloorItems.ContainsKey(itemID)) { mFloorItems.Inner.Add(itemID, item); } } } foreach (RoomItem Item in mFloorItems.Values) { if (Item.IsRoller) { mGotRollers = true; } else if (Item.GetBaseItem().InteractionType == Pici.HabboHotel.Items.InteractionType.dimmer) { if (room.MoodlightData == null) { room.MoodlightData = new MoodlightData(Item.Id); } } else if (WiredUtillity.TypeIsWired(Item.GetBaseItem().InteractionType)) { WiredLoader.LoadWiredItem(Item, room, dbClient); } if (WiredHandler.TypeIsWire(Item.GetBaseItem().InteractionType)) { room.GetWiredHandler().AddWire(Item, Item.Coordinate, Item.Rot, Item.GetBaseItem().InteractionType); } } } }