|
|
@ -759,16 +759,22 @@ player_set_gfx (_player * p, signed char gfx_nr)
|
|
|
|
|
|
|
|
|
|
|
|
/* find a free bomb */
|
|
|
|
/* find a free bomb */
|
|
|
|
int player_findfreebomb (_player *player) {
|
|
|
|
int player_findfreebomb (_player *player) {
|
|
|
|
int i, bombused = 0, res = -1;
|
|
|
|
int i, bombused = 0, res = -1, nr;
|
|
|
|
|
|
|
|
|
|
|
|
/* check every free bomb from next entry of the last
|
|
|
|
/* check every free bomb from next entry of the last
|
|
|
|
exploded bomb to the last exploded bomb */
|
|
|
|
exploded bomb to the last exploded bomb */
|
|
|
|
|
|
|
|
if (player->bomb_lastex < 0 || player->bomb_lastex >= MAX_BOMBS)
|
|
|
|
|
|
|
|
player->bomb_lastex = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for (i = player->bomb_lastex + 1; (bombused < player->bombs_n && i != player->bomb_lastex && res == -1); i++) {
|
|
|
|
for (i = 0; i < MAX_BOMBS; i++) {
|
|
|
|
if (i < 0 || i >= MAX_BOMBS) // i out of range .. restart at bomb 0
|
|
|
|
nr = player->bomb_lastex + 1 + i;
|
|
|
|
i = 0;
|
|
|
|
if (nr < 0 || nr >= MAX_BOMBS) // i out of range .. restart at bomb 0
|
|
|
|
if (player->bombs[i].state == BS_off)
|
|
|
|
nr -= MAX_BOMBS;
|
|
|
|
res = i;
|
|
|
|
|
|
|
|
|
|
|
|
if (player->bombs[i].state == BS_off) { /* check if this bomb is free */
|
|
|
|
|
|
|
|
if (res == -1)
|
|
|
|
|
|
|
|
res = i;
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
bombused++; // count number of used bombs
|
|
|
|
bombused++; // count number of used bombs
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -776,5 +782,8 @@ int player_findfreebomb (_player *player) {
|
|
|
|
if (res == -1 && i == player->bomb_lastex && player->bombs[i].state == BS_off)
|
|
|
|
if (res == -1 && i == player->bomb_lastex && player->bombs[i].state == BS_off)
|
|
|
|
res = i;
|
|
|
|
res = i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bombused >= player->bombs_n)
|
|
|
|
|
|
|
|
res = -1; /* all max number of bombs lay */
|
|
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
};
|
|
|
|
};
|
|
|
|