--- deliantra/server/random_maps/rogue_layout.C 2009/11/07 18:30:05 1.11
+++ deliantra/server/random_maps/rogue_layout.C 2010/07/04 22:12:26 1.16
@@ -1,4 +1,27 @@
-/* generate a rogue/nethack-like layout */
+/*
+ * This file is part of Deliantra, the Roguelike Realtime MMORPG.
+ *
+ * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
+ * Copyright (©) Crossfire Development Team (restored, original file without copyright notice)
+ *
+ * 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
+ */
+
+/* generate a rogue/nethack-like maze */
#include
#include
#include
@@ -17,10 +40,10 @@
static int roguelike_place_room (Room *rooms, int xsize, int ysize, int nrooms);
static void roguelike_make_rooms (Room *rooms, char **maze, int options);
-static void roguelike_link_rooms (Room *rooms, char **maze, int xsize, int ysize);
+static void roguelike_link_rooms (Room *rooms, layout &maze);
int
-surround_check (char **layout, int i, int j, int Xsize, int Ysize)
+surround_check (layout &maze, int i, int j)
{
/* 1 = wall to left,
2 = wall to right,
@@ -28,35 +51,35 @@
8 = wall below */
int surround_index = 0;
- if ((i > 0) && (layout[i - 1][j] != 0 && layout[i - 1][j] != '.')) surround_index |= 1;
- if ((i < Xsize - 1) && (layout[i + 1][j] != 0 && layout[i + 1][j] != '.')) surround_index |= 2;
- if ((j > 0) && (layout[i][j - 1] != 0 && layout[i][j - 1] != '.')) surround_index |= 4;
- if ((j < Ysize - 1) && (layout[i][j + 1] != 0 && layout[i][j + 1] != '.')) surround_index |= 8;
+ if ((i > 0) && (maze[i - 1][j] != 0 && maze[i - 1][j] != '.')) surround_index |= 1;
+ if ((i < maze.w - 1) && (maze[i + 1][j] != 0 && maze[i + 1][j] != '.')) surround_index |= 2;
+ if ((j > 0) && (maze[i][j - 1] != 0 && maze[i][j - 1] != '.')) surround_index |= 4;
+ if ((j < maze.h - 1) && (maze[i][j + 1] != 0 && maze[i][j + 1] != '.')) surround_index |= 8;
return surround_index;
}
-/* actually make the layout: we work by a reduction process:
+/* actually make the maze: we work by a reduction process:
* first we make everything a wall, then we remove areas to make rooms
*/
void
-roguelike_layout_gen (Layout maze, int options)
+roguelike_layout_gen (layout &maze, int options)
{
int i, j;
Room *walk;
int nrooms = 0;
int tries = 0;
- int xsize = maze->w;
- int ysize = maze->h;
+ int xsize = maze.w;
+ int ysize = maze.h;
/* minimum room size is basically 5x5: if xsize/ysize is
less than 3x that then hollow things out, stick in
a stairsup and stairs down, and exit */
if (xsize < 11 || ysize < 11)
{
- maze->clear ();
- maze->border ();
+ maze.clear ();
+ maze.border ();
maze[(xsize - 1) / 2][(ysize - 1) / 2 ] = '>';
maze[(xsize - 1) / 2][(ysize - 1) / 2 + 1] = '<';
@@ -64,7 +87,7 @@
return;
}
- maze->clear ('#');
+ maze.fill ('#');
/* decide on the number of rooms */
nrooms = rmg_rndm (10) + 6;
@@ -83,8 +106,8 @@
if (i == 0) /* no can do! */
{
- maze->clear ();
- maze->border ();
+ maze.clear ();
+ maze.border ();
maze [(xsize - 1) / 2][(ysize - 1) / 2 ] = '>';
maze [(xsize - 1) / 2][(ysize - 1) / 2 + 1] = '<';
@@ -96,7 +119,7 @@
/* erase the areas occupied by the rooms */
roguelike_make_rooms (rooms, maze, options);
- roguelike_link_rooms (rooms, maze, xsize, ysize);
+ roguelike_link_rooms (rooms, maze);
/* put in the stairs */
@@ -133,7 +156,7 @@
if (maze[i][j] == 'D')
{ /* remove bad door. */
- int si = surround_check (maze, i, j, xsize, ysize);
+ int si = surround_check (maze, i, j);
if (si != 3 && si != 12)
{
@@ -253,7 +276,7 @@
}
static void
-roguelike_link_rooms (Room *rooms, char **maze, int xsize, int ysize)
+roguelike_link_rooms (Room *rooms, layout &maze)
{
Room *walk;
int i, j;