diff options
Diffstat (limited to 'pieces.c')
-rw-r--r-- | pieces.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -94,7 +94,7 @@ void refillpieces(struct piece** hand, int nhand) { } } -bool placeable(char** map, struct piece* pc, int row, int col, int mapH, int mapW) { +bool placeable(char* map, struct piece* pc, int row, int col, int mapH, int mapW) { // boundary check if (row < 0 || row + (pc->h) > mapH || col < 0 || col + (pc->w) > mapW) return false; @@ -102,7 +102,7 @@ bool placeable(char** map, struct piece* pc, int row, int col, int mapH, int map // check if blocks to be taken by `pc` are vacant for (int r = 0; r < pc->h; r++) { for (int c = 0; c < pc->w; c++) { - if (map[row + r][col + c] == '+' && pc->blocks[r * pc->w + c] == '+') + if (map[(row + r) * mapW + col + c] == '+' && pc->blocks[r * pc->w + c] == '+') return false; } } @@ -110,11 +110,11 @@ bool placeable(char** map, struct piece* pc, int row, int col, int mapH, int map return true; } -void place(char** map, struct piece* pc, int row, int col) { +void place(char* map, struct piece* pc, int row, int col, int mapW) { for (int r = 0; r < pc->h; r++) { for (int c = 0; c < pc->w; c++) { if (pc->blocks[r * (pc->w) + c] == '+') - map[row + r][col + c] = '+'; + map[(row + r) * mapW + col + c] = '+'; } } } |