예제 #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);
            }
        }
예제 #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;
            }
        }
예제 #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 );
     }
 }
예제 #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;
     }
 }
예제 #5
0
파일: BlockDB.cs 프로젝트: fragmer/fCraft
 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();
     }
 }
예제 #6
0
파일: BlockDB.cs 프로젝트: fragmer/fCraft
 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;
 }
예제 #7
0
파일: BlockDB.cs 프로젝트: fragmer/fCraft
 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;
 }
예제 #8
0
파일: BlockDB.cs 프로젝트: fragmer/fCraft
 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;
 }
예제 #9
0
파일: BlockDB.cs 프로젝트: fragmer/fCraft
 public bool ProcessEntry( BlockDBEntry entry ) {
     if( selector( entry ) ) {
         result.Add( entry );
         count++;
         if( count >= max ) {
             return false;
         }
     }
     return true;
 }