Release 1.9.7.0 - Summer Update 2025

This commit is contained in:
Regalis11
2025-06-17 16:38:11 +03:00
parent 22227f13e5
commit ea5a2bc693
297 changed files with 7344 additions and 2421 deletions
@@ -46,6 +46,7 @@ namespace Steamworks.ServerList
/// </summary>
public List<ServerInfo> Unresponsive = new List<ServerInfo>();
public List<ServerInfo> Unqueried = new List<ServerInfo>();
public Base()
{
@@ -139,7 +140,7 @@ namespace Steamworks.ServerList
}
}
public void Dispose()
public virtual void Dispose()
{
ReleaseQuery();
}
@@ -167,12 +168,18 @@ namespace Steamworks.ServerList
watchList.RemoveAll( x =>
{
if (Internal is null) { return true; }
var info = Internal.GetServerDetails( request, x );
if ( info.HadSuccessfulResponse )
// First check if the server has responded without allocating server info
bool hasResponded = Internal.HasServerResponded( request, x );
if ( hasResponded )
{
OnServer( ServerInfo.From( info ), info.HadSuccessfulResponse );
return true;
// Now get all server info
var info = Internal.GetServerDetails( request, x );
if ( info.HadSuccessfulResponse )
{
OnServer( ServerInfo.From( info ), info.HadSuccessfulResponse );
return true;
}
}
return false;
@@ -185,8 +192,10 @@ namespace Steamworks.ServerList
{
if (Internal is null) { return true; }
var info = Internal.GetServerDetails( request, x );
OnServer( ServerInfo.From( info ), info.HadSuccessfulResponse );
var details = Internal.GetServerDetails( request, x );
var info = ServerInfo.From( details );
info.Ping = int.MaxValue;
Unqueried.Add( info );
return true;
} );
}
@@ -206,4 +215,4 @@ namespace Steamworks.ServerList
}
}
}
}
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Steamworks.ServerList
{
@@ -11,8 +7,8 @@ namespace Steamworks.ServerList
internal override void LaunchQuery()
{
if (Internal is null) { return; }
var filters = GetFilters();
request = Internal.RequestFavoritesServerList( AppId.Value, ref filters, (uint)filters.Length, IntPtr.Zero );
using var filters = new ServerFilterMarshaler( GetFilters() );
request = Internal.RequestFavoritesServerList( AppId.Value, filters.Pointer, (uint)filters.Count, IntPtr.Zero );
}
}
}
}
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Steamworks.ServerList
{
@@ -11,8 +7,8 @@ namespace Steamworks.ServerList
internal override void LaunchQuery()
{
if (Internal is null) { return; }
var filters = GetFilters();
request = Internal.RequestFriendsServerList( AppId.Value, ref filters, (uint)filters.Length, IntPtr.Zero );
using var filters = new ServerFilterMarshaler( GetFilters() );
request = Internal.RequestFriendsServerList( AppId.Value, filters.Pointer, (uint)filters.Count, IntPtr.Zero );
}
}
}
}
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Steamworks.ServerList
{
@@ -11,8 +7,8 @@ namespace Steamworks.ServerList
internal override void LaunchQuery()
{
if (Internal is null) { return; }
var filters = GetFilters();
request = Internal.RequestHistoryServerList( AppId.Value, ref filters, (uint)filters.Length, IntPtr.Zero );
using var filters = new ServerFilterMarshaler( GetFilters() );
request = Internal.RequestHistoryServerList( AppId.Value, filters.Pointer, (uint)filters.Count, IntPtr.Zero );
}
}
}
}
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Steamworks.ServerList
{
@@ -10,9 +6,9 @@ namespace Steamworks.ServerList
{
internal override void LaunchQuery()
{
if (Internal is null) { return; }
var filters = GetFilters();
request = Internal.RequestInternetServerList( AppId.Value, filters, (uint)filters.Length, IntPtr.Zero );
if ( Internal is null ) { return; }
using var filters = new ServerFilterMarshaler( GetFilters() );
request = Internal.RequestInternetServerList( AppId.Value, filters.Pointer, (uint)filters.Count, IntPtr.Zero );
}
}
}
}
@@ -1,9 +1,5 @@
using Steamworks.Data;
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Steamworks.ServerList
@@ -30,15 +26,17 @@ namespace Steamworks.ServerList
var ips = Ips.ToArray();
while ( true )
wantsCancel = false;
while ( !wantsCancel )
{
var sublist = ips.Skip( pointer ).Take( blockSize );
if ( sublist.Count() == 0 )
var sublist = ips.Skip( pointer ).Take( blockSize ).ToList();
if ( sublist.Count == 0 )
break;
using ( var list = new ServerList.Internet() )
{
list.AddFilter( "or", sublist.Count().ToString() );
list.AddFilter( "or", sublist.Count.ToString() );
foreach ( var server in sublist )
{
@@ -47,9 +45,6 @@ namespace Steamworks.ServerList
await list.RunQueryAsync( timeoutSeconds );
if ( wantsCancel )
return false;
Responsive.AddRange( list.Responsive );
Responsive = Responsive.Distinct().ToList();
Unresponsive.AddRange( list.Unresponsive );
@@ -64,9 +59,17 @@ namespace Steamworks.ServerList
return true;
}
// note: Cancel doesn't get called in Dispose because request is always null for this class
public override void Cancel()
{
wantsCancel = true;
}
public override void Dispose()
{
base.Dispose();
wantsCancel = true;
}
}
}
}
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Steamworks.ServerList
{
@@ -14,4 +10,4 @@ namespace Steamworks.ServerList
request = Internal.RequestLANServerList( AppId.Value, IntPtr.Zero );
}
}
}
}
@@ -0,0 +1,58 @@
using System;
using System.Runtime.InteropServices;
using Steamworks.Data;
namespace Steamworks.ServerList;
internal struct ServerFilterMarshaler : IDisposable
{
private static readonly int SizeOfPointer = Marshal.SizeOf<IntPtr>();
private static readonly int SizeOfKeyValuePair = Marshal.SizeOf<MatchMakingKeyValuePair>();
private IntPtr _arrayPtr;
private IntPtr _itemsPtr;
public int Count { get; private set; }
public IntPtr Pointer => _arrayPtr;
public ServerFilterMarshaler( MatchMakingKeyValuePair[] filters )
{
if ( filters == null || filters.Length == 0 )
{
Count = 0;
_arrayPtr = IntPtr.Zero;
_itemsPtr = IntPtr.Zero;
return;
}
Count = filters.Length;
_arrayPtr = Marshal.AllocHGlobal( SizeOfPointer * filters.Length );
_itemsPtr = Marshal.AllocHGlobal( SizeOfKeyValuePair * filters.Length );
var arrayDst = _arrayPtr;
var itemDst = _itemsPtr;
foreach ( var filter in filters )
{
Marshal.WriteIntPtr( arrayDst, itemDst );
arrayDst += SizeOfPointer;
Marshal.StructureToPtr( filter, itemDst, false );
itemDst += SizeOfKeyValuePair;
}
}
public void Dispose()
{
if ( _arrayPtr != IntPtr.Zero )
{
Marshal.FreeHGlobal( _arrayPtr );
_arrayPtr = IntPtr.Zero;
}
if ( _itemsPtr != IntPtr.Zero )
{
Marshal.FreeHGlobal( _itemsPtr );
_itemsPtr = IntPtr.Zero;
}
}
}