File: do-not-create-too-many-mines

package info (click to toggle)
freesweep 1.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 628 kB
  • sloc: ansic: 5,174; sh: 2,180; makefile: 204
file content (46 lines) | stat: -rw-r--r-- 1,436 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From: Debian Games Team <pkg-games-devel@lists.alioth.debian.org>
Date: Thu, 24 Mar 2016 12:43:31 +0100
Subject: do-not-create-too-many-mines

freesweep enters an infinite loop when placing mines if the user's
configuration has it creating more than (boardsize - 9) mines.  This is
caused by game.c:510 not allowing mines to be created within a 3x3 block
at the centre of the field, while the initial configuration allows for
more than (boardsize - 9) mines to be created.  This patch makes a board
size of 3x3 invalid because no mines can be placed and lowers the 
maximum allowable number of mines on a board to (boardsize - 9).

Patch provided by Seneca for freesweep-0.88
see http://bugs.debian.org/249896
---
 game.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/game.c b/game.c
index dbdf2f2..b19d8ad 100644
--- a/game.c
+++ b/game.c
@@ -14,12 +14,12 @@
 
 int CheckHeight(int NewVal)
 {
-	return (((NewVal>2)&&(NewVal<=MAX_H))?1:-1);
+	return (((NewVal>3)&&(NewVal<=MAX_H))?1:-1);
 }
 
 int CheckWidth(int NewVal)
 {
-	return (((NewVal>2)&&(NewVal<=MAX_W))?1:-1);
+	return (((NewVal>3)&&(NewVal<=MAX_W))?1:-1);
 }
 
 int CheckPercent(int NewVal)
@@ -53,7 +53,7 @@ int CheckLineDraw(int NewVal)
 */
 int CheckNumMines(int NewVal,int Height,int Width)
 {
-	return (((NewVal>0)&&(NewVal<(Height*Width)))?1:-1);
+	return (((NewVal>0)&&(NewVal<(Height*Width-8)))?1:-1);
 }
 
 int InitGame(GameStats* Game)