mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-04-15 22:02:28 +03:00
Some code quality stuff
This commit is contained in:
parent
b52a63bc8b
commit
d990b537a3
@ -43,11 +43,6 @@ namespace Steamworks
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnNewUrlLaunchParameters()
|
|
||||||
{
|
|
||||||
// Wow!
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void GameLangauge()
|
public void GameLangauge()
|
||||||
{
|
{
|
||||||
|
@ -195,8 +195,8 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
await SteamInventory.WaitForDefinitions();
|
await SteamInventory.WaitForDefinitions();
|
||||||
|
|
||||||
byte[] data = null;
|
byte[] data;
|
||||||
int itemCount = 0;
|
int itemCount;
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
{
|
{
|
||||||
|
@ -130,7 +130,7 @@ namespace Steamworks
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task CreateAndThenEditFile()
|
public async Task CreateAndThenEditFile()
|
||||||
{
|
{
|
||||||
PublishedFileId fileid = default;
|
PublishedFileId fileid;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Make a file
|
// Make a file
|
||||||
|
@ -168,9 +168,7 @@ namespace Steamworks
|
|||||||
appid = SteamClient.AppId;
|
appid = SteamClient.AppId;
|
||||||
|
|
||||||
var depots = new DepotId_t[32];
|
var depots = new DepotId_t[32];
|
||||||
uint count = 0;
|
uint count = Internal.GetInstalledDepots( appid.Value, depots, (uint) depots.Length );
|
||||||
|
|
||||||
count = Internal.GetInstalledDepots( appid.Value, depots, (uint) depots.Length );
|
|
||||||
|
|
||||||
for ( int i = 0; i < count; i++ )
|
for ( int i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
@ -220,7 +218,7 @@ namespace Steamworks
|
|||||||
ulong punBytesTotal = 0;
|
ulong punBytesTotal = 0;
|
||||||
|
|
||||||
if ( !Internal.GetDlcDownloadProgress( appid.Value, ref punBytesDownloaded, ref punBytesTotal ) )
|
if ( !Internal.GetDlcDownloadProgress( appid.Value, ref punBytesDownloaded, ref punBytesTotal ) )
|
||||||
return default( DownloadProgress );
|
return default;
|
||||||
|
|
||||||
return new DownloadProgress { BytesDownloaded = punBytesDownloaded, BytesTotal = punBytesTotal, Active = true };
|
return new DownloadProgress { BytesDownloaded = punBytesDownloaded, BytesTotal = punBytesTotal, Active = true };
|
||||||
}
|
}
|
||||||
@ -263,7 +261,7 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var len = Internal.GetLaunchCommandLine( out var strVal );
|
Internal.GetLaunchCommandLine( out var strVal );
|
||||||
return strVal;
|
return strVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ namespace Steamworks
|
|||||||
openInterfaces.Add( t );
|
openInterfaces.Add( t );
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SteamClass> openInterfaces = new List<SteamClass>();
|
static readonly List<SteamClass> openInterfaces = new List<SteamClass>();
|
||||||
|
|
||||||
internal static void ShutdownInterfaces()
|
internal static void ShutdownInterfaces()
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ namespace Steamworks
|
|||||||
Internal.RunFrame();
|
Internal.RunFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
static InputHandle_t[] queryArray = new InputHandle_t[STEAM_CONTROLLER_MAX_COUNT];
|
static readonly InputHandle_t[] queryArray = new InputHandle_t[STEAM_CONTROLLER_MAX_COUNT];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return a list of connected controllers.
|
/// Return a list of connected controllers.
|
||||||
|
@ -103,7 +103,7 @@ namespace Steamworks
|
|||||||
public static T CreateNormalSocket<T>( NetAddress address ) where T : SocketInterface, new()
|
public static T CreateNormalSocket<T>( NetAddress address ) where T : SocketInterface, new()
|
||||||
{
|
{
|
||||||
var t = new T();
|
var t = new T();
|
||||||
var options = new NetKeyValue[0];
|
var options = Array.Empty<NetKeyValue>();
|
||||||
t.Socket = Internal.CreateListenSocketIP( ref address, options.Length, options );
|
t.Socket = Internal.CreateListenSocketIP( ref address, options.Length, options );
|
||||||
t.Initialize();
|
t.Initialize();
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ namespace Steamworks
|
|||||||
public static T ConnectNormal<T>( NetAddress address ) where T : ConnectionInterface, new()
|
public static T ConnectNormal<T>( NetAddress address ) where T : ConnectionInterface, new()
|
||||||
{
|
{
|
||||||
var t = new T();
|
var t = new T();
|
||||||
var options = new NetKeyValue[0];
|
var options = Array.Empty<NetKeyValue>();
|
||||||
t.Connection = Internal.ConnectByIPAddress( ref address, options.Length, options );
|
t.Connection = Internal.ConnectByIPAddress( ref address, options.Length, options );
|
||||||
SetConnectionInterface( t.Connection.Id, t );
|
SetConnectionInterface( t.Connection.Id, t );
|
||||||
return t;
|
return t;
|
||||||
@ -129,7 +129,7 @@ namespace Steamworks
|
|||||||
public static T CreateRelaySocket<T>( int virtualport = 0 ) where T : SocketInterface, new()
|
public static T CreateRelaySocket<T>( int virtualport = 0 ) where T : SocketInterface, new()
|
||||||
{
|
{
|
||||||
var t = new T();
|
var t = new T();
|
||||||
var options = new NetKeyValue[0];
|
var options = Array.Empty<NetKeyValue>();
|
||||||
t.Socket = Internal.CreateListenSocketP2P( virtualport, options.Length, options );
|
t.Socket = Internal.CreateListenSocketP2P( virtualport, options.Length, options );
|
||||||
SetSocketInterface( t.Socket.Id, t );
|
SetSocketInterface( t.Socket.Id, t );
|
||||||
return t;
|
return t;
|
||||||
@ -142,7 +142,7 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
var t = new T();
|
var t = new T();
|
||||||
NetIdentity identity = serverId;
|
NetIdentity identity = serverId;
|
||||||
var options = new NetKeyValue[0];
|
var options = Array.Empty<NetKeyValue>();
|
||||||
t.Connection = Internal.ConnectP2P( ref identity, virtualport, options.Length, options );
|
t.Connection = Internal.ConnectP2P( ref identity, virtualport, options.Length, options );
|
||||||
SetConnectionInterface( t.Connection.Id, t );
|
SetConnectionInterface( t.Connection.Id, t );
|
||||||
return t;
|
return t;
|
||||||
|
@ -109,7 +109,7 @@ namespace Steamworks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static async Task WaitForPingDataAsync( float maxAgeInSeconds = 60 * 5 )
|
public static async Task WaitForPingDataAsync( float maxAgeInSeconds = 60 * 5 )
|
||||||
{
|
{
|
||||||
if ( Internal.CheckPingDataUpToDate( 120.0f ) )
|
if ( Internal.CheckPingDataUpToDate( maxAgeInSeconds ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SteamRelayNetworkStatus_t status = default;
|
SteamRelayNetworkStatus_t status = default;
|
||||||
|
@ -131,7 +131,7 @@ namespace Steamworks
|
|||||||
openInterfaces.Add( t );
|
openInterfaces.Add( t );
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SteamClass> openInterfaces = new List<SteamClass>();
|
static readonly List<SteamClass> openInterfaces = new List<SteamClass>();
|
||||||
|
|
||||||
internal static void ShutdownInterfaces()
|
internal static void ShutdownInterfaces()
|
||||||
{
|
{
|
||||||
|
@ -58,7 +58,7 @@ namespace Steamworks
|
|||||||
/// <param name="ct">Allows you to send a message to cancel the download anywhere during the process</param>
|
/// <param name="ct">Allows you to send a message to cancel the download anywhere during the process</param>
|
||||||
/// <param name="milisecondsUpdateDelay">How often to call the progress function</param>
|
/// <param name="milisecondsUpdateDelay">How often to call the progress function</param>
|
||||||
/// <returns>true if downloaded and installed correctly</returns>
|
/// <returns>true if downloaded and installed correctly</returns>
|
||||||
public static async Task<bool> DownloadAsync( PublishedFileId fileId, Action<float> progress = null, CancellationToken ct = default, int milisecondsUpdateDelay = 60 )
|
public static async Task<bool> DownloadAsync( PublishedFileId fileId, Action<float> progress = null, int milisecondsUpdateDelay = 60, CancellationToken ct = default )
|
||||||
{
|
{
|
||||||
var item = new Steamworks.Ugc.Item( fileId );
|
var item = new Steamworks.Ugc.Item( fileId );
|
||||||
|
|
||||||
|
@ -318,11 +318,11 @@ namespace Steamworks
|
|||||||
AuthTicket ticket = null;
|
AuthTicket ticket = null;
|
||||||
var stopwatch = Stopwatch.StartNew();
|
var stopwatch = Stopwatch.StartNew();
|
||||||
|
|
||||||
Action<GetAuthSessionTicketResponse_t> f = ( t ) =>
|
void f( GetAuthSessionTicketResponse_t t )
|
||||||
{
|
{
|
||||||
if ( t.AuthTicket != ticket.Handle ) return;
|
if ( t.AuthTicket != ticket.Handle ) return;
|
||||||
result = t.Result;
|
result = t.Result;
|
||||||
};
|
}
|
||||||
|
|
||||||
OnGetAuthSessionTicketResponse += f;
|
OnGetAuthSessionTicketResponse += f;
|
||||||
|
|
||||||
|
@ -75,12 +75,12 @@ namespace Steamworks.Data
|
|||||||
var ident = Identifier;
|
var ident = Identifier;
|
||||||
bool gotCallback = false;
|
bool gotCallback = false;
|
||||||
|
|
||||||
Action<string, int> f = ( x, icon ) =>
|
void f( string x, int icon )
|
||||||
{
|
{
|
||||||
if ( x != ident ) return;
|
if ( x != ident ) return;
|
||||||
i = icon;
|
i = icon;
|
||||||
gotCallback = true;
|
gotCallback = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,7 @@ namespace Steamworks
|
|||||||
/// Sometimes we don't know the user's name. This will wait until we have
|
/// Sometimes we don't know the user's name. This will wait until we have
|
||||||
/// downloaded the information on this user.
|
/// downloaded the information on this user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task RequestInfoAsync( int timeout = 5000 )
|
public async Task RequestInfoAsync()
|
||||||
{
|
{
|
||||||
await SteamFriends.CacheUserInformationAsync( Id, true );
|
await SteamFriends.CacheUserInformationAsync( Id, true );
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
FriendGameInfo_t gameInfo = default( FriendGameInfo_t );
|
FriendGameInfo_t gameInfo = default;
|
||||||
if ( !SteamFriends.Internal.GetFriendGamePlayed( Id, ref gameInfo ) )
|
if ( !SteamFriends.Internal.GetFriendGamePlayed( Id, ref gameInfo ) )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ namespace Steamworks
|
|||||||
string val = GetProperty( name );
|
string val = GetProperty( name );
|
||||||
|
|
||||||
if ( string.IsNullOrEmpty( val ) )
|
if ( string.IsNullOrEmpty( val ) )
|
||||||
return default( T );
|
return default;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -143,7 +143,7 @@ namespace Steamworks
|
|||||||
}
|
}
|
||||||
catch ( System.Exception )
|
catch ( System.Exception )
|
||||||
{
|
{
|
||||||
return default( T );
|
return default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ namespace Steamworks.Data
|
|||||||
public int EntryCount => SteamUserStats.Internal.GetLeaderboardEntryCount(Id);
|
public int EntryCount => SteamUserStats.Internal.GetLeaderboardEntryCount(Id);
|
||||||
|
|
||||||
static int[] detailsBuffer = new int[64];
|
static int[] detailsBuffer = new int[64];
|
||||||
static int[] noDetails = new int[0];
|
static int[] noDetails = Array.Empty<int>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Submit your score and replace your old score even if it was better
|
/// Submit your score and replace your old score even if it was better
|
||||||
@ -122,7 +122,7 @@ namespace Steamworks.Data
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task WaitForUserNames( LeaderboardEntry[] entries)
|
internal static async Task WaitForUserNames( LeaderboardEntry[] entries)
|
||||||
{
|
{
|
||||||
bool gotAll = false;
|
bool gotAll = false;
|
||||||
while ( !gotAll )
|
while ( !gotAll )
|
||||||
|
@ -123,7 +123,7 @@ namespace Steamworks.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets per-user metadata (for the local user implicitly)
|
/// Sets per-user metadata (for the local user implicitly)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetMemberData( Friend member, string key, string value )
|
public void SetMemberData( string key, string value )
|
||||||
{
|
{
|
||||||
SteamMatchmaking.Internal.SetLobbyMemberData( Id, key, value );
|
SteamMatchmaking.Internal.SetLobbyMemberData( Id, key, value );
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
var owner = default( SteamId );
|
var owner = default( SteamId );
|
||||||
var location = default( SteamPartyBeaconLocation_t );
|
var location = default( SteamPartyBeaconLocation_t );
|
||||||
Internal.GetBeaconDetails( Id, ref owner, ref location, out var strVal );
|
Internal.GetBeaconDetails( Id, ref owner, ref location, out _ );
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
var owner = default( SteamId );
|
var owner = default( SteamId );
|
||||||
var location = default( SteamPartyBeaconLocation_t );
|
var location = default( SteamPartyBeaconLocation_t );
|
||||||
Internal.GetBeaconDetails( Id, ref owner, ref location, out var strVal );
|
_ = Internal.GetBeaconDetails( Id, ref owner, ref location, out var strVal );
|
||||||
return strVal;
|
return strVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,6 @@ namespace Steamworks.Data
|
|||||||
{
|
{
|
||||||
public struct ServerInfo : IEquatable<ServerInfo>
|
public struct ServerInfo : IEquatable<ServerInfo>
|
||||||
{
|
{
|
||||||
static ISteamMatchmakingServers Internal => Steamworks.ServerList.Base.Internal;
|
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public int Ping { get; set; }
|
public int Ping { get; set; }
|
||||||
public string GameDir { get; set; }
|
public string GameDir { get; set; }
|
||||||
|
@ -183,8 +183,7 @@ namespace Steamworks.Ugc
|
|||||||
|
|
||||||
ulong size = 0;
|
ulong size = 0;
|
||||||
uint ts = 0;
|
uint ts = 0;
|
||||||
|
if ( !SteamUGC.Internal.GetItemInstallInfo( Id, ref size, out _, ref ts ) )
|
||||||
if ( !SteamUGC.Internal.GetItemInstallInfo( Id, ref size, out var strVal, ref ts ) )
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (long) size;
|
return (long) size;
|
||||||
@ -262,9 +261,9 @@ namespace Steamworks.Ugc
|
|||||||
/// If CancellationToken is default then there is 60 seconds timeout
|
/// If CancellationToken is default then there is 60 seconds timeout
|
||||||
/// Progress will be set to 0-1
|
/// Progress will be set to 0-1
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<bool> DownloadAsync( Action<float> progress = null, CancellationToken ct = default, int milisecondsUpdateDelay = 60 )
|
public async Task<bool> DownloadAsync( Action<float> progress = null, int milisecondsUpdateDelay = 60, CancellationToken ct = default )
|
||||||
{
|
{
|
||||||
return await SteamUGC.DownloadAsync( Id, progress, ct, milisecondsUpdateDelay );
|
return await SteamUGC.DownloadAsync( Id, progress, milisecondsUpdateDelay, ct );
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -13,7 +13,7 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
private static readonly byte[] A2S_SERVERQUERY_GETCHALLENGE = { 0x55, 0xFF, 0xFF, 0xFF, 0xFF };
|
private static readonly byte[] A2S_SERVERQUERY_GETCHALLENGE = { 0x55, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||||
// private static readonly byte A2S_PLAYER = 0x55;
|
// private static readonly byte A2S_PLAYER = 0x55;
|
||||||
private static readonly byte A2S_RULES = 0x56;
|
private const byte A2S_RULES = 0x56;
|
||||||
|
|
||||||
private static readonly Dictionary<IPEndPoint, Task<Dictionary<string, string>>> PendingQueries =
|
private static readonly Dictionary<IPEndPoint, Task<Dictionary<string, string>>> PendingQueries =
|
||||||
new Dictionary<IPEndPoint, Task<Dictionary<string, string>>>();
|
new Dictionary<IPEndPoint, Task<Dictionary<string, string>>>();
|
||||||
@ -27,7 +27,7 @@ namespace Steamworks
|
|||||||
if (PendingQueries.TryGetValue(endpoint, out var pending))
|
if (PendingQueries.TryGetValue(endpoint, out var pending))
|
||||||
return pending;
|
return pending;
|
||||||
|
|
||||||
var task = GetRulesImpl(endpoint, server)
|
var task = GetRulesImpl( endpoint )
|
||||||
.ContinueWith(t =>
|
.ContinueWith(t =>
|
||||||
{
|
{
|
||||||
lock (PendingQueries)
|
lock (PendingQueries)
|
||||||
@ -44,7 +44,7 @@ namespace Steamworks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<Dictionary<string, string>> GetRulesImpl( IPEndPoint endpoint, ServerInfo server )
|
private static async Task<Dictionary<string, string>> GetRulesImpl( IPEndPoint endpoint )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ namespace Steamworks
|
|||||||
|
|
||||||
public class SteamSharedClass<T> : SteamClass
|
public class SteamSharedClass<T> : SteamClass
|
||||||
{
|
{
|
||||||
internal static SteamInterface Interface => InterfaceClient != null ? InterfaceClient : InterfaceServer;
|
internal static SteamInterface Interface => InterfaceClient ?? InterfaceServer;
|
||||||
internal static SteamInterface InterfaceClient;
|
internal static SteamInterface InterfaceClient;
|
||||||
internal static SteamInterface InterfaceServer;
|
internal static SteamInterface InterfaceServer;
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ namespace Steamworks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static byte[] readBuffer = new byte[1024 * 8];
|
static readonly byte[] readBuffer = new byte[1024 * 8];
|
||||||
|
|
||||||
public static string ReadNullTerminatedUTF8String( this BinaryReader br )
|
public static string ReadNullTerminatedUTF8String( this BinaryReader br )
|
||||||
{
|
{
|
||||||
|
@ -100,7 +100,7 @@ namespace Generator
|
|||||||
{
|
{
|
||||||
if ( args[i + 1] is IntType || args[i + 1] is UIntType || args[i + 1] is UIntPtrType )
|
if ( args[i + 1] is IntType || args[i + 1] is UIntType || args[i + 1] is UIntPtrType )
|
||||||
{
|
{
|
||||||
if ( args[i + 1].Ref == string.Empty )
|
if ( string.IsNullOrEmpty( args[i + 1].Ref ) )
|
||||||
{
|
{
|
||||||
args[i + 1] = new LiteralType( args[i + 1], "(1024 * 32)" );
|
args[i + 1] = new LiteralType( args[i + 1], "(1024 * 32)" );
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace Generator
|
|||||||
public string ManagedType;
|
public string ManagedType;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<string, TypeDef> TypeDefs = new Dictionary<string, TypeDef>();
|
private readonly Dictionary<string, TypeDef> TypeDefs = new Dictionary<string, TypeDef>();
|
||||||
|
|
||||||
void Structs()
|
void Structs()
|
||||||
{
|
{
|
||||||
@ -29,8 +29,6 @@ namespace Generator
|
|||||||
if ( name.Contains( "::" ) )
|
if ( name.Contains( "::" ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int defaultPack = c.IsPack4OnWindows ? 4 : 8;
|
|
||||||
|
|
||||||
var partial = "";
|
var partial = "";
|
||||||
if ( c.Methods != null ) partial = " partial";
|
if ( c.Methods != null ) partial = " partial";
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ namespace Generator
|
|||||||
{
|
{
|
||||||
if ( args[i + 1] is IntType || args[i + 1] is UIntType || args[i + 1] is UIntPtrType )
|
if ( args[i + 1] is IntType || args[i + 1] is UIntType || args[i + 1] is UIntPtrType )
|
||||||
{
|
{
|
||||||
if ( args[i + 1].Ref == string.Empty )
|
if ( string.IsNullOrEmpty( args[i + 1].Ref ) )
|
||||||
{
|
{
|
||||||
args[i + 1] = new LiteralType( args[i + 1], "(1024 * 32)" );
|
args[i + 1] = new LiteralType( args[i + 1], "(1024 * 32)" );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user