|
|
@ -15,7 +15,7 @@ draw_player (_player * player)
|
|
|
|
if ((player->pos.x >> 8) < 0 || (player->pos.x >> 8) >= map.size.x ||
|
|
|
|
if ((player->pos.x >> 8) < 0 || (player->pos.x >> 8) >= map.size.x ||
|
|
|
|
(player->pos.y >> 8) < 0 || (player->pos.y >> 8) >= map.size.y) {
|
|
|
|
(player->pos.y >> 8) < 0 || (player->pos.y >> 8) >= map.size.y) {
|
|
|
|
d_printf ("FATAL: Draw Player out of range : [%d,%d]\n", (player->pos.x >> 8),
|
|
|
|
d_printf ("FATAL: Draw Player out of range : [%d,%d]\n", (player->pos.x >> 8),
|
|
|
|
(player->pos.y >> 8));
|
|
|
|
(player->pos.y >> 8));
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -89,10 +89,9 @@ restore_players_screen ()
|
|
|
|
if ((PS_IS_used (bman.players[i].state)) && bman.players[i].old.x != -1) {
|
|
|
|
if ((PS_IS_used (bman.players[i].state)) && bman.players[i].old.x != -1) {
|
|
|
|
|
|
|
|
|
|
|
|
if ((bman.players[i].old.x >> 8) < 0 || (bman.players[i].old.x >> 8) >= map.size.x
|
|
|
|
if ((bman.players[i].old.x >> 8) < 0 || (bman.players[i].old.x >> 8) >= map.size.x
|
|
|
|
|| (bman.players[i].old.y >> 8) < 0
|
|
|
|
|| (bman.players[i].old.y >> 8) < 0 || (bman.players[i].old.y >> 8) >= map.size.y)
|
|
|
|
|| (bman.players[i].old.y >> 8) >= map.size.y)
|
|
|
|
|
|
|
|
d_printf ("FATAL: Restore Player out of range : playernr %d [%d,%d]\n", i,
|
|
|
|
d_printf ("FATAL: Restore Player out of range : playernr %d [%d,%d]\n", i,
|
|
|
|
(bman.players[i].old.x >> 8), (bman.players[i].old.y >> 8));
|
|
|
|
(bman.players[i].old.x >> 8), (bman.players[i].old.y >> 8));
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
if ((bman.players[i].old.x & 0xFF) > 128) {
|
|
|
|
if ((bman.players[i].old.x & 0xFF) > 128) {
|
|
|
|
x = (bman.players[i].old.x >> 8);
|
|
|
|
x = (bman.players[i].old.x >> 8);
|
|
|
@ -229,12 +228,18 @@ check_field (short int x, short int y)
|
|
|
|
int
|
|
|
|
int
|
|
|
|
stepmove_player (int pl_nr)
|
|
|
|
stepmove_player (int pl_nr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_point bomb1[MAX_PLAYERS * MAX_BOMBS], bomb2[MAX_PLAYERS * MAX_BOMBS];
|
|
|
|
_point bomb1[MAX_PLAYERS * MAX_BOMBS],
|
|
|
|
|
|
|
|
bomb2[MAX_PLAYERS * MAX_BOMBS];
|
|
|
|
_player *p = &bman.players[pl_nr];
|
|
|
|
_player *p = &bman.players[pl_nr];
|
|
|
|
int speed = 0, i, j, f;
|
|
|
|
int speed = 0,
|
|
|
|
_point fpos, // field position
|
|
|
|
i,
|
|
|
|
_pos, // position inside the field
|
|
|
|
j,
|
|
|
|
d;
|
|
|
|
f;
|
|
|
|
|
|
|
|
_point fpos, // field position
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_pos, // position inside the field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
d;
|
|
|
|
|
|
|
|
|
|
|
|
if (p->m == 1) {
|
|
|
|
if (p->m == 1) {
|
|
|
|
|
|
|
|
|
|
|
@ -268,51 +273,76 @@ stepmove_player (int pl_nr)
|
|
|
|
speed = p->speed;
|
|
|
|
speed = p->speed;
|
|
|
|
|
|
|
|
|
|
|
|
// check the new field position
|
|
|
|
// check the new field position
|
|
|
|
d.x = d.y = 0;
|
|
|
|
d.x = d.y = 0;
|
|
|
|
if (p->d == left && _pos.y == 0 && ((_pos.x == 0 && check_field (fpos.x - 1, fpos.y)) || (_pos.x > 0)))
|
|
|
|
if (p->d == left && _pos.y == 0
|
|
|
|
d.x = -speed;
|
|
|
|
&& ((_pos.x == 0 && check_field (fpos.x - 1, fpos.y)) || (_pos.x > 0)))
|
|
|
|
if (p->d == right && _pos.y == 0 && ((_pos.x == 0 && check_field (fpos.x + 1, fpos.y)) || (_pos.x > 0)))
|
|
|
|
d.x = -speed;
|
|
|
|
d.x = speed;
|
|
|
|
if (p->d == right && _pos.y == 0
|
|
|
|
if (p->d == up && _pos.x == 0 && ((_pos.y == 0 && check_field (fpos.x, fpos.y - 1)) || (_pos.y > 0)))
|
|
|
|
&& ((_pos.x == 0 && check_field (fpos.x + 1, fpos.y)) || (_pos.x > 0)))
|
|
|
|
d.y = -speed;
|
|
|
|
d.x = speed;
|
|
|
|
if (p->d == down && _pos.x == 0 && ((_pos.y == 0 && check_field (fpos.x, fpos.y + 1)) || (_pos.y > 0)))
|
|
|
|
if (p->d == up && _pos.x == 0
|
|
|
|
d.y = speed;
|
|
|
|
&& ((_pos.y == 0 && check_field (fpos.x, fpos.y - 1)) || (_pos.y > 0)))
|
|
|
|
|
|
|
|
d.y = -speed;
|
|
|
|
// check if we can move and if there is any bomb
|
|
|
|
if (p->d == down && _pos.x == 0
|
|
|
|
if (d.y != 0 || d.x != 0) {
|
|
|
|
&& ((_pos.y == 0 && check_field (fpos.x, fpos.y + 1)) || (_pos.y > 0)))
|
|
|
|
get_bomb_on (p->pos.x, p->pos.y, bomb1);
|
|
|
|
d.y = speed;
|
|
|
|
get_bomb_on (p->pos.x + d.x, p->pos.y + d.y, bomb2);
|
|
|
|
|
|
|
|
|
|
|
|
// check if we can move and if there is any bomb
|
|
|
|
if (bomb1[0].x == -1 && bomb2[0].x != -1)
|
|
|
|
if (d.y != 0 || d.x != 0) {
|
|
|
|
/* old pos no bomb, new pos no bomb */
|
|
|
|
get_bomb_on (p->pos.x, p->pos.y, bomb1);
|
|
|
|
d.x = d.y = 0;
|
|
|
|
get_bomb_on (p->pos.x + d.x, p->pos.y + d.y, bomb2);
|
|
|
|
else if (bomb2[0].x != -1) {
|
|
|
|
|
|
|
|
/* new pos bomb, old pos bomb... check if it's the same
|
|
|
|
if (bomb1[0].x == -1 && bomb2[0].x != -1)
|
|
|
|
use f to save if we found the bomb or not
|
|
|
|
/* old pos no bomb, new pos no bomb */
|
|
|
|
f == 0 no bomb found, f == 1 bomb found */
|
|
|
|
d.x = d.y = 0;
|
|
|
|
for (i = 0, f = 1; (bomb2[i].x != -1 && f == 1); i++)
|
|
|
|
else if (bomb2[0].x != -1) {
|
|
|
|
for (f = 0, j = 0; (bomb1[j].x != -1 && f == 0); j++)
|
|
|
|
/* new pos bomb, old pos bomb... check if it's the same
|
|
|
|
if (bomb1[j].x == bomb2[i].x && bomb1[j].y == bomb2[i].y)
|
|
|
|
use f to save if we found the bomb or not
|
|
|
|
/* identical bomb found ... f = 1 */
|
|
|
|
f == 0 no bomb found, f == 1 bomb found */
|
|
|
|
f = 1;
|
|
|
|
for (i = 0, f = 1; (bomb2[i].x != -1 && f == 1); i++)
|
|
|
|
if (f == 0)
|
|
|
|
for (f = 0, j = 0; (bomb1[j].x != -1 && f == 0); j++)
|
|
|
|
d.x = d.y = 0;
|
|
|
|
if (bomb1[j].x == bomb2[i].x && bomb1[j].y == bomb2[i].y)
|
|
|
|
}
|
|
|
|
/* identical bomb found ... f = 1 */
|
|
|
|
}
|
|
|
|
f = 1;
|
|
|
|
|
|
|
|
if (f == 0)
|
|
|
|
p->pos.x += d.x;
|
|
|
|
d.x = d.y = 0;
|
|
|
|
p->pos.y += d.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
player_check_powerup (pl_nr);
|
|
|
|
|
|
|
|
}
|
|
|
|
p->pos.x += d.x;
|
|
|
|
|
|
|
|
p->pos.y += d.y;
|
|
|
|
if (d.x == 0 && d.y == 0)
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
player_check_powerup (pl_nr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (d.x == 0 && d.y == 0)
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
return (p->speed - speed);
|
|
|
|
return (p->speed - speed);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* check if the givin position is oky
|
|
|
|
|
|
|
|
1 = ok, 0 = bad */
|
|
|
|
|
|
|
|
int
|
|
|
|
|
|
|
|
player_checkpos (int x, int y)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i,
|
|
|
|
|
|
|
|
d;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0, d = 0; d < 4; d++)
|
|
|
|
|
|
|
|
if (map.field[x][y].ex[d].count > 0)
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (map.field[x][y].type == FT_block || i > 0)
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* move the player if he have to move AND check if we are on a block
|
|
|
|
|
|
|
|
or over fire */
|
|
|
|
void
|
|
|
|
void
|
|
|
|
move_player (int pl_nr)
|
|
|
|
move_player (int pl_nr)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -344,6 +374,21 @@ move_player (int pl_nr)
|
|
|
|
net_game_send_playermove (pl_nr, 1);
|
|
|
|
net_game_send_playermove (pl_nr, 1);
|
|
|
|
p->old_m = p->m; // save the old state
|
|
|
|
p->old_m = p->m; // save the old state
|
|
|
|
p->m = 0;
|
|
|
|
p->m = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* check the players position */
|
|
|
|
|
|
|
|
if ((p->pos.x & 0xFF) > EXPLOSION_SAVE_DISTANCE && (p->d == left || p->d == right))
|
|
|
|
|
|
|
|
if (!check_field ((p->pos.x >> 8) + 1, (p->pos.y >> 8)))
|
|
|
|
|
|
|
|
player_died (p, -1);
|
|
|
|
|
|
|
|
if ((p->pos.y & 0xFF) > EXPLOSION_SAVE_DISTANCE && (p->d == up || p->d == down))
|
|
|
|
|
|
|
|
if (!check_field ((p->pos.x >> 8), (p->pos.y >> 8) + 1))
|
|
|
|
|
|
|
|
player_died (p, -1);
|
|
|
|
|
|
|
|
if (((p->pos.x & 0xFF) < (0x100 - EXPLOSION_SAVE_DISTANCE)
|
|
|
|
|
|
|
|
&& (p->d == left || p->d == right))
|
|
|
|
|
|
|
|
|| ((p->pos.y & 0xFF) < (0x100 - EXPLOSION_SAVE_DISTANCE)
|
|
|
|
|
|
|
|
&& (p->d == up || p->d == down)))
|
|
|
|
|
|
|
|
if (!check_field (p->pos.x >> 8, p->pos.y >> 8))
|
|
|
|
|
|
|
|
player_died (p, -1);
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -358,7 +403,7 @@ player_drop_bomb (int pl_nr)
|
|
|
|
_y;
|
|
|
|
_y;
|
|
|
|
_point bombs[MAX_PLAYERS * MAX_BOMBS];
|
|
|
|
_point bombs[MAX_PLAYERS * MAX_BOMBS];
|
|
|
|
|
|
|
|
|
|
|
|
i = player_findfreebomb (player);
|
|
|
|
i = player_findfreebomb (player);
|
|
|
|
|
|
|
|
|
|
|
|
if (i >= 0 && i < MAX_BOMBS && 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.
|
|
|
@ -757,32 +802,37 @@ player_set_gfx (_player * p, signed char gfx_nr)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* find a free bomb */
|
|
|
|
/* find a free bomb */
|
|
|
|
int player_findfreebomb (_player *player) {
|
|
|
|
int
|
|
|
|
int i, bombused = 0, res = -1, nr;
|
|
|
|
player_findfreebomb (_player * player)
|
|
|
|
|
|
|
|
{
|
|
|
|
/* check every free bomb from next entry of the last
|
|
|
|
int i,
|
|
|
|
exploded bomb to the last exploded bomb */
|
|
|
|
bombused = 0,
|
|
|
|
if (player->bomb_lastex < 0 || player->bomb_lastex >= MAX_BOMBS)
|
|
|
|
res = -1,
|
|
|
|
player->bomb_lastex = 0;
|
|
|
|
nr;
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_BOMBS; i++) {
|
|
|
|
/* check every free bomb from next entry of the last
|
|
|
|
nr = player->bomb_lastex + 1 + i;
|
|
|
|
exploded bomb to the last exploded bomb */
|
|
|
|
if (nr < 0 || nr >= MAX_BOMBS) // i out of range .. restart at bomb 0
|
|
|
|
if (player->bomb_lastex < 0 || player->bomb_lastex >= MAX_BOMBS)
|
|
|
|
nr -= MAX_BOMBS;
|
|
|
|
player->bomb_lastex = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (player->bombs[i].state == BS_off) { /* check if this bomb is free */
|
|
|
|
for (i = 0; i < MAX_BOMBS; i++) {
|
|
|
|
if (res == -1)
|
|
|
|
nr = player->bomb_lastex + 1 + i;
|
|
|
|
res = i;
|
|
|
|
if (nr < 0 || nr >= MAX_BOMBS) // i out of range .. restart at bomb 0
|
|
|
|
}
|
|
|
|
nr -= MAX_BOMBS;
|
|
|
|
else
|
|
|
|
|
|
|
|
bombused++; // count number of used bombs
|
|
|
|
if (player->bombs[i].state == BS_off) { /* check if this bomb is free */
|
|
|
|
}
|
|
|
|
if (res == -1)
|
|
|
|
|
|
|
|
res = i;
|
|
|
|
if (res == -1 && i == player->bomb_lastex && player->bombs[i].state == BS_off)
|
|
|
|
}
|
|
|
|
res = i;
|
|
|
|
else
|
|
|
|
|
|
|
|
bombused++; // count number of used bombs
|
|
|
|
if (bombused >= player->bombs_n)
|
|
|
|
}
|
|
|
|
res = -1; /* all max number of bombs lay */
|
|
|
|
|
|
|
|
|
|
|
|
if (res == -1 && i == player->bomb_lastex && player->bombs[i].state == BS_off)
|
|
|
|
return res;
|
|
|
|
res = i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bombused >= player->bombs_n)
|
|
|
|
|
|
|
|
res = -1; /* all max number of bombs lay */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
};
|
|
|
|
};
|
|
|
|