]> git.sesse.net Git - vlc/commitdiff
I'm not sure that this is ok but it definitively prevents impossible to solve puzzles...
authorAntoine Cellerier <dionoea@videolan.org>
Sat, 11 Nov 2006 00:18:01 +0000 (00:18 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Sat, 11 Nov 2006 00:18:01 +0000 (00:18 +0000)
modules/video_filter/puzzle.c

index bc88c1de57c87a2cf284ecbd7c4d2891cf1ae797..d14dbac5eea148f8b906679516a56bb4d9a9e0d1 100644 (file)
@@ -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 )
     {