Esempio n. 1
0
        public WallCoordinate(double x, double y, sbyte n)
        {
            TextHandling.Split(x, out widthX, out widthY);
            TextHandling.Split(y, out lengthX, out lengthY);

            if (n == 7)
            {
                side = 'r';
            }
            else
            {
                side = 'l';
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WallCoordinate"/> class.
 /// </summary>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <param name="n">The n.</param>
 public WallCoordinate(double x, double y, sbyte n)
 {
     TextHandling.Split(x, out widthX, out widthY);
     TextHandling.Split(y, out lengthX, out lengthY);
     side = n == 7 ? 'r' : 'l';
 }
Esempio n. 3
0
        internal void LoadFurniture()
        {
            //this.Items.Clear();
            this.mFloorItems.Clear();
            this.mWallItems.Clear();
            DataTable Data;

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("CALL getroomitems(@roomid)");
                dbClient.addParameter("roomid", room.RoomId);
                Data = dbClient.getTable();


                uint           itemID;
                decimal        x;
                decimal        y;
                sbyte          n;
                uint           baseID;
                int            dataType;
                string         extradata;
                WallCoordinate wallCoord;
                int            extra;
                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]);
                    IRoomItemData data;
                    if (DBNull.Value.Equals(dRow[5]))
                    {
                        data  = new StringData("");
                        extra = 0;
                    }
                    else
                    {
                        dataType  = Convert.ToInt32(dRow[5]);
                        extradata = (string)dRow[6];
                        extra     = Convert.ToInt32(dRow[7]);
                        switch (dataType)
                        {
                        case 0:
                            data = new StringData(extradata);
                            break;

                        case 1:
                            data = new MapStuffData();
                            break;

                        case 2:
                            data = new StringArrayStuffData();
                            break;

                        case 3:
                            data = new StringIntData();
                            break;

                        default:
                            data = new StringData(extradata);
                            break;
                        }
                        try
                        {
                            data.Parse(extradata);
                        }
                        catch
                        {
                            Logging.LogException(string.Format("Error in furni data! Item ID: \"{0}\" and data: \"{1}\"", itemID, extradata.Replace(Convert.ToChar(1).ToString(), "[1]")));
                            dbClient.runFastQuery(string.Format("DELETE FROM items_extradata WHERE item_id = {0}", itemID));
                        }
                    }

                    if (FirewindEnvironment.GetGame().GetItemManager().GetItem(baseID).Type == 'i') // Is wallitem
                    {
                        wallCoord = new WallCoordinate((double)x, (double)y, n);
                        RoomItem item = new RoomItem(itemID, room.RoomId, baseID, data, extra, 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, data, extra, 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 == Firewind.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);
                        room.GetWiredHandler().AddWire(Item, Item.Coordinate, Item.Rot, Item.GetBaseItem().InteractionType);
                    }
                }
            }
        }
Esempio n. 4
0
        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);
                    }
                }
            }
        }