diff --git a/Facepunch.Steamworks.Test/Server/Server.cs b/Facepunch.Steamworks.Test/Server/Server.cs index 68948c5..ca7f70c 100644 --- a/Facepunch.Steamworks.Test/Server/Server.cs +++ b/Facepunch.Steamworks.Test/Server/Server.cs @@ -14,7 +14,7 @@ public class Server [TestMethod] public void Init() { - using ( var server = new Facepunch.Steamworks.Server( 252490, 30000, 30001, 30002, 30003, false, "VersionString" ) ) + using ( var server = new Facepunch.Steamworks.Server( 252490, 30001, 30002, 30003, false, "VersionString" ) ) { Assert.IsTrue( server.Valid ); } @@ -25,12 +25,17 @@ public void AuthCallback() { using ( var client = new Facepunch.Steamworks.Client( 252490 ) ) { - using ( var server = new Facepunch.Steamworks.Server( 252490, 0, 30001, 30002, 30003, true, "VersionString" ) ) - { - Assert.IsTrue( client.Valid ); + Assert.IsTrue( client.Valid ); + var ticket = client.Auth.GetAuthSessionTicket(); + var ticketBinary = ticket.Data; + + using ( var server = new Facepunch.Steamworks.Server( 252490, 30001, 30002, 30003, true, "VersionString" ) ) + { + + + server.LogOnAnonymous(); + - var ticket = client.Auth.GetAuthSessionTicket(); - var ticketBinary = ticket.Data; Assert.IsTrue( server.Valid ); diff --git a/Facepunch.Steamworks/Server.cs b/Facepunch.Steamworks/Server.cs index c3e1523..fa5feaf 100644 --- a/Facepunch.Steamworks/Server.cs +++ b/Facepunch.Steamworks/Server.cs @@ -100,9 +100,9 @@ public enum MessageType : int /// public Action OnMessage; - public Server( uint appId, uint IpAddress, ushort SteamPort, ushort GamePort, ushort QueryPort, bool Secure, string VersionString ) + public Server( uint appId, uint IpAddress, ushort GamePort, ushort QueryPort, bool Secure, string VersionString ) { - Valve.Interop.NativeEntrypoints.Extended.SteamInternal_GameServer_Init( IpAddress, SteamPort, GamePort, QueryPort, Secure ? 3 : 2, VersionString ); + Valve.Interop.NativeEntrypoints.Extended.SteamInternal_GameServer_Init( IpAddress, 0, GamePort, QueryPort, Secure ? 3 : 2, VersionString ); native = new Internal(); @@ -132,10 +132,6 @@ public Server( uint appId, uint IpAddress, ushort SteamPort, ushort GamePort, us // // Initial settings // - native.gameServer.SetModDir( "rust" ); - native.gameServer.SetProduct( "rust" ); - native.gameServer.SetGameDescription( "rust" ); - native.gameServer.LogOnAnonymous(); native.gameServer.EnableHeartbeats( true ); MaxPlayers = 32; BotCount = 0; @@ -147,6 +143,14 @@ public Server( uint appId, uint IpAddress, ushort SteamPort, ushort GamePort, us Update(); } + /// + /// Initialize a server - query port will use the same as GamePort (MASTERSERVERUPDATERPORT_USEGAMESOCKETSHARE) + /// + public Server( uint appId, uint IpAddress, ushort GamePort, bool Secure, string VersionString ) : this( appId, IpAddress, GamePort, 0xFFFF, Secure, VersionString ) + { + + } + public void Dispose() { if ( native != null) @@ -253,5 +257,100 @@ public string MapName set { if ( _mapname == value ) return; native.gameServer.SetMapName( value ); _mapname = value; } } private string _mapname; + + /// + /// Gets or sets the current ModDir + /// + public string ModDir + { + get { return _modDir; } + set { if ( _modDir == value ) return; native.gameServer.SetModDir( value ); _modDir = value; } + } + private string _modDir = ""; + + /// + /// Gets or sets the current Product + /// + public string Product + { + get { return _product; } + set { if ( _product == value ) return; native.gameServer.SetProduct( value ); _product = value; } + } + private string _product = ""; + + /// + /// Gets or sets the current Product + /// + public string GameDescription + { + get { return _gameDescription; } + set { if ( _gameDescription == value ) return; native.gameServer.SetGameDescription( value ); _gameDescription = value; } + } + private string _gameDescription = ""; + + /// + /// Gets or sets the current ServerName + /// + public string ServerName + { + get { return _serverName; } + set { if ( _serverName == value ) return; native.gameServer.SetServerName( value ); _serverName = value; } + } + private string _serverName = ""; + + /// + /// Gets or sets the current Passworded + /// + public bool Passworded + { + get { return _passworded; } + set { if ( _passworded == value ) return; native.gameServer.SetPasswordProtected( value ); _passworded = value; } + } + private bool _passworded; + + /// + /// Gets or sets the current GameTags + /// + public string GameTags + { + get { return _gametags; } + set { if ( _gametags == value ) return; native.gameServer.SetGameTags( value ); _gametags = value; } + } + private string _gametags = ""; + + /// + /// Log onto Steam anonymously + /// + public void LogOnAnonymous() + { + native.gameServer.LogOnAnonymous(); + } + + Dictionary KeyValue = new Dictionary(); + + /// + /// Sets a Key Value + /// + public void SetKey( string Key, string Value ) + { + if ( KeyValue.ContainsKey( Key ) ) + { + if ( KeyValue[Key] == Value ) + return; + + KeyValue[Key] = Value; + } + else + { + KeyValue.Add( Key, Value ); + } + + native.gameServer.SetKeyValue( Key, Value ); + } + + public void UpdatePlayer( ulong steamid, string name, int score ) + { + native.gameServer.BUpdateUserData( steamid, name, (uint) score ); + } } }