Exemplo n.º 1
0
        /// <summary>
        /// End section
        /// </summary>
        public static void EndSection()
        {
            if (!ProfilingEnabled)
            {
                return;
            }

            long l  = JavaHelper.NanoTime();
            long l1 = TimestampList[TimestampList.Count - 1];

            TimestampList.RemoveAt(TimestampList.Count - 1);
            SectionList.RemoveAt(SectionList.Count - 1);
            long l2 = l - l1;

            if (ProfilingMap.ContainsKey(ProfilingSection))
            {
                ProfilingMap[ProfilingSection] = (long)((long?)ProfilingMap[ProfilingSection]) + l2;
            }
            else
            {
                ProfilingMap[ProfilingSection] = l2;
            }

            ProfilingSection = SectionList.Count <= 0 ? "" : (string)SectionList[SectionList.Count - 1];

            if (l2 > 0x5f5e100L)
            {
                Console.WriteLine((new StringBuilder()).Append(ProfilingSection).Append(" ").Append(l2).ToString());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Start section
        /// </summary>
        public static void StartSection(string par0Str)
        {
            if (!ProfilingEnabled)
            {
                return;
            }

            if (ProfilingSection.Length > 0)
            {
                ProfilingSection = (new StringBuilder()).Append(ProfilingSection).Append(".").ToString();
            }

            ProfilingSection = (new StringBuilder()).Append(ProfilingSection).Append(par0Str).ToString();
            SectionList.Add(ProfilingSection);
            TimestampList.Add(Convert.ToInt64(JavaHelper.NanoTime()));
        }
        protected override void DrawSlot(int par1, int par2, int par3, int par4, Tessellator par5Tessellator)
        {
            ServerNBTStorage servernbtstorage = GuiMultiplayer.GetServerList(ParentGui)[par1];

            lock (GuiMultiplayer.GetLock())
            {
                if (GuiMultiplayer.GetThreadsPending() < 5 && !servernbtstorage.Polled)
                {
                    servernbtstorage.Polled      = true;
                    servernbtstorage.Lag         = -2L;
                    servernbtstorage.Motd        = "";
                    servernbtstorage.PlayerCount = "";
                    GuiMultiplayer.IncrementThreadsPending();

                    Action pollServers = () =>
                    {
                        try
                        {
                            servernbtstorage.Motd = "Polling..";
                            long l = JavaHelper.NanoTime();
                            GuiMultiplayer.PollServer(ParentGui, servernbtstorage);
                            long l1 = JavaHelper.NanoTime();
                            servernbtstorage.Lag = (l1 - l) / 0xf4240L;
                        }
                        catch (SocketException sockettimeoutexception)
                        {
                            Utilities.LogException(sockettimeoutexception);

                            servernbtstorage.Lag  = -1L;
                            servernbtstorage.Motd = "Can't reach server";
                        }
                        catch (IOException ioexception)
                        {
                            Utilities.LogException(ioexception);

                            servernbtstorage.Lag  = -1L;
                            servernbtstorage.Motd = "Communication error";
                        }
                        catch (Exception exception)
                        {
                            Utilities.LogException(exception);

                            servernbtstorage.Lag  = -1L;
                            servernbtstorage.Motd = (new StringBuilder()).Append("ERROR: ").Append(exception.GetType()).ToString();
                        }
                        finally
                        {
                            lock (GuiMultiplayer.GetLock())
                            {
                                GuiMultiplayer.DecrementThreadsPending();
                            }
                        }
                    };

                    new Thread(new ThreadStart(pollServers)).Start();
                }
            }

            ParentGui.DrawString(ParentGui.FontRenderer, servernbtstorage.Name, par2 + 2, par3 + 1, 0xffffff);
            ParentGui.DrawString(ParentGui.FontRenderer, servernbtstorage.Motd, par2 + 2, par3 + 12, 0x808080);
            ParentGui.DrawString(ParentGui.FontRenderer, servernbtstorage.PlayerCount, (par2 + 215) - (int)ParentGui.FontRenderer.GetStringWidth(servernbtstorage.PlayerCount), par3 + 12, 0x808080);
            ParentGui.DrawString(ParentGui.FontRenderer, servernbtstorage.Host, par2 + 2, par3 + 12 + 11, 0x303030);
            //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F);
            ParentGui.Mc.RenderEngine.BindTexture("gui.icons.png");
            string s = "";
            int    i;
            int    j;

            if (servernbtstorage.Polled && servernbtstorage.Lag != -2L)
            {
                i = 0;
                j = 0;

                if (servernbtstorage.Lag < 0L)
                {
                    j = 5;
                }
                else if (servernbtstorage.Lag < 150L)
                {
                    j = 0;
                }
                else if (servernbtstorage.Lag < 300L)
                {
                    j = 1;
                }
                else if (servernbtstorage.Lag < 600L)
                {
                    j = 2;
                }
                else if (servernbtstorage.Lag < 1000L)
                {
                    j = 3;
                }
                else
                {
                    j = 4;
                }

                if (servernbtstorage.Lag < 0L)
                {
                    s = "(no connection)";
                }
                else
                {
                    s = (new StringBuilder()).Append(servernbtstorage.Lag).Append("ms").ToString();
                }
            }
            else
            {
                i = 1;
                j = (int)(JavaHelper.CurrentTimeMillis() / 100L + (long)(par1 * 2) & 7L);

                if (j > 4)
                {
                    j = 8 - j;
                }

                s = "Polling..";
            }

            ParentGui.DrawTexturedModalRect(par2 + 205, par3, 0 + i * 10, 176 + j * 8, 10, 8);
            sbyte byte0 = 4;

            if (MouseX >= (par2 + 205) - byte0 && MouseY >= par3 - byte0 && MouseX <= par2 + 205 + 10 + byte0 && MouseY <= par3 + 8 + byte0)
            {
                GuiMultiplayer.SetTooltipText(ParentGui, s);
            }
        }