|
|
@ -1,4 +1,4 @@
|
|
|
|
/* $Id: player.c,v 1.105 2007/03/14 17:49:11 stpohle Exp $
|
|
|
|
/* $Id: player.c,v 1.106 2007/12/09 22:37:38 stpohle Exp $
|
|
|
|
* player.c - everything what have to do with the player */
|
|
|
|
* player.c - everything what have to do with the player */
|
|
|
|
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
#include <SDL.h>
|
|
|
@ -859,7 +859,7 @@ int
|
|
|
|
player_findfreebomb (_player * player)
|
|
|
|
player_findfreebomb (_player * player)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int i,
|
|
|
|
int i,
|
|
|
|
bombused = 0,
|
|
|
|
bombused = 0,
|
|
|
|
res = -1,
|
|
|
|
res = -1,
|
|
|
|
nr;
|
|
|
|
nr;
|
|
|
|
|
|
|
|
|
|
|
@ -868,22 +868,19 @@ player_findfreebomb (_player * player)
|
|
|
|
if (player->bomb_lastex < 0 || player->bomb_lastex >= MAX_BOMBS)
|
|
|
|
if (player->bomb_lastex < 0 || player->bomb_lastex >= MAX_BOMBS)
|
|
|
|
player->bomb_lastex = 0;
|
|
|
|
player->bomb_lastex = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_BOMBS; i++) {
|
|
|
|
for (i = 0, nr = player->bomb_lastex, bombused = 0; i < MAX_BOMBS; i++) {
|
|
|
|
nr = player->bomb_lastex + 1 + i;
|
|
|
|
nr++;
|
|
|
|
if (nr < 0 || nr >= MAX_BOMBS) // i out of range .. restart at bomb 0
|
|
|
|
if (nr >= MAX_BOMBS) // start at 0
|
|
|
|
nr -= MAX_BOMBS;
|
|
|
|
nr = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (player->bombs[nr].state == BS_off) { /* check if this bomb is free */
|
|
|
|
if (player->bombs[nr].state == BS_off) { /* check if this bomb is free */
|
|
|
|
if (res == -1)
|
|
|
|
if (res == -1)
|
|
|
|
res = i;
|
|
|
|
res = nr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
bombused++; // count number of used bombs
|
|
|
|
bombused++; // count number of used bombs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (res == -1 && nr == player->bomb_lastex && player->bombs[nr].state == BS_off)
|
|
|
|
|
|
|
|
res = nr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bombused >= player->bombs_n)
|
|
|
|
if (bombused >= player->bombs_n)
|
|
|
|
res = -1; /* all max number of bombs lay */
|
|
|
|
res = -1; /* all max number of bombs lay */
|
|
|
|
|
|
|
|
|
|
|
|