|
|
@ -1,4 +1,4 @@
|
|
|
|
/* $Id: map.c,v 1.18 2003/12/30 20:28:26 stpohle Exp $ */
|
|
|
|
/* $Id: map.c,v 1.19 2004/01/03 03:01:30 stpohle Exp $ */
|
|
|
|
/* map handling, like generate and load maps. */
|
|
|
|
/* map handling, like generate and load maps. */
|
|
|
|
|
|
|
|
|
|
|
|
#include "bomberclone.h"
|
|
|
|
#include "bomberclone.h"
|
|
|
@ -243,7 +243,7 @@ map_set_player_way1 (int pl)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
map_set_player_way2 (int pl)
|
|
|
|
map_set_player_way2 (int pl, int hardway)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_point p, t[4];
|
|
|
|
_point p, t[4];
|
|
|
|
int i, j, ok = 0;
|
|
|
|
int i, j, ok = 0;
|
|
|
@ -252,15 +252,26 @@ map_set_player_way2 (int pl)
|
|
|
|
p.y = s_random (map.size.y - 2) + 1;
|
|
|
|
p.y = s_random (map.size.y - 2) + 1;
|
|
|
|
|
|
|
|
|
|
|
|
/* check if there is no block */
|
|
|
|
/* check if there is no block */
|
|
|
|
if (map.field[p.x][p.y].type != FT_nothing)
|
|
|
|
if ((map.field[p.x][p.y].type != FT_nothing && (!hardway || map.field[p.x][p.y].type != FT_stone))
|
|
|
|
|
|
|
|
|| map.field[p.x][p.y].special == FT_tunnel)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* delete the stone under the player, only in hardway mode */
|
|
|
|
|
|
|
|
if (map.field[p.x][p.y].type != FT_stone && hardway) {
|
|
|
|
|
|
|
|
map.field[p.x][p.y].type = FT_nothing;
|
|
|
|
|
|
|
|
map.field[p.x][p.y].special = FT_nothing;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* check if we can run away somewhere */
|
|
|
|
/* check if we can run away somewhere */
|
|
|
|
for (j = 0; j < 4; j++) {
|
|
|
|
for (j = 0; j < 4; j++) {
|
|
|
|
t[j].x = p.x;
|
|
|
|
t[j].x = p.x;
|
|
|
|
t[j].y = p.y;
|
|
|
|
t[j].y = p.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (hardway) // if we using the hard way for playerposition
|
|
|
|
|
|
|
|
hardway = s_random (4)+1; // then select a side which we use
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; (i < 10 && ok == 0); i++) {
|
|
|
|
for (i = 0; (i < 10 && ok == 0); i++) {
|
|
|
|
t[left].x -= 1;
|
|
|
|
t[left].x -= 1;
|
|
|
|
t[right].x += 1;
|
|
|
|
t[right].x += 1;
|
|
|
@ -269,23 +280,33 @@ map_set_player_way2 (int pl)
|
|
|
|
for (j = 0; j < 4; j++)
|
|
|
|
for (j = 0; j < 4; j++)
|
|
|
|
if (t[j].x > 0 && t[j].x < map.size.x
|
|
|
|
if (t[j].x > 0 && t[j].x < map.size.x
|
|
|
|
&& t[j].y > 0 && t[j].y < map.size.y) {
|
|
|
|
&& t[j].y > 0 && t[j].y < map.size.y) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (hardway && (hardway - 1) == j && map.field[t[j].x][t[j].y].type == FT_stone) {
|
|
|
|
|
|
|
|
map.field[t[j].x][t[j].y].type = FT_nothing;
|
|
|
|
|
|
|
|
map.field[t[j].x][t[j].y].special = FT_nothing;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (map.field[t[j].x][t[j].y].type == FT_nothing) {
|
|
|
|
if (map.field[t[j].x][t[j].y].type == FT_nothing) {
|
|
|
|
if (ok == 0 && (j == left || j == right) && map.field[t[j].x][t[j].y - 1].type == FT_stone) {
|
|
|
|
if (ok == 0 && (j == left || j == right)
|
|
|
|
|
|
|
|
&& (map.field[t[j].x][t[j].y - 1].type == FT_stone || map.field[t[j].x][t[j].y - 1].type == FT_nothing)) {
|
|
|
|
map.field[t[j].x][t[j].y - 1].type = FT_nothing;
|
|
|
|
map.field[t[j].x][t[j].y - 1].type = FT_nothing;
|
|
|
|
map.field[t[j].x][t[j].y - 1].special = FT_nothing;
|
|
|
|
map.field[t[j].x][t[j].y - 1].special = FT_nothing;
|
|
|
|
ok = 1;
|
|
|
|
ok = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ok == 0 && (j == left || j == right) && map.field[t[j].x][t[j].y + 1].type == FT_stone) {
|
|
|
|
if (ok == 0 && (j == left || j == right)
|
|
|
|
|
|
|
|
&& (map.field[t[j].x][t[j].y + 1].type == FT_stone || map.field[t[j].x][t[j].y + 1].type == FT_nothing)) {
|
|
|
|
map.field[t[j].x][t[j].y + 1].type = FT_nothing;
|
|
|
|
map.field[t[j].x][t[j].y + 1].type = FT_nothing;
|
|
|
|
map.field[t[j].x][t[j].y + 1].special = FT_nothing;
|
|
|
|
map.field[t[j].x][t[j].y + 1].special = FT_nothing;
|
|
|
|
ok = 1;
|
|
|
|
ok = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ok == 0 && (j == up || j == down) && map.field[t[j].x + 1][t[j].y].type == FT_stone) {
|
|
|
|
if (ok == 0 && (j == up || j == down)
|
|
|
|
|
|
|
|
&& (map.field[t[j].x + 1][t[j].y].type == FT_stone || map.field[t[j].x + 1][t[j].y].type == FT_nothing)) {
|
|
|
|
map.field[t[j].x + 1][t[j].y].type = FT_nothing;
|
|
|
|
map.field[t[j].x + 1][t[j].y].type = FT_nothing;
|
|
|
|
map.field[t[j].x + 1][t[j].y].special = FT_nothing;
|
|
|
|
map.field[t[j].x + 1][t[j].y].special = FT_nothing;
|
|
|
|
ok = 1;
|
|
|
|
ok = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ok == 0 && (j == up || j == down) && map.field[t[j].x - 1][t[j].y].type == FT_stone) {
|
|
|
|
if (ok == 0 && (j == up || j == down)
|
|
|
|
|
|
|
|
&& (map.field[t[j].x - 1][t[j].y].type == FT_stone || map.field[t[j].x - 1][t[j].y].type == FT_nothing)) {
|
|
|
|
map.field[t[j].x - 1][t[j].y].type = FT_nothing;
|
|
|
|
map.field[t[j].x - 1][t[j].y].type = FT_nothing;
|
|
|
|
map.field[t[j].x - 1][t[j].y].special = FT_nothing;
|
|
|
|
map.field[t[j].x - 1][t[j].y].special = FT_nothing;
|
|
|
|
ok = 1;
|
|
|
|
ok = 1;
|
|
|
@ -314,6 +335,8 @@ map_set_playerposition (int usermap)
|
|
|
|
ready,
|
|
|
|
ready,
|
|
|
|
maxtry;
|
|
|
|
maxtry;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
d_printf ("map_set_playerposition\n");
|
|
|
|
|
|
|
|
|
|
|
|
/* try to set every player on a good place */
|
|
|
|
/* try to set every player on a good place */
|
|
|
|
maxtry = 300;
|
|
|
|
maxtry = 300;
|
|
|
|
ready = 0;
|
|
|
|
ready = 0;
|
|
|
@ -337,12 +360,28 @@ map_set_playerposition (int usermap)
|
|
|
|
if (PS_IS_used (players[pl].state) && (PLX (pl) < 0 || PLY (pl) < 0)) {
|
|
|
|
if (PS_IS_used (players[pl].state) && (PLX (pl) < 0 || PLY (pl) < 0)) {
|
|
|
|
/* set player */
|
|
|
|
/* set player */
|
|
|
|
ready = 0;
|
|
|
|
ready = 0;
|
|
|
|
map_set_player_way2 (pl);
|
|
|
|
map_set_player_way2 (pl, 0);
|
|
|
|
|
|
|
|
if (maxtry > 50)
|
|
|
|
|
|
|
|
map_playerpos_check (pl);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* try another way for setting the players */
|
|
|
|
|
|
|
|
maxtry = 200;
|
|
|
|
|
|
|
|
ready = 0;
|
|
|
|
|
|
|
|
while (!ready && maxtry-- > 0) {
|
|
|
|
|
|
|
|
ready = 1;
|
|
|
|
|
|
|
|
for (pl = 0; pl < MAX_PLAYERS; pl++)
|
|
|
|
|
|
|
|
if (PS_IS_used (players[pl].state) && (PLX (pl) < 0 || PLY (pl) < 0)) {
|
|
|
|
|
|
|
|
/* set player */
|
|
|
|
|
|
|
|
ready = 0;
|
|
|
|
|
|
|
|
map_set_player_way2 (pl, 1);
|
|
|
|
if (maxtry > 50)
|
|
|
|
if (maxtry > 50)
|
|
|
|
map_playerpos_check (pl);
|
|
|
|
map_playerpos_check (pl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* every player who is still not set ... let them die before they
|
|
|
|
/* every player who is still not set ... let them die before they
|
|
|
|
* can play put a warning on the screen */
|
|
|
|
* can play put a warning on the screen */
|
|
|
|
maxtry = 0; // mark our warning
|
|
|
|
maxtry = 0; // mark our warning
|
|
|
@ -354,8 +393,6 @@ map_set_playerposition (int usermap)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (maxtry)
|
|
|
|
if (maxtry)
|
|
|
|
d_fatal ("Not All Player could been set\n");
|
|
|
|
d_fatal ("Not All Player could been set\n");
|
|
|
|
|
|
|
|
|
|
|
|
d_printf ("map_set_playerposition\n");
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#undef PLX
|
|
|
|
#undef PLX
|
|
|
|