From 4e5a0ced33f810284b26eae661d1e1b7fafa3d42 Mon Sep 17 00:00:00 2001 From: Matthew Collins Date: Wed, 2 May 2018 21:12:13 +0100 Subject: Add restart_app_if_necessary --- Cargo.toml | 2 +- src/lib.rs | 11 +++++++++++ steamworks-sys/Cargo.toml | 2 +- steamworks-sys/src/lib.rs | 5 +++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 67073fc..4575071 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "steamworks" -version = "0.3.0" +version = "0.3.1" authors = ["Thinkofname"] description = "Provides rust friendly bindings to the steamworks sdk" license = "MIT / Apache-2.0" diff --git a/src/lib.rs b/src/lib.rs index b2ec727..26662e7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,6 +72,17 @@ unsafe impl Sync for Inner {} unsafe impl Send for Client {} unsafe impl Sync for Client {} +/// Returns true if the app wasn't launched through steam and +/// begins relaunching it, the app should exit as soon as possible. +/// +/// Returns false if the app was either launched through steam +/// or has a `steam_appid.txt` +pub fn restart_app_if_necessary(app_id: AppId) -> bool { + unsafe { + sys::SteamAPI_RestartAppIfNecessary(app_id.0) != 0 + } +} + impl Client { /// Attempts to initialize the steamworks api and returns /// a client to access the rest of the api. diff --git a/steamworks-sys/Cargo.toml b/steamworks-sys/Cargo.toml index 2d89333..a94ba83 100644 --- a/steamworks-sys/Cargo.toml +++ b/steamworks-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "steamworks-sys" -version = "0.2.1" +version = "0.2.2" authors = ["Thinkofname"] build = "build.rs" description = "Provides raw bindings to the steamworks sdk" diff --git a/steamworks-sys/src/lib.rs b/steamworks-sys/src/lib.rs index b796f77..5fbb565 100644 --- a/steamworks-sys/src/lib.rs +++ b/steamworks-sys/src/lib.rs @@ -241,7 +241,7 @@ pub struct CallbackData { pub run: unsafe extern "C" fn(*mut c_void, *mut c_void, *mut c_void), pub run_extra: unsafe extern "C" fn(*mut c_void, *mut c_void, *mut c_void, bool, SteamAPICall), pub dealloc: unsafe extern "C" fn(*mut c_void, *mut c_void), -} +} extern "C" { // Helpers from lib.cpp @@ -258,7 +258,7 @@ extern "C" { pub fn steam_rust_get_server_apps() -> *mut ISteamApps; pub fn steam_rust_game_server_init(ip: u32, steam_port: u16, game_port: u16, query_port: u16, server_mode: ServerMode, version: *const c_char) -> c_int; - + // pub fn SteamAPI_Init() -> u8; @@ -268,6 +268,7 @@ extern "C" { pub fn SteamAPI_UnregisterCallback(pCallback: *mut c_void); pub fn SteamAPI_RegisterCallResult(pCallback: *mut c_void, api_call: SteamAPICall); pub fn SteamAPI_UnregisterCallResult(pCallback: *mut c_void, api_call: SteamAPICall); + pub fn SteamAPI_RestartAppIfNecessary(app_id: u32) -> u8; pub fn SteamGameServer_Shutdown(); pub fn SteamGameServer_RunCallbacks(); -- cgit v1.2.3