コード例 #1
0
ファイル: BlockDB.cs プロジェクト: noahjoyce31/MCGalaxy
        bool FindInMemoryBy(int[] ids, int startDelta, int endDelta, Action <BlockDBEntry> output)
        {
            BlockDBCacheNode node = Cache.Head;

            while (node != null)
            {
                int count = node.Count;
                BlockDBCacheEntry[] entries = node.Entries;

                for (int i = count - 1; i >= 0; i--)
                {
                    BlockDBEntry entry = node.Unpack(entries[i]);
                    if (entry.TimeDelta < startDelta)
                    {
                        return(true);
                    }
                    if (entry.TimeDelta > endDelta)
                    {
                        continue;
                    }

                    for (int j = 0; j < ids.Length; j++)
                    {
                        if (entry.PlayerID != ids[j])
                        {
                            continue;
                        }
                        output(entry); break;
                    }
                }
                lock (Cache.Locker) node = node.Prev;
            }
            return(false);
        }
コード例 #2
0
ファイル: BlockDB.cs プロジェクト: noahjoyce31/MCGalaxy
        void FindInMemoryAt(ushort x, ushort y, ushort z, Action <BlockDBEntry> output)
        {
            int index             = (y * Dims.Z + z) * Dims.X + x;
            BlockDBCacheNode node = Cache.Tail;

            while (node != null)
            {
                BlockDBCacheEntry[] entries = node.Entries;
                int count = node.Count;

                for (int i = 0; i < count; i++)
                {
                    if (entries[i].Index != index)
                    {
                        continue;
                    }
                    BlockDBEntry entry = node.Unpack(entries[i]);
                    output(entry);
                }
                lock (Cache.Locker) node = node.Next;
            }
        }
コード例 #3
0
ファイル: BlockDBFile.V1.cs プロジェクト: takaaptech/MCGalaxy
        public override void WriteEntries(Stream s, BlockDBCache cache)
        {
            byte[]           bulk = new byte[BulkEntries * EntrySize];
            BlockDBCacheNode node = cache.Tail;

            while (node != null)
            {
                int count = node.Count;
                for (int i = 0; i < count; i += BulkEntries)
                {
                    int bulkCount = Math.Min(BulkEntries, count - i);
                    for (int j = 0; j < bulkCount; j++)
                    {
                        BlockDBEntry entry = node.Unpack(node.Entries[i + j]);
                        WriteEntry(entry, bulk, j * EntrySize);
                    }
                    s.Write(bulk, 0, bulkCount * EntrySize);
                }

                lock (cache.Locker)
                    node = node.Next;
            }
        }