Skip to content

Commit 1b0ca76

Browse files
committed
Fix packet empty byte flow
1 parent 1d5ffa5 commit 1b0ca76

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

SteamQueryNet/SteamQueryNet/ServerQuery.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,10 @@ private IEnumerable<byte> ExtractData<TObject>(TObject objectRef, byte[] dataSou
368368
*/
369369
if (property.PropertyType == typeof(string))
370370
{
371-
// Take till the termination.
372-
takenBytes = enumerableSource.TakeWhile(x => x != 0);
371+
// Clear the buffer first then take till the termination.
372+
takenBytes = enumerableSource
373+
.SkipWhile(x => x == 0)
374+
.TakeWhile(x => x != 0);
373375

374376
// Parse it into a string.
375377
property.SetValue(objectRef, Encoding.UTF8.GetString(takenBytes.ToArray()));
@@ -385,7 +387,7 @@ private IEnumerable<byte> ExtractData<TObject>(TObject objectRef, byte[] dataSou
385387
: property.PropertyType;
386388

387389
// Extract the value and the size from the source.
388-
(object result, int size) = ExtractMarshalType(enumerableSource, typeOfProperty);
390+
(object result, int size) = ExtractMarshalType(enumerableSource.SkipWhile(x => x == 0), typeOfProperty);
389391

390392
/* If the property is an enum we should parse it first then assign its value,
391393
* if not we can just give it to SetValue since it was converted by ExtractMarshalType already.*/

SteamQueryNet/SteamQueryNet/SteamQueryNet.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<Authors>Cem YILMAZ</Authors>
66
<Company>Cem YILMAZ</Company>
7-
<Version>1.0.4</Version>
8-
<AssemblyVersion>1.0.0.4</AssemblyVersion>
7+
<Version>1.0.5</Version>
8+
<AssemblyVersion>1.0.0.5</AssemblyVersion>
99
<NeutralLanguage>en</NeutralLanguage>
1010
<PackageTags>steam,query,net,steamquery,steamquerynet</PackageTags>
11-
<FileVersion>1.0.0.4</FileVersion>
11+
<FileVersion>1.0.0.5</FileVersion>
1212
<PackageReleaseNotes>Fix response header strip miscalculation</PackageReleaseNotes>
1313
<Description>SteamQueryNet is a C# wrapper for Steam Server Queries UDP protocol. It is;
1414

1515
Light
1616
Dependency free
1717
Written in .net standard 2.0 so that it works with both .NET framework 4.6+ and core.</Description>
1818
<Copyright />
19-
<PackageLicenseUrl>https://github.com/cyilcode/SteamQueryNet/blob/master/LICENSE</PackageLicenseUrl>
19+
<license>https://github.com/cyilcode/SteamQueryNet/blob/master/LICENSE</license>
2020
<PackageProjectUrl>https://github.com/cyilcode/SteamQueryNet</PackageProjectUrl>
2121
<PackageIconUrl>https://github.com/cyilcode/SteamQueryNet</PackageIconUrl>
2222
<RepositoryUrl>https://github.com/cyilcode/SteamQueryNet</RepositoryUrl>

0 commit comments

Comments
 (0)