Skip to content

Commit bbe10c8

Browse files
committed
Fix response header strip miscalculation
1 parent 8f8bf9f commit bbe10c8

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

SteamQueryNet/SteamQueryNet/Models/Player.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,18 @@ public string TotalDurationAsString
3535
get
3636
{
3737
TimeSpan totalSpan = TimeSpan.FromSeconds(Duration);
38-
string parsedHours = totalSpan.Hours >= 10 ? totalSpan.Hours.ToString() : $"0{totalSpan.Hours}";
39-
string parsedMinutes = totalSpan.Minutes >= 10 ? totalSpan.Minutes.ToString() : $"0{totalSpan.Minutes}";
40-
string parsedSeconds = totalSpan.Seconds >= 10 ? totalSpan.Seconds.ToString() : $"0{totalSpan.Seconds}";
38+
string parsedHours = totalSpan.Hours >= 10
39+
? totalSpan.Hours.ToString()
40+
: $"0{totalSpan.Hours}";
41+
42+
string parsedMinutes = totalSpan.Minutes >= 10
43+
? totalSpan.Minutes.ToString()
44+
: $"0{totalSpan.Minutes}";
45+
46+
string parsedSeconds = totalSpan.Seconds >= 10
47+
? totalSpan.Seconds.ToString()
48+
: $"0{totalSpan.Seconds}";
49+
4150
return $"{parsedHours}:{parsedMinutes}:{parsedSeconds}";
4251
}
4352
}

SteamQueryNet/SteamQueryNet/ServerQuery.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public interface IServerQuery
8181

8282
public class ServerQuery : IServerQuery, IDisposable
8383
{
84-
private const int RESPONSE_HEADER_COUNT = 6;
84+
private const int RESPONSE_HEADER_COUNT = 5;
8585
private const int RESPONSE_CODE_INDEX = 5;
8686

8787
private readonly UdpClient _client = new UdpClient(new IPEndPoint(IPAddress.Any, 0));
@@ -211,7 +211,6 @@ public async Task<List<Rule>> GetRulesAsync()
211211
byte[] response = await SendRequestAsync(RequestHeaders.A2S_RULES, BitConverter.GetBytes(_currentChallenge));
212212
if (response.Length > 0)
213213
{
214-
var rls = ExtractListData<Rule>(response);
215214
return ExtractListData<Rule>(response);
216215
}
217216
else
@@ -330,7 +329,7 @@ private IEnumerable<byte> ExtractData<TObject>(TObject objectRef, byte[] dataSou
330329

331330
// We can be a good guy and ask for any extra jobs :)
332331
IEnumerable<byte> enumerableSource = stripHeaders
333-
? dataSource.Skip(RESPONSE_HEADER_COUNT)
332+
? dataSource.Skip(RESPONSE_HEADER_COUNT)
334333
: dataSource;
335334

336335
// We get every property that does not contain ParseCustom and NotParsable attributes on them to iterate through all and parse/assign their values.
@@ -390,7 +389,7 @@ private IEnumerable<byte> ExtractData<TObject>(TObject objectRef, byte[] dataSou
390389

391390
/* If the property is an enum we should parse it first then assign its value,
392391
* if not we can just give it to SetValue since it was converted by ExtractMarshalType already.*/
393-
property.SetValue(objectRef, property.PropertyType.IsEnum
392+
property.SetValue(objectRef, property.PropertyType.IsEnum
394393
? Enum.Parse(property.PropertyType, result.ToString())
395394
: result);
396395

0 commit comments

Comments
 (0)