v1.0.13.1 (first post-1.0 patch)

This commit is contained in:
Regalis11
2023-05-10 15:07:17 +03:00
parent 96fb49ba14
commit ee1db852b1
272 changed files with 5738 additions and 2413 deletions
@@ -24,7 +24,7 @@ namespace Steamworks.Data
/// </summary>
public Result Accept()
{
return SteamNetworkingSockets.Internal.AcceptConnection( this );
return SteamNetworkingSockets.Internal?.AcceptConnection( this ) ?? Result.Fail;
}
/// <summary>
@@ -33,7 +33,7 @@ namespace Steamworks.Data
/// </summary>
public bool Close( bool linger = false, int reasonCode = 0, string debugString = "Closing Connection" )
{
return SteamNetworkingSockets.Internal.CloseConnection( this, reasonCode, debugString, linger );
return SteamNetworkingSockets.Internal != null && SteamNetworkingSockets.Internal.CloseConnection( this, reasonCode, debugString, linger );
}
/// <summary>
@@ -41,8 +41,8 @@ namespace Steamworks.Data
/// </summary>
public long UserData
{
get => SteamNetworkingSockets.Internal.GetConnectionUserData( this );
set => SteamNetworkingSockets.Internal.SetConnectionUserData( this, value );
get => SteamNetworkingSockets.Internal?.GetConnectionUserData( this ) ?? 0;
set => SteamNetworkingSockets.Internal?.SetConnectionUserData( this, value );
}
/// <summary>
@@ -52,13 +52,13 @@ namespace Steamworks.Data
{
get
{
if ( !SteamNetworkingSockets.Internal.GetConnectionName( this, out var strVal ) )
if ( SteamNetworkingSockets.Internal is null || !SteamNetworkingSockets.Internal.GetConnectionName( this, out var strVal ) )
return "ERROR";
return strVal;
}
set => SteamNetworkingSockets.Internal.SetConnectionName( this, value );
set => SteamNetworkingSockets.Internal?.SetConnectionName( this, value );
}
/// <summary>
@@ -67,7 +67,7 @@ namespace Steamworks.Data
public Result SendMessage( IntPtr ptr, int size, SendType sendType = SendType.Reliable )
{
long messageNumber = 0;
return SteamNetworkingSockets.Internal.SendMessageToConnection( this, ptr, (uint) size, (int)sendType, ref messageNumber );
return SteamNetworkingSockets.Internal?.SendMessageToConnection( this, ptr, (uint) size, (int)sendType, ref messageNumber ) ?? Result.Fail;
}
/// <summary>
@@ -107,16 +107,16 @@ namespace Steamworks.Data
/// Flush any messages waiting on the Nagle timer and send them at the next transmission
/// opportunity (often that means right now).
/// </summary>
public Result Flush() => SteamNetworkingSockets.Internal.FlushMessagesOnConnection( this );
public Result Flush() => SteamNetworkingSockets.Internal?.FlushMessagesOnConnection( this ) ?? Result.Fail;
/// <summary>
/// Returns detailed connection stats in text format. Useful
/// for dumping to a log, etc.
/// </summary>
/// <returns>Plain text connection info</returns>
public string DetailedStatus()
public string? DetailedStatus()
{
if ( SteamNetworkingSockets.Internal.GetDetailedConnectionStatus( this, out var strVal ) != 0 )
if ( SteamNetworkingSockets.Internal is null || SteamNetworkingSockets.Internal.GetDetailedConnectionStatus( this, out var strVal ) != 0 )
return null;
return strVal;
@@ -9,7 +9,7 @@ namespace Steamworks
/// <summary>
/// An optional interface to use instead of deriving
/// </summary>
public IConnectionManager Interface { get; set; }
public IConnectionManager? Interface { get; set; }
/// <summary>
/// The actual connection we're managing
@@ -94,6 +94,8 @@ namespace Steamworks
public void Receive( int bufferSize = 32 )
{
if (SteamNetworkingSockets.Internal is null) { return; }
int processed = 0;
IntPtr messageBuffer = Marshal.AllocHGlobal( IntPtr.Size * bufferSize );
@@ -107,10 +107,11 @@ namespace Steamworks.Data
/// <summary>
/// We override tostring to provide a sensible representation
/// </summary>
public override string ToString()
public override string? ToString()
{
var id = this;
SteamNetworkingUtils.Internal.SteamNetworkingIdentity_ToString( ref id, out var str );
string? str = null;
SteamNetworkingUtils.Internal?.SteamNetworkingIdentity_ToString( ref id, out str );
return str;
}
@@ -25,15 +25,16 @@ namespace Steamworks.Data
public static NetPingLocation? TryParseFromString( string str )
{
var result = default( NetPingLocation );
if ( !SteamNetworkingUtils.Internal.ParsePingLocationString( str, ref result ) )
if ( SteamNetworkingUtils.Internal is null || !SteamNetworkingUtils.Internal.ParsePingLocationString( str, ref result ) )
return null;
return result;
}
public override string ToString()
public override string? ToString()
{
SteamNetworkingUtils.Internal.ConvertPingLocationToString( ref this, out var strVal );
string? strVal = null;
SteamNetworkingUtils.Internal?.ConvertPingLocationToString( ref this, out strVal );
return strVal;
}
@@ -61,7 +62,7 @@ namespace Steamworks.Data
/// You are looking for the "ticketgen" library.
public int EstimatePingTo( NetPingLocation target )
{
return SteamNetworkingUtils.Internal.EstimatePingTimeBetweenTwoLocations( ref this, ref target );
return SteamNetworkingUtils.Internal?.EstimatePingTimeBetweenTwoLocations( ref this, ref target ) ?? Defines.k_nSteamNetworkingPing_Failed;
}
}
}
@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
namespace Steamworks.Data
@@ -17,10 +18,11 @@ namespace Steamworks.Data
/// </summary>
public bool Close()
{
return SteamNetworkingSockets.Internal.CloseListenSocket( Id );
return SteamNetworkingSockets.Internal != null && SteamNetworkingSockets.Internal.CloseListenSocket( Id );
}
public SocketManager Manager
[DisallowNull]
public SocketManager? Manager
{
get => SteamNetworkingSockets.GetSocketManager( Id );
set => SteamNetworkingSockets.SetSocketManager( Id, value );
@@ -14,7 +14,7 @@ namespace Steamworks
/// </summary>
public partial class SocketManager
{
public ISocketManager Interface { get; set; }
public ISocketManager? Interface { get; set; }
public List<Connection> Connecting = new List<Connection>();
public List<Connection> Connected = new List<Connection>();
@@ -26,12 +26,12 @@ namespace Steamworks
internal void Initialize()
{
pollGroup = SteamNetworkingSockets.Internal.CreatePollGroup();
pollGroup = SteamNetworkingSockets.Internal?.CreatePollGroup() ?? default;
}
public bool Close()
{
if ( SteamNetworkingSockets.Internal.IsValid )
if ( SteamNetworkingSockets.Internal is { IsValid: true } )
{
SteamNetworkingSockets.Internal.DestroyPollGroup( pollGroup );
Socket.Close();
@@ -94,7 +94,7 @@ namespace Steamworks
/// </summary>
public virtual void OnConnected( Connection connection, ConnectionInfo info )
{
SteamNetworkingSockets.Internal.SetConnectionPollGroup( connection, pollGroup );
SteamNetworkingSockets.Internal?.SetConnectionPollGroup( connection, pollGroup );
Interface?.OnConnected( connection, info );
}
@@ -104,7 +104,7 @@ namespace Steamworks
/// </summary>
public virtual void OnDisconnected( Connection connection, ConnectionInfo info )
{
SteamNetworkingSockets.Internal.SetConnectionPollGroup( connection, 0 );
SteamNetworkingSockets.Internal?.SetConnectionPollGroup( connection, 0 );
connection.Close();
@@ -121,7 +121,7 @@ namespace Steamworks
try
{
processed = SteamNetworkingSockets.Internal.ReceiveMessagesOnPollGroup( pollGroup, messageBuffer, bufferSize );
processed = SteamNetworkingSockets.Internal?.ReceiveMessagesOnPollGroup( pollGroup, messageBuffer, bufferSize ) ?? 0;
for ( int i = 0; i < processed; i++ )
{