[vlc-devel] [PATCH 6/6] Puzzle: puzzle shapes
Vianney Boyer
vlcvboyer at gmail.com
Thu Jul 25 07:49:29 CEST 2013
Hi,
This is a minor bug correction of puzzle filter (shapes were straight
when changing from swap mode to jigsaw mode.)
This patch re-generates the shapes in this case
Regards
Vianney
---
modules/video_filter/puzzle_mgt.c | 47
+++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/modules/video_filter/puzzle_mgt.c
b/modules/video_filter/puzzle_mgt.c
index b6a9862..8f2fd19 100644
--- a/modules/video_filter/puzzle_mgt.c
+++ b/modules/video_filter/puzzle_mgt.c
@@ -957,4 +957,51 @@ void puzzle_load( filter_t *p_filter, save_game_t
*ps_save_game)
break;
}
}
+
+ for (uint32_t i_pce=0; i_pce < p_sys->s_allocated.i_pieces_nbr;
i_pce++) {
+ /* redefine shapes */
+ uint32_t i_left_pce = 0;
+ uint32_t i_right_pce = 6;
+ uint32_t i_top_pce = 2;
+ uint32_t i_btm_pce = 4;
+
+ uint32_t i_pce_pair = 0;
+ for (int32_t i_row = 0; i_row < p_sys->s_allocated.i_rows; i_row++)
+ for (int32_t i_col = 0; i_col < p_sys->s_allocated.i_cols;
i_col++) {
+ if (p_sys->ps_pieces[i_pce].i_original_row ==
p_sys->ps_pieces[i_pce_pair].i_original_row) {
+ if (p_sys->ps_pieces[i_pce].i_original_col ==
p_sys->ps_pieces[i_pce_pair].i_original_col - 1)
+ i_right_pce = i_pce_pair;
+ else if (p_sys->ps_pieces[i_pce].i_original_col ==
p_sys->ps_pieces[i_pce_pair].i_original_col + 1)
+ i_left_pce = i_pce_pair;
+ }
+ else if (p_sys->ps_pieces[i_pce].i_original_col ==
p_sys->ps_pieces[i_pce_pair].i_original_col) {
+ if (p_sys->ps_pieces[i_pce].i_original_row ==
p_sys->ps_pieces[i_pce_pair].i_original_row - 1)
+ i_btm_pce = i_pce_pair;
+ else if (p_sys->ps_pieces[i_pce].i_original_row ==
p_sys->ps_pieces[i_pce_pair].i_original_row + 1)
+ i_top_pce = i_pce_pair;
+ }
+ i_pce_pair++;
+ }
+
+ if ((p_sys->ps_pieces[i_pce].i_left_shape == 0) &&
(p_sys->ps_pieces[i_pce].i_original_col != 0)) {
+ p_sys->ps_pieces[i_left_pce].i_right_shape = 6 + 8 + 8*((
(unsigned) vlc_mrand48()) % ( SHAPES_QTY ) ) + (vlc_mrand48() & 0x01);
+ p_sys->ps_pieces[i_pce].i_left_shape =
(p_sys->ps_pieces[i_left_pce].i_right_shape - 6 ) ^ 0x01;
+ }
+
+ if ((p_sys->ps_pieces[i_pce].i_right_shape == 6) &&
(p_sys->ps_pieces[i_pce].i_original_col != p_sys->s_allocated.i_cols-1)) {
+ p_sys->ps_pieces[i_pce].i_right_shape = 6 + 8 + 8*((
(unsigned) vlc_mrand48()) % ( SHAPES_QTY ) ) + (vlc_mrand48() & 0x01);
+ p_sys->ps_pieces[i_right_pce].i_left_shape =
(p_sys->ps_pieces[i_pce].i_right_shape - 6 ) ^ 0x01;
+ }
+
+ if ((p_sys->ps_pieces[i_pce].i_top_shape == 2) &&
(p_sys->ps_pieces[i_pce].i_original_row != 0)) {
+ p_sys->ps_pieces[i_top_pce].i_btm_shape = 4 + 8 + 8*((
(unsigned) vlc_mrand48()) % ( SHAPES_QTY ) ) + (vlc_mrand48() & 0x01);
+ p_sys->ps_pieces[i_pce].i_top_shape =
(p_sys->ps_pieces[i_top_pce].i_btm_shape - 2 ) ^ 0x01;
+ }
+
+ if ((p_sys->ps_pieces[i_pce].i_btm_shape == 4) &&
(p_sys->ps_pieces[i_pce].i_original_row != p_sys->s_allocated.i_rows-1)) {
+ p_sys->ps_pieces[i_pce].i_btm_shape = 4 + 8 + 8*((
(unsigned) vlc_mrand48()) % ( SHAPES_QTY ) ) + (vlc_mrand48() & 0x01);
+ p_sys->ps_pieces[i_btm_pce].i_top_shape =
(p_sys->ps_pieces[i_pce].i_btm_shape - 2 ) ^ 0x01;
+ }
+
+ }
}
--
1.8.1.2
More information about the vlc-devel
mailing list