/** * Lock a closed door to a given power */ void square_set_door_lock(struct chunk *c, int y, int x, int power) { struct trap_kind *lock = lookup_trap("door lock"); struct trap *trap; /* Verify it's a closed door */ if (!square_iscloseddoor(c, y, x)) return; /* If there's no lock there, add one */ if (!square_trap_specific(c, y, x, lock->tidx)) place_trap(c, y, x, lock->tidx, 0); /* Set the power (of all locks - there should be only one) */ trap = c->squares[y][x].trap; while (trap) { if (trap->kind == lock) trap->xtra = power; trap = trap->next; } }
/** * Return the power of the lock on a door */ int square_door_power(struct chunk *c, int y, int x) { struct trap_kind *lock = lookup_trap("door lock"); struct trap *trap; /* Verify it's a closed door */ if (!square_iscloseddoor(c, y, x)) return 0; /* Is there a lock there? */ if (!square_trap_specific(c, y, x, lock->tidx)) return 0; /* Get the power and return it */ trap = c->squares[y][x].trap; while (trap) { if (trap->kind == lock) return trap->xtra; trap = trap->next; } return 0; }
bool square_iswarded(struct chunk *c, int y, int x) { struct trap_kind *rune = lookup_trap("glyph of warding"); return square_trap_specific(c, y, x, rune->tidx); }