Esempio n. 1
0
        /// <summary>
        /// Internal region call only.
        /// </summary>
        public void MakeVBONow()
        {
            if (SucceededBy != null)
            {
                SucceededBy.MakeVBONow();
                return;
            }
            Chunk        c_zp       = OwningRegion.GetChunk(WorldPosition + new Vector3i(0, 0, 1));
            Chunk        c_zm       = OwningRegion.GetChunk(WorldPosition + new Vector3i(0, 0, -1));
            Chunk        c_yp       = OwningRegion.GetChunk(WorldPosition + new Vector3i(0, 1, 0));
            Chunk        c_ym       = OwningRegion.GetChunk(WorldPosition + new Vector3i(0, -1, 0));
            Chunk        c_xp       = OwningRegion.GetChunk(WorldPosition + new Vector3i(1, 0, 0));
            Chunk        c_xm       = OwningRegion.GetChunk(WorldPosition + new Vector3i(-1, 0, 0));
            Chunk        c_zpxp     = OwningRegion.GetChunk(WorldPosition + new Vector3i(0, 1, 1));
            Chunk        c_zpxm     = OwningRegion.GetChunk(WorldPosition + new Vector3i(0, -1, 1));
            Chunk        c_zpyp     = OwningRegion.GetChunk(WorldPosition + new Vector3i(1, 0, 1));
            Chunk        c_zpym     = OwningRegion.GetChunk(WorldPosition + new Vector3i(-1, 0, 1));
            List <Chunk> potentials = new List <Chunk>();

            for (int x = -1; x <= 1; x++)
            {
                for (int y = -1; y <= 1; y++)
                {
                    for (int z = -1; z <= 1; z++)
                    {
                        Chunk tch = OwningRegion.GetChunk(WorldPosition + new Vector3i(x, y, z));
                        if (tch != null)
                        {
                            potentials.Add(tch);
                        }
                    }
                }
            }
            Action a = () => VBOHInternal(c_zp, c_zm, c_yp, c_ym, c_xp, c_xm, c_zpxp, c_zpxm, c_zpyp, c_zpym, potentials);

            if (rendering != null)
            {
                ASyncScheduleItem item = OwningRegion.TheClient.Schedule.AddASyncTask(a);
                rendering = rendering.ReplaceOrFollowWith(item);
            }
            else
            {
                rendering = OwningRegion.TheClient.Schedule.StartASyncTask(a);
            }
        }
Esempio n. 2
0
 public void ReadPage(string page, Action callback = null)
 {
     Scheduled = TheClient.Schedule.StartAsyncTask(() =>
     {
         Process p = null;
         if (!Terminates)
         {
             page = "{T}" + page;
         }
         if (IsLinux)
         {
             p = StartProc("mono", "VoxaliaBrowser.exe " + page);
         }
         else
         {
             try
             {
                 p = StartProc("VoxaliaBrowser.exe", page);
             }
             catch (Exception ex)
             {
                 SysConsole.Output("Loading a browser page", ex);
             }
             if (p == null)
             {
                 IsLinux = true;
                 p       = StartProc("mono", "VoxaliaBrowser.exe " + page);
             }
         }
         Current             = p;
         TheClient.OnClosed += CleanUp;
         StreamReader sr     = p.StandardOutput;
         bool first          = true;
         while (!Terminates || first)
         {
             first           = false;
             byte[] lenbytes = new byte[4];
             int pos         = 0;
             while (pos < 4)
             {
                 pos += sr.BaseStream.Read(lenbytes, pos, lenbytes.Length - pos);
             }
             int len = BitConverter.ToInt32(lenbytes, 0);
             if (len < 0 || len > 1024 * 1024 * 64)
             {
                 SysConsole.Output(OutputType.WARNING, "Failed to read browser drawn view, invalid length: " + len);
                 return;
             }
             byte[] resbytes = new byte[len];
             pos             = 0;
             while (pos < len)
             {
                 pos += sr.BaseStream.Read(resbytes, pos, len - pos);
             }
             DataStream ds = new DataStream(resbytes);
             Image img     = Bitmap.FromStream(ds, false, false);
             Bitmap bmp    = new Bitmap(img);
             TheClient.Schedule.ScheduleSyncTask(() =>
             {
                 Loops++;
                 if (Bitmap != null)
                 {
                     Bitmap.Dispose();
                 }
                 Bitmap = bmp;
                 callback?.Invoke();
             });
         }
         CleanUp();
         TheClient.OnClosed -= CleanUp;
     });
 }