Skip to content
This repository was archived by the owner on Sep 22, 2021. It is now read-only.

Commit 2cca542

Browse files
committed
Added ServerInfo and TickInterval
1 parent ac3e820 commit 2cca542

File tree

2 files changed

+142
-0
lines changed

2 files changed

+142
-0
lines changed
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
using System;
2+
using System.IO;
3+
4+
namespace DemoInfo
5+
{
6+
public struct ServerInfo
7+
{
8+
public Int32 Protocol;
9+
public Int32 ServerCount;
10+
public bool IsDedicated;
11+
public bool IsOfficialValveServer;
12+
public bool IsHltv;
13+
public bool IsReplay;
14+
public bool IsRedirectingToProxyRelay;
15+
public Int32 COs;
16+
public UInt32 MapCrc;
17+
public UInt32 ClientCrc;
18+
public UInt32 StringTableCrc;
19+
public Int32 MaxClients;
20+
public Int32 MaxClasses;
21+
public Int32 PlayerSlot;
22+
public float TickInterval;
23+
public string GameDir;
24+
public string MapName;
25+
public string MapGroupName;
26+
public string SkyName;
27+
public string HostName;
28+
public UInt32 PublicIp;
29+
public UInt64 UgcMapId;
30+
31+
32+
public void Parse(IBitStream bitstream, DemoParser parser)
33+
{
34+
while (!bitstream.ChunkFinished)
35+
{
36+
var desc = bitstream.ReadProtobufVarInt();
37+
var wireType = desc & 7;
38+
var fieldnum = desc >> 3;
39+
40+
if (wireType == 5)
41+
{
42+
if (fieldnum == 14)
43+
{
44+
parser.TickInterval = bitstream.ReadFloat();
45+
}
46+
else
47+
{
48+
var val = bitstream.ReadInt(32);
49+
switch (fieldnum)
50+
{
51+
case 8:
52+
MapCrc = val;
53+
break;
54+
case 9:
55+
ClientCrc = val;
56+
break;
57+
case 10:
58+
StringTableCrc = val;
59+
break;
60+
}
61+
}
62+
}
63+
else if (wireType == 2)
64+
{
65+
var val = bitstream.ReadProtobufString();
66+
67+
switch (fieldnum)
68+
{
69+
case 15:
70+
GameDir = val;
71+
break;
72+
case 16:
73+
MapName = val;
74+
break;
75+
case 17:
76+
MapGroupName = val;
77+
break;
78+
case 18:
79+
SkyName = val;
80+
break;
81+
case 19:
82+
HostName = val;
83+
break;
84+
}
85+
}
86+
else if (wireType == 0)
87+
{
88+
var val = bitstream.ReadProtobufVarInt();
89+
var boolval = (val == 0) ? false : true;
90+
91+
switch (fieldnum)
92+
{
93+
case 1:
94+
Protocol = val;
95+
break;
96+
case 2:
97+
ServerCount = val;
98+
break;
99+
case 3:
100+
IsDedicated = boolval;
101+
break;
102+
case 4:
103+
IsOfficialValveServer = boolval;
104+
break;
105+
case 5:
106+
IsHltv = boolval;
107+
break;
108+
case 6:
109+
IsReplay = boolval;
110+
break;
111+
case 7:
112+
COs = val;
113+
break;
114+
case 11:
115+
MaxClients = val;
116+
break;
117+
case 12:
118+
MaxClasses = val;
119+
break;
120+
case 13:
121+
PlayerSlot = val;
122+
break;
123+
case 20:
124+
PublicIp = (uint)val;
125+
break;
126+
case 21:
127+
IsRedirectingToProxyRelay = boolval;
128+
break;
129+
case 22:
130+
UgcMapId = (uint)val;
131+
break;
132+
}
133+
}
134+
}
135+
}
136+
}
137+
}

DemoInfo/DemoParser.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,11 @@ public float ParsingProgess {
474474
/// <value>The current tick.</value>
475475
public int CurrentTick { get; private set; }
476476

477+
/// <summary>
478+
/// The tickrate *of the server*
479+
/// </summary>
480+
public float TickInterval { get; internal set; }
481+
477482
/// <summary>
478483
/// The current ingame-tick as reported by the demo-file.
479484
/// </summary>

0 commit comments

Comments
 (0)