--- deliantra/server/random_maps/room_gen_onion.C 2008/04/14 22:41:17 1.14
+++ deliantra/server/random_maps/room_gen_onion.C 2010/03/26 01:04:44 1.22
@@ -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
*/
@@ -51,19 +52,17 @@
#include
#include
+#include
-#ifndef MIN
-# define MIN(x,y) (((x)<(y))? (x):(y))
-#endif
-void centered_onion (char **maze, int xsize, int ysize, int option, int layers);
-void bottom_centered_onion (char **maze, int xsize, int ysize, int option, int layers);
-void bottom_right_centered_onion (char **maze, int xsize, int ysize, int option, int layers);
+static void centered_onion (char **maze, int xsize, int ysize, int option, int layers);
+static void bottom_centered_onion (char **maze, int xsize, int ysize, int option, int layers);
+static void bottom_right_centered_onion (char **maze, int xsize, int ysize, int option, int layers);
-void draw_onion (char **maze, float *xlocations, float *ylocations, int layers);
-void make_doors (char **maze, float *xlocations, float *ylocations, int layers, int options);
+static void draw_onion (char **maze, float *xlocations, float *ylocations, int layers);
+static void make_doors (char **maze, float *xlocations, float *ylocations, int layers, int options);
void
-map_gen_onion (Maze maze, int option, int layers)
+map_gen_onion (Layout maze, int option, int layers)
{
int i, j;
@@ -75,7 +74,7 @@
/* pick some random options if option = 0 */
if (option == 0)
{
- switch (rndm (3))
+ switch (rmg_rndm (3))
{
case 0:
option |= RMOPT_CENTERED;
@@ -88,8 +87,8 @@
break;
}
- if (rndm (2)) option |= RMOPT_LINEAR;
- if (rndm (2)) option |= RMOPT_IRR_SPACE;
+ if (rmg_rndm (2)) option |= RMOPT_LINEAR;
+ if (rmg_rndm (2)) option |= RMOPT_IRR_SPACE;
}
/* write the outer walls, if appropriate. */
@@ -108,12 +107,12 @@
centered_onion (maze, xsize, ysize, option, layers);
}
-void
+static void
centered_onion (char **maze, int xsize, int ysize, int option, int layers)
{
int i, maxlayers;
- maxlayers = (MIN (xsize, ysize) - 2) / 5;
+ maxlayers = (min (xsize, ysize) - 2) / 5;
if (!maxlayers)
return; /* map too small to onionize */
@@ -122,7 +121,7 @@
layers = maxlayers;
if (layers == 0)
- layers = rndm (maxlayers) + 1;
+ layers = rmg_rndm (maxlayers) + 1;
float *xlocations = salloc0 (2 * layers);
float *ylocations = salloc0 (2 * layers);
@@ -142,10 +141,10 @@
float xpitch = 2, ypitch = 2;
if (x_spaces_available > 0)
- xpitch = 2 + (rndm (x_spaces_available) + rndm (x_spaces_available) + rndm (x_spaces_available)) / 3;
+ xpitch = 2 + (rmg_rndm (x_spaces_available) + rmg_rndm (x_spaces_available) + rmg_rndm (x_spaces_available)) / 3;
if (y_spaces_available > 0)
- ypitch = 2 + (rndm (y_spaces_available) + rndm (y_spaces_available) + rndm (y_spaces_available)) / 3;
+ ypitch = 2 + (rmg_rndm (y_spaces_available) + rmg_rndm (y_spaces_available) + rmg_rndm (y_spaces_available)) / 3;
xlocations[i] = ((i > 0) ? xlocations[i - 1] : 0) + xpitch;
ylocations[i] = ((i > 0) ? ylocations[i - 1] : 0) + ypitch;
@@ -180,12 +179,12 @@
sfree (ylocations, 2 * layers);
}
-void
+static void
bottom_centered_onion (char **maze, int xsize, int ysize, int option, int layers)
{
int i, maxlayers;
- maxlayers = (MIN (xsize, ysize) - 2) / 5;
+ maxlayers = (min (xsize, ysize) - 2) / 5;
if (!maxlayers)
return; /* map too small to onionize */
@@ -194,7 +193,7 @@
layers = maxlayers;
if (layers == 0)
- layers = rndm (maxlayers) + 1;
+ layers = rmg_rndm (maxlayers) + 1;
float *xlocations = salloc0 (2 * layers);
float *ylocations = salloc0 (2 * layers);
@@ -214,10 +213,10 @@
float xpitch = 2, ypitch = 2;
if (x_spaces_available > 0)
- xpitch = 2 + (rndm (x_spaces_available) + rndm (x_spaces_available) + rndm (x_spaces_available)) / 3;
+ xpitch = 2 + (rmg_rndm (x_spaces_available) + rmg_rndm (x_spaces_available) + rmg_rndm (x_spaces_available)) / 3;
if (y_spaces_available > 0)
- ypitch = 2 + (rndm (y_spaces_available) + rndm (y_spaces_available) + rndm (y_spaces_available)) / 3;
+ ypitch = 2 + (rmg_rndm (y_spaces_available) + rmg_rndm (y_spaces_available) + rmg_rndm (y_spaces_available)) / 3;
xlocations[i] = ((i > 0) ? xlocations[i - 1] : 0) + xpitch;
@@ -261,8 +260,8 @@
sfree (ylocations, 2 * layers);
}
-/* draw_boxes: draws the lines in the maze defining the onion layers */
-void
+/* draw_boxes: draws the lines in the maze defining the onion layers */
+static void
draw_onion (char **maze, float *xlocations, float *ylocations, int layers)
{
int i, j, l;
@@ -292,7 +291,7 @@
}
}
-void
+static void
make_doors (char **maze, float *xlocations, float *ylocations, int layers, int options)
{
int freedoms; /* number of different walls on which we could place a door */
@@ -311,7 +310,7 @@
return;
/* pick which wall will have a door. */
- which_wall = rndm (freedoms) + 1;
+ which_wall = rmg_rndm (freedoms) + 1;
for (l = 0; l < layers; l++)
{
if (options & RMOPT_LINEAR)
@@ -346,7 +345,7 @@
}
else
{ /* random door placement. */
- which_wall = rndm (freedoms) + 1;
+ which_wall = rmg_rndm (freedoms) + 1;
switch (which_wall)
{
case 1:
@@ -354,7 +353,7 @@
x1 = (int) xlocations[l];
y2 = (int) (ylocations[2 * layers - l - 1] - ylocations[l] - 1);
if (y2 > 0)
- y1 = (int) (ylocations[l] + rndm (y2) + 1);
+ y1 = (int) (ylocations[l] + rmg_rndm (y2) + 1);
else
y1 = (int) (ylocations[l] + 1);
break;
@@ -363,7 +362,7 @@
{ /* top wall placement */
x2 = (int) ((-xlocations[l] + xlocations[2 * layers - l - 1])) - 1;
if (x2 > 0)
- x1 = (int) (xlocations[l] + rndm (x2) + 1);
+ x1 = (int) (xlocations[l] + rmg_rndm (x2) + 1);
else
x1 = (int) (xlocations[l] + 1);
y1 = (int) ylocations[l];
@@ -374,7 +373,7 @@
x1 = (int) xlocations[2 * layers - l - 1];
y2 = (int) ((-ylocations[l] + ylocations[2 * layers - l - 1])) - 1;
if (y2 > 0)
- y1 = (int) (ylocations[l] + rndm (y2) + 1);
+ y1 = (int) (ylocations[l] + rmg_rndm (y2) + 1);
else
y1 = (int) (ylocations[l] + 1);
@@ -384,7 +383,7 @@
{ /* bottom wall placement */
x2 = (int) ((-xlocations[l] + xlocations[2 * layers - l - 1])) - 1;
if (x2 > 0)
- x1 = (int) (xlocations[l] + rndm (x2) + 1);
+ x1 = (int) (xlocations[l] + rmg_rndm (x2) + 1);
else
x1 = (int) (xlocations[l] + 1);
y1 = (int) ylocations[2 * layers - l - 1];
@@ -408,12 +407,12 @@
maze[x1][y1] = 'C';
}
-void
+static void
bottom_right_centered_onion (char **maze, int xsize, int ysize, int option, int layers)
{
int i, maxlayers;
- maxlayers = (MIN (xsize, ysize) - 2) / 5;
+ maxlayers = (min (xsize, ysize) - 2) / 5;
if (!maxlayers)
return; /* map too small to onionize */
@@ -422,7 +421,7 @@
layers = maxlayers;
if (layers == 0)
- layers = rndm (maxlayers) + 1;
+ layers = rmg_rndm (maxlayers) + 1;
float *xlocations = salloc0 (2 * layers);
float *ylocations = salloc0 (2 * layers);
@@ -443,10 +442,10 @@
float xpitch = 2, ypitch = 2;
if (x_spaces_available > 0)
- xpitch = 2 + (rndm (x_spaces_available) + rndm (x_spaces_available) + rndm (x_spaces_available)) / 3;
+ xpitch = 2 + (rmg_rndm (x_spaces_available) + rmg_rndm (x_spaces_available) + rmg_rndm (x_spaces_available)) / 3;
if (y_spaces_available > 0)
- ypitch = 2 + (rndm (y_spaces_available) + rndm (y_spaces_available) + rndm (y_spaces_available)) / 3;
+ ypitch = 2 + (rmg_rndm (y_spaces_available) + rmg_rndm (y_spaces_available) + rmg_rndm (y_spaces_available)) / 3;
if (i < layers)
xlocations[i] = ((i > 0) ? xlocations[i - 1] : 0) + xpitch;