version 1.4 | | version 1.5 |
---|
| | |
4 = wall above | | 4 = wall above |
8 = wall below */ | | 8 = wall below */ |
int surround_index = 0; | | int surround_index = 0; |
if((i > 0) && layout[i-1][j]!=0) surround_index |=1; | | if((i > 0) && (layout[i-1][j]!=0&&layout[i-1][j]!='.')) surround_index +=1; |
if((i < Xsize-1) && layout[i+1][j]!=0) surround_index |=2; | | if((i < Xsize-1) && (layout[i+1][j]!=0&&layout[i+1][j]!='.')) surround_index +=2; |
if((j > 0) && layout[i][j-1]!=0) surround_index |=4; | | if((j > 0) && (layout[i][j-1]!=0&&layout[i][j-1]!='.')) surround_index +=4; |
if((j < Ysize-1) && layout[i][j+1]!=0) surround_index |=8; | | if((j < Ysize-1) && (layout[i][j+1]!=0&&layout[i][j+1]!='.')) surround_index +=8; |
return surround_index; | | return surround_index; |
} | | } |
| | |
| | |
maze[walk->x][walk->y] = '>'; | | maze[walk->x][walk->y] = '>'; |
| | |
/* convert all the '.' to 0, we're through with the '.' */ | | /* convert all the '.' to 0, we're through with the '.' */ |
/* also, fix any 'dangling doors' */ | | |
for(i=0;i<xsize;i++) | | for(i=0;i<xsize;i++) |
for(j=0;j<ysize;j++) { | | for(j=0;j<ysize;j++) { |
if(maze[i][j]=='.') maze[i][j]=0; | | if(maze[i][j]=='.') maze[i][j]=0; |
if(maze[i][j]=='D') { /* remove bad door. */ | | if(maze[i][j]=='D') { /* remove bad door. */ |
int si = surround_check(maze,i,j,xsize,ysize); | | int si = surround_check(maze,i,j,xsize,ysize); |
if(si!=3 && si!=12) maze[i][j]=0; | | if(si!=3 && si!=12) { |
| | maze[i][j]=0; |
| | /* back up and recheck any nearby doors */ |
| | i=0;j=0; |
| | } |
} | | } |
} | | } |
| | |