From 93e01bc3b57520b44b616ab01c8fa7075ee0b438 Mon Sep 17 00:00:00 2001 From: stpohle Date: Sat, 3 Jan 2004 03:01:30 +0000 Subject: [PATCH] map_set_playerposition fixed.. not players should be always set. --- ChangeLog | 5 ++++- TODO | 6 +----- include/map.h | 5 ++++- src/map.c | 57 ++++++++++++++++++++++++++++++++++++++++++--------- 4 files changed, 56 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 88dfff0..3b1da20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ -$Id: ChangeLog,v 1.47 2004/01/02 13:54:47 stpohle Exp $ +$Id: ChangeLog,v 1.48 2004/01/03 03:01:30 stpohle Exp $ + +- Added smal help screen in the multiplayer selection + screen. - Fixed: If the player is move on a field where is currently an explosion then will the player die. diff --git a/TODO b/TODO index 8fe973b..db7214f 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,4 @@ -$Id: TODO,v 1.33 2004/01/02 13:54:47 stpohle Exp $ - -* player position at start up need some little work - it is still happening that player just die because - they could not been set. +$Id: TODO,v 1.34 2004/01/03 03:01:30 stpohle Exp $ - better configuration for home made map files diff --git a/include/map.h b/include/map.h index f2e74dc..b1b2e7c 100644 --- a/include/map.h +++ b/include/map.h @@ -1,4 +1,4 @@ -/* $Id: map.h,v 1.6 2003/12/28 01:21:42 stpohle Exp $ */ +/* $Id: map.h,v 1.7 2004/01/03 03:01:30 stpohle Exp $ */ /* map.h */ #ifndef _MAP_H_ @@ -65,5 +65,8 @@ extern void init_map_tileset(); extern void map_new (char *filename); extern void map_set_playerposition (int usermap); extern void map_load (FILE * fmap); +extern void map_set_player_way (int pl); +extern void map_set_player_way2 (int pl, int hardway); + #endif diff --git a/src/map.c b/src/map.c index fb59486..2e96a45 100644 --- a/src/map.c +++ b/src/map.c @@ -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. */ #include "bomberclone.h" @@ -243,7 +243,7 @@ map_set_player_way1 (int pl) void -map_set_player_way2 (int pl) +map_set_player_way2 (int pl, int hardway) { _point p, t[4]; int i, j, ok = 0; @@ -252,15 +252,26 @@ map_set_player_way2 (int pl) p.y = s_random (map.size.y - 2) + 1; /* 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; + /* 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 */ for (j = 0; j < 4; j++) { t[j].x = p.x; 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++) { t[left].x -= 1; t[right].x += 1; @@ -269,23 +280,33 @@ map_set_player_way2 (int pl) for (j = 0; j < 4; j++) if (t[j].x > 0 && t[j].x < map.size.x && 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 (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].special = FT_nothing; 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].special = FT_nothing; 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].special = FT_nothing; 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].special = FT_nothing; ok = 1; @@ -314,6 +335,8 @@ map_set_playerposition (int usermap) ready, maxtry; + d_printf ("map_set_playerposition\n"); + /* try to set every player on a good place */ maxtry = 300; ready = 0; @@ -337,12 +360,28 @@ map_set_playerposition (int usermap) if (PS_IS_used (players[pl].state) && (PLX (pl) < 0 || PLY (pl) < 0)) { /* set player */ 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) + map_playerpos_check (pl); + } + } + + /* every player who is still not set ... let them die before they * can play put a warning on the screen */ maxtry = 0; // mark our warning @@ -354,8 +393,6 @@ map_set_playerposition (int usermap) } if (maxtry) d_fatal ("Not All Player could been set\n"); - - d_printf ("map_set_playerposition\n"); }; #undef PLX