ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/rmg.h
Revision: 1.1
Committed: Sun Aug 22 20:23:06 2010 UTC (13 years, 9 months ago) by root
Content type: text/plain
Branch: MAIN
Log Message:
rproto.h => include and random_map.h => include/rmg.h

File Contents

# User Rev Content
1 root 1.1 /*
2     * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3     *
4     * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5     * Copyright (©) 2001 Mark Wedel & Crossfire Development Team
6     * Copyright (©) 1992 Frank Tore Johansen
7     *
8     * 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     *
13     * 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     *
18     * 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     *
22     * The authors can be reached via e-mail to <support@deliantra.net>
23     */
24    
25     #ifndef RMG_H
26     #define RMG_H
27    
28     #include "util.h"
29     #include "layout.h"
30    
31     struct random_map_params : zero_initialised
32     {
33     char wall_name[512];
34    
35     int xsize, ysize;
36     int expand2x;
37     int layoutoptions1;
38     int layoutoptions2;
39     int layoutoptions3;
40     int difficulty;
41     int difficulty_given;
42     float difficulty_increase;
43    
44     int dungeon_level;
45     int dungeon_depth;
46    
47     uint32_t random_seed;
48     uint64_t total_map_hp;
49    
50     HV *hv;
51    
52     shstr_tmp as_shstr () const;
53    
54     // fetch something from the options hash
55     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    
67     void set (const char *option, int value) const { set (option, (IV)value); }
68    
69     // "private", adjusted sizes
70     int Xsize;
71     int Ysize;
72    
73     int map_layout_style;
74     int symmetry_used;
75    
76     random_map_params ();
77     random_map_params (random_map_params *RP);
78     random_map_params (HV *hv);
79     ~random_map_params ();
80     };
81    
82     enum {
83     LAYOUT_NONE,
84     LAYOUT_ONION,
85     LAYOUT_MAZE,
86     LAYOUT_SPIRAL,
87     LAYOUT_ROGUELIKE,
88     LAYOUT_SNAKE,
89     LAYOUT_SQUARE_SPIRAL,
90     LAYOUT_CAVE,
91     LAYOUT_CASTLE,
92     LAYOUT_MULTIPLE,
93     NROFLAYOUTS,
94     };
95    
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     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    
123     /* symmetry definitions--used in this file AND in treasure.c:
124     the numerical values matter so don't change them. */
125     enum {
126     SYMMETRY_RANDOM,
127     SYMMETRY_NONE,
128     SYMMETRY_X,
129     SYMMETRY_Y,
130     SYMMETRY_XY,
131     };
132    
133     // 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    
138     // we often use signed chars for coordinates (and U8 for distances)
139     #define MAX_RANDOM_MAP_SIZE 120
140    
141     // 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     #endif
152