Merge pull request 'Fix crash when 25 players are exceeded' (#5) from dev into master
Reviewed-on: #5
This commit is contained in:
commit
8b2a80a5c1
5 changed files with 26 additions and 20 deletions
|
@ -1,3 +1,3 @@
|
||||||
# Build package for arch-based systems
|
# Build package for arch-based systems
|
||||||
* simply build it: `makepkg`
|
* simply build it: `makepkg -fc`
|
||||||
* also install it directly afterwards: `makepkg -i`
|
* also install it directly afterwards: `makepkg -ifc`
|
||||||
|
|
|
@ -128,13 +128,12 @@ impl LeaderBoard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: when people disconnect there needs to be a remove function
|
|
||||||
// vehicle_scorings.len() != self.leaderboard_entries.len()
|
|
||||||
|
|
||||||
write_log!("create entries");
|
write_log!("create entries");
|
||||||
|
|
||||||
// check if entry count in grid is the same as the gathered entries
|
// check if entry count in grid is the same as the gathered entries
|
||||||
|
// that means some joined or left the game
|
||||||
let force_update = if !self.leaderboard_entries.is_empty()
|
let force_update = if !self.leaderboard_entries.is_empty()
|
||||||
|
&& self.leaderboard_entries.len() <= self.leaderboard_grid.dimensions().1
|
||||||
&& self
|
&& self
|
||||||
.leaderboard_grid
|
.leaderboard_grid
|
||||||
.child_at(0, self.leaderboard_entries.len() - 1)?
|
.child_at(0, self.leaderboard_entries.len() - 1)?
|
||||||
|
@ -145,6 +144,16 @@ impl LeaderBoard {
|
||||||
entry.snippet().set_visibility(false)?;
|
entry.snippet().set_visibility(false)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
// there are more entries in leaderboard when someone leaves and ID doesn't get reused
|
||||||
|
else if self.leaderboard_entries.len() > vehicle_scorings.len() {
|
||||||
|
self.leaderboard_entries.retain(|entry| {
|
||||||
|
vehicle_scorings
|
||||||
|
.iter()
|
||||||
|
.any(|scoring| scoring.mID == entry.id())
|
||||||
|
});
|
||||||
|
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
@ -265,13 +274,12 @@ impl UiOverlay for LeaderBoard {}
|
||||||
impl DataReceiver for LeaderBoard {
|
impl DataReceiver for LeaderBoard {
|
||||||
fn game_phase_change(&mut self, phase: GamePhase) -> Result<()> {
|
fn game_phase_change(&mut self, phase: GamePhase) -> Result<()> {
|
||||||
match phase {
|
match phase {
|
||||||
GamePhase::Practice | GamePhase::Qualifying => {
|
GamePhase::Practice | GamePhase::Qualifying | GamePhase::TestDay => {
|
||||||
for entry in self.leaderboard_entries.iter_mut() {
|
for entry in self.leaderboard_entries.iter_mut() {
|
||||||
entry.update_best_lap(-1.0)?;
|
entry.update_best_lap(-1.0)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.leaderboard.enable()?;
|
self.leaderboard.enable()?;
|
||||||
self.deltaboard.enable()?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GamePhase::Race => {
|
GamePhase::Race => {
|
||||||
|
@ -294,7 +302,9 @@ impl DataReceiver for LeaderBoard {
|
||||||
|
|
||||||
fn update_for_phase(&self, phase: GamePhase) -> bool {
|
fn update_for_phase(&self, phase: GamePhase) -> bool {
|
||||||
match phase {
|
match phase {
|
||||||
GamePhase::Practice | GamePhase::Qualifying | GamePhase::Race => true,
|
GamePhase::Practice | GamePhase::Qualifying | GamePhase::Race | GamePhase::TestDay => {
|
||||||
|
true
|
||||||
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,7 +317,7 @@ impl DataReceiver for LeaderBoard {
|
||||||
write_log!("=================== leader board: scoring update ===================");
|
write_log!("=================== leader board: scoring update ===================");
|
||||||
|
|
||||||
match phase {
|
match phase {
|
||||||
GamePhase::Practice | GamePhase::Qualifying => {
|
GamePhase::Practice | GamePhase::Qualifying | GamePhase::TestDay => {
|
||||||
self.quali_leaderboard(vehicle_scorings)?;
|
self.quali_leaderboard(vehicle_scorings)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@ impl UiOverlay for Pedals {}
|
||||||
impl DataReceiver for Pedals {
|
impl DataReceiver for Pedals {
|
||||||
fn game_phase_change(&mut self, phase: GamePhase) -> Result<()> {
|
fn game_phase_change(&mut self, phase: GamePhase) -> Result<()> {
|
||||||
match phase {
|
match phase {
|
||||||
GamePhase::None | GamePhase::TestDay => {
|
GamePhase::None => {
|
||||||
self.enable = false;
|
self.enable = false;
|
||||||
self.gui.disable()?;
|
self.gui.disable()?;
|
||||||
}
|
}
|
||||||
|
@ -252,10 +252,8 @@ impl DataReceiver for Pedals {
|
||||||
|
|
||||||
fn update_for_phase(&self, phase: GamePhase) -> bool {
|
fn update_for_phase(&self, phase: GamePhase) -> bool {
|
||||||
match phase {
|
match phase {
|
||||||
GamePhase::Practice | GamePhase::Qualifying | GamePhase::Race | GamePhase::Warmup => {
|
GamePhase::None => false,
|
||||||
true
|
_ => true,
|
||||||
}
|
|
||||||
_ => false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -274,7 +274,7 @@ impl UiOverlay for Radar {}
|
||||||
impl DataReceiver for Radar {
|
impl DataReceiver for Radar {
|
||||||
fn game_phase_change(&mut self, phase: GamePhase) -> Result<()> {
|
fn game_phase_change(&mut self, phase: GamePhase) -> Result<()> {
|
||||||
match phase {
|
match phase {
|
||||||
GamePhase::None | GamePhase::TestDay => self.enable = false,
|
GamePhase::None => self.enable = false,
|
||||||
_ => self.enable = true,
|
_ => self.enable = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,10 +283,8 @@ impl DataReceiver for Radar {
|
||||||
|
|
||||||
fn update_for_phase(&self, phase: GamePhase) -> bool {
|
fn update_for_phase(&self, phase: GamePhase) -> bool {
|
||||||
match phase {
|
match phase {
|
||||||
GamePhase::Practice | GamePhase::Qualifying | GamePhase::Race | GamePhase::Warmup => {
|
GamePhase::None => false,
|
||||||
true
|
_ => true,
|
||||||
}
|
|
||||||
_ => false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ impl UiOverlay for Watermark {}
|
||||||
impl DataReceiver for Watermark {
|
impl DataReceiver for Watermark {
|
||||||
fn game_phase_change(&mut self, phase: GamePhase) -> Result<()> {
|
fn game_phase_change(&mut self, phase: GamePhase) -> Result<()> {
|
||||||
match phase {
|
match phase {
|
||||||
GamePhase::TestDay => self.gui.enable()?,
|
GamePhase::None => self.gui.enable()?,
|
||||||
_ => self.gui.disable()?,
|
_ => self.gui.disable()?,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue