--- deliantra/server/random_maps/random_map.h 2010/03/28 22:29:50 1.24 +++ deliantra/server/random_maps/random_map.h 2010/07/06 20:00:46 1.46 @@ -26,31 +26,17 @@ #define RANDOM_MAP_H #include "util.h" +#include "layout.h" -struct random_map_params +struct random_map_params : zero_initialised { - char wallstyle[512]; char wall_name[512]; - char floorstyle[512]; - char monsterstyle[512]; - char treasurestyle[512]; - char layoutstyle[512]; - char doorstyle[512]; - char decorstyle[512]; - char miningstyle[512]; - shstr origin_map; - shstr final_map; - char exitstyle[512]; - shstr this_map; - char exit_on_final_map[512]; - char *custom; - + int xsize, ysize; int expand2x; int layoutoptions1; int layoutoptions2; int layoutoptions3; - int symmetry; int difficulty; int difficulty_given; float difficulty_increase; @@ -58,21 +44,39 @@ int dungeon_level; int dungeon_depth; - int decoroptions; - int orientation; - int origin_y; - int origin_x; uint32_t random_seed; uint64_t total_map_hp; - int map_layout_style; - int treasureoptions; - int symmetry_used; - struct region *region; + HV *hv; + + shstr_tmp as_shstr () const; + + // fetch something from the options hash + SV *get_sv (const char *option) const; + const_utf8_string get_str (const char *option, const_utf8_string fallback = "") const; + IV get_iv (const char *option, IV fallback = 0) const; + UV get_uv (const char *option, UV fallback = 0) const; + NV get_nv (const char *option, NV fallback = 0) const; + + void set (const char *option, SV *value) const; + void set (const char *option, const_utf8_string value) const; + void set (const char *option, IV value) const; + void set (const char *option, UV value) const; + void set (const char *option, NV value) const; + + void set (const char *option, int value) const { set (option, (IV)value); } // "private", adjusted sizes int Xsize; int Ysize; + + int map_layout_style; + int symmetry_used; + + random_map_params (); + random_map_params (random_map_params *RP); + random_map_params (HV *hv); + ~random_map_params (); }; enum { @@ -83,6 +87,9 @@ LAYOUT_ROGUELIKE, LAYOUT_SNAKE, LAYOUT_SQUARE_SPIRAL, + LAYOUT_CAVE, + LAYOUT_CASTLE, + LAYOUT_MULTIPLE, NROFLAYOUTS, }; @@ -128,74 +135,18 @@ // needs a minimum size of at least 12 #define MIN_RANDOM_MAP_SIZE 12 -// reference -// -// \0 floor only -// # wall -// D door -// < up -// > down -// C "center" (of onion layout) -// . ?? (rogue) -// +// we often use signed chars for coordinates (and U8 for distances) +#define MAX_RANDOM_MAP_SIZE 120 -struct LayoutData : zero_initialised +// utility functions, to use rmg_rndm instead of rndm. +static inline int +rmg_find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop) { - 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 ); - } -}; + swap (rmg_rndm, rndm); + int i = find_free_spot (ob, m, x, y, start, stop); + swap (rmg_rndm, rndm); + return i; +} #endif