Exemplo n.º 1
0
Arquivo: Rooms.cs Projeto: habb0/Bfly
        internal void PlaceItem()
        {
            // AZ@J16 10 10 0

            Room Room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null || !Room.CheckRights(Session))
            {
                return;
            }

            string PlacementData = Request.PopFixedString();
            string[] DataBits = PlacementData.Split(' ');
            uint ItemId = uint.Parse(DataBits[0].Replace("-",""));

            UserItem Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId);

            if (Item == null)
            {
                return;
            }
            //bool UpdateNeeded = false;

            switch (Item.GetBaseItem().InteractionType)
            {
                case Butterfly.HabboHotel.Items.InteractionType.dimmer:
                    {
                        MoodlightData moodData = Room.MoodlightData;
                        if (moodData != null && Room.GetRoomItemHandler().GetItem(moodData.ItemId) != null)
                            Session.SendNotif(LanguageLocale.GetValue("user.maxmoodlightsreached"));
                        break;
                    }
            }

            // Wall Item
            if (DataBits[1].StartsWith(":"))
            {
                try
                {
                    WallCoordinate coordinate = new WallCoordinate(":" + PlacementData.Split(':')[1]);
                    RoomItem RoomItem = new RoomItem(Item.Id, Room.RoomId, Item.BaseItem, Item.ExtraData, coordinate, Room);

                    if (Room.GetRoomItemHandler().SetWallItem(Session, RoomItem))
                    {
                        Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId, true);
                    }
                }
                catch
                {
                    Response.Init(516);
                    Response.AppendInt32(11);
                    SendResponse();
                    return;
                }
            }
            // Floor Item
            else
            {
                int X = int.Parse(DataBits[1]);
                int Y = int.Parse(DataBits[2]);
                int Rot = int.Parse(DataBits[3]);

                if (Session.GetHabbo().forceRot > -1)
                    Rot = Session.GetHabbo().forceRot;

                RoomItem RoomItem = new RoomItem(Item.Id, Room.RoomId, Item.BaseItem, Item.ExtraData, X, Y, 0, Rot, Room);

                if (Room.GetRoomItemHandler().SetFloorItem(Session, RoomItem, X, Y, Rot, true, false, true))
                {
                    Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId, true);
                }

                if (WiredUtillity.TypeIsWired(Item.GetBaseItem().InteractionType))
                {
                    WiredSaver.HandleDefaultSave(Item.Id, Room);
                }

                ButterflyEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, HabboHotel.Quests.QuestType.FURNI_PLACE);
            }
            //if (UpdateNeeded)
            //    Room.SaveFurniture();
        }
Exemplo n.º 2
0
Arquivo: Rooms.cs Projeto: habb0/Bfly
        internal void PlacePostIt()
        {
            Room Room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);
            if (Room == null || !Room.CheckRights(Session))
            {
                return;
            }

            uint itemId = Request.PopWiredUInt();
            string locationData = Request.PopFixedString();

            UserItem item = Session.GetHabbo().GetInventoryComponent().GetItem(itemId);

            if (item == null || Room == null)
                return;

            try
            {
                WallCoordinate coordinate = new WallCoordinate(":" + locationData.Split(':')[1]);

                RoomItem RoomItem = new RoomItem(item.Id, Room.RoomId, item.BaseItem, item.ExtraData, coordinate, Room);

                if (Room.GetRoomItemHandler().SetWallItem(Session, RoomItem))
                {
                    Session.GetHabbo().GetInventoryComponent().RemoveItem(itemId, true);
                }
            }
            catch
            {
                Response.Init(516);
                Response.AppendInt32(11);
                SendResponse();
                return;
            }
        }
Exemplo n.º 3
0
Arquivo: Rooms.cs Projeto: habb0/Bfly
        internal void MoveWallItem()
        {
            Room Room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null || !Room.CheckRights(Session))
            {
                return;
            }

            uint itemID = Request.PopWiredUInt();
            string wallPositionData = Request.PopFixedString();

            RoomItem Item = Room.GetRoomItemHandler().GetItem(itemID);

            if (Item == null)
                return;

            try
            {
                WallCoordinate coordinate = new WallCoordinate(":" + wallPositionData.Split(':')[1]);
                Item.wallCoord = coordinate;
            }
            catch
            {
                Response.Init(516);
                Response.AppendInt32(11);
                SendResponse();

                return;
            }

            Room.GetRoomItemHandler().UpdateItem(Item);

            ServerMessage LeaveMessage = new ServerMessage(84);
            LeaveMessage.AppendRawUInt(Item.Id);
            LeaveMessage.AppendStringWithBreak(string.Empty);
            LeaveMessage.AppendBoolean(false);
            Room.SendMessage(LeaveMessage);

            ServerMessage Message = new ServerMessage(83);
            Item.Serialize(Message);
            Room.SendMessage(Message);
        }
Exemplo n.º 4
0
        internal void LoadFurniture()
        {
            //this.Items.Clear();
            this.mFloorItems.Clear();
            this.mWallItems.Clear();
            DataTable Data;
            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
				//if (dbClient.dbType == Database_Manager.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((float)x, (float)y, n);
                        RoomItem item = new RoomItem(itemID, room.RoomId, baseID, extradata, wallCoord, room);

                        if (!mWallItems.ContainsKey(itemID))
                            mWallItems.Inner.Add(itemID, item);

                        if (item.GetBaseItem().InteractionType == Butterfly.HabboHotel.Items.InteractionType.dimmer)
                        {
                            if (room.MoodlightData == null)
                                room.MoodlightData = new MoodlightData(item.Id);
                        }
                    }
                    else //Is flooritem
                    {
                        int coordX, coordY;
                        TextHandling.Split((float)x, out coordX, out coordY);

                        RoomItem item = new RoomItem(itemID, room.RoomId, baseID, room.OwnerId, 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 (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);
                    }
                }
            }
        }
Exemplo n.º 5
0
Arquivo: Rooms.cs Projeto: BjkGkh/R106
        internal void MoveWallItem()
        {
            Room Room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null || !Room.CheckRights(Session))
            {
                return;
            }

            uint itemID = Request.ReadUInt();
            string wallPositionData = Request.ReadString();

            RoomItem Item = Room.GetRoomItemHandler().GetItem(itemID);

            if (Item == null)
                return;

            try
            {
                WallCoordinate coordinate = new WallCoordinate(":" + wallPositionData.Split(':')[1]);
                Item.wallCoord = coordinate;
            }
            catch
            {
                //ServerMessage message = new ServerMessage(OutputCode.PlaceObjectErrorMessageEvent);
                //message.AddInt32(11);
                //Session.SendMessage(message);

                return;
            }

            Room.GetRoomItemHandler().UpdateItem(Item);

            //ServerMessage LeaveMessage = new ServerMessage(OutputCode.ItemRemoveMessageEvent);
            //LeaveMessage.AddString(Item.Id.ToString());
            //Room.SendMessage(LeaveMessage);

            ServerMessage Message = PacketHandelingManager.GetRecycledItem(OutputCode.ItemAddMessageEvent);
            Item.Serialize(Message);
            Room.SendMessage(Message);
        }
Exemplo n.º 6
0
Arquivo: Rooms.cs Projeto: BjkGkh/R106
        private void HandleWallItemPlace(UserItem item, string placementData, Room room)
        {
            string[] dataBits = placementData.Split(' ');
            if (!dataBits[1].StartsWith(":")) //Is wallitem
                return;

            switch (item.GetBaseItem().InteractionType)
            {
                case Butterfly.HabboHotel.Items.InteractionType.dimmer:
                    {
                        MoodlightData moodData = room.MoodlightData;
                        if (moodData != null && room.GetRoomItemHandler().GetItem(moodData.ItemId) != null)
                        {
                            Session.SendChatMessage("Je kunt maar 1 sfeerverlichter per kamer plaatsen.", 0);
                            return;
                        }
                    }
                    break;
            }

            try
            {
                WallCoordinate coordinate = new WallCoordinate(":" + placementData.Split(':')[1]);
                RoomItem roomItem = new RoomItem(item.itemID, room.RoomId, item.BaseItemID, item.extraData, coordinate, room);

                if (room.GetRoomItemHandler().SetWallItem(Session, roomItem))
                {
                    Session.GetHabboDataContainer().GetInventoryComponent().RemoveItem(item.itemID, true);
                }
            }
            catch
            {
                return;
            }
        }
Exemplo n.º 7
0
Arquivo: Rooms.cs Projeto: BjkGkh/R106
        internal void PlacePostIt()
        {
            Room Room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);
            if (Room == null || !Room.CheckRights(Session))
            {
                return;
            }

            uint itemId = Request.ReadUInt();
            string locationData = Request.ReadString();

            UserItem item = Session.GetHabboDataContainer().GetInventoryComponent().GetItem(itemId);

            if (item == null || Room == null)
                return;

            try
            {
                WallCoordinate coordinate = new WallCoordinate(":" + locationData.Split(':')[1]);

                RoomItem _RoomItem = new RoomItem(item.itemID, Room.RoomId, item.BaseItemID, item.extraData, coordinate, Room);

                if (Room.GetRoomItemHandler().SetWallItem(Session, _RoomItem))
                {
                    Session.GetHabboDataContainer().GetInventoryComponent().RemoveItem(itemId, true);
                }
            }
            catch
            {
                //ServerMessage message = new ServerMessage(OutputCode.PlaceObjectErrorMessageEvent);
                //message.AddInt32(11);
                //Session.SendMessage(message);
                return;
            }
        }