From 38b0cac09b65803591f3b28405a9e64665300ef8 Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Thu, 19 Mar 2020 23:03:21 -0300 Subject: [PATCH] get player counts for room lists --- src/ship/location.rs | 10 ++++++++++ src/ship/room.rs | 4 ---- src/ship/ship.rs | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ship/location.rs b/src/ship/location.rs index 04b78fa..7aa5541 100644 --- a/src/ship/location.rs +++ b/src/ship/location.rs @@ -292,4 +292,14 @@ impl ClientLocation { .map(|lobby| lobby.write().unwrap().remove(id)) .any(|k| k); } + + pub fn get_clients_in_room(&self, room_id: RoomId) -> u8 { + self.rooms[room_id.0].as_ref() + .unwrap() + .read() + .unwrap() + .clients() + .filter(|k| k.is_some()) + .count() as u8 + } } diff --git a/src/ship/room.rs b/src/ship/room.rs index 9bf4338..08e49ad 100644 --- a/src/ship/room.rs +++ b/src/ship/room.rs @@ -127,10 +127,6 @@ pub struct RoomState { // drop_table // items on ground // enemy info - pub difficulty: u8, - pub players: u8, - pub episode: u8, - pub flags: u8, } impl RoomState { diff --git a/src/ship/ship.rs b/src/ship/ship.rs index ae12b84..e3f9649 100644 --- a/src/ship/ship.rs +++ b/src/ship/ship.rs @@ -447,7 +447,7 @@ impl ShipServerState { menu_id: ROOM_MENU_ID, item_id: i as u32, difficulty: room.get_difficulty_for_room_list(), - players: 0, // TODO + players: self.client_location.get_clients_in_room(RoomId(i)), // TODO name: libpso::utf8_to_utf16_array!(room.name, 16), episode: room.get_episode_for_room_list(), flags: room.get_flags_for_room_list(),