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

Comparing deliantra/server/random_maps/random_map.h (file contents):
Revision 1.18 by root, Mon Apr 14 22:41:17 2008 UTC vs.
Revision 1.19 by root, Tue Apr 15 03:00:24 2008 UTC

124// 12 has been experimentally :( determined ot be a lot more stable 124// 12 has been experimentally :( determined ot be a lot more stable
125// than 11 or 10, leading to the assumption that something inherently 125// than 11 or 10, leading to the assumption that something inherently
126// needs a minimum size of at least 12 126// needs a minimum size of at least 12
127#define MIN_RANDOM_MAP_SIZE 12 127#define MIN_RANDOM_MAP_SIZE 12
128 128
129struct MazeData : zero_initialised 129struct LayoutData : zero_initialised
130{ 130{
131 char **col; 131 char **col;
132 int w, h; 132 int w, h;
133 133
134 MazeData (int w, int h); 134 LayoutData (int w, int h);
135 ~MazeData (); 135 ~LayoutData ();
136 136
137 operator char **() 137 operator char **()
138 { 138 {
139 return col; 139 return col;
140 } 140 }
141 141
142 void clear (char fill = 0); 142 void clear (char fill = 0);
143 void border (char fill = '#'); 143 void border (char fill = '#');
144}; 144};
145 145
146struct Maze 146struct Layout
147{ 147{
148 MazeData *ptr; 148 LayoutData *ptr;
149 149
150 Maze () 150 Layout ()
151 { 151 {
152 } 152 }
153 153
154 Maze (int xsize, int ysize) 154 Layout (int xsize, int ysize)
155 : ptr (new MazeData (xsize, ysize)) 155 : ptr (new LayoutData (xsize, ysize))
156 { 156 {
157 } 157 }
158 158
159 Maze (random_map_params *RP) 159 Layout (random_map_params *RP)
160 : ptr (new MazeData (RP->Xsize, RP->Ysize)) 160 : ptr (new LayoutData (RP->Xsize, RP->Ysize))
161 { 161 {
162 } 162 }
163 163
164 void free () 164 void free ()
165 { 165 {
166 delete ptr; 166 delete ptr;
167 } 167 }
168 168
169 MazeData *operator ->() const 169 LayoutData *operator ->() const
170 { 170 {
171 return ptr; 171 return ptr;
172 } 172 }
173 173
174 operator char **() const 174 operator char **() const
175 { 175 {
176 return *ptr; 176 return *ptr;
177 } 177 }
178 178
179 void swap (Maze &maze) 179 void swap (const Layout &layout) const
180 { 180 {
181 MazeData *p = maze.ptr; 181 ::swap (layout.ptr->col, ptr->col);
182 maze.ptr = ptr; 182 ::swap (layout.ptr->w , ptr->w );
183 ptr = p; 183 ::swap (layout.ptr->h , ptr->h );
184 } 184 }
185}; 185};
186 186
187#endif 187#endif
188 188

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines