Example #1
0
        void Process(Level lvl)
        {
            try {
                if (Count == 0)
                {
                    return;
                }
                if (!lvl.HasPlayers())
                {
                    Clear(); return;
                }

                bulkSender.level = lvl;
                int count = Count;
                if (count > UpdatesPerTick)
                {
                    count = UpdatesPerTick;
                }

                for (int i = 0; i < count; i++)
                {
                    ulong   flags = this[i];
                    int     index = (int)(flags >> posShift);
                    BlockID block = (BlockID)(flags & blockMask);
                    bulkSender.Add(index, block);
                }
                bulkSender.Send(true);
                RemoveRange(0, count);
            } catch (Exception e)  {
                Logger.LogError(e);
                Logger.Log(LogType.Warning, "Block cache failed for map: {0}. {1} lost.", lvl.name, Count);
                Clear();
            }
        }
Example #2
0
        static void ProcessLevelBlocks(Level lvl)
        {
            try {
                if (lvl.blockqueue.Count < 1)
                {
                    return;
                }
                bulkSender.level = lvl;
                int count = blockupdates;
                if (lvl.blockqueue.Count < blockupdates || !lvl.HasPlayers())
                {
                    count = lvl.blockqueue.Count;
                }

                for (int i = 0; i < count; i++)
                {
                    ulong flags    = lvl.blockqueue[i];
                    int   index    = (int)(flags >> 32);
                    byte  block    = (flags & 0x100) != 0 ? Block.custom_block : (byte)flags;
                    byte  extBlock = (flags & 0x100) != 0 ? (byte)flags : Block.air;
                    bulkSender.Add(index, block, extBlock);
                }
                bulkSender.Send(true);
                lvl.blockqueue.RemoveRange(0, count);
            } catch (Exception e)  {
                Server.s.ErrorCase("error:" + e);
                Server.s.Log(String.Format("Block cache failed for map: {0}. {1} lost.", lvl.name, lvl.blockqueue.Count));
                lvl.blockqueue.Clear();
            }
        }
Example #3
0
        static void ProcessLevelBlocks(Level lvl)
        {
            try {
                if (lvl.blockqueue.Count == 0)
                {
                    return;
                }
                if (!lvl.HasPlayers())
                {
                    lvl.blockqueue.Clear(); return;
                }

                bulkSender.level = lvl;
                int count = blockupdates;
                if (lvl.blockqueue.Count < blockupdates)
                {
                    count = lvl.blockqueue.Count;
                }

                for (int i = 0; i < count; i++)
                {
                    ulong flags    = lvl.blockqueue[i];
                    int   index    = (int)(flags >> 32);
                    byte  block    = (flags & 0x100) != 0 ? Block.custom_block : (byte)flags;
                    byte  extBlock = (flags & 0x100) != 0 ? (byte)flags : Block.Air;
                    bulkSender.Add(index, block, extBlock);
                }
                bulkSender.Send(true);
                lvl.blockqueue.RemoveRange(0, count);
            } catch (Exception e)  {
                Logger.LogError(e);
                Logger.Log(LogType.Warning, "Block cache failed for map: {0}. {1} lost.", lvl.name, lvl.blockqueue.Count);
                lvl.blockqueue.Clear();
            }
        }