|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
/* $Id: map.c,v 1.26 2004/04/03 14:48:43 stpohle Exp $ */
|
|
|
|
|
/* $Id: map.c,v 1.27 2006/07/30 11:44:57 stpohle Exp $ */
|
|
|
|
|
/* map handling, like generate and load maps. */
|
|
|
|
|
|
|
|
|
|
#include "bomberclone.h"
|
|
|
|
@ -62,6 +62,10 @@ map_new (char *filename)
|
|
|
|
|
if (fmap == NULL)
|
|
|
|
|
map_genrandom ();
|
|
|
|
|
|
|
|
|
|
/* Generate a More random map if requested */
|
|
|
|
|
if (map.map_selection == MAPS_morerand)
|
|
|
|
|
map_genmorerandom();
|
|
|
|
|
|
|
|
|
|
if (map.type == -1)
|
|
|
|
|
map.type = s_random (MAPT_max);
|
|
|
|
|
|
|
|
|
@ -197,6 +201,54 @@ map_genrandom ()
|
|
|
|
|
// map_ensure_corner_start_points();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
map_genmorerandom ()
|
|
|
|
|
{
|
|
|
|
|
int x,
|
|
|
|
|
y,
|
|
|
|
|
d,
|
|
|
|
|
ra;
|
|
|
|
|
|
|
|
|
|
/* This is an enhanced version of genrandom() used by "more random" */
|
|
|
|
|
d_printf("genmorerandom: *** init ***\n");
|
|
|
|
|
/* if we can't load the map check first the fieldsize settings */
|
|
|
|
|
if (map.size.x < MIN_FIELDSIZE_X)
|
|
|
|
|
map.size.x = MIN_FIELDSIZE_X;
|
|
|
|
|
if (map.size.x > MAX_FIELDSIZE_X)
|
|
|
|
|
map.size.x = MAX_FIELDSIZE_X;
|
|
|
|
|
|
|
|
|
|
for (x = 0; x < map.size.x; x++)
|
|
|
|
|
for (y = 0; y < map.size.y; y++) {
|
|
|
|
|
if ((y == 0) || (y == map.size.y - 1))
|
|
|
|
|
map.field[x][y].type = FT_block;
|
|
|
|
|
else if ((x == 0) || (x == map.size.x - 1))
|
|
|
|
|
map.field[x][y].type = FT_block;
|
|
|
|
|
else {
|
|
|
|
|
// create random field
|
|
|
|
|
ra = s_random (256) & 3;
|
|
|
|
|
d_printf("genmorerandom: ra = %i\n", ra);
|
|
|
|
|
|
|
|
|
|
if (ra == 0)
|
|
|
|
|
map.field[x][y].type = FT_nothing;
|
|
|
|
|
else if (ra == 1)
|
|
|
|
|
map.field[x][y].type = FT_block;
|
|
|
|
|
else
|
|
|
|
|
map.field[x][y].type = FT_stone;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (d = 0; d < 4; d++)
|
|
|
|
|
map.field[x][y].ex[d].frame = map.field[x][y].ex[d].count = 0;
|
|
|
|
|
map.field[x][y].ex_nr = -1;
|
|
|
|
|
map.field[x][y].frame = 0.0f;
|
|
|
|
|
map.field[x][y].special = FT_nothing;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
d_printf("genmorerandom: *** exit ***\n");
|
|
|
|
|
/* set the corners of the map to be valid start points */
|
|
|
|
|
|
|
|
|
|
// map_ensure_corner_start_points();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* will set the playerposition but in a way that we won't start on a block */
|
|
|
|
|
/* i am just too lazy to write this all again and again */
|
|
|
|
@ -265,6 +317,8 @@ init_map_tileset ()
|
|
|
|
|
break;
|
|
|
|
|
case (2):
|
|
|
|
|
map_new (NULL);
|
|
|
|
|
case (3):
|
|
|
|
|
map_new (NULL); /* for more random */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (map.random_tileset)
|
|
|
|
|