示例#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;
 }