ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/wall.C
(Generate patch)

Comparing deliantra/server/random_maps/wall.C (file contents):
Revision 1.41 by root, Fri Jul 2 17:18:04 2010 UTC vs.
Revision 1.43 by root, Fri Jul 2 17:43:16 2010 UTC

21 * 21 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 23 */
24 24
25#include <global.h> 25#include <global.h>
26#include <util.h>
26#include <random_map.h> 27#include <random_map.h>
27#include <rproto.h> 28#include <rproto.h>
28 29
29/* Put in the walls and autojoin them. */ 30/* Put in the walls and autojoin them. */
30 31
151 wall_arch = archetype::find (wall_name); 152 wall_arch = archetype::find (wall_name);
152 153
153 return wall_arch ? wall_arch->instance () : the_wall->arch->instance (); 154 return wall_arch ? wall_arch->instance () : the_wall->arch->instance ();
154} 155}
155 156
156// checks whether the layout has a "reachable" wall at a givne point, i.e. 157// checks whether the layout has a "reachable" space at a given point, i.e.
157// a wall that is not completely surrounded by walls. 158// not a wall that is completely surrounded by walls.
158static bool inline 159static bool inline
159is_visible (layout &maze, int i, int j) 160is_visible (layout &maze, int i, int j)
160{ 161{
161 int cnt = 0;
162
163 for (int dx = -1; dx <= 1; ++dx) 162 for (int dx = -1; dx <= 1; ++dx)
164 for (int dy = -1; dy <= 1; ++dy) 163 for (int dy = -1; dy <= 1; ++dy)
165 { 164 {
166 int x = i + dx; 165 int x = i + dx;
167 int y = j + dy; 166 int y = j + dy;
168 167
169 cnt += x < 0 || x >= maze.w 168 if (IN_RANGE_EXC (x, 0, maze.w)
170 || y < 0 || y >= maze.h 169 && IN_RANGE_EXC (y, 0, maze.h)
171 || maze [x][y] == '#'; 170 && maze [x][y] != '#')
171 return true;
172 } 172 }
173 173
174 return cnt != 9; 174 return false;
175} 175}
176 176
177/* takes a map and a maze, and puts walls in the map (picked from 177/* takes a map and a maze, and puts walls in the map (picked from
178 w_style) at '#' marks. */ 178 w_style) at '#' marks. */
179void 179void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines