From fd8799f36b02e3a579c8eafd0863452de4634a4c Mon Sep 17 00:00:00 2001 From: Linus Probert Date: Mon, 15 Oct 2018 09:35:05 +0200 Subject: [PATCH] Prevent tiles with objects on them from falling. --- src/player.c | 9 +++++++-- src/roommatrix.c | 2 ++ src/roommatrix.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/player.c b/src/player.c index 874f1c0..3cfc016 100644 --- a/src/player.c +++ b/src/player.c @@ -293,11 +293,16 @@ move(Player *player, RoomMatrix *matrix, Vector2d direction) if (!has_collided(player, matrix, direction)) { action_spent(player); + RoomSpace *lastSpace = &matrix->spaces[lastPos.x][lastPos.y]; if (lastPos.x > 1 && lastPos.y > 1 && lastPos.x < 14 && - lastPos.y < 10) - map_trigger_tile_fall(matrix->spaces[lastPos.x][lastPos.y].tile); + lastPos.y < 10 && + lastSpace->decoration == NULL && + lastSpace->trap == NULL && + lastSpace->objects == NULL + ) + map_trigger_tile_fall(lastSpace->tile); } } diff --git a/src/roommatrix.c b/src/roommatrix.c index fed95ac..d05b2dd 100644 --- a/src/roommatrix.c +++ b/src/roommatrix.c @@ -47,6 +47,7 @@ roommatrix_reset(RoomMatrix *m) space->player = NULL; space->trap = NULL; space->tile = NULL; + space->decoration = NULL; while (space->items != NULL) linkedlist_pop(&space->items); while (space->artifacts != NULL) @@ -126,6 +127,7 @@ void roommatrix_populate_from_map(RoomMatrix *rm, Map *m) r->tiles[i][j]->lethal; } if (r->decorations[i][j]) { + space->decoration = r->decorations[i][j]; space->occupied |= r->decorations[i][j]->collider; space->lightsource |= diff --git a/src/roommatrix.h b/src/roommatrix.h index 32b22e9..60160d8 100644 --- a/src/roommatrix.h +++ b/src/roommatrix.h @@ -45,6 +45,7 @@ typedef struct RoomSpace { bool damaging; int light; MapTile *tile; + MapTile *decoration; Monster *monster; Player *player; Trap *trap;