Esempio n. 1
0
        static void OnPlayerPlacedBlock(object sender, [NotNull] PlayerPlacedBlockEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }
            World world = e.Map.World;

            if (world != null && world.BlockDB.IsEnabled)
            {
                BlockDBEntry newEntry = new BlockDBEntry((int)DateTime.UtcNow.ToUnixTime(),
                                                         e.Player.Info.ID,
                                                         e.Coords,
                                                         e.OldBlock,
                                                         e.NewBlock,
                                                         e.Context);
                world.BlockDB.AddEntry(newEntry);
            }
        }
Esempio n. 2
0
                  CacheLinearResizeThreshold = 64 * 1024; // 1 MB (at 16 bytes/entry)

        void AddEntry(BlockDBEntry item)
        {
            lock ( SyncRoot ) {
                if (CacheSize == cacheStore.Length)
                {
                    if (!isPreloaded && CacheSize >= CacheLinearResizeThreshold)
                    {
                        // Avoid bloating the cacheStore if we are not preloaded.
                        // This might cause lag spikes, since it's ran from main scheduler thread.
                        Flush();
                    }
                    else
                    {
                        // resize cache to fit
                        EnsureCapacity(CacheSize + 1);
                    }
                }
                cacheStore[CacheSize++] = item;
            }
        }
Esempio n. 3
0
 static void OnPlayerPlacedBlock( object sender, [NotNull] PlayerPlacedBlockEventArgs e )
 {
     if( e == null ) throw new ArgumentNullException( "e" );
     World world = e.Map.World;
     if( world != null && world.BlockDB.IsEnabled ) {
         BlockDBEntry newEntry = new BlockDBEntry( (int)DateTime.UtcNow.ToUnixTime(),
                                                   e.Player.Info.ID,
                                                   e.Coords,
                                                   e.OldBlock,
                                                   e.NewBlock,
                                                   e.Context );
         world.BlockDB.AddEntry( newEntry );
     }
 }
Esempio n. 4
0
 void AddEntry( BlockDBEntry item )
 {
     lock( SyncRoot ) {
         if( CacheSize == cacheStore.Length ) {
             if( !isPreloaded && CacheSize >= CacheLinearResizeThreshold ) {
                 // Avoid bloating the cacheStore if we are not preloaded.
                 // This might cause lag spikes, since it's ran from main scheduler thread.
                 Flush();
             } else {
                 // resize cache to fit
                 EnsureCapacity( CacheSize + 1 );
             }
         }
         cacheStore[CacheSize++] = item;
     }
 }
Esempio n. 5
0
 void AddEntry( BlockDBEntry item ) {
     try {
         locker.EnterUpgradeableReadLock();
         if( CacheSize == cacheStore.Length ) {
             using( locker.WriteLock() ) {
                 if( !isPreloaded && CacheSize >= CacheLinearResizeThreshold ) {
                     // Avoid bloating the cacheStore if we are not preloaded.
                     // This might cause lag spikes, since it's ran from main scheduler thread.
                     Flush( false );
                 } else {
                     // resize cache to fit
                     EnsureCapacity( CacheSize + 1 );
                 }
             }
         }
         cacheStore[CacheSize++] = item;
     } finally {
         locker.ExitUpgradeableReadLock();
     }
 }
Esempio n. 6
0
 public bool ProcessEntry( BlockDBEntry entry ) {
     if( inclusionSelector( entry ) ) {
         int index = map.Index( entry.X, entry.Y, entry.Z );
         if( !excluded.Contains( index ) ) {
             if( exclusionSelector( entry ) ) {
                 excluded.Add( index );
             } else {
                 result[index] = entry;
             }
             count++;
             if( count >= max ) {
                 return false;
             }
         }
     }
     return true;
 }
Esempio n. 7
0
 public bool ProcessEntry( BlockDBEntry entry ) {
     if( selector( entry ) ) {
         int index = map.Index( entry.X, entry.Y, entry.Z );
         if( !result.ContainsKey( index ) ) {
             result.Add( index, entry );
         }
         count++;
         if( count >= max ) {
             return false;
         }
     }
     return true;
 }
Esempio n. 8
0
 public bool ProcessEntry( BlockDBEntry entry ) {
     if( selector( entry ) ) {
         int index = map.Index( entry.X, entry.Y, entry.Z );
         result[index] = entry;
         count++;
         if( count >= max ) {
             return false;
         }
     }
     return true;
 }
Esempio n. 9
0
 public bool ProcessEntry( BlockDBEntry entry ) {
     if( selector( entry ) ) {
         result.Add( entry );
         count++;
         if( count >= max ) {
             return false;
         }
     }
     return true;
 }