summaryrefslogtreecommitdiff
path: root/pieces.c
diff options
context:
space:
mode:
Diffstat (limited to 'pieces.c')
-rw-r--r--pieces.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/pieces.c b/pieces.c
index 3b71003..001c9df 100644
--- a/pieces.c
+++ b/pieces.c
@@ -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] = '+';
}
}
}