summaryrefslogtreecommitdiff
path: root/src/trap.c
blob: e0547068da54795a7b4b6cc520d15f174aa6caca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "global.h"
#include "trap.h"

#include "dungeon_map_access.h"
#include "dungeon_util.h"
#include "map.h"

bool8 CanLayTrap(struct Position *pos)
{
    struct MapTile *tile = GetMapTile_2(pos->x, pos->y);
    if (tile->tileType & TILE_TYPE_STAIRS ||
        tile->roomIndex == CORRIDOR_ROOM_INDEX ||
        tile->tileType & TILE_TYPE_ROOM_EXIT)
    {
        return FALSE;
    }
    if (tile->tileType & TILE_TYPE_SHOP)
    {
        return FALSE;
    }
    if ((tile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)) != TILE_TYPE_FLOOR ||
        (tile->mapObject != NULL && GetEntityType(tile->mapObject) != ENTITY_TRAP))
    {
        return FALSE;
    }
    return TRUE;
}