Skip to content

Commit

Permalink
Fixed demo doctor
Browse files Browse the repository at this point in the history
  • Loading branch information
Traderain committed Nov 30, 2016
1 parent 0cc380d commit 72943b2
Show file tree
Hide file tree
Showing 10 changed files with 359 additions and 188 deletions.
Binary file modified .vs/VolvoWrench/v14/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion VolvoWrench/DG/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private static void Main()
Application.SetCompatibleTextRenderingDefault(false);
if (Environment.GetCommandLineArgs().Any(x => Path.GetExtension(x) == ".dem" || Path.GetExtension(x) == ".sav"))
if (Environment.GetCommandLineArgs().Any(x => Path.GetExtension(x) == ".dem"))
Application.Run(new Main(Environment.GetCommandLineArgs().First(x => Path.GetExtension(x) == ".dem")));
Application.Run(new Main());
else if (Environment.GetCommandLineArgs().Any(x => Path.GetExtension(x) == ".sav"))
Application.Run(new saveanalyzerform(Environment.GetCommandLineArgs().First(x => Path.GetExtension(x) == ".sav")));
else
Expand Down
4 changes: 3 additions & 1 deletion VolvoWrench/DG/Roadmap.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
- Statefile decompressor
- Demo doctor fix
- Demo doctor fix -> Done
- Statistics : Nearly done
- HTML Display instead of the richtextbox
- High performance mode fix for Griffin -> wontix kek
- Verification check if broken demo -> Done
4 changes: 2 additions & 2 deletions VolvoWrench/Demo stuff/GoldSource/Demo doctor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ private void button2_Click(object sender, EventArgs e)
{
StartInfo = new ProcessStartInfo(path)
{
Arguments = DemoFile + " " + sf.FileName,
Arguments = "\""+ DemoFile + "\"" + " " + "\"" + sf.FileName + "\"",
WorkingDirectory = Path.GetTempPath(),
CreateNoWindow = true,
UseShellExecute = false
}
};
p.Start();
var output = p.StandardOutput.ReadToEnd();

p.WaitForExit();
File.Delete(path);
if(File.Exists(sf.FileName))
Expand Down
59 changes: 57 additions & 2 deletions VolvoWrench/Demo stuff/GoldSource/GoldSourceParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace VolvoWrench.Demo_stuff.GoldSource
{
/// <summary>
/// Types for HLSOOE
/// </summary>
public class Hlsooe
{
public enum DemoFrameType
Expand Down Expand Up @@ -137,7 +140,9 @@ public class DemoDirectoryEntry
public Dictionary<DemoFrame,ConsoleCommandFrame> Flags;
}
}

/// <summary>
/// Types for goldsource
/// </summary>
public class GoldSource
{
public enum DemoFrameType
Expand Down Expand Up @@ -434,13 +439,35 @@ public struct MoveVars
}
}


/// <summary>
/// Aditional demo stats
/// </summary>
public struct stats
{
public float FrametimeMin;
public float FrametimeMax;
public double FrametimeSum;
public int Count;
public int MsecMin;
public int MsecMax;
public long MsecSum;
}

/// <summary>
/// Info class about normal GoldSource engine demos
/// </summary>
public struct GoldSourceDemoInfo
{
public List<GoldSource.DemoDirectoryEntry> DirectoryEntries;
public stats AditionalStats;
public GoldSource.DemoHeader Header;
public List<string> ParsingErrors;
}

/// <summary>
/// Info class about HLSOOE Demos
/// </summary>
public class GoldSourceDemoInfoHlsooe
{
public List<Hlsooe.DemoDirectoryEntry> DirectoryEntries;
Expand All @@ -451,7 +478,12 @@ public class GoldSourceDemoInfoHlsooe
public class GoldSourceParser
{


/// <summary>
/// This checks if we are will be past the end of the file if we read lengthtocheck
/// </summary>
/// <param name="b"></param>
/// <param name="lengthtocheck"></param>
/// <returns></returns>
public static bool UnexpectedEof(BinaryReader b, long lengthtocheck)
{
return (b.BaseStream.Position + lengthtocheck) > b.BaseStream.Length;
Expand Down Expand Up @@ -1124,6 +1156,29 @@ public static GoldSourceDemoInfo ParseGoldSourceDemo(string s)
Main.Log("Exception happened in the goldsource parser: " + e.Message);
gDemo.ParsingErrors.Add(e.Message);
}
var first = true;
foreach (var f in from entry in gDemo.DirectoryEntries from frame in entry.Frames where (int)frame.Key.Type < 2 || (int)frame.Key.Type > 9 select (GoldSource.NetMsgFrame)frame.Value)
{
gDemo.AditionalStats.FrametimeSum += f.RParms.Frametime;
gDemo.AditionalStats.MsecSum += f.UCmd.Msec;
gDemo.AditionalStats.Count++;

if (first)
{
first = false;
gDemo.AditionalStats.FrametimeMin = f.RParms.Frametime;
gDemo.AditionalStats.FrametimeMax = f.RParms.Frametime;
gDemo.AditionalStats.MsecMin = f.UCmd.Msec;
gDemo.AditionalStats.MsecMax = f.UCmd.Msec;
}
else
{
gDemo.AditionalStats.FrametimeMin = Math.Min(gDemo.AditionalStats.FrametimeMin, f.RParms.Frametime);
gDemo.AditionalStats.FrametimeMax = Math.Max(gDemo.AditionalStats.FrametimeMax, f.RParms.Frametime);
gDemo.AditionalStats.MsecMin = Math.Min(gDemo.AditionalStats.MsecMin, f.UCmd.Msec);
gDemo.AditionalStats.MsecMax = Math.Max(gDemo.AditionalStats.MsecMax, f.UCmd.Msec);
}
}
return gDemo;
}
}
Expand Down
69 changes: 17 additions & 52 deletions VolvoWrench/Demo stuff/GoldSource/Verification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ public void Verify(string[] files)
mrtb.Refresh();
Application.DoEvents();
}
if (Df.Any(x => x.Value.GsDemoInfo.ParsingErrors.Count > 0))
{
var brokendemos = Df.Where(x => x.Value.GsDemoInfo.ParsingErrors.Count > 0)
.ToList()
.Aggregate("", (c, n) => c += "\n" + n.Key);
MessageBox.Show(@"Broken demos found:
" + brokendemos,@"Error!",MessageBoxButtons.OK);
Main.Log("Broken demos when verification: " + brokendemos);
mrtb.Text = @"Please fix the demos then reselect the files!";
return;
}
if (Df.Any(x => x.Value.Type != Parseresult.GoldSource))
MessageBox.Show(@"Only goldsource supported");
else
Expand All @@ -96,59 +107,13 @@ public void Verify(string[] files)
mrtb.AppendText("" + "\n");
mrtb.AppendText("Parsed demos. Results:" + "\n");
mrtb.AppendText("General stats:" + "\n");
var frametimeMax = new List<float>();
var frametimeMin = new List<float>();
var frametimeSum = new List<double>();
var msecMin = new List<double>();
var msecMax = new List<double>();
var avgmsec = new List<double>();
foreach (var d in Df)
{
float ftm = 0f, ftmx = 0f;
var fts = 0.0;
var count = 0;
int mm = 0, mmx = 0;
long msecSum = 0;
var first = true;
foreach (var f in from entry in d.Value.GsDemoInfo.DirectoryEntries
from frame in entry.Frames
where (int)frame.Key.Type < 2 || (int)frame.Key.Type > 9
select (GoldSource.NetMsgFrame)frame.Value)
{
fts += f.RParms.Frametime;
msecSum += f.UCmd.Msec;
count++;

if (first)
{
first = false;
ftm = f.RParms.Frametime;
ftmx = f.RParms.Frametime;
mm = f.UCmd.Msec;
mmx = f.UCmd.Msec;
}
else
{
ftm = Math.Min(ftm, f.RParms.Frametime);
ftmx = Math.Max(ftmx, f.RParms.Frametime);
mm = Math.Min(mm, f.UCmd.Msec);
mmx = Math.Max(mmx, f.UCmd.Msec);
}
}
frametimeMax.Add(1 / ftmx);
frametimeMin.Add(1 / ftm);
frametimeSum.Add(count / fts);
msecMin.Add(1000.0 / mm);
msecMax.Add(1000.0 / mmx);
avgmsec.Add(1000.0 / (msecSum / (double)count));
}
mrtb.AppendText($@"
Highest FPS: {(frametimeMin.Max()).ToString("N2")}
Lowest FPS: {(frametimeMin.Min()).ToString("N2")}
Average FPS: {frametimeSum.Average().ToString("N2")}
Lowest msec: {(msecMax.Min()).ToString("N2")} FPS
Highest msec: {(msecMin.Max()).ToString("N2")} FPS
Average msec: {avgmsec.Average().ToString("N2")} FPS
Highest FPS: {(1/Df.Select(x=> x.Value).Max(y => y.GsDemoInfo.AditionalStats.FrametimeMin)).ToString("N2")}
Lowest FPS: {(1/Df.Select(x=> x.Value).Min(y => y.GsDemoInfo.AditionalStats.FrametimeMax)).ToString("N2")}
Average FPS: {(Df.Select(z => z.Value).Average(k => k.GsDemoInfo.AditionalStats.Count) / Df.Select(x=> x.Value).Max(y => y.GsDemoInfo.AditionalStats.FrametimeSum)).ToString("N2")}
Lowest msec: {(1000.0 / Df.Select(x => x.Value).Max(y => y.GsDemoInfo.AditionalStats.MsecMin)).ToString("N2")} FPS
Highest msec: {(1000.0 / Df.Select(x => x.Value).Min(y => y.GsDemoInfo.AditionalStats.MsecMax)).ToString("N2")} FPS
Average msec: {(Df.Select(x => x.Value).Select(y => y.GsDemoInfo.AditionalStats.MsecSum / (double)y.GsDemoInfo.AditionalStats.Count)).Average().ToString("N2")} FPS
Total time of the demos: {Df.Sum(x => x.Value.GsDemoInfo.DirectoryEntries.Sum(y => y.TrackTime))}s" + "\n\n");
mrtb.AppendText("Demo cheat check:" + "\n");
Expand Down
Loading

0 comments on commit 72943b2

Please sign in to comment.