fixed: single lost fire on the filed

origin
stpohle 22 years ago
parent e4245211c0
commit 123560996d

@ -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 - Fixed: forgot to put the Message F4 to start the game
into the playerselection screen. I put this only into the 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 - Fixed: Bombtickingtime could not be read from the config
file. file.
- Fixed: If you select "Host a Netgame" nothing happened if firewall was - Fixed: If you select "Host a Netgame" nothing happened if
enabled. Now a error message is displayed. firewall was enabled. Now a error message is displayed.
- Fixed: Chat input in multiplayer wait menu is now smoother. - Fixed: Chat input in multiplayer wait menu is now smoother.
- Changed: Download-Screen shows now a progress bar. Additionally, every - Changed: Download-Screen shows now a progress bar.
player can now see the download progress of all other players. 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 Version 0.11.1

@ -1,8 +1,4 @@
$Id: TODO,v 1.38 2004/02/01 23:51:10 stpohle Exp $ $Id: TODO,v 1.39 2004/02/05 21:32:11 stpohle Exp $
* major network bug with forwarded packets.
- bug: which creates just some explosions on the field.
- support for more player on one keyboard - support for more player on one keyboard

@ -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 */ /* bomberclone.h */
#ifndef _BOMBERCLONE_H_ #ifndef _BOMBERCLONE_H_
@ -57,7 +57,11 @@ struct {
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 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) int firerst[4]; /* just save here where the direction was going to stop (-1)
if the exp is still growing */ if the exp is still growing */
@ -192,6 +196,7 @@ extern void field_hurrysize ();
extern void field_hurrydropitems (); extern void field_hurrydropitems ();
extern int field_check_alldirs (int x, int y, int type); extern int field_check_alldirs (int x, int y, int type);
extern void draw_stone (int x, int y); 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_add (int x, int y);
extern void stonelist_del (); extern void stonelist_del ();
extern void stonelist_draw (); extern void stonelist_draw ();
@ -222,14 +227,13 @@ extern void player_checkdeath (int pnr);
// for the bomb.. // for the bomb..
extern int bomb_loop (); 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 inline void bomb_action (_bomb *bomb);
extern void bomb_move (_bomb *bomb); extern void bomb_move (_bomb *bomb);
extern void get_bomb_on (float x, float y, _point bombs[]); 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 (_bomb *bomb);
extern void do_explosion (int p, int b);
extern void restore_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 // configuration
extern void config_init (int argc, char **argv); extern void config_init (int argc, char **argv);

@ -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 */ /* map.h */
#ifndef _MAP_H_ #ifndef _MAP_H_
@ -18,6 +18,8 @@
struct __ex_field { struct __ex_field {
unsigned char count; unsigned char count;
float frame; float frame;
int bomb_b; // BombID from the last know
int bomb_p; // explosion on this field
} typedef _ex_field; } typedef _ex_field;

@ -102,6 +102,8 @@ struct pkg_field {
struct { struct {
unsigned char count; unsigned char count;
unsigned char frame; 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 } ex[4]; // count up every explosion there is on this field for ever direction
Sint32 ex_nr; // number to identify the explosion. Sint32 ex_nr; // number to identify the explosion.
}; };

@ -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 */ /* everything what have to do with the bombs */
#include "bomberclone.h" #include "bomberclone.h"
@ -88,17 +88,16 @@ draw_bomb (_bomb * bomb)
void void
bomb_explode (int p, int b, int net) bomb_explode (_bomb *bomb, int net)
{ {
int d; 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) if (bomb->ex_nr == -1)
bomb->ex_nr = bman.last_ex_nr++; // set bomb explosion id 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->to = EXPLOSIONTIMEOUT; /* set the timeout for the fireexplosion */
bomb->state = BS_exploding; 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 */ 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); snd_play (SND_explode);
}; };
@ -242,7 +241,7 @@ bomb_loop ()
if (GT_MP_PTPM || GT_SP) { if (GT_MP_PTPM || GT_SP) {
bomb->to -= timediff; bomb->to -= timediff;
if (bomb->to <= 0.0f) // bomb will have to explode in the next loop if (bomb->to <= 0.0f) // bomb will have to explode in the next loop
bomb_explode (p, i, 1); bomb_explode (bomb, 1);
else else
draw_bomb (bomb); draw_bomb (bomb);
} }
@ -267,7 +266,7 @@ bomb_loop ()
case BS_exploding: case BS_exploding:
if (bomb->to > 0.0f) { if (bomb->to > 0.0f) {
do_explosion (p, i); do_explosion (bomb);
} }
if (bomb->to <= 0.0f) { // explosion done if (bomb->to <= 0.0f) { // explosion done
restore_explosion (bomb); 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 void
restore_explosion (_bomb * bomb) restore_explosion (_bomb * bomb)
{ {
int i, int i,
j,
d, d,
dx = 0, dx = 0,
dy = 0, dy = 0,
@ -370,22 +345,21 @@ restore_explosion (_bomb * bomb)
_x = bomb->pos.x; _x = bomb->pos.x;
_y = bomb->pos.y; _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++) { for (i = 0; i < bomb->firer[d]; i++) {
if (--map.field[_x][_y].ex[d].count == 0) // there was only one explosion so 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 map.field[_x][_y].ex[d].frame = 0; // reset the framenumber
for (j = 0; j >= 0 && j < 4; j++) stonelist_add (_x, _y);
if (map.field[_x][_y].ex[j].count > 0 && j != d)
j = -4;
if (j > 0)
stonelist_add (_x, _y);
_x = _x + dx; _x = _x + dx;
_y = _y + dy; _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 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) { && 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 if there is another bomb stone or wathever
check the field on which the explosion is * 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
int * RETURN: value of the stonetype (FT_*) */
explosion_check_field (int x, int y, int p, int b) int explosion_check_field (int x, int y, _bomb *bomb)
{ {
_bomb *bomb = &players[p].bombs[b];
int pl[MAX_PLAYERS]; int pl[MAX_PLAYERS];
int i; int i;
_point bo[MAX_PLAYERS * MAX_BOMBS]; _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_player_on (x, y, pl);
get_bomb_on (x, y, bo); 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++) { for (i = 0; bo[i].x != -1; i++) {
tmpbomb = &players[bo[i].x].bombs[bo[i].y]; tmpbomb = &players[bo[i].x].bombs[bo[i].y];
if (tmpbomb != bomb && tmpbomb->state != BS_exploding) { if (tmpbomb != bomb && tmpbomb->state != BS_exploding) {
tmpbomb->ex_nr = bomb->ex_nr; // set the ex_nr to identify explosions 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) if (((tmpplayer->state & PSF_alife) != 0)
&& (GT_SP || (GT_MP && (&players[bman.p_nr] == tmpplayer)) && (GT_SP || (GT_MP && (&players[bman.p_nr] == tmpplayer))
|| (GT_MP_PTPM && PS_IS_aiplayer (tmpplayer->state)))) || (GT_MP_PTPM && PS_IS_aiplayer (tmpplayer->state))))
player_died (tmpplayer, p); player_died (tmpplayer, bomb->id.p);
} }
// let the stones right beside explode // let the stones right beside explode
@ -499,22 +472,23 @@ draw_explosion (_bomb * bomb)
p.y = bomb->pos.y; p.y = bomb->pos.y;
for (r = 0; r < bomb->firer[d]; r++) { 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; map.field[p.x][p.y].ex[d].frame += timefactor;
if (map.field[p.x][p.y].ex[d].frame >= gfx.fire.frames) if (map.field[p.x][p.y].ex[d].frame >= gfx.fire.frames)
map.field[p.x][p.y].ex[d].frame = 0.0f; map.field[p.x][p.y].ex[d].frame = 0.0f;
stonelist_add (p.x, p.y); stonelist_add (p.x, p.y);
draw_fire (p.x, p.y, d, -1);
p.x += dx; p.x += dx;
p.y += dy; 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 void
do_explosion (int p, int b) do_explosion (_bomb *bomb)
{ {
_bomb *bomb = &players[p].bombs[b];
int dx = 0, int dx = 0,
dy = 0, dy = 0,
d; d;
@ -545,15 +519,13 @@ do_explosion (int p, int b)
dx = bomb->firer[d] * dx; dx = bomb->firer[d] * dx;
dy = bomb->firer[d] * dy; 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) if ((checkfield == FT_nothing || checkfield == FT_tunnel)
&& bomb->firerst[d] == -1) { && bomb->firerst[d] == -1) {
bomb->firer[d]++; 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].count++;
map.field[(int) bomb->pos.x + dx][(int) bomb->pos.y + dy].ex[d].frame = map.field[(int) bomb->pos.x + dx][(int) bomb->pos.y + dy].ex[d].frame =
bomb->firer[d]; 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 { else {
bomb->firerst[d] = bomb->firer[d]; bomb->firerst[d] = bomb->firer[d];

@ -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 */ /* field.c - procedures which are needed to control the field */
#include "bomberclone.h" #include "bomberclone.h"
@ -178,10 +178,10 @@ draw_stone (int x, int y)
} }
// draw explosions if there is any // 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) { if (stone->ex[d].count > 0) {
i = 1; // mark that there is already an explosion stone_drawfire (x, y, -1);
draw_fire (x, y, d, -1); break;
} }
// if (debug) // if (debug)
@ -268,8 +268,17 @@ field_animation ()
} }
stonelist_add (fieldani[i].x, fieldani[i].y); stonelist_add (fieldani[i].x, fieldani[i].y);
} }
else /* delete this entry */ else {
fieldani[i].y = fieldani[i].x = -1; /* 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 */ else /* delete this entry */
fieldani[i].y = fieldani[i].x = -1; fieldani[i].y = fieldani[i].x = -1;
@ -487,7 +496,7 @@ field_hurrysize ()
fieldhurrypos = old; fieldhurrypos = old;
else if (bombs[0].y != -1 && bombs[0].x != -1) { else if (bombs[0].y != -1 && bombs[0].x != -1) {
fieldhurrypos = old; fieldhurrypos = old;
bomb_explode (bombs[0].x, bombs[0].y, 1); bomb_explode (&players[bombs[0].x].bombs[bombs[0].y], 1);
} }
else { else {
/* set the block on the position */ /* 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--;
}
}
};

@ -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. */ game.c - procedures for the game. */
#include <string.h> #include <string.h>
@ -358,6 +358,8 @@ game_start ()
players[p].bombs[i].dest.x = 0; players[p].bombs[i].dest.x = 0;
players[p].bombs[i].dest.y = 0; players[p].bombs[i].dest.y = 0;
players[p].bombs[i].mode = BM_normal; players[p].bombs[i].mode = BM_normal;
players[p].bombs[i].id.p = p;
players[p].bombs[i].id.b = i;
} }
} }

@ -438,6 +438,8 @@ send_field (_net_addr * addr, int x, int y, _field * field)
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
f_dat.ex[i].count = map.field[x][y].ex[i].count; 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].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.type = map.field[x][y].type;
f_dat.mixframe = map.field[x][y].mixframe; 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].type = f_dat->type;
map.field[f_dat->x][f_dat->y].mixframe = f_dat->mixframe; map.field[f_dat->x][f_dat->y].mixframe = f_dat->mixframe;
map.field[f_dat->x][f_dat->y].special = f_dat->special; 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].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].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].frame = I16TOF (NTOH16 (f_dat->frame));
map.field[f_dat->x][f_dat->y].ex_nr = NTOH32 (f_dat->ex_nr); 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); bomb->dest.y = NTOH16 (b_dat->desty);
if (bomb->state == BS_exploding) 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) if (bomb->ex_nr > bman.last_ex_nr)
bman.last_ex_nr = bomb->ex_nr; bman.last_ex_nr = bomb->ex_nr;

@ -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 */ /* special.c - procedues to control the specials */
#include "bomberclone.h" #include "bomberclone.h"
@ -17,7 +17,7 @@ special_trigger (int p_nr)
for (i = 0; i < MAX_BOMBS; i++) for (i = 0; i < MAX_BOMBS; i++)
if (p->bombs[i].state == BS_trigger) { if (p->bombs[i].state == BS_trigger) {
p->bombs[i].ex_nr = ex_nr + 5; // we take the next 5 number to be shure 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 z++; // count the bombs which will explode
} }

Loading…
Cancel
Save