mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-12 14:48:02 +03:00
randomize steam port by default
This commit is contained in:
parent
aa28a78d8c
commit
a53340ddea
@ -34,18 +34,28 @@ namespace Facepunch.Steamworks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="appId">You game's AppId</param>
|
/// <param name="appId">You game's AppId</param>
|
||||||
/// <param name="IpAddress">The IP Address to bind to. Can be 0 to mean "any".</param>
|
/// <param name="IpAddress">The IP Address to bind to. Can be 0 to mean "any".</param>
|
||||||
|
/// <param name="SteamPort">Port to talk to steam on, can be anything as long as it's not used.".</param>
|
||||||
/// <param name="GamePort">The port you game listens to for connections.</param>
|
/// <param name="GamePort">The port you game listens to for connections.</param>
|
||||||
/// <param name="QueryPort">The port Steam should use for server queries.</param>
|
/// <param name="QueryPort">The port Steam should use for server queries.</param>
|
||||||
/// <param name="Secure">True if you want to use VAC</param>
|
/// <param name="Secure">True if you want to use VAC</param>
|
||||||
/// <param name="VersionString">A string defining version, ie "1001"</param>
|
/// <param name="VersionString">A string defining version, ie "1001"</param>
|
||||||
public Server( uint appId, uint IpAddress, ushort GamePort, ushort QueryPort, bool Secure, string VersionString )
|
public Server( uint appId, uint IpAddress, ushort SteamPort, ushort GamePort, ushort QueryPort, bool Secure, string VersionString )
|
||||||
{
|
{
|
||||||
native = new Interop.NativeInterface();
|
native = new Interop.NativeInterface();
|
||||||
|
|
||||||
|
//
|
||||||
|
// If we don't have a SteamPort defined, choose one at 'random'
|
||||||
|
//
|
||||||
|
if ( SteamPort == 0 )
|
||||||
|
{
|
||||||
|
SteamPort = (ushort) new Random().Next( 10000, 60000 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get other interfaces
|
// Get other interfaces
|
||||||
//
|
//
|
||||||
if ( !native.InitServer( this, IpAddress, 0, GamePort, QueryPort, Secure ? 3 : 2, VersionString ) )
|
if ( !native.InitServer( this, IpAddress, SteamPort, GamePort, QueryPort, Secure ? 3 : 2, VersionString ) )
|
||||||
{
|
{
|
||||||
native.Dispose();
|
native.Dispose();
|
||||||
native = null;
|
native = null;
|
||||||
@ -83,6 +93,20 @@ namespace Facepunch.Steamworks
|
|||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize a Steam Server instance
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="appId">You game's AppId</param>
|
||||||
|
/// <param name="IpAddress">The IP Address to bind to. Can be 0 to mean "any".</param>
|
||||||
|
/// <param name="GamePort">The port you game listens to for connections.</param>
|
||||||
|
/// <param name="QueryPort">The port Steam should use for server queries.</param>
|
||||||
|
/// <param name="Secure">True if you want to use VAC</param>
|
||||||
|
/// <param name="VersionString">A string defining version, ie "1001"</param>
|
||||||
|
public Server( uint appId, uint IpAddress, ushort GamePort, ushort QueryPort, bool Secure, string VersionString ) : this( appId, IpAddress, 0, GamePort, QueryPort, Secure, VersionString )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialize a server - query port will use the same as GamePort (MASTERSERVERUPDATERPORT_USEGAMESOCKETSHARE)
|
/// Initialize a server - query port will use the same as GamePort (MASTERSERVERUPDATERPORT_USEGAMESOCKETSHARE)
|
||||||
/// This means you'll need to detect and manually process and reply to server queries.
|
/// This means you'll need to detect and manually process and reply to server queries.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user