fCraft.World.EndFlushMapBuffer C# (CSharp) Method

EndFlushMapBuffer() private method

private EndFlushMapBuffer ( ) : void
return void
        internal void EndFlushMapBuffer()
        {
            lock ( SyncRoot ) {
                IsFlushing = false;
                Players.Message( "&WMap flushed. Reloading..." );
                foreach ( Player player in Players ) {
                    player.JoinWorld( this, WorldChangeReason.Rejoin, player.Position );
                }
            }
        }

Usage Example

Example #1
0
        // Applies pending updates and sends them to players (if applicable).
        internal void ProcessUpdates()
        {
            if (World == null)
            {
                throw new InvalidOperationException("Map must be assigned to a world to process updates.");
            }

            if (World.IsLocked)
            {
                if (World.IsPendingMapUnload)
                {
                    World.UnloadMap(true);
                }
                return;
            }

            int  packetsSent         = 0;
            bool canFlush            = false;
            int  maxPacketsPerUpdate = Server.CalculateMaxPacketsPerUpdate(World);

            while (packetsSent < maxPacketsPerUpdate)
            {
                BlockUpdate update;
                if (!updates.TryDequeue(out update))
                {
                    if (World.IsFlushing)
                    {
                        canFlush = true;
                    }
                    break;
                }
                if (!InBounds(update.X, update.Y, update.Z))
                {
                    continue;
                }
                int blockIndex = Index(update.X, update.Y, update.Z);
                Blocks[blockIndex] = (byte)update.BlockType;

                if (!World.IsFlushing)
                {
                    //non classicube players get fallbacks instead of the real blocks
                    Packet packet  = PacketWriter.MakeSetBlock(update.X, update.Y, update.Z, update.BlockType);
                    Packet packet2 = PacketWriter.MakeSetBlock(update.X, update.Y, update.Z, Map.GetFallbackBlock(update.BlockType));

                    World.Players.Where(p => p.usesCPE).SendLowPriority(update.Origin, packet);
                    World.Players.Where(p => !p.usesCPE).SendLowPriority(update.Origin, packet2);
                }
                packetsSent++;
            }

            if (drawOps.Count > 0)
            {
                lock ( drawOpLock ) {
                    if (drawOps.Count > 0)
                    {
                        packetsSent += ProcessDrawOps(maxPacketsPerUpdate - packetsSent);
                    }
                }
            }
            else if (canFlush)
            {
                World.EndFlushMapBuffer();
            }

            if (packetsSent == 0 && World.IsPendingMapUnload)
            {
                World.UnloadMap(true);
            }
        }
All Usage Examples Of fCraft.World::EndFlushMapBuffer