aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-03-29 14:21:54 +0300
committereug-vs <eugene@eug-vs.xyz>2022-03-29 14:21:54 +0300
commita75449b1d9d5012991db123f62a208860b3cd590 (patch)
tree83437dd258682ca05d6fd265cb1ea33e05be89ce
parent1ce760e73a10da34ef1360f64202d4d03492f859 (diff)
downloadcarcassonne-engine-c-a75449b1d9d5012991db123f62a208860b3cd590.tar.gz
fix: don't allow overlapping tiles
-rw-r--r--src/main.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index d74335c..9d3205d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -23,6 +23,8 @@ int is_center_index(int index) {
}
int is_allowed_placement(char* tile, int index, char* board) {
+ if (board[index] != EMPTY) return 0;
+
for (int i = 0; i < 4; i++) {
char neighbor = board[index + neighbor_increments[i]];
if (neighbor != EMPTY && neighbor != tile[i + 1]) return 0;