From 51968034b19c246a921ff04318f2c18e6f16b6cc Mon Sep 17 00:00:00 2001 From: stpohle Date: Sun, 10 Aug 2003 21:10:07 +0000 Subject: [PATCH] Tunnel fixed player postitions and destination of the tunnels.. they got sometimes overwritten --- src/bomberclone.h | 4 +++- src/field.c | 13 ++++++++++++- src/map.c | 7 ++++--- src/player.c | 15 +++++++++++++-- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/bomberclone.h b/src/bomberclone.h index 6f81e62..bc191d7 100644 --- a/src/bomberclone.h +++ b/src/bomberclone.h @@ -1,4 +1,4 @@ -/* $Id: bomberclone.h,v 1.50 2003/08/10 15:10:19 stpohle Exp $ */ +/* $Id: bomberclone.h,v 1.51 2003/08/10 21:10:07 stpohle Exp $ */ /* bomberclone.h */ #ifndef _BOMBERCLONE_H_ @@ -191,6 +191,7 @@ extern void field_animation (); extern void field_loop (); extern void field_hurrysize (); extern void field_hurrydropitems (); +extern int field_check_alldirs (int x, int y, int type); extern void draw_stone (int x, int y); extern void stonelist_add (int x, int y); extern void stonelist_del (); @@ -217,6 +218,7 @@ extern void player_check_powerup (int p_nr); extern void player_set_gfx (_player *p, signed char gfx_nr); extern int player_findfreebomb (_player *player); extern int player_checkpos (int x, int y); +extern inline int postofield (int pos); // for the bomb.. extern int bomb_loop (); diff --git a/src/field.c b/src/field.c index d6c470e..09f7b51 100644 --- a/src/field.c +++ b/src/field.c @@ -1,4 +1,4 @@ -/* $Id: field.c,v 1.43 2003/08/10 15:10:19 stpohle Exp $ */ +/* $Id: field.c,v 1.44 2003/08/10 21:10:07 stpohle Exp $ */ /* field.c - procedures which are needed to control the field */ #include "bomberclone.h" @@ -203,6 +203,17 @@ draw_field () }; +/* will check all direction without the field on pos x,y + for the fieldtype */ +int field_check_alldirs (int x, int y, int type) { + if (x <= 0 || y <= 0 || x >= map.size.x-1 || y >= map.size.y-1) + return 0; + if (map.field[x-1][y].type == type || map.field[x+1][y].type == type || map.field[x][y-1].type == type || map.field[x][y+1].type == type) + return 1; + else + return 0; +} + // clear field and send this to all netplayers void field_clear (int x, int y) diff --git a/src/map.c b/src/map.c index c03e59b..683ecfe 100644 --- a/src/map.c +++ b/src/map.c @@ -1,4 +1,4 @@ -/* $Id: map.c,v 1.8 2003/08/10 19:31:14 stpohle Exp $ */ +/* $Id: map.c,v 1.9 2003/08/10 21:10:07 stpohle Exp $ */ /* map handling, like generate and load maps. */ #include "bomberclone.h" @@ -19,14 +19,15 @@ map_fillitems (int fieldtype, int num) for (d = 0; d < num * fkt; d++) { x = y = 0; - while (map.field[x][y].type != FT_tunnel && map.field[x][y].type != FT_stone && map.field[x][y].special != FT_nothing) { + while (map.field[x][y].type != FT_stone && map.field[x][y].special != FT_nothing) { x = ((float) rand () / (float) RAND_MAX) * (map.size.x - 1); y = ((float) rand () / (float) RAND_MAX) * (map.size.y - 1); nb_try--; if (nb_try < 0) break; } - map.field[x][y].special = fieldtype; + if (map.field[x][y].type != FT_tunnel) + map.field[x][y].special = fieldtype; } } diff --git a/src/player.c b/src/player.c index c15c6e2..3d9a14f 100644 --- a/src/player.c +++ b/src/player.c @@ -397,8 +397,9 @@ move_player (int pl_nr) /* network packet send control - send data if it's time to send or if we need to */ if (bman.gametype != GT_single) net_game_send_playermove (pl_nr, (p->old_m == 0)); - if (p->tunnelto == 0) - p->tunnelto = -1; + + if (p->tunnelto == 0 && (map.field[postofield(p->pos.x)][postofield(p->pos.y)].type != FT_tunnel || !field_check_alldirs (p->pos.x>>8, p->pos.y>>8, FT_nothing))) + p->tunnelto = -1; } /* the player just stopt moving so send data */ @@ -425,6 +426,16 @@ move_player (int pl_nr) }; +inline int postofield (int pos) { + int rp = pos & 8; + + if (rp > 0 && rp <= 128) + return (pos >> 8); + else + return ((pos >> 8)+1); +} + + void player_drop_bomb (int pl_nr) {