From 123560996df8daae2ae3c9bfb6984e46a5ba9bf1 Mon Sep 17 00:00:00 2001 From: stpohle Date: Thu, 5 Feb 2004 21:32:10 +0000 Subject: [PATCH] fixed: single lost fire on the filed --- ChangeLog | 16 ++++++--- TODO | 6 +--- include/bomberclone.h | 16 +++++---- include/map.h | 4 ++- include/packets.h | 2 ++ src/bomb.c | 82 ++++++++++++++----------------------------- src/field.c | 77 ++++++++++++++++++++++++++++++++++++---- src/game.c | 4 ++- src/packets.c | 8 +++-- src/special.c | 4 +-- 10 files changed, 135 insertions(+), 84 deletions(-) diff --git a/ChangeLog b/ChangeLog index 714f0fb..da28f81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -$Id: ChangeLog,v 1.68 2004/02/04 22:56:47 patty21 Exp $ +$Id: ChangeLog,v 1.69 2004/02/05 21:32:10 stpohle Exp $ - Fixed: forgot to put the Message F4 to start the game into the playerselection screen. I put this only into the @@ -19,13 +19,19 @@ $Id: ChangeLog,v 1.68 2004/02/04 22:56:47 patty21 Exp $ - Fixed: Bombtickingtime could not be read from the config file. -- Fixed: If you select "Host a Netgame" nothing happened if firewall was - enabled. Now a error message is displayed. +- Fixed: If you select "Host a Netgame" nothing happened if + firewall was enabled. Now a error message is displayed. - Fixed: Chat input in multiplayer wait menu is now smoother. -- Changed: Download-Screen shows now a progress bar. Additionally, every - player can now see the download progress of all other players. +- Changed: Download-Screen shows now a progress bar. + Additionally, every player can now see the download + progress of all other players. + +- Fixed: Single Lost Fire on the field will be put now in + the animation list now which will check an decrease the + ex[*].count value as long as no specialy explosion was + found. Version 0.11.1 diff --git a/TODO b/TODO index 8fd5c10..080c2cb 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,4 @@ -$Id: TODO,v 1.38 2004/02/01 23:51:10 stpohle Exp $ - -* major network bug with forwarded packets. - -- bug: which creates just some explosions on the field. +$Id: TODO,v 1.39 2004/02/05 21:32:11 stpohle Exp $ - support for more player on one keyboard diff --git a/include/bomberclone.h b/include/bomberclone.h index 2a76ec5..bd61308 100644 --- a/include/bomberclone.h +++ b/include/bomberclone.h @@ -1,4 +1,4 @@ -/* $Id: bomberclone.h,v 1.21 2004/02/01 01:15:04 stpohle Exp $ */ +/* $Id: bomberclone.h,v 1.22 2004/02/05 21:32:13 stpohle Exp $ */ /* bomberclone.h */ #ifndef _BOMBERCLONE_H_ @@ -57,7 +57,11 @@ struct { struct { - _pointf pos; // lower byte = _X Higher Byte = FX + _pointf pos; // lower byte = _X Higher Byte = FX + struct __bomb_id { // save the bomb id + signed char p; // playernumber of this bomb + signed char b; // bombnumber of this bomb + } id; int firer[4]; // range of the fire for the fire for each direction int firerst[4]; /* just save here where the direction was going to stop (-1) if the exp is still growing */ @@ -192,6 +196,7 @@ 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 stone_drawfire (int x, int y, int frame); extern void stonelist_add (int x, int y); extern void stonelist_del (); extern void stonelist_draw (); @@ -222,14 +227,13 @@ extern void player_checkdeath (int pnr); // for the bomb.. extern int bomb_loop (); -extern void bomb_explode (int p, int b, int net); +extern void bomb_explode (_bomb *bomb, int net); extern inline void bomb_action (_bomb *bomb); extern void bomb_move (_bomb *bomb); extern void get_bomb_on (float x, float y, _point bombs[]); -extern void draw_fire (int x, int y, int d, int frame); -extern void do_explosion (int p, int b); +extern void do_explosion (_bomb *bomb); extern void restore_explosion (_bomb * bomb); -extern int explosion_check_field (int x, int y, int p, int b); +extern int explosion_check_field (int x, int y, _bomb *bomb); // configuration extern void config_init (int argc, char **argv); diff --git a/include/map.h b/include/map.h index 9d8ef69..988e650 100644 --- a/include/map.h +++ b/include/map.h @@ -1,4 +1,4 @@ -/* $Id: map.h,v 1.11 2004/01/27 21:58:05 stpohle Exp $ */ +/* $Id: map.h,v 1.12 2004/02/05 21:32:17 stpohle Exp $ */ /* map.h */ #ifndef _MAP_H_ @@ -18,6 +18,8 @@ struct __ex_field { unsigned char count; float frame; + int bomb_b; // BombID from the last know + int bomb_p; // explosion on this field } typedef _ex_field; diff --git a/include/packets.h b/include/packets.h index 7676c7e..e6adabb 100644 --- a/include/packets.h +++ b/include/packets.h @@ -102,6 +102,8 @@ struct pkg_field { struct { unsigned char count; unsigned char frame; + unsigned char bomb_b; + unsigned char bomb_p; } ex[4]; // count up every explosion there is on this field for ever direction Sint32 ex_nr; // number to identify the explosion. }; diff --git a/src/bomb.c b/src/bomb.c index daafb0e..aa9080c 100644 --- a/src/bomb.c +++ b/src/bomb.c @@ -1,4 +1,4 @@ -/* $Id: bomb.c,v 1.54 2004/01/25 19:36:46 stpohle Exp $ */ +/* $Id: bomb.c,v 1.55 2004/02/05 21:32:18 stpohle Exp $ */ /* everything what have to do with the bombs */ #include "bomberclone.h" @@ -88,17 +88,16 @@ draw_bomb (_bomb * bomb) void -bomb_explode (int p, int b, int net) +bomb_explode (_bomb *bomb, int net) { int d; - _bomb *bomb = &players[p].bombs[b]; - d_printf ("Bomb Explode p:%d, b:%d [%f,%f]\n", p, b, bomb->pos.x, bomb->pos.y); + d_printf ("Bomb Explode p:%d, b:%d [%f,%f]\n", bomb->id.p, bomb->id.b, bomb->pos.x, bomb->pos.y); if (bomb->ex_nr == -1) bomb->ex_nr = bman.last_ex_nr++; // set bomb explosion id - players[p].bomb_lastex = b; + players[bomb->id.p].bomb_lastex = bomb->id.b; bomb->to = EXPLOSIONTIMEOUT; /* set the timeout for the fireexplosion */ bomb->state = BS_exploding; @@ -108,7 +107,7 @@ bomb_explode (int p, int b, int net) } if (GT_MP_PTPM && net) /* from now on only the server let the bomb explode */ - net_game_send_bomb (p, b); + net_game_send_bomb (bomb->id.p, bomb->id.b); snd_play (SND_explode); }; @@ -242,7 +241,7 @@ bomb_loop () if (GT_MP_PTPM || GT_SP) { bomb->to -= timediff; if (bomb->to <= 0.0f) // bomb will have to explode in the next loop - bomb_explode (p, i, 1); + bomb_explode (bomb, 1); else draw_bomb (bomb); } @@ -267,7 +266,7 @@ bomb_loop () case BS_exploding: if (bomb->to > 0.0f) { - do_explosion (p, i); + do_explosion (bomb); } if (bomb->to <= 0.0f) { // explosion done restore_explosion (bomb); @@ -313,35 +312,11 @@ get_bomb_on (float x, float y, _point bombs[]) }; -/* if frame == -1 we will draw the framenumber in - the field.ex data */ -void -draw_fire (int x, int y, int d, int frame) -{ - SDL_Rect src, - dest; - - if (frame == -1) // no giving frame - frame = map.field[x][y].ex[d].frame; - - dest.w = src.w = gfx.block.x; - dest.h = src.h = gfx.block.y; - - dest.x = gfx.offset.x + x * gfx.block.x; - dest.y = gfx.offset.y + y * gfx.block.y; - - src.y = frame * src.w; - src.x = d * src.w; - - gfx_blit (gfx.fire.image, &src, gfx.screen, &dest, (y * 100)); -}; - void restore_explosion (_bomb * bomb) { int i, - j, d, dx = 0, dy = 0, @@ -370,22 +345,21 @@ restore_explosion (_bomb * bomb) _x = bomb->pos.x; _y = bomb->pos.y; - + + /* with every field where was an fire on it decrease the ex[].count value + * and force an drawing of this field */ for (i = 0; i < bomb->firer[d]; i++) { if (--map.field[_x][_y].ex[d].count == 0) // there was only one explosion so map.field[_x][_y].ex[d].frame = 0; // reset the framenumber - for (j = 0; j >= 0 && j < 4; j++) - if (map.field[_x][_y].ex[j].count > 0 && j != d) - j = -4; - if (j > 0) - stonelist_add (_x, _y); + stonelist_add (_x, _y); _x = _x + dx; _y = _y + dy; } - // delete the stone completly if there was any in the way + /* delete the stone completly if there was any in the way + * push the values field->type = fiels->special */ if (bomb->firer[d] <= bomb->r && map.field[_x][_y].type != FT_block && map.field[_x][_y].type != FT_tunnel && bomb->ex_nr != map.field[_x][_y].ex_nr) { @@ -416,13 +390,12 @@ restore_explosion (_bomb * bomb) }; -/* - check the field on which the explosion is -*/ -int -explosion_check_field (int x, int y, int p, int b) +/* check the field if there is another bomb stone or wathever + * if a bomb is found let this one explode, on a player well this player + * will die and if a stone was found, start with the stone explosion + * RETURN: value of the stonetype (FT_*) */ +int explosion_check_field (int x, int y, _bomb *bomb) { - _bomb *bomb = &players[p].bombs[b]; int pl[MAX_PLAYERS]; int i; _point bo[MAX_PLAYERS * MAX_BOMBS]; @@ -435,12 +408,12 @@ explosion_check_field (int x, int y, int p, int b) get_player_on (x, y, pl); get_bomb_on (x, y, bo); - // check if any bomb have to explode.. + /* check if any bomb have to explode.. */ for (i = 0; bo[i].x != -1; i++) { tmpbomb = &players[bo[i].x].bombs[bo[i].y]; if (tmpbomb != bomb && tmpbomb->state != BS_exploding) { tmpbomb->ex_nr = bomb->ex_nr; // set the ex_nr to identify explosions - bomb_explode (bo[i].x, bo[i].y, 1); + bomb_explode (&players[bo[i].x].bombs[bo[i].y], 1); } } @@ -450,7 +423,7 @@ explosion_check_field (int x, int y, int p, int b) if (((tmpplayer->state & PSF_alife) != 0) && (GT_SP || (GT_MP && (&players[bman.p_nr] == tmpplayer)) || (GT_MP_PTPM && PS_IS_aiplayer (tmpplayer->state)))) - player_died (tmpplayer, p); + player_died (tmpplayer, bomb->id.p); } // let the stones right beside explode @@ -499,22 +472,23 @@ draw_explosion (_bomb * bomb) p.y = bomb->pos.y; for (r = 0; r < bomb->firer[d]; r++) { + map.field[p.x][p.y].ex[d].bomb_p = bomb->id.p; + map.field[p.x][p.y].ex[d].bomb_b = bomb->id.b; map.field[p.x][p.y].ex[d].frame += timefactor; if (map.field[p.x][p.y].ex[d].frame >= gfx.fire.frames) map.field[p.x][p.y].ex[d].frame = 0.0f; stonelist_add (p.x, p.y); - draw_fire (p.x, p.y, d, -1); p.x += dx; p.y += dy; } } } -/* do the bombexplosion itself */ +/* do the bombexplosion itself, with every loop for one explosion + * add one more distance from the bomb if no stones are in the way */ void -do_explosion (int p, int b) +do_explosion (_bomb *bomb) { - _bomb *bomb = &players[p].bombs[b]; int dx = 0, dy = 0, d; @@ -545,15 +519,13 @@ do_explosion (int p, int b) dx = bomb->firer[d] * dx; dy = bomb->firer[d] * dy; - checkfield = explosion_check_field (bomb->pos.x + dx, bomb->pos.y + dy, p, b); + checkfield = explosion_check_field (bomb->pos.x + dx, bomb->pos.y + dy, bomb); if ((checkfield == FT_nothing || checkfield == FT_tunnel) && bomb->firerst[d] == -1) { bomb->firer[d]++; map.field[(int) bomb->pos.x + dx][(int) bomb->pos.y + dy].ex[d].count++; map.field[(int) bomb->pos.x + dx][(int) bomb->pos.y + dy].ex[d].frame = bomb->firer[d]; - /* if we have a slow pc we can enable this and disable the drawing animation */ - // draw_fire (bomb->pos.x + dx, bomb->pos.y + dy, d, gfx.fire.frames>>1); } else { bomb->firerst[d] = bomb->firer[d]; diff --git a/src/field.c b/src/field.c index 095ae9c..eade486 100644 --- a/src/field.c +++ b/src/field.c @@ -1,4 +1,4 @@ -/* $Id: field.c,v 1.53 2004/01/03 04:39:21 stpohle Exp $ */ +/* $Id: field.c,v 1.54 2004/02/05 21:32:18 stpohle Exp $ */ /* field.c - procedures which are needed to control the field */ #include "bomberclone.h" @@ -178,10 +178,10 @@ draw_stone (int x, int y) } // draw explosions if there is any - for (d = 0, i = 0; d < 4; d++) + for (d = 0; d < 4; d++) if (stone->ex[d].count > 0) { - i = 1; // mark that there is already an explosion - draw_fire (x, y, d, -1); + stone_drawfire (x, y, -1); + break; } // if (debug) @@ -268,8 +268,17 @@ field_animation () } stonelist_add (fieldani[i].x, fieldani[i].y); } - else /* delete this entry */ - fieldani[i].y = fieldani[i].x = -1; + else { + /* check for a fire, and if so add to the drawing if not delete */ + unsigned int d; + + for (d = 0; d < 4; d++) + if (map.field[fieldani[i].x][fieldani[i].y].ex[d].count > 0) + break; + + if (d >= 4) + fieldani[i].y = fieldani[i].x = -1; + } } else /* delete this entry */ fieldani[i].y = fieldani[i].x = -1; @@ -487,7 +496,7 @@ field_hurrysize () fieldhurrypos = old; else if (bombs[0].y != -1 && bombs[0].x != -1) { fieldhurrypos = old; - bomb_explode (bombs[0].x, bombs[0].y, 1); + bomb_explode (&players[bombs[0].x].bombs[bombs[0].y], 1); } else { /* set the block on the position */ @@ -501,3 +510,57 @@ field_hurrysize () } } }; + + +/* draw the fire on one field + * if frame == -1 we will draw the framenumber in the field.ex data + * Add stone to the animation list, draw the fire and then check if + * the bomb in the ex field is still showing on a explosion + */ +void stone_drawfire (int x, int y, int frame) +{ + SDL_Rect src, + dest; + int d; + _field *stone = &map.field[x][y]; + + /* add to the animation list */ + field_animation_add (x ,y); + + /* draw the stone */ + dest.w = src.w = gfx.block.x; + dest.h = src.h = gfx.block.y; + + dest.x = gfx.offset.x + x * gfx.block.x; + dest.y = gfx.offset.y + y * gfx.block.y; + + for (d = 0; d < 4; d++) + if (stone->ex[d].count > 0) { + if (frame == -1) // no giving frame + frame = map.field[x][y].ex[d].frame; + + src.y = frame * src.w; + src.x = d * src.w; + + gfx_blit (gfx.fire.image, &src, gfx.screen, &dest, (y * 100)); + } + + /* check if the last explosion is still right */ + for (d = 0; d < 4; d++) + if (stone->ex[d].count > 0) { + /* check if the bombid is right */ + if (stone->ex[d].bomb_p >= 0 && stone->ex[d].bomb_p < MAX_PLAYERS + && stone->ex[d].bomb_b >= 0 && stone->ex[d].bomb_b < MAX_BOMBS) { + /* check if the bomb explosion finished already */ + if (players[stone->ex[d].bomb_p].bombs[stone->ex[d].bomb_b].state != BS_exploding) { + stone->ex[d].count--; + stone->ex[d].bomb_b = -1; + stone->ex[d].bomb_p = -1; + } + } + else { + /* bombid is not right, set: count-1 */ + stone->ex[d].count--; + } + } +}; diff --git a/src/game.c b/src/game.c index 90cf146..a7bfa60 100644 --- a/src/game.c +++ b/src/game.c @@ -1,4 +1,4 @@ -/* $Id: game.c,v 1.75 2004/02/01 00:10:27 stpohle Exp $ +/* $Id: game.c,v 1.76 2004/02/05 21:32:18 stpohle Exp $ game.c - procedures for the game. */ #include @@ -358,6 +358,8 @@ game_start () players[p].bombs[i].dest.x = 0; players[p].bombs[i].dest.y = 0; players[p].bombs[i].mode = BM_normal; + players[p].bombs[i].id.p = p; + players[p].bombs[i].id.b = i; } } diff --git a/src/packets.c b/src/packets.c index f08b6a0..1d10471 100644 --- a/src/packets.c +++ b/src/packets.c @@ -438,6 +438,8 @@ send_field (_net_addr * addr, int x, int y, _field * field) for (i = 0; i < 4; i++) { f_dat.ex[i].count = map.field[x][y].ex[i].count; f_dat.ex[i].frame = (int) map.field[x][y].ex[i].frame; + f_dat.ex[i].bomb_p = map.field[x][y].ex[i].bomb_p; + f_dat.ex[i].bomb_b = map.field[x][y].ex[i].bomb_b; } f_dat.type = map.field[x][y].type; f_dat.mixframe = map.field[x][y].mixframe; @@ -462,9 +464,11 @@ do_field (struct pkg_field *f_dat, _net_addr * addr) map.field[f_dat->x][f_dat->y].type = f_dat->type; map.field[f_dat->x][f_dat->y].mixframe = f_dat->mixframe; map.field[f_dat->x][f_dat->y].special = f_dat->special; - for (i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { /* set the explosion field data */ map.field[f_dat->x][f_dat->y].ex[i].count = f_dat->ex[i].count; map.field[f_dat->x][f_dat->y].ex[i].frame = f_dat->ex[i].frame; + map.field[f_dat->x][f_dat->y].ex[i].bomb_p = f_dat->ex[i].bomb_p; + map.field[f_dat->x][f_dat->y].ex[i].bomb_b = f_dat->ex[i].bomb_b; } map.field[f_dat->x][f_dat->y].frame = I16TOF (NTOH16 (f_dat->frame)); map.field[f_dat->x][f_dat->y].ex_nr = NTOH32 (f_dat->ex_nr); @@ -789,7 +793,7 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr) bomb->dest.y = NTOH16 (b_dat->desty); if (bomb->state == BS_exploding) - bomb_explode (b_dat->p_nr, b_dat->b_nr, 0); + bomb_explode (bomb, 0); if (bomb->ex_nr > bman.last_ex_nr) bman.last_ex_nr = bomb->ex_nr; diff --git a/src/special.c b/src/special.c index 6e4693e..1914558 100644 --- a/src/special.c +++ b/src/special.c @@ -1,4 +1,4 @@ -/* $Id: special.c,v 1.31 2004/01/25 14:10:47 stpohle Exp $ */ +/* $Id: special.c,v 1.32 2004/02/05 21:32:18 stpohle Exp $ */ /* special.c - procedues to control the specials */ #include "bomberclone.h" @@ -17,7 +17,7 @@ special_trigger (int p_nr) for (i = 0; i < MAX_BOMBS; i++) if (p->bombs[i].state == BS_trigger) { p->bombs[i].ex_nr = ex_nr + 5; // we take the next 5 number to be shure - bomb_explode (p_nr, i, 0); // no other explosion interfear with it. + bomb_explode (&p->bombs[i], 0); // no other explosion interfear with it. z++; // count the bombs which will explode }