|
|
@ -11,15 +11,16 @@ draw_bomb (_bomb * bomb)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SDL_Rect src,
|
|
|
|
SDL_Rect src,
|
|
|
|
dest;
|
|
|
|
dest;
|
|
|
|
int x=bomb->pos.x >> 8,
|
|
|
|
int x = bomb->pos.x >> 8,
|
|
|
|
y= bomb->pos.y >> 8;
|
|
|
|
y = bomb->pos.y >> 8;
|
|
|
|
|
|
|
|
|
|
|
|
if (x < 0 || y < 0 || x >= bman.fieldsize.x || y >= bman.fieldsize.y) {
|
|
|
|
if (x < 0 || y < 0 || x >= bman.fieldsize.x || y >= bman.fieldsize.y) {
|
|
|
|
d_fatal ("Draw Bomb out of range [%d,%d]\n", x,y);
|
|
|
|
d_fatal ("Draw Bomb out of range [%d,%d]\n", x, y);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (bomb->state != BS_trigger || ((bomb->state == BS_trigger) && (bomb->to<BOMB_TIMEOUT*TIME_FACTOR))) {
|
|
|
|
if (bomb->state != BS_trigger
|
|
|
|
|
|
|
|
|| ((bomb->state == BS_trigger) && (bomb->to < BOMB_TIMEOUT * TIME_FACTOR))) {
|
|
|
|
/* check the framenumber */
|
|
|
|
/* check the framenumber */
|
|
|
|
if (bomb->frameto-- == 0) {
|
|
|
|
if (bomb->frameto-- == 0) {
|
|
|
|
bomb->frameto = ANI_BOMBTIMEOUT;
|
|
|
|
bomb->frameto = ANI_BOMBTIMEOUT;
|
|
|
@ -33,8 +34,8 @@ draw_bomb (_bomb * bomb)
|
|
|
|
dest.w = src.w = gfx.bomb.image->w;
|
|
|
|
dest.w = src.w = gfx.bomb.image->w;
|
|
|
|
dest.h = src.h = gfx.block.y;
|
|
|
|
dest.h = src.h = gfx.block.y;
|
|
|
|
|
|
|
|
|
|
|
|
dest.x = gfx.offset.x + (x* gfx.block.x);
|
|
|
|
dest.x = gfx.offset.x + (x * gfx.block.x);
|
|
|
|
dest.y = gfx.offset.y + (y* gfx.block.y);
|
|
|
|
dest.y = gfx.offset.y + (y * gfx.block.y);
|
|
|
|
|
|
|
|
|
|
|
|
src.x = 0;
|
|
|
|
src.x = 0;
|
|
|
|
src.y = src.h * bomb->frame;
|
|
|
|
src.y = src.h * bomb->frame;
|
|
|
@ -62,39 +63,44 @@ bomb_explode (int p, int b, int net)
|
|
|
|
bomb->firer[d] = 0;
|
|
|
|
bomb->firer[d] = 0;
|
|
|
|
bomb->firerst[d] = -1;
|
|
|
|
bomb->firerst[d] = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (GT_MP_PTPM && net) /* from now on only the server let the bomb explode */
|
|
|
|
if (GT_MP_PTPM && net) /* from now on only the server let the bomb explode */
|
|
|
|
net_game_send_bomb (p, b);
|
|
|
|
net_game_send_bomb (p, b);
|
|
|
|
|
|
|
|
|
|
|
|
snd_play (SND_explode);
|
|
|
|
snd_play (SND_explode);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
bomb_move (_bomb *bomb)
|
|
|
|
bomb_move (_bomb * bomb)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_point npos;
|
|
|
|
_point npos;
|
|
|
|
if (bomb->pos.x==bomb->moveto.x) {
|
|
|
|
if (bomb->pos.x == bomb->moveto.x) {
|
|
|
|
if (bomb->pos.y==bomb->moveto.y) {
|
|
|
|
if (bomb->pos.y == bomb->moveto.y) {
|
|
|
|
bomb->moves=0;return;}
|
|
|
|
bomb->moves = 0;
|
|
|
|
if (bomb->pos.y>bomb->moveto.y) {
|
|
|
|
return;
|
|
|
|
npos.y=bomb->pos.y-bomb->moves; //move bomb up
|
|
|
|
}
|
|
|
|
npos.x=bomb->pos.x;
|
|
|
|
if (bomb->pos.y > bomb->moveto.y) {
|
|
|
|
} else {
|
|
|
|
npos.y = bomb->pos.y - bomb->moves; //move bomb up
|
|
|
|
npos.y=bomb->pos.y+bomb->moves; // move bomb down
|
|
|
|
npos.x = bomb->pos.x;
|
|
|
|
npos.x=bomb->pos.x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
} else {
|
|
|
|
npos.y = bomb->pos.y + bomb->moves; // move bomb down
|
|
|
|
if (bomb->pos.x>bomb->moveto.x) {
|
|
|
|
npos.x = bomb->pos.x;
|
|
|
|
npos.x=bomb->pos.x-bomb->moves; //move bomb left
|
|
|
|
}
|
|
|
|
npos.y=bomb->pos.y;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else {
|
|
|
|
npos.x=bomb->pos.x+bomb->moves; // move bomb right
|
|
|
|
if (bomb->pos.x > bomb->moveto.x) {
|
|
|
|
npos.y=bomb->pos.y;
|
|
|
|
npos.x = bomb->pos.x - bomb->moves; //move bomb left
|
|
|
|
}
|
|
|
|
npos.y = bomb->pos.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
npos.x = bomb->pos.x + bomb->moves; // move bomb right
|
|
|
|
|
|
|
|
npos.y = bomb->pos.y;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
int
|
|
|
|
bomb_loop ()
|
|
|
|
bomb_loop ()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -109,30 +115,30 @@ bomb_loop ()
|
|
|
|
if ((bman.players[p].state & PSFM_used) != 0) {
|
|
|
|
if ((bman.players[p].state & PSFM_used) != 0) {
|
|
|
|
for (i = 0; i < MAX_BOMBS; i++) {
|
|
|
|
for (i = 0; i < MAX_BOMBS; i++) {
|
|
|
|
bomb = &player->bombs[i];
|
|
|
|
bomb = &player->bombs[i];
|
|
|
|
switch (bomb->state){
|
|
|
|
switch (bomb->state) {
|
|
|
|
case BS_ticking:
|
|
|
|
case BS_ticking:
|
|
|
|
case BS_trigger:
|
|
|
|
case BS_trigger:
|
|
|
|
if (GT_MP_PTPM || bman.gametype == GT_single) {
|
|
|
|
if (GT_MP_PTPM || bman.gametype == GT_single) {
|
|
|
|
if (--bomb->to == 0) // bomb will have to explode in the next loop
|
|
|
|
if (--bomb->to == 0) // bomb will have to explode in the next loop
|
|
|
|
bomb_explode (p, i, 1);
|
|
|
|
bomb_explode (p, i, 1);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
draw_bomb (bomb);
|
|
|
|
draw_bomb (bomb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
if (--bomb->to == 0) { // bomb did not explode -> resend bombdata
|
|
|
|
if (--bomb->to == 0) { // bomb did not explode -> resend bombdata
|
|
|
|
if (bomb->state==BS_ticking)
|
|
|
|
if (bomb->state == BS_ticking)
|
|
|
|
bomb->to = BOMB_TIMEOUT * TIME_FACTOR;
|
|
|
|
bomb->to = BOMB_TIMEOUT * TIME_FACTOR;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
bomb->to = SPECIAL_TRIGGER_TIMEOUT * TIME_FACTOR;
|
|
|
|
bomb->to = SPECIAL_TRIGGER_TIMEOUT * TIME_FACTOR;
|
|
|
|
net_game_send_bomb (bman.p_nr, i);
|
|
|
|
net_game_send_bomb (bman.p_nr, i);
|
|
|
|
bomb->to = bomb->to + ((2 * RESENDCACHE_RETRY) / TIME_FACTOR);
|
|
|
|
bomb->to = bomb->to + ((2 * RESENDCACHE_RETRY) / TIME_FACTOR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
draw_bomb (bomb);
|
|
|
|
draw_bomb (bomb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if (bomb->moves>0) bomb_move(bomb);
|
|
|
|
// if (bomb->moves>0) bomb_move(bomb);
|
|
|
|
b++; // Count ticking Bombs for Return value
|
|
|
|
b++; // Count ticking Bombs for Return value
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case BS_exploding:
|
|
|
|
case BS_exploding:
|
|
|
|
if (bomb->to > 0) {
|
|
|
|
if (bomb->to > 0) {
|
|
|
|
do_explosion (p, i);
|
|
|
|
do_explosion (p, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -143,8 +149,8 @@ bomb_loop ()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bomb->to--;
|
|
|
|
bomb->to--;
|
|
|
|
b++;
|
|
|
|
b++;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -163,8 +169,8 @@ get_bomb_on (int x, int y, _point bombs[])
|
|
|
|
if ((bman.players[p].state & PSFM_used) != 0) {
|
|
|
|
if ((bman.players[p].state & PSFM_used) != 0) {
|
|
|
|
for (b = 0; b < MAX_BOMBS; b++) {
|
|
|
|
for (b = 0; b < MAX_BOMBS; b++) {
|
|
|
|
bomb = &bman.players[p].bombs[b];
|
|
|
|
bomb = &bman.players[p].bombs[b];
|
|
|
|
if (bomb->state == BS_ticking || bomb->state==BS_trigger) {
|
|
|
|
if (bomb->state == BS_ticking || bomb->state == BS_trigger) {
|
|
|
|
if (bomb->pos.x >>8 == x && bomb->pos.y>>8 == y) {
|
|
|
|
if (bomb->pos.x >> 8 == x && bomb->pos.y >> 8 == y) {
|
|
|
|
bombs[i].x = p;
|
|
|
|
bombs[i].x = p;
|
|
|
|
bombs[i].y = b;
|
|
|
|
bombs[i].y = b;
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
@ -209,11 +215,11 @@ restore_explosion (_bomb * bomb)
|
|
|
|
dy = 0;
|
|
|
|
dy = 0;
|
|
|
|
int _x,
|
|
|
|
int _x,
|
|
|
|
_y;
|
|
|
|
_y;
|
|
|
|
_point bpos;
|
|
|
|
_point bpos;
|
|
|
|
|
|
|
|
|
|
|
|
bpos.x = bomb->pos.x >> 8;
|
|
|
|
bpos.x = bomb->pos.x >> 8;
|
|
|
|
bpos.y = bomb->pos.y >> 8;
|
|
|
|
bpos.y = bomb->pos.y >> 8;
|
|
|
|
|
|
|
|
|
|
|
|
for (d = 0; d < 4; d++) {
|
|
|
|
for (d = 0; d < 4; d++) {
|
|
|
|
switch (d) {
|
|
|
|
switch (d) {
|
|
|
|
case (left):
|
|
|
|
case (left):
|
|
|
@ -278,7 +284,7 @@ restore_explosion (_bomb * bomb)
|
|
|
|
gfx.block.x * (bomb->firer[up] + bomb->firer[down] + 1));
|
|
|
|
gfx.block.x * (bomb->firer[up] + bomb->firer[down] + 1));
|
|
|
|
|
|
|
|
|
|
|
|
/* delete field from the bfield map */
|
|
|
|
/* delete field from the bfield map */
|
|
|
|
bman.bfield[bpos.x ][bpos.y] = 0;
|
|
|
|
bman.bfield[bpos.x][bpos.y] = 0;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -326,9 +332,9 @@ explosion_check_field (int x, int y, int p, int b)
|
|
|
|
if (bman.field[x][y].frame == 0) {
|
|
|
|
if (bman.field[x][y].frame == 0) {
|
|
|
|
bman.field[x][y].frameto = ANI_STONETIMEOUT;
|
|
|
|
bman.field[x][y].frameto = ANI_STONETIMEOUT;
|
|
|
|
bman.field[x][y].frame = 1;
|
|
|
|
bman.field[x][y].frame = 1;
|
|
|
|
|
|
|
|
|
|
|
|
draw_stone (x, y);
|
|
|
|
draw_stone (x, y);
|
|
|
|
field_update(x, y);
|
|
|
|
field_update (x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return bman.field[x][y].type;
|
|
|
|
return bman.field[x][y].type;
|
|
|
@ -343,11 +349,12 @@ draw_explosion (_bomb * bomb)
|
|
|
|
r,
|
|
|
|
r,
|
|
|
|
dx,
|
|
|
|
dx,
|
|
|
|
dy;
|
|
|
|
dy;
|
|
|
|
_point p, bpos;
|
|
|
|
_point p,
|
|
|
|
|
|
|
|
bpos;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bpos.x = bomb->pos.x >> 8;
|
|
|
|
|
|
|
|
bpos.y = bomb->pos.y >> 8;
|
|
|
|
|
|
|
|
|
|
|
|
bpos.x = bomb->pos.x >> 8;
|
|
|
|
|
|
|
|
bpos.y = bomb->pos.y >> 8;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bomb->frameto--;
|
|
|
|
bomb->frameto--;
|
|
|
|
if (bomb->frameto < 0 || bomb->frameto > ANI_FIRETIMEOUT)
|
|
|
|
if (bomb->frameto < 0 || bomb->frameto > ANI_FIRETIMEOUT)
|
|
|
|
bomb->frameto = ANI_FIRETIMEOUT;
|
|
|
|
bomb->frameto = ANI_FIRETIMEOUT;
|
|
|
@ -395,11 +402,11 @@ do_explosion (int p, int b)
|
|
|
|
int dx = 0,
|
|
|
|
int dx = 0,
|
|
|
|
dy = 0,
|
|
|
|
dy = 0,
|
|
|
|
d;
|
|
|
|
d;
|
|
|
|
_point bpos;
|
|
|
|
_point bpos;
|
|
|
|
|
|
|
|
|
|
|
|
bpos.x = bomb->pos.x >> 8;
|
|
|
|
bpos.x = bomb->pos.x >> 8;
|
|
|
|
bpos.y = bomb->pos.y >> 8;
|
|
|
|
bpos.y = bomb->pos.y >> 8;
|
|
|
|
|
|
|
|
|
|
|
|
for (d = 0; d < 4; d++) {
|
|
|
|
for (d = 0; d < 4; d++) {
|
|
|
|
switch (d) {
|
|
|
|
switch (d) {
|
|
|
|
case (left):
|
|
|
|
case (left):
|
|
|
@ -434,7 +441,7 @@ do_explosion (int p, int b)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
bomb->firerst[d] = bomb->firer[d];
|
|
|
|
bomb->firerst[d] = bomb->firer[d];
|
|
|
|
draw_stone (bpos.x + dx, bpos.y + dy);
|
|
|
|
draw_stone (bpos.x + dx, bpos.y + dy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|