Add ISteamMatchmakingServers.HasServerResponded() to partial class instead

This commit is contained in:
Jake Rich 2024-08-12 21:30:28 -04:00
parent 09db39d9e3
commit a80e8590d5

View File

@ -0,0 +1,28 @@
using Steamworks.Data;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace Steamworks
{
internal partial class ISteamMatchmakingServers
{
/// <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;
// first 8 bytes is IPAddress, next 4 bytes is ping, next 1 byte is m_bHadSuccessfulResponse
return Marshal.ReadByte( IntPtr.Add( returnValue, 12 ) ) == 1;
}
}
}