… | |
… | |
151 | wall_arch = archetype::find (wall_name); |
151 | wall_arch = archetype::find (wall_name); |
152 | |
152 | |
153 | return wall_arch ? wall_arch->instance () : the_wall->arch->instance (); |
153 | return wall_arch ? wall_arch->instance () : the_wall->arch->instance (); |
154 | } |
154 | } |
155 | |
155 | |
156 | // checks whether the layout has a "reachable" wall at a givne point, i.e. |
156 | // checks whether the layout has a "reachable" space at a given point, i.e. |
157 | // a wall that is not completely surrounded by walls. |
157 | // not a wall that is completely surrounded by walls. |
158 | static bool inline |
158 | static bool inline |
159 | is_visible (layout &maze, int i, int j) |
159 | is_visible (layout &maze, int i, int j) |
160 | { |
160 | { |
161 | int cnt = 0; |
|
|
162 | |
|
|
163 | for (int dx = -1; dx <= 1; ++dx) |
161 | for (int dx = -1; dx <= 1; ++dx) |
164 | for (int dy = -1; dy <= 1; ++dy) |
162 | for (int dy = -1; dy <= 1; ++dy) |
165 | { |
163 | { |
166 | int x = i + dx; |
164 | int x = i + dx; |
167 | int y = j + dy; |
165 | int y = j + dy; |
168 | |
166 | |
169 | cnt += x < 0 || x >= maze.w |
167 | if (x >= 0 && x < maze.w |
170 | || y < 0 || y >= maze.h |
168 | && y >= 0 && y < maze.h |
171 | || maze [x][y] == '#'; |
169 | && maze [x][y] != '#') |
|
|
170 | return true; |
172 | } |
171 | } |
173 | |
172 | |
174 | return cnt != 9; |
173 | return false; |
175 | } |
174 | } |
176 | |
175 | |
177 | /* takes a map and a maze, and puts walls in the map (picked from |
176 | /* takes a map and a maze, and puts walls in the map (picked from |
178 | w_style) at '#' marks. */ |
177 | w_style) at '#' marks. */ |
179 | void |
178 | void |