Skip to content

Commit

Permalink
Add ISteamMatchmakingServers.HasServerResponded() to partial class in…
Browse files Browse the repository at this point in the history
…stead
  • Loading branch information
Jake-Rich committed Aug 13, 2024
1 parent 09db39d commit a80e859
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Facepunch.Steamworks/Interfaces/ISteamMatchmakingServers.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}

0 comments on commit a80e859

Please sign in to comment.