1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
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 (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * 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 |
… | |
… | |
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 | #ifndef RANDOM_MAP_H |
24 | #ifndef RANDOM_MAP_H |
25 | #define RANDOM_MAP_H |
25 | #define RANDOM_MAP_H |
|
|
26 | |
|
|
27 | #include "util.h" |
26 | |
28 | |
27 | struct random_map_params |
29 | struct random_map_params |
28 | { |
30 | { |
29 | char wallstyle[512]; |
31 | char wallstyle[512]; |
30 | char wall_name[512]; |
32 | char wall_name[512]; |
… | |
… | |
122 | // 12 has been experimentally :( determined ot be a lot more stable |
124 | // 12 has been experimentally :( determined ot be a lot more stable |
123 | // than 11 or 10, leading to the assumption that something inherently |
125 | // than 11 or 10, leading to the assumption that something inherently |
124 | // needs a minimum size of at least 12 |
126 | // needs a minimum size of at least 12 |
125 | #define MIN_RANDOM_MAP_SIZE 12 |
127 | #define MIN_RANDOM_MAP_SIZE 12 |
126 | |
128 | |
|
|
129 | // reference |
|
|
130 | // |
|
|
131 | // \0 floor only |
|
|
132 | // # wall |
|
|
133 | // D door |
|
|
134 | // < up |
|
|
135 | // > down |
|
|
136 | // C "center" (of onion layout) |
|
|
137 | // . ?? (rogue) |
|
|
138 | // |
|
|
139 | |
|
|
140 | struct LayoutData : zero_initialised |
|
|
141 | { |
|
|
142 | char **col; |
|
|
143 | int w, h; |
|
|
144 | |
|
|
145 | LayoutData (int w, int h); |
|
|
146 | ~LayoutData (); |
|
|
147 | |
|
|
148 | operator char **() |
|
|
149 | { |
|
|
150 | return col; |
|
|
151 | } |
|
|
152 | |
|
|
153 | void clear (char fill = 0); |
|
|
154 | void border (char fill = '#'); |
|
|
155 | }; |
|
|
156 | |
|
|
157 | struct Layout |
|
|
158 | { |
|
|
159 | LayoutData *ptr; |
|
|
160 | |
|
|
161 | Layout () |
|
|
162 | { |
|
|
163 | } |
|
|
164 | |
|
|
165 | Layout (int xsize, int ysize) |
|
|
166 | : ptr (new LayoutData (xsize, ysize)) |
|
|
167 | { |
|
|
168 | } |
|
|
169 | |
|
|
170 | Layout (random_map_params *RP) |
|
|
171 | : ptr (new LayoutData (RP->Xsize, RP->Ysize)) |
|
|
172 | { |
|
|
173 | } |
|
|
174 | |
|
|
175 | void free () |
|
|
176 | { |
|
|
177 | delete ptr; |
|
|
178 | } |
|
|
179 | |
|
|
180 | LayoutData *operator ->() const |
|
|
181 | { |
|
|
182 | return ptr; |
|
|
183 | } |
|
|
184 | |
|
|
185 | operator char **() const |
|
|
186 | { |
|
|
187 | return *ptr; |
|
|
188 | } |
|
|
189 | |
|
|
190 | void swap (const Layout &layout) const |
|
|
191 | { |
|
|
192 | ::swap (layout.ptr->col, ptr->col); |
|
|
193 | ::swap (layout.ptr->w , ptr->w ); |
|
|
194 | ::swap (layout.ptr->h , ptr->h ); |
|
|
195 | } |
|
|
196 | }; |
|
|
197 | |
127 | #endif |
198 | #endif |
128 | |
199 | |