single player needed to be fixed for the tunnel thing.. network is still not tested... but i am working on it

origin
stpohle 22 years ago
parent 494a2137bb
commit 0a2af7c18c

@ -1,4 +1,4 @@
/* $Id: map.c,v 1.7 2003/08/10 15:10:19 stpohle Exp $ */ /* $Id: map.c,v 1.8 2003/08/10 19:31:14 stpohle Exp $ */
/* map handling, like generate and load maps. */ /* map handling, like generate and load maps. */
#include "bomberclone.h" #include "bomberclone.h"
@ -55,8 +55,6 @@ map_new (char *filename)
if (fmap == NULL) if (fmap == NULL)
map_genrandom (); map_genrandom ();
map.type = 1;
if (map.type == -1) if (map.type == -1)
map.type = s_random (MAPT_max); map.type = s_random (MAPT_max);
@ -255,19 +253,28 @@ map_set_playerposition (int usermap)
PLX = 2 * (s_random ((map.size.x - 1) / 2)) + 1; PLX = 2 * (s_random ((map.size.x - 1) / 2)) + 1;
PLY = 2 * (s_random ((map.size.y - 1) / 2)) + 1; PLY = 2 * (s_random ((map.size.y - 1) / 2)) + 1;
map.field[PLX][PLY].type = FT_nothing; if (map.field[PLX][PLY].type != FT_tunnel)
map.field[PLX][PLY].type = FT_nothing;
dx = s_random (4); // bit 1 = up/down bit 2 = left/right dx = s_random (4); // bit 1 = up/down bit 2 = left/right
/* up and down */ /* up and down */
if (((dx & 1) == 0 && PLX > 1) || PLX >= map.size.x - 2) if (((dx & 1) == 0 && PLX > 1) || PLX >= map.size.x - 2) {
map.field[PLX - 1][PLY].type = FT_nothing; if (map.field[PLX - 1][PLY].type != FT_tunnel)
else map.field[PLX - 1][PLY].type = FT_nothing;
map.field[PLX + 1][PLY].type = FT_nothing; }
else {
if (map.field[PLX + 1][PLY].type != FT_tunnel)
map.field[PLX + 1][PLY].type = FT_nothing;
}
/* left and right */ /* left and right */
if (((dx & 2) == 0 && PLY > 1) || PLY >= map.size.y - 2) if (((dx & 2) == 0 && PLY > 1) || PLY >= map.size.y - 2) {
map.field[PLX][PLY - 1].type = FT_nothing; if (map.field[PLX][PLY - 1].type != FT_tunnel)
else map.field[PLX][PLY - 1].type = FT_nothing;
map.field[PLX][PLY + 1].type = FT_nothing; }
else {
if (map.field[PLX][PLY + 1].type != FT_tunnel)
map.field[PLX][PLY + 1].type = FT_nothing;
}
} }
mx = my = 100; mx = my = 100;
for (j = 0; j <= i; j++) { /* search smalest distance */ for (j = 0; j <= i; j++) { /* search smalest distance */

@ -319,11 +319,25 @@ stepmove_player (int pl_nr)
_pos.x = p->pos.x & 255; _pos.x = p->pos.x & 255;
_pos.y = p->pos.y & 255; _pos.y = p->pos.y & 255;
if (_pos.x == 0 && _pos.y == 0 && map.field[fpos.x][fpos.y].type == FT_tunnel && p->tunnelto == -1) { if (_pos.x == 0 && _pos.y == 0 && map.field[fpos.x][fpos.y].type == FT_tunnel
&& p->tunnelto == -1) {
d_printf ("Tunnel [%d] Player %s is going to (%d,%d)\n",
map.field[fpos.x][fpos.y].special, p->name,
map.tunnel[map.field[fpos.x][fpos.y].special].x,
map.tunnel[map.field[fpos.x][fpos.y].special].y);
d.x = d.y = 0; d.x = d.y = 0;
p->pos.x = map.tunnel[map.field[fpos.x][fpos.y].special].x << 8; if (map.
p->pos.y = map.tunnel[map.field[fpos.x][fpos.y].special].y << 8; bfield[map.tunnel[map.field[fpos.x][fpos.y].special].x][map.
p->tunnelto = GAME_TUNNEL_TO; tunnel[map.
field[fpos.x][fpos.
y].
special].y])
d_printf (" *** End of tunnel is with an bomb.\n");
else {
p->pos.x = map.tunnel[map.field[fpos.x][fpos.y].special].x << 8;
p->pos.y = map.tunnel[map.field[fpos.x][fpos.y].special].y << 8;
p->tunnelto = GAME_TUNNEL_TO;
}
} }
} }
@ -383,9 +397,9 @@ move_player (int pl_nr)
/* network packet send control - send data if it's time to send or if we need to */ /* network packet send control - send data if it's time to send or if we need to */
if (bman.gametype != GT_single) if (bman.gametype != GT_single)
net_game_send_playermove (pl_nr, (p->old_m == 0)); net_game_send_playermove (pl_nr, (p->old_m == 0));
if (p->tunnelto==0) if (p->tunnelto == 0)
p->tunnelto = -1; p->tunnelto = -1;
} }
/* the player just stopt moving so send data */ /* the player just stopt moving so send data */
if (bman.gametype != GT_single && p->m == 0 && p->old_m != 0) if (bman.gametype != GT_single && p->m == 0 && p->old_m != 0)
@ -393,21 +407,21 @@ move_player (int pl_nr)
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))
/* check the players position */ if (!check_field ((p->pos.x >> 8) + 1, (p->pos.y >> 8)))
if ((p->pos.x & 0xFF) > EXPLOSION_SAVE_DISTANCE && (p->d == left || p->d == right)) player_died (p, -1);
if (!check_field ((p->pos.x >> 8) + 1, (p->pos.y >> 8))) if ((p->pos.y & 0xFF) > EXPLOSION_SAVE_DISTANCE && (p->d == up || p->d == down))
player_died (p, -1); if (!check_field ((p->pos.x >> 8), (p->pos.y >> 8) + 1))
if ((p->pos.y & 0xFF) > EXPLOSION_SAVE_DISTANCE && (p->d == up || p->d == down)) player_died (p, -1);
if (!check_field ((p->pos.x >> 8), (p->pos.y >> 8) + 1)) if (((p->pos.x & 0xFF) < (0x100 - EXPLOSION_SAVE_DISTANCE)
player_died (p, -1); && (p->d == left || p->d == right))
if (((p->pos.x & 0xFF) < (0x100 - EXPLOSION_SAVE_DISTANCE) || ((p->pos.y & 0xFF) < (0x100 - EXPLOSION_SAVE_DISTANCE)
&& (p->d == left || p->d == right)) && (p->d == up || p->d == down)))
|| ((p->pos.y & 0xFF) < (0x100 - EXPLOSION_SAVE_DISTANCE) if (!check_field (p->pos.x >> 8, p->pos.y >> 8))
&& (p->d == up || p->d == down))) player_died (p, -1);
if (!check_field (p->pos.x >> 8, p->pos.y >> 8))
player_died (p, -1); }
}; };
@ -485,7 +499,7 @@ get_player_on (short int x, short int y, int pl_nr[])
p; p;
for (i = 0, p = 0; p < MAX_PLAYERS; p++) for (i = 0, p = 0; p < MAX_PLAYERS; p++)
if (PS_IS_alife (bman.players[p].state)) { if (PS_IS_alife (bman.players[p].state) && bman.players[p].tunnelto <= 0) {
if (bman.players[p].pos.x - EXPLOSION_SAVE_DISTANCE > x - 256 if (bman.players[p].pos.x - EXPLOSION_SAVE_DISTANCE > x - 256
&& bman.players[p].pos.x + EXPLOSION_SAVE_DISTANCE < x + 256 && bman.players[p].pos.x + EXPLOSION_SAVE_DISTANCE < x + 256
&& bman.players[p].pos.y - EXPLOSION_SAVE_DISTANCE > y - 256 && bman.players[p].pos.y - EXPLOSION_SAVE_DISTANCE > y - 256

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.42 2003/07/27 20:16:58 stpohle Exp $ */ /* $Id: single.c,v 1.43 2003/08/10 19:31:15 stpohle Exp $ */
/* single player */ /* single player */
#include "basic.h" #include "basic.h"
@ -20,6 +20,7 @@ single_game_new ()
if (PS_IS_used (bman.players[p].state)) { if (PS_IS_used (bman.players[p].state)) {
bman.players_nr_s++; bman.players_nr_s++;
bman.players_nr++; bman.players_nr++;
bman.players[p].tunnelto = 0;
bman.players[p].state = PSF_used + PSF_alife + PSF_playing; bman.players[p].state = PSF_used + PSF_alife + PSF_playing;
} }
else else
@ -62,7 +63,7 @@ ai_checkfield (int x, int y)
{ {
return ((map.field[x][y].type == FT_nothing || map.field[x][y].type == FT_fire return ((map.field[x][y].type == FT_nothing || map.field[x][y].type == FT_fire
|| map.field[x][y].type == FT_shoe || map.field[x][y].type == FT_bomb || map.field[x][y].type == FT_shoe || map.field[x][y].type == FT_bomb
|| map.field[x][y].type == FT_mixed) || map.field[x][y].type == FT_mixed || map.field[x][y].type == FT_tunnel)
&& map.bfield[x][y] == 0); && map.bfield[x][y] == 0);
} }
@ -287,12 +288,12 @@ ai_bombpoints (_point pos, int range)
p = pos; p = pos;
for (r = 0; (r < range && map.field[p.x][p.y].type == FT_nothing); r++) { for (r = 0; (r < range && (map.field[p.x][p.y].type == FT_nothing || map.field[p.x][p.y].type == FT_tunnel)); r++) {
p.x += m.x; p.x += m.x;
p.y += m.y; p.y += m.y;
} }
if (map.field[p.x][p.y].type != FT_nothing if (map.field[p.x][p.y].type != FT_nothing && map.field[p.x][p.y].type != FT_tunnel
&& (map.field[p.x][p.y].type != FT_block || map.field[p.x][p.y].type == FT_shoe && (map.field[p.x][p.y].type != FT_block || map.field[p.x][p.y].type == FT_shoe
|| map.field[p.x][p.y].type == FT_bomb || map.field[p.x][p.y].type == FT_fire)) || map.field[p.x][p.y].type == FT_bomb || map.field[p.x][p.y].type == FT_fire))
points++; points++;
@ -691,6 +692,9 @@ single_loop ()
pl->m = 1; pl->m = 1;
} }
} }
if (pl->m == 0 && map.field[pl->pos.x >> 8][pl->pos.y >> 8].type == FT_tunnel)
pl->m = 1;
} }
player_ilness_loop (p); player_ilness_loop (p);
move_player (p); move_player (p);

Loading…
Cancel
Save