Exemplo n.º 1
0
        public static void Frame(Int32 msec)
        {
            try
            {
                if (Globals.log_stats.modified)
                {
                    Globals.log_stats.modified = false;
                    if (Globals.log_stats.value != 0F)
                    {
                        if (Globals.log_stats_file != null)
                        {
                            try
                            {
                                Globals.log_stats_file.Close();
                            }
                            catch (IOException e)
                            {
                            }

                            Globals.log_stats_file = null;
                        }

                        try
                        {
                            Globals.log_stats_file = new QuakeFile("stats.log", FileAccess.ReadWrite);
                        }
                        catch (IOException e)
                        {
                            Globals.log_stats_file = null;
                        }

                        if (Globals.log_stats_file != null)
                        {
                            try
                            {
                                var bytes = Encoding.ASCII.GetBytes("entities,dlights,parts,frame time\\n");
                                Globals.log_stats_file.Write(bytes);
                            }
                            catch (IOException e)
                            {
                            }
                        }
                    }
                    else
                    {
                        if (Globals.log_stats_file != null)
                        {
                            try
                            {
                                Globals.log_stats_file.Close();
                            }
                            catch (IOException e)
                            {
                            }

                            Globals.log_stats_file = null;
                        }
                    }
                }

                if (Globals.fixedtime.value != 0F)
                {
                    msec = ( Int32 )Globals.fixedtime.value;
                }
                else if (Globals.timescale.value != 0F)
                {
                    msec = ( Int32 )(msec * Globals.timescale.value);
                    if (msec < 1)
                    {
                        msec = 1;
                    }
                }

                if (Globals.showtrace.value != 0F)
                {
                    Com.Printf("%4i traces  %4i points\\n", Globals.c_traces, Globals.c_pointcontents);
                    Globals.c_traces        = 0;
                    Globals.c_brush_traces  = 0;
                    Globals.c_pointcontents = 0;
                }

                Cbuf.Execute();
                var time_before  = 0;
                var time_between = 0;
                var time_after   = 0;
                if (Globals.host_speeds.value != 0F)
                {
                    time_before = Timer.Milliseconds();
                }
                Com.debugContext = "SV:";
                SV_MAIN.SV_Frame(msec);
                if (Globals.host_speeds.value != 0F)
                {
                    time_between = Timer.Milliseconds();
                }
                Com.debugContext = "CL:";
                CL.Frame(msec);
                if (Globals.host_speeds.value != 0F)
                {
                    time_after = Timer.Milliseconds();
                    var all = time_after - time_before;
                    var sv  = time_between - time_before;
                    var cl  = time_after - time_between;
                    var gm  = Globals.time_after_game - Globals.time_before_game;
                    var rf  = Globals.time_after_ref - Globals.time_before_ref;
                    sv -= gm;
                    cl -= rf;
                    Com.Printf("all:%3i sv:%3i gm:%3i cl:%3i rf:%3i\\n", all, sv, gm, cl, rf);
                }
            }
            catch (longjmpException e)
            {
                Com.DPrintf("longjmp exception:" + e);
            }
        }
Exemplo n.º 2
0
        /**
         * Trigger generation of a frame for the given time. The setjmp/longjmp
         * mechanism of the original was replaced with exceptions.
         * @param msec the current game time
         */
        public static void FrameUpdate(int msec)
        {
            try
            {
                if (Globals.log_stats.modified)
                {
                    Globals.log_stats.modified = false;

                    if (Globals.log_stats.value != 0.0f)
                    {
                        if (Globals.log_stats_file != null)
                        {
                            try
                            {
                                Globals.log_stats_file.Close();
                            }
                            catch (Exception)
                            {
                            }

                            Globals.log_stats_file = null;
                        }

                        try
                        {
                            Globals.log_stats_file = File.CreateText("stats.log");
                        }
                        catch (Exception)
                        {
                            Globals.log_stats_file = null;
                        }

                        if (Globals.log_stats_file != null)
                        {
                            try
                            {
                                Globals.log_stats_file.Write("entities,dlights,parts,frame time\n");
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                    else
                    {
                        if (Globals.log_stats_file != null)
                        {
                            try
                            {
                                Globals.log_stats_file.Close();
                            }
                            catch (Exception)
                            {
                            }

                            Globals.log_stats_file = null;
                        }
                    }
                }

                if (Globals.fixedtime.value != 0.0f)
                {
                    msec = (int)Globals.fixedtime.value;
                }
                else if (Globals.timescale.value != 0.0f)
                {
                    msec = (int)(msec * Globals.timescale.value);

                    if (msec < 1)
                    {
                        msec = 1;
                    }
                }

                if (Globals.showtrace.value != 0.0f)
                {
                    Com.Printf("%4i traces  %4i points\n", Globals.c_traces, Globals.c_pointcontents);

                    Globals.c_traces        = 0;
                    Globals.c_brush_traces  = 0;
                    Globals.c_pointcontents = 0;
                }

                Cbuf.Execute();

                var time_before = 0;
                var time_after  = 0;

                if (Globals.host_speeds.value != 0.0f)
                {
                    time_before = Timer.Milliseconds();
                }

                Com.debugContext = "SV:";
                SV_MAIN.SV_Frame(msec);

                if (Globals.host_speeds.value != 0.0f)
                {
                    time_after = Timer.Milliseconds();

                    var sv = time_after - time_before;
                    var gm = Globals.time_after_game - Globals.time_before_game;
                    var rf = Globals.time_after_ref - Globals.time_before_ref;
                    sv -= gm;

                    Com.Printf("update:%3i gm:%3i rf:%3i\n", sv, gm, rf);
                }
            }
            catch (Exception e)
            {
                Com.DPrintf("exception:" + e);
            }
        }