summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jones <admin@danieljon.es>2020-06-15 22:51:14 +0930
committerDaniel Jones <admin@danieljon.es>2020-06-15 22:51:14 +0930
commitec9f9c906c5944e59cb52d69b8c7c2f3da516540 (patch)
treed92f7ffc224a1fd4f98866abbca85af3e06ed7a4
parent9080cdebf0ac27a3ceee46b400aa6bf1748dfa6f (diff)
downloadcsweeper-ec9f9c906c5944e59cb52d69b8c7c2f3da516540.tar.gz
csweeper-ec9f9c906c5944e59cb52d69b8c7c2f3da516540.zip
fixed segfault on widt and height differingHEADmaster
-rw-r--r--ncsweeper.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ncsweeper.c b/ncsweeper.c
index 42308de..80bcfaa 100644
--- a/ncsweeper.c
+++ b/ncsweeper.c
@@ -153,9 +153,9 @@ checkwin()
int correctflags = 0;
int correcttiles = 0;
- for (int y = 0; y < game.height; y++)
+ for (int x = 0; x < game.width; x++)
{
- for (int x = 0; x < game.width; x++)
+ for (int y = 0; y < game.height; y++)
{
struct tile *tile = gettileat(x, y);
if (tile->state & MINE && tile->state & FLAGGED)
@@ -226,7 +226,7 @@ gettileat(int x, int y)
if (x < 0 || x > game.width-1 || y < 0 || y > game.height-1 || board == NULL)
return NULL;
/* the board is single dimensional, so we map it as 2d */
- return &board[game.width*x+y];
+ return &board[game.height*x+y];
}
int