bombexplosions should be fixed. Problem with slow computers are not anymore there. Rewrote do_explosion function.

origin
stpohle 21 years ago
parent 4486b04a4d
commit 13e1ebea43

@ -1,9 +1,12 @@
$Id: ChangeLog,v 1.87 2004/11/30 23:07:58 stpohle Exp $ $Id: ChangeLog,v 1.88 2004/12/01 02:41:53 stpohle Exp $
* FINISH TEAM MODE. * FINISH TEAM MODE.
* Server quits, will the AI player moved correctls to the - Bombs will not explode right on slow computers.. it
new Server? seems they jump one field to far.
fixed: rewrote part of the do_explosion stuff and
part of the explosion_restore function. Explosion
was growing on slow PC more as one field per cycle.
- AI Player die on a slow computer because they move more - AI Player die on a slow computer because they move more
as 1 Field. This might be also the problem Acidjnk told as 1 Field. This might be also the problem Acidjnk told

@ -5,7 +5,7 @@ dnl Please disable it in the Anjuta project configuration
AC_INIT(configure.in) AC_INIT(configure.in)
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE(bomberclone, 0.11.4test) AM_INIT_AUTOMAKE(bomberclone, 0.11.4test2)
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)

@ -1,4 +1,4 @@
/* $Id: bomb.h,v 1.3 2004/08/30 20:01:29 stpohle Exp $ /* $Id: bomb.h,v 1.4 2004/12/01 02:41:54 stpohle Exp $
* bomb include file * bomb include file
*/ */
@ -44,7 +44,7 @@ struct {
// for the bomb.. // for the bomb..
extern int bomb_loop (); extern void bomb_loop ();
extern void bomb_explode (_bomb *bomb, 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);

@ -1,4 +1,4 @@
/* $Id: bomb.c,v 1.60 2004/10/18 18:27:19 stpohle Exp $ */ /* $Id: bomb.c,v 1.61 2004/12/01 02:41:54 stpohle Exp $ */
/* everything what have to do with the bombs */ /* everything what have to do with the bombs */
#include "bomberclone.h" #include "bomberclone.h"
@ -242,12 +242,11 @@ bomb_move (_bomb * bomb)
} }
int void
bomb_loop () bomb_loop ()
{ {
int p, int p,
i, i;
b = 0;
_player *player; _player *player;
_bomb *bomb; _bomb *bomb;
@ -282,26 +281,24 @@ bomb_loop ()
if (bomb->mode != BM_normal) if (bomb->mode != BM_normal)
bomb_action (bomb); bomb_action (bomb);
b++; // Count ticking Bombs for Return value
break; break;
case BS_exploding: case BS_exploding:
if (bomb->to > 0.0f) { if (bomb->to > 0.0f) {
explosion_do (bomb); explosion_do (bomb);
} }
if (bomb->to <= 0.0f) { // explosion done else if (bomb->to <= 0.0f) { // explosion done
explosion_restore (bomb); explosion_restore (bomb);
bomb->to = 0.0f; bomb->to = 0.0f;
bomb->state = BS_off; bomb->state = BS_off;
} }
bomb->to -= timediff; bomb->to -= timediff;
b++;
break; break;
} }
} }
} }
} }
return b; return;
}; };
@ -343,30 +340,31 @@ void explosion_restore (_bomb *bomb) {
d, d,
_x, _x,
_y; _y;
// printf ("342: bomb (%d,%d)\n", (int) bomb->pos.x, (int) bomb->pos.y);
d_printf ("explosion_restore: %f,%f\n", bomb->pos.x, bomb->pos.y);
for (d = 0; d < 4; d++) { for (d = 0; d < 4; d++) {
_x = bomb->pos.x; _x = bomb->pos.x;
_y = bomb->pos.y; _y = bomb->pos.y;
if (map.field[_x][_y].ex[d].count > 0) if (map.field[_x][_y].ex[d].count > 0)
map.field[_x][_y].ex[d].count--; map.field[_x][_y].ex[d].count--;
if (map.field[_x][_y].ex[d].count == 0) map.field[_x][_y].ex[d].frame = 0.0f; // reset the framenumber
map.field[_x][_y].ex[d].frame = 0; // reset the framenumber if (d==3) {
if (d==3) stonelist_add (_x, _y); stonelist_add (_x, _y);
// printf ("restore: %d,%d\n", _x, _y);
}
/* with every field where was an fire on it decrease the ex[].count value /* with every field where was an fire on it decrease the ex[].count value
* and force an drawing of this field */ * and force an drawing of this field */
for (i = 0; i < bomb->firer[d]; i++) { // lower the number of explosions for (i = 0; i < rintf(bomb->firer[d]); i++) { // lower the number of explosions
_x = _x + dir_change[d].x; _x = _x + dir_change[d].x;
_y = _y + dir_change[d].y; _y = _y + dir_change[d].y;
if (map.field[_x][_y].ex[d].count > 0) if (map.field[_x][_y].ex[d].count > 0)
map.field[_x][_y].ex[d].count--; map.field[_x][_y].ex[d].count--;
if (map.field[_x][_y].ex[d].count == 0) map.field[_x][_y].ex[d].frame = 0.0f; // reset the framenumber
map.field[_x][_y].ex[d].frame = 0; // reset the framenumber
// printf ("361: d = %d, (%d,%d)\n", d, _x, _y);
stonelist_add (_x, _y); stonelist_add (_x, _y);
// printf ("restore: %d,%d c=%d\n", _x, _y, map.field[_x][_y].ex[d].count);
} }
/* delete the stone completly if there was any in the way /* delete the stone completly if there was any in the way
@ -382,7 +380,7 @@ void explosion_restore (_bomb *bomb) {
} }
else else
map.field[_x][_y].type = FT_nothing; map.field[_x][_y].type = FT_nothing;
d_printf ("field_explode (%d,%d) ex_nr = %d\n", _x, _y, map.field[_x][_y].ex_nr); // d_printf ("field_explode (%d,%d) ex_nr = %d\n", _x, _y, map.field[_x][_y].ex_nr);
// printf ("380: d = %d, (%d,%d)\n", d, _x, _y); // printf ("380: d = %d, (%d,%d)\n", d, _x, _y);
stonelist_add (_x, _y); stonelist_add (_x, _y);
@ -444,32 +442,33 @@ explosion_draw (_bomb * bomb)
void explosion_do (_bomb *bomb) { void explosion_do (_bomb *bomb) {
int d, dx, dy, ftype; int d, dx, dy, ftype;
float range_grow = (timediff * (float) MAX_RANGE)/EXPLOSION_GROW_SPEED; float range_grow = (timediff * (float) MAX_RANGE)/EXPLOSION_GROW_SPEED;
float range; float new_range;
float step;
if (bomb->state == BS_exploding) { if (bomb->state == BS_exploding) {
for (d = 0; d < 4; d++) { for (d = 0; d < 4; d++) {
if (bomb->firemaxr[d] == 0 && bomb->firer[d] < bomb->r) { if (bomb->firemaxr[d] == 0 && bomb->firer[d] < bomb->r) {
range = bomb->firer[d]; new_range = bomb->firer[d] + range_grow;
bomb->firer[d] += range_grow; if (new_range > bomb->r) new_range = bomb->r;
if (bomb->firer[d] > bomb->r) bomb->firer[d] = bomb->r;
dx = bomb->pos.x + (dir_change[d].x * rintf (range));
dy = bomb->pos.y + (dir_change[d].y * rintf (range));
/* check all fields between [dx,dy] and [odx,ody] */ /* check all fields between [dx,dy] and [odx,ody] */
while (bomb->firemaxr[d] == 0 && (rintf (range) < rintf (bomb->firer[d]))) { while (bomb->firemaxr[d] == 0 && (bomb->firer[d] < new_range)) {
step = new_range - bomb->firer[d];
if (rintf (range) < rintf(bomb->firer[d])) {
range += 1.0f; if (step > 1.0f) {
dx += dir_change[d].x; step = 1.0f;
dy += dir_change[d].y;
} }
bomb->firer[d] += step;
// printf ("d:%d, Cur_Range:%f New_Range:%f\n", d, bomb->firer[d], new_range);
dx = rintf(bomb->pos.x + dir_change[d].x * bomb->firer[d]);
dy = rintf(bomb->pos.y + dir_change[d].y * bomb->firer[d]);
ftype = explosion_check_field (dx, dy, bomb); ftype = explosion_check_field (dx, dy, bomb);
if (ftype == FT_nothing || ftype == FT_tunnel) { if (ftype == FT_nothing || ftype == FT_tunnel) {
// printf ("484: count++ d=%d (%d,%d) c_old: %d\n", d, dx, dy, map.field[dx][dy].ex[d].count); if (map.field[dx][dy].ex[d].count == 0 || map.field[dx][dy].ex_nr != bomb->ex_nr)
map.field[dx][dy].ex[d].count++; map.field[dx][dy].ex[d].count++;
map.field[dx][dy].ex[d].frame = 0.0f; map.field[dx][dy].ex[d].frame = 0.0f;
map.field[dx][dy].ex_nr = bomb->ex_nr; map.field[dx][dy].ex_nr = bomb->ex_nr;
map.field[dx][dy].ex[d].bomb_p = bomb->id.p; map.field[dx][dy].ex[d].bomb_p = bomb->id.p;

@ -1,4 +1,4 @@
/* $Id: game.c,v 1.102 2004/11/30 14:30:36 stpohle Exp $ /* $Id: game.c,v 1.103 2004/12/01 02:41:54 stpohle Exp $
game.c - procedures for the game. */ game.c - procedures for the game. */
#include <string.h> #include <string.h>
@ -194,7 +194,7 @@ void game_keys_loop () {
bman.updatestatusbar = 1; // force an update bman.updatestatusbar = 1; // force an update
} }
*/ */
if (keyb_gamekeys.state[BCK_esc] && !keyb_gamekeys.old[BCK_esc]) { if (keyb_gamekeys.state[BCK_esc] && !keyb_gamekeys.old[BCK_esc]) {
if (chat.active && (bman.state == GS_ready || bman.state == GS_running) && IS_LPLAYER2) { if (chat.active && (bman.state == GS_ready || bman.state == GS_running) && IS_LPLAYER2) {
chat.active = 0; chat.active = 0;
@ -262,7 +262,9 @@ game_loop ()
game_keys_loop (); game_keys_loop ();
chat_loop (&event); if (GT_MP)
chat_loop (&event);
if ((!IS_LPLAYER2) && (!chat.active)) if ((!IS_LPLAYER2) && (!chat.active))
chat_setactive (1, 1); chat_setactive (1, 1);
@ -298,7 +300,7 @@ game_loop ()
if (game_check_endgame () && bman.timeout >= 0.0f) if (game_check_endgame () && bman.timeout >= 0.0f)
bman.timeout = 0.0f; bman.timeout = 0.0f;
if ((GT_SP || GT_MP_PTPM) && bman.timeout < -GAME_OVERTIMEOUT) { if ((GT_SP || GT_MP_PTPM) && bman.timeout < -GAME_OVERTIMEOUT && (!debug)) {
d_printf ("GAME: Game Over\n"); d_printf ("GAME: Game Over\n");
done = 1; done = 1;
} }
@ -309,6 +311,8 @@ game_loop ()
if (menu != NULL) if (menu != NULL)
game_menu_loop (&event, eventstate); game_menu_loop (&event, eventstate);
s_delay (60); // for debug only
gfx_blitdraw (); gfx_blitdraw ();
s_calctimesync (); s_calctimesync ();
bman.timeout -= timediff; bman.timeout -= timediff;

Loading…
Cancel
Save