Пример #1
0
        public BlockDBEntry[] Lookup( int max, [NotNull] PlayerInfo[] infos, bool exclude, TimeSpan span ) {
            if( infos == null ) throw new ArgumentNullException( "infos" );
            if( infos.Length == 0 ) throw new ArgumentException( "At least one PlayerInfo must be given", "infos" );
            if( span < TimeSpan.Zero ) throw new ArgumentOutOfRangeException( "span" );
            if( infos.Length == 1 ) return Lookup( max, infos[0], exclude, span );
            long ticks = DateTime.UtcNow.Subtract( span ).ToUnixTime();
            Map map = World.LoadMap();

            IBlockDBQueryProcessor processor;
            if( exclude ) {
                processor = new ExcludingReturnOldestProcessor( map, max,
                                                                entry => entry.Timestamp >= ticks,
                                                                entry => infos.Any( t => entry.PlayerID == t.ID ) );
            } else {
                processor = new ReturnOldestProcessor( map, max,
                                                       entry => entry.Timestamp >= ticks &&
                                                                infos.Any( t => entry.PlayerID == t.ID ) );
            }
            Traverse( processor );
            return processor.GetResults();
        }
Пример #2
0
        public BlockDBEntry[] Lookup( int max, [NotNull] PlayerInfo info, bool exclude, TimeSpan span ) {
            if( info == null ) throw new ArgumentNullException( "info" );
            if( span < TimeSpan.Zero ) throw new ArgumentOutOfRangeException( "span" );
            int pid = info.ID;
            long ticks = DateTime.UtcNow.Subtract( span ).ToUnixTime();
            Map map = World.LoadMap();

            IBlockDBQueryProcessor processor;
            if( exclude ) {
                processor = new ExcludingReturnOldestProcessor( map, max,
                                                                entry => entry.Timestamp >= ticks,
                                                                entry => entry.PlayerID == pid );
            } else {
                processor = new ReturnOldestProcessor( map, max,
                                                       entry => entry.Timestamp >= ticks && entry.PlayerID == pid );
            }
            Traverse( processor );
            return processor.GetResults();
        }
Пример #3
0
        public BlockDBEntry[] Lookup( int max, [NotNull] PlayerInfo[] infos, bool exclude ) {
            if( infos == null ) throw new ArgumentNullException( "infos" );
            if( infos.Length == 0 ) throw new ArgumentException( "At least one PlayerInfo must be given", "infos" );
            if( infos.Length == 1 ) return Lookup( max, infos[0], exclude );
            Map map = World.LoadMap();

            IBlockDBQueryProcessor processor;
            if( exclude ) {
                processor = new ExcludingReturnOldestProcessor( map, max,
                                                                entry => true,
                                                                entry => infos.Any( t => entry.PlayerID == t.ID ) );
            } else {
                processor = new ReturnOldestProcessor( map, max,
                                                       entry => infos.Any( t => entry.PlayerID == t.ID ) );
            }
            Traverse( processor );
            return processor.GetResults();
        }
Пример #4
0
        public BlockDBEntry[] Lookup( int max, [NotNull] PlayerInfo info, bool exclude ) {
            if( info == null ) throw new ArgumentNullException( "info" );
            int pid = info.ID;
            Map map = World.LoadMap();

            IBlockDBQueryProcessor processor;
            if( exclude ) {
                processor = new ExcludingReturnOldestProcessor( map, max,
                                                                entry => true,
                                                                entry => entry.PlayerID == pid );
            } else {
                processor = new ReturnOldestProcessor( map, max,
                                                       entry => entry.PlayerID == pid );
            }
            Traverse( processor );
            return processor.GetResults();
        }
Пример #5
0
        public BlockDBEntry[] Lookup( int max, [NotNull] BoundingBox area, [NotNull] PlayerInfo[] infos, bool exclude, TimeSpan span ) {
            if( area == null ) throw new ArgumentNullException( "area" );
            if( infos == null ) throw new ArgumentNullException( "infos" );
            if( infos.Length == 0 ) throw new ArgumentException( "At least one PlayerInfo must be given", "infos" );
            if( span < TimeSpan.Zero ) throw new ArgumentOutOfRangeException( "span" );
            if( infos.Length == 1 ) return Lookup( max, area, infos[0], exclude, span );
            long ticks = DateTime.UtcNow.Subtract( span ).ToUnixTime();
            Map map = World.LoadMap();

            IBlockDBQueryProcessor processor;
            if( exclude ) {
                // ReSharper disable ImplicitlyCapturedClosure
                processor = new ExcludingReturnOldestProcessor( map, max,
                                                                entry => entry.Timestamp >= ticks &&
                                                                         area.Contains( entry.X, entry.Y, entry.Z ),
                                                                entry => infos.Any( t => entry.PlayerID == t.ID ) );
                // ReSharper restore ImplicitlyCapturedClosure
            } else {
                processor = new ReturnOldestProcessor( map, max,
                                                       entry => entry.Timestamp >= ticks &&
                                                                area.Contains( entry.X, entry.Y, entry.Z ) &&
                                                                infos.Any( t => entry.PlayerID == t.ID ) );
            }
            Traverse( processor );
            return processor.GetResults();
        }
Пример #6
0
        public BlockDBEntry[] Lookup( int max, [NotNull] BoundingBox area, [NotNull] PlayerInfo[] infos, bool exclude ) {
            if( area == null ) throw new ArgumentNullException( "area" );
            if( infos == null ) throw new ArgumentNullException( "infos" );
            if( infos.Length == 0 ) throw new ArgumentException( "At least one PlayerInfo must be given", "infos" );
            if( infos.Length == 1 ) return Lookup( max, area, infos[0], exclude );
            Map map = World.LoadMap();

            IBlockDBQueryProcessor processor;
            if( exclude ) {
                // ReSharper disable ImplicitlyCapturedClosure
                processor = new ExcludingReturnOldestProcessor( map, max,
                                                                entry => area.Contains( entry.X, entry.Y, entry.Z ),
                                                                entry => infos.Any( t => entry.PlayerID == t.ID ) );
                // ReSharper restore ImplicitlyCapturedClosure
            } else {
                processor = new ReturnOldestProcessor( map, max,
                                                       entry => area.Contains( entry.X, entry.Y, entry.Z ) &&
                                                                infos.Any( t => entry.PlayerID == t.ID ) );
            }
            Traverse( processor );
            return processor.GetResults();
        }
Пример #7
0
        public BlockDBEntry[] Lookup( int max, [NotNull] BoundingBox area, [NotNull] PlayerInfo info, bool exclude, TimeSpan span ) {
            if( area == null ) throw new ArgumentNullException( "area" );
            if( info == null ) throw new ArgumentNullException( "info" );
            if( span < TimeSpan.Zero ) throw new ArgumentOutOfRangeException( "span" );
            int pid = info.ID;
            long ticks = DateTime.UtcNow.Subtract( span ).ToUnixTime();
            Map map = World.LoadMap();

            IBlockDBQueryProcessor processor;
            if( exclude ) {
                // ReSharper disable ImplicitlyCapturedClosure
                processor = new ExcludingReturnOldestProcessor( map, max,
                                                                entry => entry.Timestamp >= ticks &&
                                                                         area.Contains( entry.X, entry.Y, entry.Z ),
                                                                entry => entry.PlayerID == pid );
                // ReSharper restore ImplicitlyCapturedClosure
            } else {
                processor = new ReturnOldestProcessor( map, max,
                                                       entry => entry.Timestamp >= ticks &&
                                                                entry.PlayerID == pid &&
                                                                area.Contains( entry.X, entry.Y, entry.Z ) );
            }
            Traverse( processor );
            return processor.GetResults();
        }
Пример #8
0
        public BlockDBEntry[] Lookup( int max, [NotNull] BoundingBox area, [NotNull] PlayerInfo info, bool exclude ) {
            if( area == null ) throw new ArgumentNullException( "area" );
            if( info == null ) throw new ArgumentNullException( "info" );
            int pid = info.ID;
            Map map = World.LoadMap();

            IBlockDBQueryProcessor processor;
            if( exclude ) {
                // ReSharper disable ImplicitlyCapturedClosure
                processor = new ExcludingReturnOldestProcessor( map, max,
                                                                entry => area.Contains( entry.X, entry.Y, entry.Z ),
                                                                entry => entry.PlayerID == pid );
                // ReSharper restore ImplicitlyCapturedClosure
            } else {
                processor = new ReturnOldestProcessor( map, max,
                                                       entry => area.Contains( entry.X, entry.Y, entry.Z ) &&
                                                                entry.PlayerID == pid );
            }
            Traverse( processor );
            return processor.GetResults();
        }