[vlc-devel] [PATCH 1/2] Puzzle: fix shapes bug when changing game mode
Vianney Boyer
vlcvboyer at gmail.com
Fri Jul 26 20:02:15 CEST 2013
Hi,
You'll find below and in 1 additional patches the puzzle video filter
bug fix and GUI.
This is the same as previous one but separated from the other new
modules (oldmovie, vhs & freeze)
However it has to be applied after freeze, oldmovie and vhs patch set
This fix regenerates the shapes when you change the game mode. However
you'll see straight shapes.
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20130726/1ed87640/attachment.html>
More information about the vlc-devel
mailing list