--- deliantra/server/random_maps/random_map.h 2007/11/08 19:43:25 1.16 +++ deliantra/server/random_maps/random_map.h 2008/04/15 03:00:24 1.19 @@ -1,7 +1,7 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team * Copyright (©) 1992,2007 Frank Tore Johansen * @@ -24,6 +24,8 @@ #ifndef RANDOM_MAP_H #define RANDOM_MAP_H +#include "util.h" + struct random_map_params { char wallstyle[512]; @@ -124,5 +126,63 @@ // needs a minimum size of at least 12 #define MIN_RANDOM_MAP_SIZE 12 +struct LayoutData : zero_initialised +{ + char **col; + int w, h; + + LayoutData (int w, int h); + ~LayoutData (); + + operator char **() + { + return col; + } + + void clear (char fill = 0); + void border (char fill = '#'); +}; + +struct Layout +{ + LayoutData *ptr; + + Layout () + { + } + + Layout (int xsize, int ysize) + : ptr (new LayoutData (xsize, ysize)) + { + } + + Layout (random_map_params *RP) + : ptr (new LayoutData (RP->Xsize, RP->Ysize)) + { + } + + void free () + { + delete ptr; + } + + LayoutData *operator ->() const + { + return ptr; + } + + operator char **() const + { + return *ptr; + } + + void swap (const Layout &layout) const + { + ::swap (layout.ptr->col, ptr->col); + ::swap (layout.ptr->w , ptr->w ); + ::swap (layout.ptr->h , ptr->h ); + } +}; + #endif