fix: empty frame in redis

It's caused an infinit loop. Now some point in (0, 0) with no light ar
added instead of added empty frame.
This commit is contained in:
Lapin Raving 2023-08-23 15:48:05 +02:00
parent baf149ef8a
commit a006bd87a6
2 changed files with 8 additions and 2 deletions

View File

@ -153,6 +153,7 @@ fn get_next_frame(
line = transformer.apply(&line, world_state); line = transformer.apply(&line, world_state);
} }
info!("Draw Black -> {}", world_state.draw_black); info!("Draw Black -> {}", world_state.draw_black);
info!("Draw Grid -> {}", world_state.draw_grid); info!("Draw Grid -> {}", world_state.draw_grid);

View File

@ -1,4 +1,4 @@
use crate::point::Point; use crate::point::{Point, Color};
use crate::transformer::Transformers; use crate::transformer::Transformers;
use crate::worldstate::WorldState; use crate::worldstate::WorldState;
@ -16,10 +16,15 @@ pub enum Replicate {
impl Transformers for Replicate { impl Transformers for Replicate {
fn apply(&self, point_list: &[Point], _ws: &WorldState) -> Vec<Point> { fn apply(&self, point_list: &[Point], _ws: &WorldState) -> Vec<Point> {
let mut point_list2 = vec![]; let mut point_list2 = vec![];
match self { match self {
Replicate::Until(n) => { Replicate::Until(n) => {
while point_list2.len() < *n { while point_list2.len() < *n {
point_list2.append(&mut point_list.to_vec()); if point_list.len() == 0 { // to prevent infinit loop in case of empty frame
point_list2.append(&mut vec![Point{x:0., y:0., color: Color{r:0, g:0, b:0}}; *n].to_vec());
} else {
point_list2.append(&mut point_list.to_vec());
}
} }
} }
Replicate::Times(n) => { Replicate::Times(n) => {