From 019d46580eb8d4a946c5bbedf977b97d05701083 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Tue, 8 Nov 2016 11:13:04 +0000 Subject: [PATCH] reset capacity, length on depool --- Facepunch.Steamworks.Test/Client/Workshop.cs | 39 +++++++++++++++++++ .../SteamNative/SteamNative.Helpers.cs | 3 ++ 2 files changed, 42 insertions(+) diff --git a/Facepunch.Steamworks.Test/Client/Workshop.cs b/Facepunch.Steamworks.Test/Client/Workshop.cs index a55c0c2..7c7a40f 100644 --- a/Facepunch.Steamworks.Test/Client/Workshop.cs +++ b/Facepunch.Steamworks.Test/Client/Workshop.cs @@ -20,6 +20,7 @@ namespace Facepunch.Steamworks.Test Assert.IsTrue( client.IsValid ); var Query = client.Workshop.CreateQuery(); + Query.Order = Workshop.Order.RankedByTrend; Query.Run(); @@ -66,6 +67,44 @@ namespace Facepunch.Steamworks.Test } } + [TestMethod] + public void QueryMyFiles() + { + using ( var client = new Facepunch.Steamworks.Client( 252490 ) ) + { + Assert.IsTrue( client.IsValid ); + + var Query = client.Workshop.CreateQuery(); + + Query.UserId = client.SteamId; + Query.UserQueryType = Workshop.UserQueryType.Published; + + Query.Run(); + + // Block, wait for result + // (don't do this in realtime) + Query.Block(); + + Assert.IsFalse( Query.IsRunning ); + Assert.IsTrue( Query.TotalResults > 0 ); + Assert.IsTrue( Query.Items.Length > 0 ); + + Console.WriteLine( "Query.TotalResults: {0}", Query.TotalResults ); + Console.WriteLine( "Query.Items.Length: {0}", Query.Items.Length ); + + foreach ( var item in Query.Items ) + { + Console.WriteLine( "{0}", item.Title ); + Console.WriteLine( "\t WebsiteViews: {0}", item.WebsiteViews ); + Console.WriteLine( "\t VotesUp: {0}", item.VotesUp ); + Console.WriteLine( "\t PreviewUrl: {0}", item.PreviewImageUrl ); + Console.WriteLine( "\t Directory: {0}", item.Directory ); + + Assert.IsTrue( item.PreviewImageUrl.Contains( "http" ) ); + } + } + } + [TestMethod] public void QueryTagRequire() { diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.Helpers.cs b/Facepunch.Steamworks/SteamNative/SteamNative.Helpers.cs index eea11aa..6f2db07 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.Helpers.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.Helpers.cs @@ -31,6 +31,9 @@ namespace SteamNative if ( StringBuilderPoolIndex >= StringBuilderPool.Length ) StringBuilderPoolIndex = 0; + StringBuilderPool[StringBuilderPoolIndex].Capacity = 4096; + StringBuilderPool[StringBuilderPoolIndex].Length = 0; + return StringBuilderPool[StringBuilderPoolIndex]; } }