#include #include "vars.h" #include "dice.h" #include "digdungeon.h" #include "digdoors.h" #define PAUSE() ((int)refresh(),(int)getch()) static int doorok(LEVEL *lv, int x, int y) { LOC *lc; LOC *lcu; LOC *lcd; LOC *lcl; LOC *lcr; lc = &lv->cells[x][y]; if (lc->flags & LF_FLAGB) return(0); if ( ((lc->type == LOC_CAVE) && (lc->cavetype == LOC_JUSTCAVE)) || (lc->type == LOC_WALL) ) { lcu = &lv->cells[x][y-1]; lcd = &lv->cells[x][y+1]; lcl = &lv->cells[x-1][y]; lcr = &lv->cells[x+1][y]; return( ( (lcu->type == LOC_WALL) && (lcd->type == LOC_WALL) && (lcl->type == LOC_CAVE) && (lcr->type == LOC_CAVE) ) || ( (lcl->type == LOC_WALL) && (lcr->type == LOC_WALL) && (lcu->type == LOC_CAVE) && (lcd->type == LOC_CAVE) ) ); } return(0); } void digdoor(LEVEL *lv, int x, int y, int secretp, int openp) { LOC *lc; lc = &lv->cells[x][y]; if (lc->type != LOC_CAVE) digcell(lc->on,lc->x,lc->y); if (secretp) { lc->type = LOC_SDOOR; lc->walldoor = LOC_UWALL; } else { lc->type = LOC_DOOR; lc->walldoor = (openp ? LOC_DOOR_OPEN : LOC_DOOR_CLOSED) | ((lv->cells[x][y-1].type == LOC_CAVE) ? LOC_VWALL : LOC_HWALL); } } static void digdoors(LEVEL *lv) { int i; int x; int y; LOC *lc; for (i=0;i<100;i++) { x = 1 + rnd(LEV_X-2); y = 1 + rnd(LEV_Y-2); lc = &lv->cells[x][y]; if (doorok(lv,x,y)) digdoor(lv,x,y,onein(3),onein(3)); } } void makedoors(void) { int l; for (l=0;l