Skip to content

Commit 350b059

Browse files
committed
Update and fix bugs
1 parent c83249b commit 350b059

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/epsilon/server/instance.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ impl Instance {
109109
}
110110

111111
pub async fn get_online_count(&self) -> i32 {
112-
self.get_info().await.unwrap().players.online as i32
112+
match self.get_info().await {
113+
Ok(status) => status.players.online as i32,
114+
Err(_) => 0,
115+
}
113116
}
114117

115118
pub async fn get_available_slots(&self) -> i32 {

src/tasks/hub_task.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,11 @@ impl Task for HubTask {
8787
let mut hub_option = None;
8888

8989
for instance in hubs_ready {
90-
let info_result = instance.get_info().await;
90+
let online_player = instance.get_online_count().await;
9191

92-
if let Ok(info) = info_result {
93-
let online_player = info.players.online;
94-
95-
if instance.get_state() == EpsilonState::Running
96-
&& online_player <= n
97-
{
98-
n = online_player;
99-
hub_option = Some(instance);
100-
}
92+
if instance.get_state() == EpsilonState::Running && online_player <= n {
93+
n = online_player;
94+
hub_option = Some(instance);
10195
}
10296
}
10397

0 commit comments

Comments
 (0)