Skip to content

Commit

Permalink
Update main branch module to support Steamworks 1.57
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamVenner committed May 11, 2023
1 parent 55a8f7b commit 7313650
Show file tree
Hide file tree
Showing 11 changed files with 63,940 additions and 1,191 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gmsv_workshop"
version = "2.2.4"
version = "2.2.5"
edition = "2021"
authors = ["William Venner <[email protected]>"]
publish = false
Expand Down
9 changes: 8 additions & 1 deletion src/workshop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,14 @@ pub struct Steam {
impl Steam {
pub fn init() -> Steam {
let (server, callbacks) = unsafe {
steamworks::Server::from_raw(steamworks::sys::SteamAPI_SteamGameServer_v013())
steamworks::Server::from_raw({
#[cfg(target_pointer_width = "32")] {
steamworks::sys::SteamAPI_SteamGameServer_v015()
}
#[cfg(target_pointer_width = "64")] {
steamworks::sys::SteamAPI_SteamGameServer_v013()
}
})
};

let steam = Steam {
Expand Down
38 changes: 37 additions & 1 deletion steamworks-rs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
#![allow(unused)]
#![feature(hash_drain_filter)]

#[macro_export]
#[cfg(target_pointer_width = "64")]
macro_rules! sys_ugc {
() => { $crate::sys::SteamAPI_SteamGameServerUGC_v014() }
}

#[macro_export]
#[cfg(target_pointer_width = "64")]
macro_rules! sys_gameserver {
() => { $crate::sys::SteamAPI_SteamGameServer_v013() }
}

#[macro_export]
#[cfg(target_pointer_width = "64")]
macro_rules! sys_steamuser {
() => { $crate::sys::SteamAPI_SteamUser_v021() };
}

#[macro_export]
#[cfg(target_pointer_width = "32")]
macro_rules! sys_ugc {
() => { $crate::sys::SteamAPI_SteamGameServerUGC_v017() }
}

#[macro_export]
#[cfg(target_pointer_width = "32")]
macro_rules! sys_gameserver {
() => { $crate::sys::SteamAPI_SteamGameServer_v015() }
}

#[macro_export]
#[cfg(target_pointer_width = "32")]
macro_rules! sys_steamuser {
() => { $crate::sys::SteamAPI_SteamUser_v023() };
}

#[macro_use]
extern crate thiserror;
#[macro_use]
Expand Down Expand Up @@ -349,7 +385,7 @@ impl<Manager> Client<Manager> {
/// Returns an accessor to the steam user interface
pub fn user(&self) -> User<Manager> {
unsafe {
let user = sys::SteamAPI_SteamUser_v021();
let user = sys_steamuser!();
debug_assert!(!user.is_null());
User {
user,
Expand Down
6 changes: 3 additions & 3 deletions steamworks-rs/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl Server {
return Err(SteamError::InitFailed);
}
sys::SteamAPI_ManualDispatch_Init();
let server_raw = sys::SteamAPI_SteamGameServer_v013();
let server_raw = sys_gameserver!();
let server = Arc::new(Inner {
_manager: ServerManager { _priv: () },
callbacks: Mutex::new(Callbacks {
Expand Down Expand Up @@ -165,7 +165,7 @@ impl Server {
unsafe {
let mut ticket = vec![0; 1024];
let mut ticket_len = 0;
let auth_ticket = sys::SteamAPI_ISteamGameServer_GetAuthSessionTicket(self.server, ticket.as_mut_ptr() as *mut _, 1024, &mut ticket_len);
let auth_ticket = sys::SteamAPI_ISteamGameServer_GetAuthSessionTicket(self.server, ticket.as_mut_ptr() as *mut _, 1024, &mut ticket_len, #[cfg(target_pointer_width = "32")] unimplemented!("not used in gmsv_workshop"));
ticket.truncate(ticket_len as usize);
(AuthTicket(auth_ticket), ticket)
}
Expand Down Expand Up @@ -316,7 +316,7 @@ impl Server {
/// **For this to work properly, you need to call `UGC::init_for_game_server()`!**
pub fn ugc(&self) -> UGC<ServerManager> {
unsafe {
let ugc = sys::SteamAPI_SteamGameServerUGC_v014();
let ugc = sys_ugc!();
debug_assert!(!ugc.is_null());
UGC {
ugc,
Expand Down
6 changes: 3 additions & 3 deletions steamworks-rs/src/ugc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ impl <Manager> UserListQuery<Manager> {
register_call_result::<sys::SteamUGCQueryCompleted_t, _, _>(
&inner, api_call, CALLBACK_BASE_ID + 1,
move |v, io_error| {
let ugc = sys::SteamAPI_SteamGameServerUGC_v014();
let ugc = sys_ugc!();
if io_error {
sys::SteamAPI_ISteamUGC_ReleaseQueryUGCRequest(ugc, handle);
cb(Err(SteamError::IOFailure));
Expand Down Expand Up @@ -1011,7 +1011,7 @@ impl <Manager> ItemListDetailsQuery<Manager> {
register_call_result::<sys::SteamUGCQueryCompleted_t, _, _>(
&inner, api_call, CALLBACK_BASE_ID + 1,
move |v, io_error| {
let ugc = sys::SteamAPI_SteamGameServerUGC_v014();
let ugc = sys_ugc!();
if io_error {
sys::SteamAPI_ISteamUGC_ReleaseQueryUGCRequest(ugc, handle);
cb(Err(SteamError::IOFailure));
Expand Down Expand Up @@ -1140,7 +1140,7 @@ impl <Manager> ItemDetailsQuery<Manager> {
register_call_result::<sys::SteamUGCQueryCompleted_t, _, _>(
&inner, api_call, CALLBACK_BASE_ID + 1,
move |v, io_error| {
let ugc = sys::SteamAPI_SteamGameServerUGC_v014();
let ugc = sys_ugc!();
if io_error {
sys::SteamAPI_ISteamUGC_ReleaseQueryUGCRequest(ugc, handle);
cb(Err(SteamError::IOFailure));
Expand Down
2 changes: 1 addition & 1 deletion steamworks-rs/src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl <Manager> User<Manager> {
unsafe {
let mut ticket = vec![0; 1024];
let mut ticket_len = 0;
let auth_ticket = sys::SteamAPI_ISteamUser_GetAuthSessionTicket(self.user, ticket.as_mut_ptr() as *mut _, 1024, &mut ticket_len);
let auth_ticket = sys::SteamAPI_ISteamUser_GetAuthSessionTicket(self.user, ticket.as_mut_ptr() as *mut _, 1024, &mut ticket_len, #[cfg(target_pointer_width = "32")] unimplemented!("not used in gmsv_workshop"));
ticket.truncate(ticket_len as usize);
(AuthTicket(auth_ticket), ticket)
}
Expand Down
6 changes: 5 additions & 1 deletion steamworks-rs/steamworks-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());

let sdk_loc = "../../lib/steamworks_150";
let sdk_loc = if build_cfg!(target_pointer_width = "32") {
"../../lib/steamworks_157"
} else {
"../../lib/steamworks_150"
};
let sdk_loc = Path::new(&sdk_loc);
println!("cargo:rerun-if-env-changed=STEAM_SDK_LOCATION");

Expand Down
31,368 changes: 31,367 additions & 1 deletion steamworks-rs/steamworks-sys/src/bindings_linux32.rs

Large diffs are not rendered by default.

29,602 changes: 29,601 additions & 1 deletion steamworks-rs/steamworks-sys/src/bindings_linux64.rs

Large diffs are not rendered by default.

Loading

0 comments on commit 7313650

Please sign in to comment.