|
|
1 | /* |
|
|
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
|
|
3 | * |
|
|
4 | * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
|
|
5 | * Copyright (©) Crossfire Development Team (restored, original file without copyright notice) |
|
|
6 | * |
|
|
7 | * Deliantra is free software: you can redistribute it and/or modify it under |
|
|
8 | * the terms of the Affero GNU General Public License as published by the |
|
|
9 | * Free Software Foundation, either version 3 of the License, or (at your |
|
|
10 | * option) any later version. |
|
|
11 | * |
|
|
12 | * This program is distributed in the hope that it will be useful, |
|
|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
15 | * GNU General Public License for more details. |
|
|
16 | * |
|
|
17 | * You should have received a copy of the Affero GNU General Public License |
|
|
18 | * and the GNU General Public License along with this program. If not, see |
|
|
19 | * <http://www.gnu.org/licenses/>. |
|
|
20 | * |
|
|
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
|
|
22 | */ |
1 | |
23 | |
2 | /* peterm@langmuir.eecs.berkeley.edu: this function generates a random |
24 | /* peterm@langmuir.eecs.berkeley.edu: this function generates a random |
3 | snake-type layout. |
25 | snake-type layout. |
4 | |
26 | |
5 | input: xsize, ysize; |
27 | input: xsize, ysize; |
… | |
… | |
13 | #include <global.h> |
35 | #include <global.h> |
14 | #include "random_map.h" |
36 | #include "random_map.h" |
15 | #include "rproto.h" |
37 | #include "rproto.h" |
16 | |
38 | |
17 | void |
39 | void |
18 | make_snake_layout (Maze maze, int options) |
40 | make_snake_layout (Layout maze, int options) |
19 | { |
41 | { |
20 | int i, j; |
42 | int i, j; |
21 | |
43 | |
22 | maze->clear (); |
44 | maze->clear (); |
23 | maze->border (); |
45 | maze->border (); |
… | |
… | |
30 | return; |
52 | return; |
31 | |
53 | |
32 | /* decide snake orientation--vertical or horizontal , and |
54 | /* decide snake orientation--vertical or horizontal , and |
33 | make the walls and place the doors. */ |
55 | make the walls and place the doors. */ |
34 | |
56 | |
35 | if (rndm (2)) |
57 | if (rmg_rndm (2)) |
36 | { /* vertical orientation */ |
58 | { /* vertical orientation */ |
37 | int n_walls = rndm (xsize - 5) / 3 + 1; |
59 | int n_walls = rmg_rndm (xsize - 5) / 3 + 1; |
38 | int spacing = xsize / (n_walls + 1); |
60 | int spacing = xsize / (n_walls + 1); |
39 | int orientation = 1; |
61 | int orientation = 1; |
40 | |
62 | |
41 | for (i = spacing; i < xsize - 3; i += spacing) |
63 | for (i = spacing; i < xsize - 3; i += spacing) |
42 | { |
64 | { |
… | |
… | |
58 | orientation ^= 1; /* toggle the value of orientation */ |
80 | orientation ^= 1; /* toggle the value of orientation */ |
59 | } |
81 | } |
60 | } |
82 | } |
61 | else |
83 | else |
62 | { /* horizontal orientation */ |
84 | { /* horizontal orientation */ |
63 | int n_walls = rndm (ysize - 5) / 3 + 1; |
85 | int n_walls = rmg_rndm (ysize - 5) / 3 + 1; |
64 | int spacing = ysize / (n_walls + 1); |
86 | int spacing = ysize / (n_walls + 1); |
65 | int orientation = 1; |
87 | int orientation = 1; |
66 | |
88 | |
67 | for (i = spacing; i < ysize - 3; i += spacing) |
89 | for (i = spacing; i < ysize - 3; i += spacing) |
68 | { |
90 | { |
… | |
… | |
84 | orientation ^= 1; /* toggle the value of orientation */ |
106 | orientation ^= 1; /* toggle the value of orientation */ |
85 | } |
107 | } |
86 | } |
108 | } |
87 | |
109 | |
88 | /* place the exit up/down */ |
110 | /* place the exit up/down */ |
89 | if (rndm (2)) |
111 | if (rmg_rndm (2)) |
90 | { |
112 | { |
91 | maze[1][1] = '<'; |
113 | maze[1][1] = '<'; |
92 | maze[xsize - 2][ysize - 2] = '>'; |
114 | maze[xsize - 2][ysize - 2] = '>'; |
93 | } |
115 | } |
94 | else |
116 | else |