Last Exploded bomb won't used right away if there is another free bomb. (it should fix the NO BOMB but explosion bug in multiplayergames

origin
stpohle 23 years ago
parent cd97b0f87c
commit 89d2f4261b

@ -64,6 +64,8 @@ bomb_explode (int p, int b, int net)
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
bman.players[p].bomb_lastex = 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;
for (d = 0; d < 4; d++) { for (d = 0; d < 4; d++) {

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.39 2003/06/09 22:56:40 stpohle Exp $ */ /* $Id: bomberclone.h,v 1.40 2003/06/22 02:03:09 stpohle Exp $ */
/* bomberclone.h */ /* bomberclone.h */
#ifndef _BOMBERCLONE_H_ #ifndef _BOMBERCLONE_H_
@ -91,6 +91,7 @@ struct __player {
signed char old_m; // to save the old state.. signed char old_m; // to save the old state..
int bombs_n; // maximal number of bombs for the player int bombs_n; // maximal number of bombs for the player
int bomb_lastex; // number of the bomb which explode the last time
_bomb bombs[MAX_BOMBS]; // number of bombs who are ticking. _bomb bombs[MAX_BOMBS]; // number of bombs who are ticking.
int range; // range of the bombs int range; // range of the bombs
int speed; // how fast we can go (0 = slow, 1 = normal... 3 = fastest) int speed; // how fast we can go (0 = slow, 1 = normal... 3 = fastest)
@ -226,6 +227,7 @@ extern void player_clear_ilness (_player *p, int type);
extern void player_ilness_loop (int pl_nr); extern void player_ilness_loop (int pl_nr);
extern void player_check_powerup (int p_nr); extern void player_check_powerup (int p_nr);
extern void player_set_gfx (_player *p, signed char gfx_nr); extern void player_set_gfx (_player *p, signed char gfx_nr);
extern int player_findfreebomb (_player *player);
// for the bomb.. // for the bomb..
extern int bomb_loop (); extern int bomb_loop ();

@ -360,9 +360,9 @@ player_drop_bomb (int pl_nr)
_y; _y;
_point bombs[MAX_PLAYERS * MAX_BOMBS]; _point bombs[MAX_PLAYERS * MAX_BOMBS];
for (i = 0; ((i < player->bombs_n) && (player->bombs[i].state != BS_off)); i++); i = player_findfreebomb (player);
if (i < player->bombs_n && PS_IS_alife (player->state)) { // free bomb found if (i >= 0 && i < MAX_BOMBS && PS_IS_alife (player->state)) { // free bomb found
// get the best position for the bomb. // get the best position for the bomb.
bomb = &player->bombs[i]; bomb = &player->bombs[i];
bomb->pos.x = player->pos.x >> 8; bomb->pos.x = player->pos.x >> 8;
@ -753,3 +753,23 @@ player_set_gfx (_player * p, signed char gfx_nr)
p->state |= PSF_playing; p->state |= PSF_playing;
} }
}; };
/* find a free bomb */
int player_findfreebomb (_player *player) {
int i, bombused = 0, res = -1;
/* check every free bomb from next entry of the last
exploded bomb to the last exploded bomb */
for (i = player->bomb_lastex + 1; (bombused < player->bombs_n && i != player->bomb_lastex && res == -1); i++) {
if (i < 0 || i > MAX_BOMBS) // i out of range .. restart at bomb 0
i = 0;
if (player->bombs[i].state == BS_off)
res = i;
else
bombused++; // count number of used bombs
}
return res;
};

Loading…
Cancel
Save