diff --git a/overlay/src/network.rs b/overlay/src/network.rs index 88268d19..3d9f2abf 100644 --- a/overlay/src/network.rs +++ b/overlay/src/network.rs @@ -103,10 +103,16 @@ impl TeamInfoRaw { ) ); MemberRaw { - name: member["rosterName"].to_string().trim().to_string(), + name: member["rosterName"] + .as_str() + .unwrap_or("Player") + .trim() + .to_string(), number: member["capNumber"].as_u64().map(|e| e as u8), role: member["roles"].as_array().and_then(|a| { - a.iter().map(|v| v.to_string()).find(|v| *v == "Player") + a.iter() + .map(|v| v.as_str().unwrap_or("").to_owned()) + .find(|v| *v != "Player") }), picture, geared_picture, diff --git a/overlay/src/pages/roster/picture.rs b/overlay/src/pages/roster/picture.rs index 5f3153a0..353a8f67 100644 --- a/overlay/src/pages/roster/picture.rs +++ b/overlay/src/pages/roster/picture.rs @@ -50,9 +50,23 @@ pub fn draw(renderer: &mut PageRenderer, state: &State) { // p1: Team White -> Team Black // p3: Team Black -> Referees // p5: Referees -> Fade out - let p1 = 4.5 + ((state.white.members.len() + 3) / 4 * RPD_GROUP_TIME as usize) as f32; - let p2 = p1 + 4.5 + ((state.black.members.len() + 3) / 4 * RPD_GROUP_TIME as usize) as f32; - let p3 = p2 + 4.5 + ((state.referees.len() + 3) / 4 * RPD_GROUP_TIME as usize) as f32; + let p1 = if !state.white.members.is_empty() { + 4.5 + ((state.white.members.len() + 3) / 4 * RPD_GROUP_TIME as usize) as f32 + } else { + 0f32 + }; + let p2 = p1 + + if !state.black.members.is_empty() { + 4.5 + ((state.black.members.len() + 3) / 4 * RPD_GROUP_TIME as usize) as f32 + } else { + 0f32 + }; + let p3 = p2 + + if !state.referees.is_empty() { + 4.5 + ((state.referees.len() + 3) / 4 * RPD_GROUP_TIME as usize) as f32 + } else { + 0f32 + }; let (team_name, team_flag, card_repr, team_textures, text_color, (page_start, page_end)) = match Instant::now()