ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/rmg.h
Revision: 1.9
Committed: Sat Nov 17 23:40:01 2018 UTC (5 years, 6 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +1 -0 lines
Log Message:
copyright update 2018

File Contents

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