Skip to content

report a bug in minesweeper #23

@Cao-Wuhui

Description

@Cao-Wuhui

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions