--- deliantra/server/random_maps/random_map.h 2008/04/14 22:41:17 1.18
+++ deliantra/server/random_maps/random_map.h 2010/06/26 22:10:18 1.26
@@ -1,22 +1,23 @@
/*
* This file is part of Deliantra, the Roguelike Realtime MMORPG.
*
- * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
- * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team
- * Copyright (©) 1992,2007 Frank Tore Johansen
+ * 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 GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * 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 GNU General Public License
- * along with this program. If not, see .
+ * 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
*/
@@ -26,11 +27,9 @@
#include "util.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];
@@ -38,11 +37,9 @@
char decorstyle[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;
@@ -68,9 +65,20 @@
struct region *region;
+ HV *hv;
+
+ // fetch something from the options hash
+ const_utf8_string get_str (const_utf8_string option, const_utf8_string fallback = "") const;
+ IV get_iv (const_utf8_string option, IV fallback = 0) const;
+
+ void set (const_utf8_string option, const_utf8_string value);
+ void set (const_utf8_string option, IV value);
+
// "private", adjusted sizes
int Xsize;
int Ysize;
+
+ ~random_map_params ();
};
enum {
@@ -126,13 +134,24 @@
// needs a minimum size of at least 12
#define MIN_RANDOM_MAP_SIZE 12
-struct MazeData : zero_initialised
+// reference
+//
+// \0 floor only
+// # wall
+// D door
+// < up
+// > down
+// C "center" (of onion layout)
+// . ?? (rogue)
+//
+
+struct LayoutData : zero_initialised
{
char **col;
int w, h;
- MazeData (int w, int h);
- ~MazeData ();
+ LayoutData (int w, int h);
+ ~LayoutData ();
operator char **()
{
@@ -143,21 +162,21 @@
void border (char fill = '#');
};
-struct Maze
+struct Layout
{
- MazeData *ptr;
+ LayoutData *ptr;
- Maze ()
+ Layout ()
{
}
- Maze (int xsize, int ysize)
- : ptr (new MazeData (xsize, ysize))
+ Layout (int xsize, int ysize)
+ : ptr (new LayoutData (xsize, ysize))
{
}
- Maze (random_map_params *RP)
- : ptr (new MazeData (RP->Xsize, RP->Ysize))
+ Layout (random_map_params *RP)
+ : ptr (new LayoutData (RP->Xsize, RP->Ysize))
{
}
@@ -166,7 +185,7 @@
delete ptr;
}
- MazeData *operator ->() const
+ LayoutData *operator ->() const
{
return ptr;
}
@@ -176,13 +195,23 @@
return *ptr;
}
- void swap (Maze &maze)
+ void swap (const Layout &layout) const
{
- MazeData *p = maze.ptr;
- maze.ptr = ptr;
- ptr = p;
+ ::swap (layout.ptr->col, ptr->col);
+ ::swap (layout.ptr->w , ptr->w );
+ ::swap (layout.ptr->h , ptr->h );
}
};
+// 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