added bman.bfield for faster access by the ai players.

origin
stpohle 23 years ago
parent 871e349f63
commit d964440d5f

@ -230,6 +230,9 @@ restore_explosion (_bomb * bomb)
gfx.offset.y + (_y-bomb->firer[up]) * gfx.block.y,
gfx.block.x*(bomb->firer[left]+bomb->firer[right]+1),
gfx.block.x*(bomb->firer[up]+bomb->firer[down]+1));
/* delete field from the bfield map */
bman.bfield [bomb->pos.x][bomb->pos.y] = 0;
};

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.20 2003/05/11 17:27:30 stpohle Exp $ */
/* $Id: bomberclone.h,v 1.21 2003/05/11 22:28:14 stpohle Exp $ */
/* bomberclone.h */
#ifndef _BOMBERCLONE_H_
@ -124,6 +124,7 @@ struct __bomberclone {
int p_nr; // Playernumber 0 if you host a game or the number of the one you are.
_field field[MAX_FIELDSIZE_X][MAX_FIELDSIZE_Y];
unsigned char bfield[MAX_FIELDSIZE_X][MAX_FIELDSIZE_Y]; // will hold informations if ther is a bomb
int random_map; // random selecting of a map
char fieldpath[512]; // path of the field file
@ -182,7 +183,7 @@ extern void draw_player (_player * player);
extern void restore_players_screen ();
extern void move_player ();
extern int stepmove_player ();
extern void player_drop_bomb ();
extern void player_drop_bomb (int pl_nr);
extern void get_player_on (short int x, short int y, int pl_nr[]);
extern void player_died (_player * player, signed char dead_by);
extern void draw_players ();

@ -1,4 +1,4 @@
/* $Id: field.c,v 1.17 2003/05/11 03:27:18 patty21 Exp $ */
/* $Id: field.c,v 1.18 2003/05/11 22:29:28 stpohle Exp $ */
/* field.c - procedures which are needed to control the field */
#include <stdlib.h>
@ -328,6 +328,11 @@ field_new (char *filename)
}
}
/* delete the bfield data */
for (x = 0; x < MAX_FIELDSIZE_X; x++)
for (y = 0; y < MAX_FIELDSIZE_Y; y++)
bman.bfield[x][y] = 0;
/* Set the Playerinformation */
field_set_playerposition (fmap != NULL);

@ -168,7 +168,7 @@ game_loop ()
}
if (keys[SDLK_LCTRL] || keys[SDLK_RCTRL]) {
if (key_bomb == 0)
player_drop_bomb ();
player_drop_bomb (bman.p_nr);
key_bomb = 1;
}
else

@ -593,6 +593,8 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr)
bomb->pos.y = b_dat->y;
if (bomb->state != BS_ticking)
bomb->to = b_dat->to;
else
bman.bfield[bomb->pos.x][bomb->pos.y] = 1; // keep the bfield up to date
bomb->r = b_dat->r;
bomb->ex_nr = b_dat->ex_nr;
bomb->state = b_dat->state;
@ -601,6 +603,7 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr)
if (bomb->ex_nr > bman.last_ex_nr)
bman.last_ex_nr = bomb->ex_nr;
};

@ -315,9 +315,9 @@ move_player ()
void
player_drop_bomb ()
player_drop_bomb (int pl_nr)
{
_player *player = &bman.players[bman.p_nr];
_player *player = &bman.players[pl_nr];
_bomb *bomb = NULL;
int i,
_x,
@ -361,7 +361,7 @@ player_drop_bomb ()
bomb->to = BOMB_TIMEOUT * TIME_FACTOR; // 5 Secs * 200
if (bman.gametype != GT_single) {
net_game_send_bomb (bman.p_nr, i);
net_game_send_bomb (pl_nr, i);
if (GT_MP_PTPS)
bomb->to = bomb->to + ((2 * RESENDCACHE_RETRY) / TIME_FACTOR);
}
@ -608,7 +608,7 @@ player_ilness_loop (int pl_nr)
}
else if (type == PI_bomb)
/* player is dropping bombs */
player_drop_bomb ();
player_drop_bomb (bman.p_nr);
}
}
}

Loading…
Cancel
Save