Ejemplo n.º 1
0
        public void QueuedDictionaryEvictAccessCountMru()
        {
            QueuedDictionary<Guid, int> dict = new QueuedDictionary<Guid, int>(3, QueuedDictionaryAccessCompareMode.AccessCountDescending);
            Guid one = Guid.NewGuid(), two = Guid.NewGuid(), three = Guid.NewGuid();

            dict[one] = 1;
            dict[two] = 2;
            dict[three] = 3;

            for (int i = 0; i < 5; i++)
            {
                int value = dict[one];
                value = dict[two];
                value = dict[three];
            }

            for (int i = 0; i < 25; i++)
            {
                dict[Guid.NewGuid()] = i;
            }

            Assert.AreEqual(3, dict.Count);
            Assert.IsFalse(dict.ContainsKey(one));
            Assert.IsFalse(dict.ContainsKey(two));
            Assert.IsFalse(dict.ContainsKey(three));
        }
Ejemplo n.º 2
0
 internal void AddPuck(RoomItem item)
 {
     if (!pucks.ContainsKey(item.Id))
     {
         pucks.Add(item.Id, item);
     }
 }
Ejemplo n.º 3
0
        internal void AddPuck(RoomItem item)
        {
            if (_pucks.ContainsKey(item.Id))
            {
                return;
            }

            _pucks.Add(item.Id, item);
        }
Ejemplo n.º 4
0
 /// <summary>
 ///     Adds the teleport.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="itemId">The item identifier.</param>
 internal void AddTeleport(RoomItem item, uint itemId)
 {
     if (_banzaiTeleports.ContainsKey(itemId))
     {
         _banzaiTeleports.Inner[itemId] = item;
         return;
     }
     _banzaiTeleports.Add(itemId, item);
 }
Ejemplo n.º 5
0
 internal void AddTeleport(RoomItem item, uint itemID)
 {
     if (banzaiTeleports.ContainsKey(itemID))
     {
         banzaiTeleports.Inner[itemID] = item;
     }
     else
     {
         banzaiTeleports.Add(itemID, item);
     }
 }
Ejemplo n.º 6
0
 internal void AddPyramid(RoomItem item, uint itemID)
 {
     if (banzaiPyramids.ContainsKey(itemID))
     {
         banzaiPyramids.Inner[itemID] = item;
     }
     else
     {
         banzaiPyramids.Add(itemID, item);
     }
 }
Ejemplo n.º 7
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);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public void QueuedDictionaryEvictAccessDateLru()
        {
            QueuedDictionary<Guid, int> dict = new QueuedDictionary<Guid, int>(3, QueuedDictionaryAccessCompareMode.LastAccessDateAscending);
            Stack<Guid> stack = new Stack<Guid>();

            for (int i = 0; i < 25; i++)
            {
                Guid key = Guid.NewGuid();
                dict[key] = i;
                stack.Push(key);
                Thread.Sleep(1);
            }

            Assert.AreEqual(3, dict.Count);
            Assert.IsTrue(dict.ContainsKey(stack.Pop()));
            Assert.IsTrue(dict.ContainsKey(stack.Pop()));
            Assert.IsTrue(dict.ContainsKey(stack.Pop()));
        }
Ejemplo n.º 9
0
        public void QueuedDictionaryEvictCreationDateMru()
        {
            QueuedDictionary<Guid, int> dict = new QueuedDictionary<Guid, int>(3, QueuedDictionaryAccessCompareMode.CreationDateDescending);
            Queue<Guid> queue = new Queue<Guid>();

            for (int i = 0; i < 25; i++)
            {
                Guid key = Guid.NewGuid();
                dict[key] = i;
                queue.Enqueue(key);
                Thread.Sleep(1);
            }

            Assert.AreEqual(3, dict.Count);
            Assert.IsTrue(dict.ContainsKey(queue.Dequeue()));
            Assert.IsTrue(dict.ContainsKey(queue.Dequeue()));
            Assert.IsTrue(dict.ContainsKey(queue.Dequeue()));
        }
Ejemplo n.º 10
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);
                    }
                }
            }
        }