From ec9f9c906c5944e59cb52d69b8c7c2f3da516540 Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Mon, 15 Jun 2020 22:51:14 +0930 Subject: fixed segfault on widt and height differing --- ncsweeper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ncsweeper.c') 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 -- cgit v1.2.3