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

Comparing deliantra/server/random_maps/room_gen_spiral.C (file contents):
Revision 1.13 by root, Mon Apr 14 22:41:17 2008 UTC vs.
Revision 1.14 by root, Tue Apr 15 03:00:24 2008 UTC

23 23
24/* The onion room generator: 24/* The onion room generator:
25Onion rooms are like this: 25Onion rooms are like this:
26 26
27char **map_gen_spiral(int xsize, int ysize, int option); 27char **map_gen_spiral(int xsize, int ysize, int option);
28
29
30*/ 28*/
29
31#include <global.h> 30#include <global.h>
32#include <random_map.h> 31#include <random_map.h>
33 32
34#define RANDOM_OPTIONS 0 /* Pick random options below */ 33#define RANDOM_OPTIONS 0 /* Pick random options below */
35#define REGULAR_SPIRAL 1 /* Regular spiral--distance increases constantly */ 34#define REGULAR_SPIRAL 1 /* Regular spiral--distance increases constantly */
50#define MAX_FINE .454545 49#define MAX_FINE .454545
51 50
52extern int surround_check (char **maze, int i, int j, int xsize, int ysize); 51extern int surround_check (char **maze, int i, int j, int xsize, int ysize);
53 52
54void 53void
55map_gen_spiral (Maze maze, int option) 54map_gen_spiral (Layout maze, int option)
56{ 55{
57 int i, j; 56 int i, j;
58 float parm = 0; 57 float parm = 0;
59 float x = 0, y = 0; 58 float x = 0, y = 0;
60 int ic, jc; 59 int ic, jc;
133/* the following function connects disjoint spirals which may 132/* the following function connects disjoint spirals which may
134 result from the symmetrization process. */ 133 result from the symmetrization process. */
135void 134void
136connect_spirals (int xsize, int ysize, int sym, char **layout) 135connect_spirals (int xsize, int ysize, int sym, char **layout)
137{ 136{
138
139 int i, j, ic = xsize / 2, jc = ysize / 2; 137 int i, j, ic = xsize / 2, jc = ysize / 2;
140 138
141 if (sym == SYMMETRY_X) 139 if (sym == SYMMETRY_X)
142 { 140 {
143 layout[ic][jc] = 0; 141 layout[ic][jc] = 0;
142
144 /* go left from map center */ 143 /* go left from map center */
145 for (i = ic - 1, j = jc; i > 0 && layout[i][j] == '#'; i--) 144 for (i = ic - 1, j = jc; i > 0 && layout[i][j] == '#'; i--)
146 layout[i][j] = 0; 145 layout[i][j] = 0;
146
147 /* go right */ 147 /* go right */
148 for (i = ic + 1, j = jc; i < xsize - 1 && layout[i][j] == '#'; i++) 148 for (i = ic + 1, j = jc; i < xsize - 1 && layout[i][j] == '#'; i++)
149 layout[i][j] = 0; 149 layout[i][j] = 0;
150 } 150 }
151 151
152 if (sym == SYMMETRY_Y) 152 if (sym == SYMMETRY_Y)
153 { 153 {
154
155 layout[ic][jc] = 0; 154 layout[ic][jc] = 0;
155
156 /* go up */ 156 /* go up */
157 for (i = ic, j = jc - 1; j > 0 && layout[i][j] == '#'; j--) 157 for (i = ic, j = jc - 1; j > 0 && layout[i][j] == '#'; j--)
158 layout[i][j] = 0; 158 layout[i][j] = 0;
159
159 /* go down */ 160 /* go down */
160 for (i = ic, j = jc + 1; j < ysize - 1 && layout[i][j] == '#'; j++) 161 for (i = ic, j = jc + 1; j < ysize - 1 && layout[i][j] == '#'; j++)
161 layout[i][j] = 0; 162 layout[i][j] = 0;
162 } 163 }
163 164
166 /* go left from map center */ 167 /* go left from map center */
167 layout[ic][jc / 2] = 0; 168 layout[ic][jc / 2] = 0;
168 layout[ic / 2][jc] = 0; 169 layout[ic / 2][jc] = 0;
169 layout[ic][jc / 2 + jc] = 0; 170 layout[ic][jc / 2 + jc] = 0;
170 layout[ic / 2 + ic][jc] = 0; 171 layout[ic / 2 + ic][jc] = 0;
172
171 for (i = ic - 1, j = jc / 2; i > 0 && layout[i][j] == '#'; i--) 173 for (i = ic - 1, j = jc / 2; i > 0 && layout[i][j] == '#'; i--)
172 { 174 {
173 layout[i][j + jc] = 0; 175 layout[i][j + jc] = 0;
174 layout[i][j] = 0; 176 layout[i][j] = 0;
175 } 177 }
178
176 /* go right */ 179 /* go right */
177 for (i = ic + 1, j = jc / 2; i < xsize - 1 && layout[i][j] == '#'; i++) 180 for (i = ic + 1, j = jc / 2; i < xsize - 1 && layout[i][j] == '#'; i++)
178 { 181 {
179 layout[i][j + jc] = 0; 182 layout[i][j + jc] = 0;
180 layout[i][j] = 0; 183 layout[i][j] = 0;
181 } 184 }
185
182 /* go up */ 186 /* go up */
183 for (i = ic / 2, j = jc - 1; j > 0 && layout[i][j] == '#'; j--) 187 for (i = ic / 2, j = jc - 1; j > 0 && layout[i][j] == '#'; j--)
184 { 188 {
185 layout[i][j] = 0; 189 layout[i][j] = 0;
186 layout[i + ic][j] = 0; 190 layout[i + ic][j] = 0;
187 } 191 }
192
188 /* go down */ 193 /* go down */
189 for (i = ic / 2, j = jc + 1; j < ysize - 1 && layout[i][j] == '#'; j++) 194 for (i = ic / 2, j = jc + 1; j < ysize - 1 && layout[i][j] == '#'; j++)
190 { 195 {
191 layout[i][j] = 0; 196 layout[i][j] = 0;
192 layout[i + ic][j] = 0; 197 layout[i + ic][j] = 0;
210 j = 0; 215 j = 0;
211 } 216 }
212 } 217 }
213 } 218 }
214} 219}
220

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines