diff options
| author | Flaise <[email protected]> | 2019-08-11 17:03:24 -0500 |
|---|---|---|
| committer | Matthew Collins <[email protected]> | 2019-08-14 15:47:12 +0100 |
| commit | f8818e261699eb58b71ab8b9dcc9672a9bd5054e (patch) | |
| tree | 85d4ede2726f64fd44f407994f0fbac3073dc0c5 /src/server.rs | |
| parent | Implemented P2PSessionConnectFail callback and removed a result handler's Syn... (diff) | |
| download | steamworks-rs-f8818e261699eb58b71ab8b9dcc9672a9bd5054e.tar.xz steamworks-rs-f8818e261699eb58b71ab8b9dcc9672a9bd5054e.zip | |
Added more bindings to SteamGameServer API
Diffstat (limited to 'src/server.rs')
| -rw-r--r-- | src/server.rs | 62 |
1 files changed, 53 insertions, 9 deletions
diff --git a/src/server.rs b/src/server.rs index 3d957ee..1f9a246 100644 --- a/src/server.rs +++ b/src/server.rs @@ -183,25 +183,26 @@ impl Server { } } - /// Sets the game product identifier. + /// Sets the game product identifier. This is currently used by the master server for version + /// checking purposes. Converting the games app ID to a string for this is recommended. /// - /// Used by the master server for version checking. Required - /// field but it will go away eventually. + /// This is required for all game servers and can only be set before calling + /// log_on() or log_on_anonymous(). pub fn set_product(&self, product: &str) { + let product = CString::new(product).unwrap(); unsafe { - let product = CString::new(product).unwrap(); sys::SteamAPI_ISteamGameServer_SetProduct(self.server, product.as_ptr() as *const _); } } - /// Sets the game description. + /// Sets the game description. Setting this to the full name of your game is recommended. /// - /// Displayed in the steam server browser (for now). Required - /// field but it will go away eventually. + /// This is required for all game servers and can only be set before calling + /// log_on() or log_on_anonymous(). pub fn set_game_description(&self, desc: &str) { + let desc = CString::new(desc).unwrap(); unsafe { - let desc = CString::new(desc).unwrap(); - sys::SteamAPI_ISteamGameServer_SetGameDescription(self.server, desc.as_ptr() as *const _); + sys::SteamAPI_ISteamGameServer_SetGameDescription(self.server, desc.as_ptr()); } } @@ -219,6 +220,49 @@ impl Server { } } + /// If active, updates the master server with this server's presence so players can find it via + /// the steam matchmaking/server browser interfaces. + pub fn enable_heartbeats(&self, active: bool) { + unsafe { + sys::SteamAPI_ISteamGameServer_EnableHeartbeats(self.server, active); + } + } + + /// If your game is a "mod," pass the string that identifies it. The default is an empty + /// string, meaning this application is the original game, not a mod. + pub fn set_mod_dir(&self, mod_dir: &str) { + let mod_dir = CString::new(mod_dir).unwrap(); + unsafe { + sys::SteamAPI_ISteamGameServer_SetModDir(self.server, mod_dir.as_ptr()); + } + } + + /// Set name of map to report in the server browser + pub fn set_map_name(&self, map_name: &str) { + let map_name = CString::new(map_name).unwrap(); + unsafe { + sys::SteamAPI_ISteamGameServer_SetMapName(self.server, map_name.as_ptr()); + } + } + + /// Set the name of server as it will appear in the server browser + pub fn set_server_name(&self, server_name: &str) { + let server_name = CString::new(server_name).unwrap(); + unsafe { + sys::SteamAPI_ISteamGameServer_SetMapName(self.server, server_name.as_ptr()); + } + } + + + /// Sets the maximum number of players allowed on the server at once. + /// + /// This value may be changed at any time. + pub fn set_max_players(&self, count: i32) { + unsafe { + sys::SteamAPI_ISteamGameServer_SetMaxPlayerCount(self.server, count); + } + } + /* TODO: Buggy currently? /// Returns an accessor to the steam apps interface pub fn apps(&self) -> Apps<ServerManager> { |