Commit a1b3f1fb authored by Antoine Cellerier's avatar Antoine Cellerier

I'm not sure that this is ok but it definitively prevents impossible to solve...

I'm not sure that this is ok but it definitively prevents impossible to solve puzzles from being generated here.
parent 5506025a
......@@ -118,6 +118,18 @@ static vlc_bool_t finished( vout_sys_t *p_sys )
}
return VLC_TRUE;
}
static vlc_bool_t is_valid( vout_sys_t *p_sys )
{
int i, s;
if( p_sys->b_blackslot == VLC_FALSE ) return VLC_TRUE;
for( i = 0; i < p_sys->i_cols * p_sys->i_rows; i++ )
{
if( (p_sys->i_cols*p_sys->i_rows+i-p_sys->pi_order[i])%2 ) s++;
else s--;
}
if( s!=0 ) return VLC_FALSE;
else return VLC_TRUE;
}
static void shuffle( vout_sys_t *p_sys )
{
int i, c;
......@@ -140,7 +152,8 @@ static void shuffle( vout_sys_t *p_sys )
}
}
p_sys->b_finished = finished( p_sys );
} while( p_sys->b_finished == VLC_TRUE );
} while( p_sys->b_finished == VLC_TRUE
&& is_valid( p_sys ) == VLC_FALSE );
if( p_sys->b_blackslot == VLC_TRUE )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment