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.
* Server quits, will the AI player moved correctls to the
new Server?
- Bombs will not explode right on slow computers.. it
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
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_CANONICAL_TARGET
AM_INIT_AUTOMAKE(bomberclone, 0.11.4test)
AM_INIT_AUTOMAKE(bomberclone, 0.11.4test2)
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
*/
@ -44,7 +44,7 @@ struct {
// for the bomb..
extern int bomb_loop ();
extern void bomb_loop ();
extern void bomb_explode (_bomb *bomb, int net);
extern inline void bomb_action (_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 */
#include "bomberclone.h"
@ -242,12 +242,11 @@ bomb_move (_bomb * bomb)
}
int
void
bomb_loop ()
{
int p,
i,
b = 0;
i;
_player *player;
_bomb *bomb;
@ -282,26 +281,24 @@ bomb_loop ()
if (bomb->mode != BM_normal)
bomb_action (bomb);
b++; // Count ticking Bombs for Return value
break;
case BS_exploding:
if (bomb->to > 0.0f) {
explosion_do (bomb);
}
if (bomb->to <= 0.0f) { // explosion done
else if (bomb->to <= 0.0f) { // explosion done
explosion_restore (bomb);
bomb->to = 0.0f;
bomb->state = BS_off;
}
bomb->to -= timediff;
b++;
break;
}
}
}
}
return b;
return;
};
@ -343,30 +340,31 @@ void explosion_restore (_bomb *bomb) {
d,
_x,
_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++) {
_x = bomb->pos.x;
_y = bomb->pos.y;
if (map.field[_x][_y].ex[d].count > 0)
map.field[_x][_y].ex[d].count--;
if (map.field[_x][_y].ex[d].count == 0)
map.field[_x][_y].ex[d].frame = 0; // reset the framenumber
if (d==3) stonelist_add (_x, _y);
map.field[_x][_y].ex[d].frame = 0.0f; // reset the framenumber
if (d==3) {
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
* 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;
_y = _y + dir_change[d].y;
if (map.field[_x][_y].ex[d].count > 0)
map.field[_x][_y].ex[d].count--;
if (map.field[_x][_y].ex[d].count == 0)
map.field[_x][_y].ex[d].frame = 0; // reset the framenumber
// printf ("361: d = %d, (%d,%d)\n", d, _x, _y);
map.field[_x][_y].ex[d].frame = 0.0f; // reset the framenumber
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
@ -382,7 +380,7 @@ void explosion_restore (_bomb *bomb) {
}
else
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);
stonelist_add (_x, _y);
@ -444,31 +442,32 @@ explosion_draw (_bomb * bomb)
void explosion_do (_bomb *bomb) {
int d, dx, dy, ftype;
float range_grow = (timediff * (float) MAX_RANGE)/EXPLOSION_GROW_SPEED;
float range;
float new_range;
float step;
if (bomb->state == BS_exploding) {
for (d = 0; d < 4; d++) {
if (bomb->firemaxr[d] == 0 && bomb->firer[d] < bomb->r) {
range = bomb->firer[d];
bomb->firer[d] += range_grow;
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));
new_range = bomb->firer[d] + range_grow;
if (new_range > bomb->r) new_range = bomb->r;
/* 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;
dx += dir_change[d].x;
dy += dir_change[d].y;
if (step > 1.0f) {
step = 1.0f;
}
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);
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].frame = 0.0f;
map.field[dx][dy].ex_nr = bomb->ex_nr;

@ -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. */
#include <string.h>
@ -262,7 +262,9 @@ game_loop ()
game_keys_loop ();
if (GT_MP)
chat_loop (&event);
if ((!IS_LPLAYER2) && (!chat.active))
chat_setactive (1, 1);
@ -298,7 +300,7 @@ game_loop ()
if (game_check_endgame () && 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");
done = 1;
}
@ -309,6 +311,8 @@ game_loop ()
if (menu != NULL)
game_menu_loop (&event, eventstate);
s_delay (60); // for debug only
gfx_blitdraw ();
s_calctimesync ();
bman.timeout -= timediff;

Loading…
Cancel
Save