Browse Source

get player counts for room lists

pbs
Andy Newjack 5 years ago
committed by jake
parent
commit
38b0cac09b
  1. 10
      src/ship/location.rs
  2. 4
      src/ship/room.rs
  3. 2
      src/ship/ship.rs

10
src/ship/location.rs

@ -292,4 +292,14 @@ impl ClientLocation {
.map(|lobby| lobby.write().unwrap().remove(id)) .map(|lobby| lobby.write().unwrap().remove(id))
.any(|k| k); .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
}
} }

4
src/ship/room.rs

@ -127,10 +127,6 @@ pub struct RoomState {
// drop_table // drop_table
// items on ground // items on ground
// enemy info // enemy info
pub difficulty: u8,
pub players: u8,
pub episode: u8,
pub flags: u8,
} }
impl RoomState { impl RoomState {

2
src/ship/ship.rs

@ -447,7 +447,7 @@ impl<EG: EntityGateway> ShipServerState<EG> {
menu_id: ROOM_MENU_ID, menu_id: ROOM_MENU_ID,
item_id: i as u32, item_id: i as u32,
difficulty: room.get_difficulty_for_room_list(), 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), name: libpso::utf8_to_utf16_array!(room.name, 16),
episode: room.get_episode_for_room_list(), episode: room.get_episode_for_room_list(),
flags: room.get_flags_for_room_list(), flags: room.get_flags_for_room_list(),

Loading…
Cancel
Save