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.3 by root, Thu Sep 14 22:34:02 2006 UTC vs.
Revision 1.11 by root, Thu Nov 8 19:43:25 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
4 Copyright (C) 1994 Mark Wedel 5 * Copyright (©) 1994,2007 Mark Wedel
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version. 11 * (at your option) any later version.
11 12 *
12 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 *
20 21 * The authors can be reached via e-mail to <support@deliantra.net>
21 The author can be reached via e-mail to mark@pyramid.com
22*/ 22 */
23
24 23
25/* The onion room generator: 24/* The onion room generator:
26Onion rooms are like this: 25Onion rooms are like this:
27 26
28char **map_gen_spiral(int xsize, int ysize, int option); 27char **map_gen_spiral(int xsize, int ysize, int option);
81 SizeY = ysize / 2 - 2; 80 SizeY = ysize / 2 - 2;
82 81
83 /* select random options if necessary */ 82 /* select random options if necessary */
84 if (option == 0) 83 if (option == 0)
85 { 84 {
86 option = RANDOM () % MAX_SPIRAL_OPT; 85 option = rndm (MAX_SPIRAL_OPT);
87 } 86 }
88 87
89 /* the order in which these are evaluated matters */ 88 /* the order in which these are evaluated matters */
90 89
91 /* the following two are mutually exclusive. 90 /* the following two are mutually exclusive.
92 pick one if they're both set. */ 91 pick one if they're both set. */
93 if ((option & REGULAR_SPIRAL) && (option & FIT_SPIRAL)) 92 if ((option & REGULAR_SPIRAL) && (option & FIT_SPIRAL))
94 { 93 {
95 /* unset REGULAR_SPIRAL half the time */ 94 /* unset REGULAR_SPIRAL half the time */
96 if (RANDOM () % 2 && (option & REGULAR_SPIRAL)) 95 if (rndm (2) && (option & REGULAR_SPIRAL))
97 option -= REGULAR_SPIRAL; 96 option -= REGULAR_SPIRAL;
98 else 97 else
99 option -= FIT_SPIRAL; 98 option -= FIT_SPIRAL;
100 } 99 }
101 100
102 xscale = yscale = MAX_FINE; /* fine spiral */ 101 xscale = yscale = MAX_FINE; /* fine spiral */
103 102
104 /* choose the spiral pitch */ 103 /* choose the spiral pitch */
105 if (!(option & FINE_SPIRAL)) 104 if (!(option & FINE_SPIRAL))
106 { 105 {
107 float pitch = (RANDOM () % 5) / 10. + 10. / 22.; 106 float pitch = (rndm (5)) / 10. + 10. / 22.;
108 107
109 xscale = yscale = pitch; 108 xscale = yscale = pitch;
110 } 109 }
111 110
112 if ((option & FIT_SPIRAL) && (xsize != ysize)) 111 if ((option & FIT_SPIRAL) && (xsize != ysize))
150connect_spirals (int xsize, int ysize, int sym, char **layout) 149connect_spirals (int xsize, int ysize, int sym, char **layout)
151{ 150{
152 151
153 int i, j, ic = xsize / 2, jc = ysize / 2; 152 int i, j, ic = xsize / 2, jc = ysize / 2;
154 153
155 if (sym == X_SYM) 154 if (sym == SYMMETRY_X)
156 { 155 {
157 layout[ic][jc] = 0; 156 layout[ic][jc] = 0;
158 /* go left from map center */ 157 /* go left from map center */
159 for (i = ic - 1, j = jc; i > 0 && layout[i][j] == '#'; i--) 158 for (i = ic - 1, j = jc; i > 0 && layout[i][j] == '#'; i--)
160 layout[i][j] = 0; 159 layout[i][j] = 0;
161 /* go right */ 160 /* go right */
162 for (i = ic + 1, j = jc; i < xsize - 1 && layout[i][j] == '#'; i++) 161 for (i = ic + 1, j = jc; i < xsize - 1 && layout[i][j] == '#'; i++)
163 layout[i][j] = 0; 162 layout[i][j] = 0;
164 } 163 }
165 164
166 if (sym == Y_SYM) 165 if (sym == SYMMETRY_Y)
167 { 166 {
168 167
169 layout[ic][jc] = 0; 168 layout[ic][jc] = 0;
170 /* go up */ 169 /* go up */
171 for (i = ic, j = jc - 1; j > 0 && layout[i][j] == '#'; j--) 170 for (i = ic, j = jc - 1; j > 0 && layout[i][j] == '#'; j--)
173 /* go down */ 172 /* go down */
174 for (i = ic, j = jc + 1; j < ysize - 1 && layout[i][j] == '#'; j++) 173 for (i = ic, j = jc + 1; j < ysize - 1 && layout[i][j] == '#'; j++)
175 layout[i][j] = 0; 174 layout[i][j] = 0;
176 } 175 }
177 176
178 if (sym == XY_SYM) 177 if (sym == SYMMETRY_XY)
179 { 178 {
180 /* go left from map center */ 179 /* go left from map center */
181 layout[ic][jc / 2] = 0; 180 layout[ic][jc / 2] = 0;
182 layout[ic / 2][jc] = 0; 181 layout[ic / 2][jc] = 0;
183 layout[ic][jc / 2 + jc] = 0; 182 layout[ic][jc / 2 + jc] = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines