aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Collins <[email protected]>2018-06-26 19:54:56 +0100
committerMatthew Collins <[email protected]>2018-06-26 19:55:21 +0100
commit6d94bd0cd0b57b4e8ea87ed4e8d30c4d6a9bd3b8 (patch)
tree79964281d2dd631398da98d7a4a579ad33c425da
parentImprove the generated wrappers (diff)
downloadsteamworks-rs-6d94bd0cd0b57b4e8ea87ed4e8d30c4d6a9bd3b8.tar.xz
steamworks-rs-6d94bd0cd0b57b4e8ea87ed4e8d30c4d6a9bd3b8.zip
Fix a crash requesting friends when the user is offline
-rw-r--r--src/friends.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/friends.rs b/src/friends.rs
index 68cbe6d..2604fa6 100644
--- a/src/friends.rs
+++ b/src/friends.rs
@@ -65,6 +65,9 @@ impl <Manager> Friends<Manager> {
pub fn get_friends(&self, flags: FriendFlags) -> Vec<Friend<Manager>> {
unsafe {
let count = sys::SteamAPI_ISteamFriends_GetFriendCount(self.friends, flags.bits() as _);
+ if count == -1 {
+ return Vec::new();
+ }
let mut friends = Vec::with_capacity(count as usize);
for idx in 0 .. count {
let friend = SteamId(sys::SteamAPI_ISteamFriends_GetFriendByIndex(self.friends, idx, flags.bits() as _));