chiark / gitweb /
Constrain mine count to be at most the largest number of mines we
authorSimon Tatham <anakin@pobox.com>
Mon, 30 May 2005 17:57:45 +0000 (17:57 +0000)
committerSimon Tatham <anakin@pobox.com>
Mon, 30 May 2005 17:57:45 +0000 (17:57 +0000)
can guarantee to fit into the grid!

[originally from svn r5867]

mines.c

diff --git a/mines.c b/mines.c
index 881cad0d12390baf653dfafd20af40ebf3a0673d..73d4c09153651fb2a570925a60c7e09b086aae4c 100644 (file)
--- a/mines.c
+++ b/mines.c
@@ -255,6 +255,8 @@ static char *validate_params(game_params *params)
        return "Width must be greater than zero";
     if (params->h <= 0)
        return "Height must be greater than zero";
+    if (params->n > params->w * params->h - 9)
+       return "Too many mines for grid size";
 
     /*
      * FIXME: Need more constraints here. Not sure what the