aboutsummaryrefslogtreecommitdiff
path: root/src/matchmaking.rs
diff options
context:
space:
mode:
authorMatthew Collins <[email protected]>2020-02-22 20:50:46 +0000
committerMatthew Collins <[email protected]>2020-02-22 20:50:46 +0000
commit0b4f68b1f4fac5c7e608861274eadeb5186688b3 (patch)
tree9d69e5fd94e4d6cd8c7a535f4a0236e2d55c7d35 /src/matchmaking.rs
parentBump version to 0.6.1 (diff)
downloadsteamworks-rs-0b4f68b1f4fac5c7e608861274eadeb5186688b3.tar.xz
steamworks-rs-0b4f68b1f4fac5c7e608861274eadeb5186688b3.zip
Rework to use the new flat steam api
Diffstat (limited to 'src/matchmaking.rs')
-rw-r--r--src/matchmaking.rs35
1 files changed, 14 insertions, 21 deletions
diff --git a/src/matchmaking.rs b/src/matchmaking.rs
index f10eff1..ed4cd57 100644
--- a/src/matchmaking.rs
+++ b/src/matchmaking.rs
@@ -40,13 +40,6 @@ impl LobbyId {
pub fn raw(&self) -> u64 {
self.0
}
-
- /// Returns whether this id is valid or not
- pub fn is_valid(&self) -> bool {
- unsafe {
- sys::steam_rust_is_steam_id_valid(self.0) != 0
- }
- }
}
impl <Manager> Matchmaking<Manager> {
@@ -64,7 +57,7 @@ impl <Manager> Matchmaking<Manager> {
} else {
let mut out = Vec::with_capacity(v.m_nLobbiesMatching as usize);
for idx in 0 .. v.m_nLobbiesMatching {
- out.push(LobbyId(sys::SteamAPI_ISteamMatchmaking_GetLobbyByIndex(sys::steam_rust_get_matchmaking(), idx as _).0));
+ out.push(LobbyId(sys::SteamAPI_ISteamMatchmaking_GetLobbyByIndex(sys::SteamAPI_SteamMatchmaking_v009(), idx as _)));
}
Ok(out)
})
@@ -89,10 +82,10 @@ impl <Manager> Matchmaking<Manager> {
assert!(max_members <= 250); // Steam API limits
unsafe {
let ty = match ty {
- LobbyType::Private => sys::ELobbyType::ELobbyTypePrivate,
- LobbyType::FriendsOnly => sys::ELobbyType::ELobbyTypeFriendsOnly,
- LobbyType::Public => sys::ELobbyType::ELobbyTypePublic,
- LobbyType::Invisible => sys::ELobbyType::ELobbyTypeInvisible,
+ LobbyType::Private => sys::ELobbyType::k_ELobbyTypePrivate,
+ LobbyType::FriendsOnly => sys::ELobbyType::k_ELobbyTypeFriendsOnly,
+ LobbyType::Public => sys::ELobbyType::k_ELobbyTypePublic,
+ LobbyType::Invisible => sys::ELobbyType::k_ELobbyTypeInvisible,
};
let api_call = sys::SteamAPI_ISteamMatchmaking_CreateLobby(self.mm, ty, max_members as _);
register_call_result::<sys::LobbyCreated_t, _, _>(
@@ -100,7 +93,7 @@ impl <Manager> Matchmaking<Manager> {
move |v, io_error| {
cb(if io_error {
Err(SteamError::IOFailure)
- } else if v.m_eResult != sys::EResult::EResultOK {
+ } else if v.m_eResult != sys::EResult::k_EResultOK {
Err(v.m_eResult.into())
} else {
Ok(LobbyId(v.m_ulSteamIDLobby))
@@ -115,7 +108,7 @@ impl <Manager> Matchmaking<Manager> {
where F: FnMut(Result<LobbyId, ()>) + 'static + Send
{
unsafe {
- let api_call = sys::SteamAPI_ISteamMatchmaking_JoinLobby(self.mm, sys::CSteamID(lobby.0));
+ let api_call = sys::SteamAPI_ISteamMatchmaking_JoinLobby(self.mm, lobby.0);
register_call_result::<sys::LobbyEnter_t, _, _>(
&self.inner, api_call, CALLBACK_BASE_ID + 4,
move |v, io_error| {
@@ -134,14 +127,14 @@ impl <Manager> Matchmaking<Manager> {
/// Exits the passed lobby
pub fn leave_lobby(&self, lobby: LobbyId) {
unsafe {
- sys::SteamAPI_ISteamMatchmaking_LeaveLobby(self.mm, sys::CSteamID(lobby.0));
+ sys::SteamAPI_ISteamMatchmaking_LeaveLobby(self.mm, lobby.0);
}
}
/// Returns the steam id of the current owner of the passed lobby
pub fn lobby_owner(&self, lobby: LobbyId) -> SteamId {
unsafe {
- SteamId(sys::SteamAPI_ISteamMatchmaking_GetLobbyOwner(self.mm, sys::CSteamID(lobby.0)).0)
+ SteamId(sys::SteamAPI_ISteamMatchmaking_GetLobbyOwner(self.mm, lobby.0))
}
}
@@ -150,7 +143,7 @@ impl <Manager> Matchmaking<Manager> {
/// Useful if you are not currently in the lobby
pub fn lobby_member_count(&self, lobby: LobbyId) -> usize {
unsafe {
- let count = sys::SteamAPI_ISteamMatchmaking_GetNumLobbyMembers(self.mm, sys::CSteamID(lobby.0));
+ let count = sys::SteamAPI_ISteamMatchmaking_GetNumLobbyMembers(self.mm, lobby.0);
count as usize
}
}
@@ -158,11 +151,11 @@ impl <Manager> Matchmaking<Manager> {
/// Returns a list of members currently in the lobby
pub fn lobby_members(&self, lobby: LobbyId) -> Vec<SteamId> {
unsafe {
- let count = sys::SteamAPI_ISteamMatchmaking_GetNumLobbyMembers(self.mm, sys::CSteamID(lobby.0));
+ let count = sys::SteamAPI_ISteamMatchmaking_GetNumLobbyMembers(self.mm, lobby.0);
let mut members = Vec::with_capacity(count as usize);
for idx in 0 .. count {
members.push(SteamId(
- sys::SteamAPI_ISteamMatchmaking_GetLobbyMemberByIndex(self.mm, sys::CSteamID(lobby.0), idx).0
+ sys::SteamAPI_ISteamMatchmaking_GetLobbyMemberByIndex(self.mm, lobby.0, idx)
))
}
members
@@ -181,8 +174,8 @@ impl <Manager> Matchmaking<Manager> {
pub fn set_lobby_joinable(&self, lobby: LobbyId, joinable: bool) -> bool {
unsafe {
sys::SteamAPI_ISteamMatchmaking_SetLobbyJoinable(
- self.mm, sys::CSteamID(lobby.0), joinable
- ) != 0
+ self.mm, lobby.0, joinable
+ )
}
}
}