Merge from fix_serverlist_query_allocations -> master

This commit is contained in:
Jake Rich 2024-08-14 12:46:15 -04:00
commit eec3c05ecd
38 changed files with 88 additions and 40 deletions

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamAppList : SteamInterface
internal unsafe partial class ISteamAppList : SteamInterface
{
internal ISteamAppList( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamApps : SteamInterface
internal unsafe partial class ISteamApps : SteamInterface
{
internal ISteamApps( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamClient : SteamInterface
internal unsafe partial class ISteamClient : SteamInterface
{
internal ISteamClient( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamController : SteamInterface
internal unsafe partial class ISteamController : SteamInterface
{
internal ISteamController( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamFriends : SteamInterface
internal unsafe partial class ISteamFriends : SteamInterface
{
internal ISteamFriends( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamGameSearch : SteamInterface
internal unsafe partial class ISteamGameSearch : SteamInterface
{
internal ISteamGameSearch( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamGameServer : SteamInterface
internal unsafe partial class ISteamGameServer : SteamInterface
{
internal ISteamGameServer( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamGameServerStats : SteamInterface
internal unsafe partial class ISteamGameServerStats : SteamInterface
{
internal ISteamGameServerStats( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamHTMLSurface : SteamInterface
internal unsafe partial class ISteamHTMLSurface : SteamInterface
{
internal ISteamHTMLSurface( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamHTTP : SteamInterface
internal unsafe partial class ISteamHTTP : SteamInterface
{
internal ISteamHTTP( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamInput : SteamInterface
internal unsafe partial class ISteamInput : SteamInterface
{
internal ISteamInput( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamInventory : SteamInterface
internal unsafe partial class ISteamInventory : SteamInterface
{
internal ISteamInventory( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamMatchmaking : SteamInterface
internal unsafe partial class ISteamMatchmaking : SteamInterface
{
internal ISteamMatchmaking( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamMatchmakingPingResponse : SteamInterface
internal unsafe partial class ISteamMatchmakingPingResponse : SteamInterface
{
internal ISteamMatchmakingPingResponse( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamMatchmakingPlayersResponse : SteamInterface
internal unsafe partial class ISteamMatchmakingPlayersResponse : SteamInterface
{
internal ISteamMatchmakingPlayersResponse( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamMatchmakingRulesResponse : SteamInterface
internal unsafe partial class ISteamMatchmakingRulesResponse : SteamInterface
{
internal ISteamMatchmakingRulesResponse( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamMatchmakingServerListResponse : SteamInterface
internal unsafe partial class ISteamMatchmakingServerListResponse : SteamInterface
{
internal ISteamMatchmakingServerListResponse( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamMatchmakingServers : SteamInterface
internal unsafe partial class ISteamMatchmakingServers : SteamInterface
{
internal ISteamMatchmakingServers( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamMusic : SteamInterface
internal unsafe partial class ISteamMusic : SteamInterface
{
internal ISteamMusic( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamMusicRemote : SteamInterface
internal unsafe partial class ISteamMusicRemote : SteamInterface
{
internal ISteamMusicRemote( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamNetworking : SteamInterface
internal unsafe partial class ISteamNetworking : SteamInterface
{
internal ISteamNetworking( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamNetworkingFakeUDPPort : SteamInterface
internal unsafe partial class ISteamNetworkingFakeUDPPort : SteamInterface
{
internal ISteamNetworkingFakeUDPPort( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamNetworkingMessages : SteamInterface
internal unsafe partial class ISteamNetworkingMessages : SteamInterface
{
internal ISteamNetworkingMessages( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamNetworkingSockets : SteamInterface
internal unsafe partial class ISteamNetworkingSockets : SteamInterface
{
internal ISteamNetworkingSockets( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamNetworkingUtils : SteamInterface
internal unsafe partial class ISteamNetworkingUtils : SteamInterface
{
internal ISteamNetworkingUtils( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamParentalSettings : SteamInterface
internal unsafe partial class ISteamParentalSettings : SteamInterface
{
internal ISteamParentalSettings( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamParties : SteamInterface
internal unsafe partial class ISteamParties : SteamInterface
{
internal ISteamParties( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamRemotePlay : SteamInterface
internal unsafe partial class ISteamRemotePlay : SteamInterface
{
internal ISteamRemotePlay( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamRemoteStorage : SteamInterface
internal unsafe partial class ISteamRemoteStorage : SteamInterface
{
internal ISteamRemoteStorage( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamScreenshots : SteamInterface
internal unsafe partial class ISteamScreenshots : SteamInterface
{
internal ISteamScreenshots( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamUGC : SteamInterface
internal unsafe partial class ISteamUGC : SteamInterface
{
internal ISteamUGC( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamUser : SteamInterface
internal unsafe partial class ISteamUser : SteamInterface
{
internal ISteamUser( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamUserStats : SteamInterface
internal unsafe partial class ISteamUserStats : SteamInterface
{
internal ISteamUserStats( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamUtils : SteamInterface
internal unsafe partial class ISteamUtils : SteamInterface
{
internal ISteamUtils( bool IsGameServer )

View File

@ -7,7 +7,7 @@
namespace Steamworks
{
internal unsafe class ISteamVideo : SteamInterface
internal unsafe partial class ISteamVideo : SteamInterface
{
internal ISteamVideo( bool IsGameServer )

View File

@ -0,0 +1,42 @@
using Steamworks.Data;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace Steamworks
{
internal partial class ISteamMatchmakingServers
{
// Cached offset of gameserveritem_t.m_bHadSuccessfulResponse
private static int hasSuccessfulResponseOffset;
/// <summary>
/// Read gameserveritem_t.m_bHadSuccessfulResponse without allocating the struct on the heap
/// </summary>
/// <param name="hRequest"></param>
/// <param name="iServer"></param>
/// <returns></returns>
internal bool HasServerResponded( HServerListRequest hRequest, int iServer )
{
IntPtr returnValue = _GetServerDetails( Self, hRequest, iServer );
// Return false if steam returned null
if ( returnValue == IntPtr.Zero ) return false;
// Cache the offset of m_bHadSuccessfulResponse
if ( hasSuccessfulResponseOffset == 0 )
{
hasSuccessfulResponseOffset = Marshal.OffsetOf<gameserveritem_t>( nameof( gameserveritem_t.HadSuccessfulResponse ) ).ToInt32();
if ( hasSuccessfulResponseOffset == 0 )
{
throw new Exception( "Failed to get offset of gameserveritem_t.HadSuccessfulResponse" );
}
}
// Read byte m_bHadSuccessfulResponse
return Marshal.ReadByte( IntPtr.Add( returnValue, hasSuccessfulResponseOffset ) ) == 1;
}
}
}

View File

@ -162,11 +162,17 @@ public void UpdateResponsive()
{
watchList.RemoveAll( x =>
{
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;

View File

@ -23,7 +23,7 @@ public void GenerateInterface( SteamApiDefinition.Interface iface, string folder
StartBlock( $"namespace Steamworks" );
{
StartBlock( $"internal unsafe class {iface.Name} : SteamInterface" );
StartBlock( $"internal unsafe partial class {iface.Name} : SteamInterface" );
{
WriteLine();
StartBlock( $"internal {iface.Name}( bool IsGameServer )" );