Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report a bug in minesweeper #23

Open
Cao-Wuhui opened this issue Jul 8, 2022 · 0 comments
Open

report a bug in minesweeper #23

Cao-Wuhui opened this issue Jul 8, 2022 · 0 comments

Comments

@Cao-Wuhui
Copy link

Cao-Wuhui commented Jul 8, 2022

I noticed that there's a bug in usr/minesweeper.c.
The function mine_mark() is defined in line 304~311 to mark the mine if this cell is not opened.

// usr/minesweeper.c, line 304~311
void mine_mark(struct command *com){
  int x, y;
  x = com->x;
  y = com->y;

  if(!(board[x][y] & OPEN)) // check if the cell is opened
    board[x][y] ^= MARKED;
}

However the macro OPEN is not a status but a command.

// usr/minesweeper.c, line 15~28
// cell status
#define BOMB_MASK 15
#define OPENED 16
#define MARKED 32
#define BOMB   64

// command
#define INIT 0
#define IOPEN 1
#define OPEN 2
#define MARK 3
#define QUIT 4
#define HELP 5
#define NOP  6

So, in function mine_mark(), OPEN should be replaced with OPENED as follows:

void mine_mark(struct command *com){
  int x, y;
  x = com->x;
  y = com->y;

  if(!(board[x][y] & OPENED))
    board[x][y] ^= MARKED;
}

I'd say sorry that I am not familiar with github and my git skill is not good.
That is why I have to report in this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant