internal static void AlertUser(GameClient ModSession, uint UserId, String Message, Boolean Caution) { GameClient Client = FirewindEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId); if (Client == null || Client.GetHabbo().Id == ModSession.GetHabbo().Id) { return; } if (Caution && Client.GetHabbo().Rank >= ModSession.GetHabbo().Rank) { ModSession.SendNotif(LanguageLocale.GetValue("moderation.caution.missingrank")); Caution = false; } Client.SendNotif(Message, Caution); if (Caution) { using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("UPDATE user_info SET cautions = cautions + 1 WHERE user_id = " + UserId + ""); } } }
internal static void BanUser(GameClient ModSession, uint UserId, int Length, String Message) { GameClient Client = FirewindEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId); if (Client == null || Client.GetHabbo().Id == ModSession.GetHabbo().Id) { return; } if (Client.GetHabbo().Rank >= ModSession.GetHabbo().Rank) { ModSession.SendNotif(LanguageLocale.GetValue("moderation.ban.missingrank")); return; } Double dLength = Length; FirewindEnvironment.GetGame().GetBanManager().BanUser(Client, ModSession.GetHabbo().Username, dLength, Message, false); }
internal void HandlePurchase(GameClient Session, int PageId, uint ItemId, string extraParameter, int buyAmount, Boolean IsGift, string GiftUser, string GiftMessage, int GiftSpriteId, int GiftLazo, int GiftColor, bool giftShowIdentity) { int finalAmount = buyAmount; if (buyAmount > 5) // Possible discount! { // Nearest number that increases the amount of free items int nearestDiscount = ((int)Math.Floor(buyAmount / 6.0) * 6); // How many free ones we get int freeItemsCount = (nearestDiscount - 3) / 3; // Add 1 free if more than 42 if (buyAmount >= 42) freeItemsCount++; // Doesn't follow rules as it isn't dividable by 6, but still increases free items if (buyAmount >= 99) { freeItemsCount = 33; } // This is how many we pay for in the end finalAmount = buyAmount - freeItemsCount; } //Logging.WriteLine("Amount: " + priceAmount + "; withOffer= " + finalAmount); CatalogPage Page; if (!Pages.TryGetValue(PageId, out Page)) return; if (Page == null || !Page.Enabled || !Page.Visible || Session == null || Session.GetHabbo() == null) { Session.SendMessage(new ServerMessage(Outgoing.PurchaseError)); return; } if (Page.ClubOnly && !Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club") && !Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip")) { Session.SendMessage(new ServerMessage(Outgoing.PurchaseError)); return; } if (Page.MinRank > Session.GetHabbo().Rank) { Session.SendMessage(new ServerMessage(Outgoing.PurchaseError)); return; } CatalogItem Item = Page.GetItem(ItemId); if (Item == null) // TODO: Check item minimum club rank { Session.SendMessage(new ServerMessage(Outgoing.PurchaseError)); return; } if (!Item.HaveOffer && buyAmount > 1) // Check if somebody is bulk-buying when not allowed { Session.SendMessage(new ServerMessage(Outgoing.PurchaseError)); return; } if (Item.IsLimited && Item.LimitedStack <= Item.LimitedSelled) { Session.SendMessage(new ServerMessage(Outgoing.PurchaseError)); return; } uint GiftUserId = 0; //int giftWrappingCost = 0; if (IsGift) { if(!Item.AllowGift) { Session.SendMessage(new ServerMessage(Outgoing.PurchaseError)); return; } if(Item.Items.Count > 1 || Item.Amount > 1) // Gifts can only have 1 item? { Session.SendMessage(new ServerMessage(Outgoing.PurchaseError)); return; } DataRow dRow; using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT id FROM users WHERE username = @gift_user"); dbClient.addParameter("gift_user", GiftUser); dRow = dbClient.getRow(); } if (dRow == null) { Session.GetMessageHandler().GetResponse().Init(Outgoing.GiftError); Session.GetMessageHandler().GetResponse().AppendString(GiftUser); Session.GetMessageHandler().SendResponse(); return; } GiftUserId = Convert.ToUInt32(dRow[0]); if (GiftUserId == 0) { Session.GetMessageHandler().GetResponse().Init(Outgoing.GiftError); Session.GetMessageHandler().GetResponse().AppendString(GiftUser); Session.GetMessageHandler().SendResponse(); return; } } Boolean CreditsError = false; Boolean PixelError = false; Boolean CrystalError = false; if (Session.GetHabbo().Credits < (Item.CreditsCost * finalAmount)) { CreditsError = true; } if (Session.GetHabbo().VipPoints < (Item.CrystalCost * finalAmount)) { CrystalError = true; } if (Session.GetHabbo().ActivityPoints < (Item.PixelsCost * finalAmount)) { PixelError = true; } if (CreditsError || PixelError) { ServerMessage message = new ServerMessage(Outgoing.NotEnoughBalance); message.AppendBoolean(CreditsError); message.AppendBoolean(PixelError); Session.SendMessage(message); return; } if (Item.CrystalCost > 0) { int cost = Item.CrystalCost * finalAmount; if (Session.GetHabbo().VipPoints < cost) { Session.SendNotif("You can't afford that item!"); Session.SendMessage(new ServerMessage(Outgoing.PurchaseError)); return; } Session.GetHabbo().VipPoints -= cost; Session.GetHabbo().UpdateActivityPointsBalance(true); using (IQueryAdapter adapter = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { adapter.runFastQuery("UPDATE users SET vip_points = " + Session.GetHabbo().VipPoints + " WHERE id = " + Session.GetHabbo().Id); } } if (Item.CreditsCost > 0 && !IsGift) { Session.GetHabbo().Credits -= (Item.CreditsCost * finalAmount); Session.GetHabbo().UpdateCreditsBalance(); } if (Item.PixelsCost > 0 && !IsGift) { Session.GetHabbo().ActivityPoints -= (Item.PixelsCost * finalAmount); Session.GetHabbo().UpdateActivityPointsBalance(true); } // Item is purchased, now do post-proccessing if (Item.IsLimited) { Item.LimitedSelled++; using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("UPDATE catalog_items SET limited_sells = " + Item.LimitedSelled + " WHERE id = " + Item.Id); } Page.InitMsg(); // update page! // send update Session.SendMessage(Page.GetMessage); } foreach (uint i in Item.Items) { //Logging.WriteLine(Item.GetBaseItem().ItemId); //Logging.WriteLine(Item.GetBaseItem().InteractionType.ToLower()); // Extra Data is _NOT_ filtered at this point and MUST BE VERIFIED BELOW: if (Item.GetBaseItem(i).Type == 'h') // Subscription { int Months = 0; int Days = 0; if (Item.Name.Contains("HABBO_CLUB_VIP_")) { if (Item.Name.Contains("_DAY")) { Days = int.Parse(Item.Name.Split('_')[3]); } else if (Item.Name.Contains("_MONTH")) { Months = int.Parse(Item.Name.Split('_')[3]); Days = 31 * Months; } } else if (Item.Name.Equals("deal_vip_1_year_and_badge")) { Months = 12; Days = 31 * Months; } else if (Item.Name.Equals("HABBO_CLUB_VIP_5_YEAR")) { Months = 5 * 12; Days = 31 * Months; } else if (Item.Name.StartsWith("DEAL_HC_")) { Months = int.Parse(Item.Name.Split('_')[2]); Days = 31 * Months; Session.GetHabbo().GetSubscriptionManager().AddOrExtendSubscription("habbo_club", Days * 24 * 3600); Session.GetHabbo().SerializeClub(); return; } Session.GetHabbo().GetSubscriptionManager().AddOrExtendSubscription("habbo_vip", Days * 24 * 3600); Session.GetHabbo().SerializeClub(); return; } if (IsGift && Item.GetBaseItem(i).Type == 'e') { Session.SendNotif(LanguageLocale.GetValue("catalog.gift.send.error")); return; } IRoomItemData itemData = new StringData(extraParameter); switch (Item.GetBaseItem(i).InteractionType) { case InteractionType.none: //itemData = new StringData(extraParameter); break; case InteractionType.musicdisc: itemData = new StringData(Item.songID.ToString()); break; #region Pet handling case InteractionType.pet: try { string[] Bits = extraParameter.Split('\n'); string PetName = Bits[0]; string Race = Bits[1]; string Color = Bits[2]; int.Parse(Race); // to trigger any possible errors if (!CheckPetName(PetName)) { Session.SendMessage(new ServerMessage(Outgoing.PurchaseError)); return; } //if (Race.Length != 1) // return; if (Color.Length != 6) { Session.SendMessage(new ServerMessage(Outgoing.PurchaseError)); return; } } catch (Exception e) { Logging.WriteLine(e.ToString()); Logging.HandleException(e, "Catalog.HandlePurchase"); Session.SendMessage(new ServerMessage(Outgoing.PurchaseError)); return; } break; #endregion case InteractionType.roomeffect: Double Number = 0; try { if (string.IsNullOrEmpty(extraParameter)) Number = 0; else Number = Double.Parse(extraParameter, FirewindEnvironment.cultureInfo); } catch (Exception e) { Logging.HandleException(e, "Catalog.HandlePurchase: " + extraParameter); } itemData = new StringData(Number.ToString().Replace(',', '.')); break; // maintain extra data // todo: validate case InteractionType.postit: itemData = new StringData("FFFF33"); break; case InteractionType.dimmer: itemData = new StringData("1,1,1,#000000,255"); break; case InteractionType.trophy: itemData = new StringData(String.Format("{0}\t{1}\t{2}", Session.GetHabbo().Username, DateTime.Now.ToString("d-M-yyy"), extraParameter)); break; //case InteractionType.mannequin: // MapStuffData data = new MapStuffData(); // data.Data.Add("OUTFIT_NAME", ""); // data.Data.Add("FIGURE", ""); // data.Data.Add("GENDER", ""); // itemData = data; // break; default: //itemData = new StringData(extraParameter); break; } //Session.GetMessageHandler().GetResponse().Init(Outgoing.UpdateInventary); //Session.GetMessageHandler().SendResponse(); Session.GetMessageHandler().GetResponse().Init(Outgoing.PurchaseOK); // PurchaseOKMessageEvent Item.Serialize(Session.GetMessageHandler().GetResponse()); Session.GetMessageHandler().SendResponse(); if (IsGift) { uint itemID; //uint GenId = GenerateItemId(); Item Present = FirewindEnvironment.GetGame().GetItemManager().GetItemBySpriteID(GiftSpriteId); if (Present == null) { Logging.LogDebug(string.Format("Somebody tried to purchase a present with invalid sprite ID: {0}", GiftSpriteId)); Session.SendMessage(new ServerMessage(Outgoing.PurchaseError)); return; } MapStuffData giftData = new MapStuffData(); if (giftShowIdentity) { giftData.Data.Add("PURCHASER_NAME", Session.GetHabbo().Username); giftData.Data.Add("PURCHASER_FIGURE", Session.GetHabbo().Look); } giftData.Data.Add("MESSAGE", GiftMessage); giftData.Data.Add("PRODUCT_CODE", "10"); giftData.Data.Add("EXTRA_PARAM", "test"); giftData.Data.Add("state", "1"); using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("INSERT INTO items (base_id) VALUES (" + Present.ItemId + ")"); itemID = (uint)dbClient.insertQuery(); dbClient.runFastQuery("INSERT INTO items_users VALUES (" + itemID + "," + GiftUserId + ")"); if (!string.IsNullOrEmpty(GiftMessage)) { dbClient.setQuery("INSERT INTO items_extradata VALUES (" + itemID + ",@datatype,@data,@extra)"); dbClient.addParameter("datatype", giftData.GetTypeID()); dbClient.addParameter("data", giftData.ToString()); dbClient.addParameter("extra", GiftColor * 1000 + GiftLazo); dbClient.runQuery(); } dbClient.setQuery("INSERT INTO user_presents (item_id,base_id,amount,extra_data) VALUES (" + itemID + "," + Item.GetBaseItem(i).ItemId + "," + Item.Amount + ",@extra_data)"); dbClient.addParameter("extra_data", itemData.ToString()); dbClient.runQuery(); } GameClient Receiver = FirewindEnvironment.GetGame().GetClientManager().GetClientByUserID(GiftUserId); if (Receiver != null) { Receiver.SendNotif(LanguageLocale.GetValue("catalog.gift.received") + Session.GetHabbo().Username); UserItem u = Receiver.GetHabbo().GetInventoryComponent().AddNewItem(itemID, Present.ItemId, giftData, GiftColor * 1000 + GiftLazo, false, false, 0); Receiver.GetHabbo().GetInventoryComponent().SendFloorInventoryUpdate(); Receiver.GetMessageHandler().GetResponse().Init(Outgoing.UnseenItems); Receiver.GetMessageHandler().GetResponse().AppendInt32(1); // items Receiver.GetMessageHandler().GetResponse().AppendInt32(1); // type (gift) == s Receiver.GetMessageHandler().GetResponse().AppendInt32(1); Receiver.GetMessageHandler().GetResponse().AppendUInt(u.Id); Receiver.GetMessageHandler().SendResponse(); InventoryComponent targetInventory = Receiver.GetHabbo().GetInventoryComponent(); if (targetInventory != null) targetInventory.RunDBUpdate(); } Session.SendNotif(LanguageLocale.GetValue("catalog.gift.sent")); } else { List<UserItem> items = DeliverItems(Session, Item.GetBaseItem(i), (buyAmount * Item.Amount), itemData.ToString(), Item.songID); int Type = 2; if (Item.GetBaseItem(i).Type.ToString().ToLower().Equals("s")) { if (Item.GetBaseItem(i).InteractionType == InteractionType.pet) Type = 3; else Type = 1; } Session.GetMessageHandler().GetResponse().Init(Outgoing.UnseenItems); Session.GetMessageHandler().GetResponse().AppendInt32(1); // items Session.GetMessageHandler().GetResponse().AppendInt32(Type); Session.GetMessageHandler().GetResponse().AppendInt32(items.Count); foreach (UserItem u in items) Session.GetMessageHandler().GetResponse().AppendUInt(u.Id); Session.GetMessageHandler().SendResponse(); //Logging.WriteLine("Purchased " + items.Count); Session.GetHabbo().GetInventoryComponent().UpdateItems(false); if (Item.GetBaseItem(i).InteractionType == InteractionType.pet) { Session.SendMessage(Session.GetHabbo().GetInventoryComponent().SerializePetInventory()); } } } }
internal List<UserItem> DeliverItems(GameClient Session, Item Item, int Amount, String ExtraData, uint songID = 0) { List<UserItem> result = new List<UserItem>(); switch (Item.Type.ToString()) { case "i": case "s": for (int i = 0; i < Amount; i++) { //uint GeneratedId = GenerateItemId(); switch (Item.InteractionType) { case InteractionType.pet: //int petType = int.Parse(Item.InteractionType.ToString().Replace("pet", "")); int petType = int.Parse(Item.Name.Substring(Item.Name.IndexOf(' ') + 4)); string[] PetData = ExtraData.Split('\n'); Pet GeneratedPet = CreatePet(Session.GetHabbo().Id, PetData[0], petType, PetData[1], PetData[2]); Session.GetHabbo().GetInventoryComponent().AddPet(GeneratedPet); result.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, new StringData("0"), 0, true, false, 0)); break; case InteractionType.teleport: UserItem one = Session.GetHabbo().GetInventoryComponent().AddNewItem(0, Item.ItemId, new StringData("0"), 0, true, false, 0); uint idOne = one.Id; UserItem two = Session.GetHabbo().GetInventoryComponent().AddNewItem(0, Item.ItemId, new StringData("0"), 0, true, false, 0); uint idTwo = two.Id; result.Add(one); result.Add(two); using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("INSERT INTO items_tele_links (tele_one_id,tele_two_id) VALUES (" + idOne + "," + idTwo + ")"); dbClient.runFastQuery("INSERT INTO items_tele_links (tele_one_id,tele_two_id) VALUES (" + idTwo + "," + idOne + ")"); } break; case InteractionType.dimmer: UserItem it = Session.GetHabbo().GetInventoryComponent().AddNewItem(0, Item.ItemId, new StringData(ExtraData), 0, true, false, 0); uint id = it.Id; result.Add(it); using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("INSERT INTO items_moodlight (item_id,enabled,current_preset,preset_one,preset_two,preset_three) VALUES (" + id + ",0,1,'#000000,255,0','#000000,255,0','#000000,255,0')"); } break; case InteractionType.musicdisc: { result.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0, Item.ItemId, new StringData(songID.ToString()), 0, true, false, songID)); break; } case InteractionType.mannequin: MapStuffData data = new MapStuffData(); data.Data.Add("OUTFIT_NAME", ""); data.Data.Add("FIGURE", "hr-515-33.hd-600-1.ch-635-70.lg-716-66-62.sh-735-68"); data.Data.Add("GENDER", "M"); result.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0, Item.ItemId, data, 0, true, false, songID)); break; case InteractionType.guildgeneric: case InteractionType.guilddoor: StringArrayStuffData stringData = new StringArrayStuffData(); stringData.Data.Add(""); // furniture state stringData.Data.Add("1"); // guild id stringData.Data.Add(""); // badge string stringData.Data.Add("FFFFFF"); // COLOR_1_STUFFDATA stringData.Data.Add("FFFFFF"); // COLOR_2_STUFFDATA result.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0, Item.ItemId, stringData, 0, true, false, songID)); break; default: result.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0, Item.ItemId, new StringData(ExtraData), 0, true, false, songID)); break; } } return result; case "e": for (int i = 0; i < Amount; i++) { Session.GetHabbo().GetAvatarEffectsInventoryComponent().AddEffect(Item.SpriteId, 3600); } return result; case "r": // Rentable bot return result; default: Session.SendNotif(LanguageLocale.GetValue("catalog.buyerror")); return result; } }
internal RoomData CreateRoom(GameClient Session, string Name, string Model) { Name = FirewindEnvironment.FilterInjectionChars(Name); if (!roomModels.ContainsKey(Model)) { Session.SendNotif(LanguageLocale.GetValue("room.modelmissing")); return null; } if (((RoomModel)roomModels[Model]).ClubOnly && !Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip")) { Session.SendNotif(LanguageLocale.GetValue("room.missingclub")); return null; } if (Name.Length < 3) { Session.SendNotif(LanguageLocale.GetValue("room.namelengthshort")); return null; } UInt32 RoomId = 0; using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("INSERT INTO rooms (caption,owner,model_name) VALUES (@caption,@username,@model)"); dbClient.addParameter("caption", Name); dbClient.addParameter("model", Model); dbClient.addParameter("username", Session.GetHabbo().Username); RoomId = (UInt32)dbClient.insertQuery(); } RoomData newRoomData = GenerateRoomData(RoomId); Session.GetHabbo().UsersRooms.Add(newRoomData); return newRoomData; }
internal static void KickUser(GameClient ModSession, uint UserId, String Message, Boolean Soft) { GameClient Client = FirewindEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId); if (Client == null || Client.GetHabbo().CurrentRoomId < 1 || Client.GetHabbo().Id == ModSession.GetHabbo().Id) { return; } if (Client.GetHabbo().Rank >= ModSession.GetHabbo().Rank) { ModSession.SendNotif(LanguageLocale.GetValue("moderation.kick.missingrank")); return; } Room Room = FirewindEnvironment.GetGame().GetRoomManager().GetRoom(Client.GetHabbo().CurrentRoomId); if (Room == null) { return; } Room.GetRoomUserManager().RemoveUserFromRoom(Client, true, false); Client.CurrentRoomUserID = -1; if (!Soft) { Client.SendNotif(Message); using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("UPDATE user_info SET cautions = cautions + 1 WHERE user_id = " + UserId + ""); } } }
internal bool SetWallItem(GameClient Session, RoomItem Item) { if (!Item.IsWallItem || mWallItems.ContainsKey(Item.Id)) return false; if (mFloorItems.ContainsKey(Item.Id)) { Session.SendNotif(LanguageLocale.GetValue("room.itemplaced")); return true; } Item.Interactor.OnPlace(Session, Item); if (Item.GetBaseItem().InteractionType == InteractionType.dimmer) { if (room.MoodlightData == null) { room.MoodlightData = new MoodlightData(Item.Id); ((StringData)Item.data).Data = room.MoodlightData.GenerateExtraData(); } } mWallItems.Add(Item.Id, Item); AddItem(Item); ServerMessage Message = new ServerMessage(Outgoing.AddWallItemToRoom); Item.Serialize(Message, room.OwnerId); Message.AppendString(room.Owner); // TODO room.SendMessage(Message); return true; }
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().GetRoomUsers(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().UpdateUserStatusses(); return true; }