--- deliantra/server/random_maps/random_map.h 2006/02/03 07:14:21 1.1.1.1 +++ deliantra/server/random_maps/random_map.h 2010/08/28 00:31:12 1.47 @@ -1,83 +1,97 @@ /* - * static char *rcsid_map_c = - * "$Id$"; + * This file is part of Deliantra, the Roguelike Realtime MMORPG. + * + * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2001 Mark Wedel & Crossfire Development Team + * Copyright (©) 1992 Frank Tore Johansen + * + * Deliantra is free software: you can redistribute it and/or modify it under + * the terms of the Affero GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the Affero GNU General Public License + * and the GNU General Public License along with this program. If not, see + * . + * + * The authors can be reached via e-mail to */ -/* - CrossFire, A Multiplayer game for X-windows - - Copyright (C) 2001 Mark Wedel & Crossfire Development Team - Copyright (C) 1992 Frank Tore Johansen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - The authors can be reached via e-mail at crossfire-devel@real-time.com -*/ - #ifndef RANDOM_MAP_H #define RANDOM_MAP_H -typedef struct { - char wallstyle[512]; +#include "util.h" +#include "layout.h" + +struct random_map_params : zero_initialised +{ char wall_name[512]; - char floorstyle[512]; - char monsterstyle[512]; - char treasurestyle[512]; - char layoutstyle[512]; - char doorstyle[512]; - char decorstyle[512]; - char origin_map[512]; - char final_map[512]; - char exitstyle[512]; - char this_map[512]; - char exit_on_final_map[512]; - - int Xsize; - int Ysize; + + int xsize, ysize; int expand2x; int layoutoptions1; int layoutoptions2; int layoutoptions3; - int symmetry; int difficulty; int difficulty_given; float difficulty_increase; + int dungeon_level; int dungeon_depth; - int decoroptions; - int orientation; - int origin_y; - int origin_x; - int random_seed; - long unsigned int total_map_hp; - int map_layout_style; - int treasureoptions; - int symmetry_used; - region *region; -} RMParms; -int load_parameters(FILE *fp, int bufstate,RMParms *RP); + uint32_t random_seed; + uint64_t total_map_hp; + + HV *hv; + shstr_tmp as_shstr () const; -#define ONION_LAYOUT 1 -#define MAZE_LAYOUT 2 -#define SPIRAL_LAYOUT 3 -#define ROGUELIKE_LAYOUT 4 -#define SNAKE_LAYOUT 5 -#define SQUARE_SPIRAL_LAYOUT 6 -#define NROFLAYOUTS 6 + // 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 { + LAYOUT_NONE, + LAYOUT_ONION, + LAYOUT_MAZE, + LAYOUT_SPIRAL, + LAYOUT_ROGUELIKE, + LAYOUT_SNAKE, + LAYOUT_SQUARE_SPIRAL, + LAYOUT_CAVE, + LAYOUT_CASTLE, + LAYOUT_MULTIPLE, + NROFLAYOUTS, +}; /* * Move these defines out of room_gen_onion.c to here, as @@ -94,32 +108,45 @@ */ -#define OPT_RANDOM 0 -#define OPT_CENTERED 1 -#define OPT_LINEAR 2 -#define OPT_BOTTOM_C 4 -#define OPT_BOTTOM_R 8 -#define OPT_IRR_SPACE 16 -#define OPT_WALL_OFF 32 -#define OPT_WALLS_ONLY 64 -#define OPT_NO_DOORS 256 /* Place walls insead of doors. Produces broken map. */ - - +enum { + RMOPT_RANDOM = 0, + RMOPT_CENTERED = 1, + RMOPT_LINEAR = 2, + RMOPT_BOTTOM_C = 4, + RMOPT_BOTTOM_R = 8, + RMOPT_IRR_SPACE = 16, + RMOPT_WALL_OFF = 32, + RMOPT_WALLS_ONLY = 64, + RMOPT_NO_DOORS = 256, /* Place walls insead of doors. Produces broken map. */ +}; /* symmetry definitions--used in this file AND in treasure.c: the numerical values matter so don't change them. */ -#define RANDOM_SYM 0 -#define NO_SYM 1 -#define X_SYM 2 -#define Y_SYM 3 -#define XY_SYM 4 - -#define MIN_RANDOM_MAP_SIZE 10 - -/* a macro to get a strongly centered random distribution, - from 0 to x, centered at x/2 */ -#define BC_RANDOM(x) ((int) ((RANDOM() % (x)+RANDOM()%(x)+RANDOM()%(x))/3.)) - -int set_random_map_variable(RMParms *rp,const char *buf); +enum { + SYMMETRY_RANDOM, + SYMMETRY_NONE, + SYMMETRY_X, + SYMMETRY_Y, + SYMMETRY_XY, +}; + +// 12 has been experimentally :( determined ot be a lot more stable +// than 11 or 10, leading to the assumption that something inherently +// needs a minimum size of at least 12 +#define MIN_RANDOM_MAP_SIZE 12 + +// we often use signed chars for coordinates (and U8 for distances) +#define MAX_RANDOM_MAP_SIZE 120 + +// 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) +{ + swap (rmg_rndm, rndm); + int i = find_free_spot (ob, m, x, y, start, stop); + swap (rmg_rndm, rndm); + return i; +} #endif +