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

Comparing deliantra/server/random_maps/rogue_layout.C (file contents):
Revision 1.14 by root, Thu Jul 1 01:22:44 2010 UTC vs.
Revision 1.15 by root, Fri Jul 2 15:03:57 2010 UTC

19 * <http://www.gnu.org/licenses/>. 19 * <http://www.gnu.org/licenses/>.
20 * 20 *
21 * The authors can be reached via e-mail to <support@deliantra.net> 21 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 22 */
23 23
24/* generate a rogue/nethack-like layout */ 24/* generate a rogue/nethack-like maze */
25#include <global.h> 25#include <global.h>
26#include <random_map.h> 26#include <random_map.h>
27#include <rproto.h> 27#include <rproto.h>
28 28
29typedef struct 29typedef struct
41static int roguelike_place_room (Room *rooms, int xsize, int ysize, int nrooms); 41static int roguelike_place_room (Room *rooms, int xsize, int ysize, int nrooms);
42static void roguelike_make_rooms (Room *rooms, char **maze, int options); 42static void roguelike_make_rooms (Room *rooms, char **maze, int options);
43static void roguelike_link_rooms (Room *rooms, char **maze, int xsize, int ysize); 43static void roguelike_link_rooms (Room *rooms, char **maze, int xsize, int ysize);
44 44
45int 45int
46surround_check (char **layout, int i, int j, int Xsize, int Ysize) 46surround_check (char **maze, int i, int j, int Xsize, int Ysize)
47{ 47{
48 /* 1 = wall to left, 48 /* 1 = wall to left,
49 2 = wall to right, 49 2 = wall to right,
50 4 = wall above 50 4 = wall above
51 8 = wall below */ 51 8 = wall below */
52 int surround_index = 0; 52 int surround_index = 0;
53 53
54 if ((i > 0) && (layout[i - 1][j] != 0 && layout[i - 1][j] != '.')) surround_index |= 1; 54 if ((i > 0) && (maze[i - 1][j] != 0 && maze[i - 1][j] != '.')) surround_index |= 1;
55 if ((i < Xsize - 1) && (layout[i + 1][j] != 0 && layout[i + 1][j] != '.')) surround_index |= 2; 55 if ((i < Xsize - 1) && (maze[i + 1][j] != 0 && maze[i + 1][j] != '.')) surround_index |= 2;
56 if ((j > 0) && (layout[i][j - 1] != 0 && layout[i][j - 1] != '.')) surround_index |= 4; 56 if ((j > 0) && (maze[i][j - 1] != 0 && maze[i][j - 1] != '.')) surround_index |= 4;
57 if ((j < Ysize - 1) && (layout[i][j + 1] != 0 && layout[i][j + 1] != '.')) surround_index |= 8; 57 if ((j < Ysize - 1) && (maze[i][j + 1] != 0 && maze[i][j + 1] != '.')) surround_index |= 8;
58 58
59 return surround_index; 59 return surround_index;
60} 60}
61 61
62/* actually make the layout: we work by a reduction process: 62/* actually make the maze: we work by a reduction process:
63 * first we make everything a wall, then we remove areas to make rooms 63 * first we make everything a wall, then we remove areas to make rooms
64 */ 64 */
65void 65void
66roguelike_layout_gen (Layout &maze, int options) 66roguelike_layout_gen (layout &maze, int options)
67{ 67{
68 int i, j; 68 int i, j;
69 Room *walk; 69 Room *walk;
70 int nrooms = 0; 70 int nrooms = 0;
71 int tries = 0; 71 int tries = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines