FS#5384 - Bugfix #4908 & minesweeper rework

Attached to Project: Rockbox
Opened by Alexander Spyridakis (xaviergr) - Thursday, 18 May 2006, 00:00 GMT
Last edited by Alexander Spyridakis (xaviergr) - Friday, 19 May 2006, 23:17 GMT
Task Type Patches
Category Plugins
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


This is a patch that will solve reported bug #4908 and extends (a little) the plugin.
The following are added:

1) Center the board on all platforms (instead of always starting at 0,0).
2) Bugfix various logical paths that could lead to unexpected behaviour.
3) Added mine icon.
4) Unveil the whole board when the player loses or wins. (can easily be extended to be a solver, like sudoku)
5) Make options change repeteadly when you are holding the button.
6) Replace recursive function 'discover()' with a cascade algorithm that prevents stack overflow on big screens.
This task depends upon

View Dependency Graph

This task blocks these from closing
 FS#4908 - Stack overflow in minesweeper 
Closed by  Dave Chapman (linuxstb)
Saturday, 20 May 2006, 14:01 GMT
Reason for closing:  Accepted
Additional comments about closing:  Committed to CVS, thanks.
Comment by Alexander Spyridakis (xaviergr) - Thursday, 18 May 2006, 01:12 GMT
It is strange that no-one has reported this yet, but minesweeper uses a recursive function (discover(), which calls it self up to 8 times) that will make all targets with big screen to crash with a stack overflow error.

This can be reproduced if you start the game on a full board but you reduce mines down to 2%.
This way discover() is called so many times that a stack overflow error occurs.

Even with this patch I can't think of an alternate solution. Any advices?
Comment by Alexander Spyridakis (xaviergr) - Thursday, 18 May 2006, 01:36 GMT
new patch!
Comment by Eli Sherer (elisherer) - Thursday, 18 May 2006, 16:02 GMT
Do what I did woth Xobox... I used there 3 recursive functions
one after the first it crashed every single time
but after I made a counter matrix and reverted the recursion to a stack (with push and pop)
it stopped crashing even on ipod5g which has the largest screen of all
Comment by Alexander Spyridakis (xaviergr) - Friday, 19 May 2006, 23:09 GMT
Ok new patch.

Finally I managed to replace the recursive function with a normal one.
No more overflows on big screens.