ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/random_map.h
Revision: 1.46
Committed: Tue Jul 6 20:00:46 2010 UTC (13 years, 10 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.45: +1 -164 lines
Log Message:
move layout stuff to it's own include file

File Contents

# User Rev Content
1 root 1.1 /*
2 root 1.16 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 root 1.14 *
4 root 1.23 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 root 1.22 * Copyright (©) 2001 Mark Wedel & Crossfire Development Team
6     * Copyright (©) 1992 Frank Tore Johansen
7 root 1.14 *
8 root 1.21 * Deliantra is free software: you can redistribute it and/or modify it under
9     * the terms of the Affero GNU General Public License as published by the
10     * Free Software Foundation, either version 3 of the License, or (at your
11     * option) any later version.
12 root 1.14 *
13 root 1.15 * This program is distributed in the hope that it will be useful,
14     * but WITHOUT ANY WARRANTY; without even the implied warranty of
15     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16     * GNU General Public License for more details.
17 root 1.14 *
18 root 1.21 * You should have received a copy of the Affero GNU General Public License
19     * and the GNU General Public License along with this program. If not, see
20     * <http://www.gnu.org/licenses/>.
21 root 1.14 *
22 root 1.16 * The authors can be reached via e-mail to <support@deliantra.net>
23 root 1.1 */
24    
25     #ifndef RANDOM_MAP_H
26     #define RANDOM_MAP_H
27    
28 root 1.17 #include "util.h"
29 root 1.46 #include "layout.h"
30 root 1.17
31 root 1.25 struct random_map_params : zero_initialised
32 root 1.6 {
33 root 1.1 char wall_name[512];
34 root 1.26
35 root 1.11 int xsize, ysize;
36 root 1.1 int expand2x;
37     int layoutoptions1;
38     int layoutoptions2;
39     int layoutoptions3;
40     int difficulty;
41     int difficulty_given;
42     float difficulty_increase;
43 root 1.8
44 root 1.1 int dungeon_level;
45     int dungeon_depth;
46 root 1.8
47 root 1.12 uint32_t random_seed;
48 root 1.6 uint64_t total_map_hp;
49    
50 root 1.26 HV *hv;
51 root 1.28
52     shstr_tmp as_shstr () const;
53 root 1.26
54     // fetch something from the options hash
55 root 1.28 SV *get_sv (const char *option) const;
56     const_utf8_string get_str (const char *option, const_utf8_string fallback = "") const;
57     IV get_iv (const char *option, IV fallback = 0) const;
58     UV get_uv (const char *option, UV fallback = 0) const;
59     NV get_nv (const char *option, NV fallback = 0) const;
60    
61     void set (const char *option, SV *value) const;
62     void set (const char *option, const_utf8_string value) const;
63     void set (const char *option, IV value) const;
64     void set (const char *option, UV value) const;
65     void set (const char *option, NV value) const;
66 root 1.26
67 root 1.28 void set (const char *option, int value) const { set (option, (IV)value); }
68 root 1.26
69 root 1.11 // "private", adjusted sizes
70     int Xsize;
71     int Ysize;
72 root 1.26
73 root 1.44 int map_layout_style;
74     int symmetry_used;
75    
76 root 1.39 random_map_params ();
77 root 1.41 random_map_params (random_map_params *RP);
78 root 1.39 random_map_params (HV *hv);
79 root 1.26 ~random_map_params ();
80 root 1.6 };
81 root 1.1
82 root 1.6 enum {
83     LAYOUT_NONE,
84     LAYOUT_ONION,
85     LAYOUT_MAZE,
86     LAYOUT_SPIRAL,
87     LAYOUT_ROGUELIKE,
88     LAYOUT_SNAKE,
89     LAYOUT_SQUARE_SPIRAL,
90 root 1.30 LAYOUT_CAVE,
91 root 1.42 LAYOUT_CASTLE,
92 root 1.41 LAYOUT_MULTIPLE,
93 root 1.6 NROFLAYOUTS,
94     };
95 root 1.1
96     /*
97     * Move these defines out of room_gen_onion.c to here, as
98     * other files (like square_spiral) also uses them.
99    
100     options:
101     0 Pick random options below
102     1 "centered"
103     2 linear doors (default is nonlinear)
104     4 bottom "centered"
105     8 bottom-right centered
106     16 irregularly/randomly spaced layers (default: regular)
107     32 outer wall off: i.e., no outer wall.
108    
109     */
110    
111 root 1.6 enum {
112     RMOPT_RANDOM = 0,
113     RMOPT_CENTERED = 1,
114     RMOPT_LINEAR = 2,
115     RMOPT_BOTTOM_C = 4,
116     RMOPT_BOTTOM_R = 8,
117     RMOPT_IRR_SPACE = 16,
118     RMOPT_WALL_OFF = 32,
119     RMOPT_WALLS_ONLY = 64,
120     RMOPT_NO_DOORS = 256, /* Place walls insead of doors. Produces broken map. */
121     };
122 root 1.1
123     /* symmetry definitions--used in this file AND in treasure.c:
124     the numerical values matter so don't change them. */
125 root 1.6 enum {
126     SYMMETRY_RANDOM,
127     SYMMETRY_NONE,
128     SYMMETRY_X,
129     SYMMETRY_Y,
130     SYMMETRY_XY,
131     };
132 root 1.1
133 root 1.13 // 12 has been experimentally :( determined ot be a lot more stable
134     // than 11 or 10, leading to the assumption that something inherently
135     // needs a minimum size of at least 12
136     #define MIN_RANDOM_MAP_SIZE 12
137 root 1.1
138 root 1.31 // we often use signed chars for coordinates (and U8 for distances)
139     #define MAX_RANDOM_MAP_SIZE 120
140    
141 root 1.25 // utility functions, to use rmg_rndm instead of rndm.
142     static inline int
143     rmg_find_free_spot (const object *ob, maptile *m, int x, int y, int start, int stop)
144     {
145     swap (rmg_rndm, rndm);
146     int i = find_free_spot (ob, m, x, y, start, stop);
147     swap (rmg_rndm, rndm);
148     return i;
149     }
150    
151 root 1.6 #endif
152 root 1.1