|
|
@ -1,4 +1,4 @@
|
|
|
|
/* $Id: network.c,v 1.73 2005/04/09 18:22:41 stpohle Exp $ */
|
|
|
|
/* $Id: network.c,v 1.74 2005/04/10 00:22:17 stpohle Exp $ */
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
network routines.
|
|
|
|
network routines.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -61,7 +61,7 @@ net_dyn_pkgoption ()
|
|
|
|
_net_pkgopt *npkg;
|
|
|
|
_net_pkgopt *npkg;
|
|
|
|
|
|
|
|
|
|
|
|
for (p = 0; p < MAX_PLAYERS; p++)
|
|
|
|
for (p = 0; p < MAX_PLAYERS; p++)
|
|
|
|
if (PS_IS_netplayer (players[p].state) && !PS_IS_aiplayer(players[p].state)) {
|
|
|
|
if (PS_IS_netplayer (players[p].state) && !PS_IS_aiplayer (players[p].state)) {
|
|
|
|
npkg = &players[p].net.pkgopt;
|
|
|
|
npkg = &players[p].net.pkgopt;
|
|
|
|
|
|
|
|
|
|
|
|
if (npkg->to_2sec > DYN_PKG_MAX_MISSING) {
|
|
|
|
if (npkg->to_2sec > DYN_PKG_MAX_MISSING) {
|
|
|
@ -71,7 +71,8 @@ net_dyn_pkgoption ()
|
|
|
|
npkg->to_timestamp = timestamp;
|
|
|
|
npkg->to_timestamp = timestamp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((timestamp - npkg->to_timestamp > 2000) && npkg->to_2sec <= DYN_PKG_MIN_MISSING) {
|
|
|
|
if ((timestamp - npkg->to_timestamp > 2000)
|
|
|
|
|
|
|
|
&& npkg->to_2sec <= DYN_PKG_MIN_MISSING) {
|
|
|
|
if (npkg->send_set > PKG_SENDSETOPT)
|
|
|
|
if (npkg->send_set > PKG_SENDSETOPT)
|
|
|
|
npkg->send_set--;
|
|
|
|
npkg->send_set--;
|
|
|
|
npkg->to_2sec = 0;
|
|
|
|
npkg->to_2sec = 0;
|
|
|
@ -154,14 +155,16 @@ network_shutdown ()
|
|
|
|
|
|
|
|
|
|
|
|
/* find new server */
|
|
|
|
/* find new server */
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++) {
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++) {
|
|
|
|
if (PS_IS_used(players[i].state) && PS_IS_netplayer(players[i].state) && i != bman.p_servnr && players[i].net.flags == 0)
|
|
|
|
if (PS_IS_used (players[i].state) && PS_IS_netplayer (players[i].state)
|
|
|
|
|
|
|
|
&& i != bman.p_servnr && players[i].net.flags == 0)
|
|
|
|
new_server = i;
|
|
|
|
new_server = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
d_printf ("netword_shutdown: new server set to: %d\n", new_server);
|
|
|
|
d_printf ("netword_shutdown: new server set to: %d\n", new_server);
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
if (i != bman.p_servnr && PS_IS_netplayer (players[i].state) && !PS_IS_aiplayer (players[i].state))
|
|
|
|
if (i != bman.p_servnr && PS_IS_netplayer (players[i].state)
|
|
|
|
|
|
|
|
&& !PS_IS_aiplayer (players[i].state))
|
|
|
|
send_quit (&players[i].net.addr, bman.p_servnr, new_server);
|
|
|
|
send_quit (&players[i].net.addr, bman.p_servnr, new_server);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (players[bman.p_servnr].net.addr.host[0] != 0) {
|
|
|
|
else if (players[bman.p_servnr].net.addr.host[0] != 0) {
|
|
|
@ -205,8 +208,7 @@ net_check_timeout (int pl_nr)
|
|
|
|
timestamp - players[pl_nr].net.timestamp);
|
|
|
|
timestamp - players[pl_nr].net.timestamp);
|
|
|
|
players[pl_nr].net.timestamp = timestamp;
|
|
|
|
players[pl_nr].net.timestamp = timestamp;
|
|
|
|
players[pl_nr].net.pingack = players[pl_nr].net.pingreq;
|
|
|
|
players[pl_nr].net.pingack = players[pl_nr].net.pingreq;
|
|
|
|
send_ping (&players[pl_nr].net.addr, players[pl_nr].net.pingack + 100,
|
|
|
|
send_ping (&players[pl_nr].net.addr, players[pl_nr].net.pingack + 100, PKG_pingreq);
|
|
|
|
PKG_pingreq);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((players[pl_nr].state & (PSF_net + PSF_used + PSF_ai)) == (PSF_used + PSF_net)
|
|
|
|
if ((players[pl_nr].state & (PSF_net + PSF_used + PSF_ai)) == (PSF_used + PSF_net)
|
|
|
|
&& ((players[pl_nr].net.flags & NETF_local2) == 0)
|
|
|
|
&& ((players[pl_nr].net.flags & NETF_local2) == 0)
|
|
|
@ -254,8 +256,8 @@ network_loop ()
|
|
|
|
inlen = udp_get (bman.sock, data, MAX_UDPDATA, &addr.sAddr, bman.net_ai_family);
|
|
|
|
inlen = udp_get (bman.sock, data, MAX_UDPDATA, &addr.sAddr, bman.net_ai_family);
|
|
|
|
addr.port[0] = addr.host[0] = 0;
|
|
|
|
addr.port[0] = addr.host[0] = 0;
|
|
|
|
if (inlen > 0)
|
|
|
|
if (inlen > 0)
|
|
|
|
dns_filladdr (addr.host, LEN_SERVERNAME, addr.port, LEN_PORT, bman.net_ai_family,
|
|
|
|
dns_filladdr (addr.host, LEN_SERVERNAME, addr.port, LEN_PORT,
|
|
|
|
&addr.sAddr);
|
|
|
|
bman.net_ai_family, &addr.sAddr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -302,13 +304,13 @@ draw_netupdatestate (char st)
|
|
|
|
int y = 0,
|
|
|
|
int y = 0,
|
|
|
|
b1,
|
|
|
|
b1,
|
|
|
|
z,
|
|
|
|
z,
|
|
|
|
zx=200,
|
|
|
|
zx = 200,
|
|
|
|
i,
|
|
|
|
i,
|
|
|
|
j,
|
|
|
|
j,
|
|
|
|
s=map.size.y+MAX_PLAYERS+GAME_MAX_TUNNELS;
|
|
|
|
s = map.size.y + MAX_PLAYERS + GAME_MAX_TUNNELS;
|
|
|
|
SDL_Rect src,
|
|
|
|
SDL_Rect src,
|
|
|
|
dest;
|
|
|
|
dest;
|
|
|
|
z=gfx.res.x-zx-30-8;
|
|
|
|
z = gfx.res.x - zx - 30 - 8;
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
if (PS_IS_used (players[i].state)) {
|
|
|
|
if (PS_IS_used (players[i].state)) {
|
|
|
|
y += 50;
|
|
|
|
y += 50;
|
|
|
@ -333,71 +335,74 @@ draw_netupdatestate (char st)
|
|
|
|
dest.w = menulistimages[1][0]->w;
|
|
|
|
dest.w = menulistimages[1][0]->w;
|
|
|
|
dest.h = menulistimages[1][0]->h;
|
|
|
|
dest.h = menulistimages[1][0]->h;
|
|
|
|
gfx_blit (menulistimages[1][0], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menulistimages[1][0], NULL, gfx.screen, &dest, 10000);
|
|
|
|
dest.x = z+zx+4;
|
|
|
|
dest.x = z + zx + 4;
|
|
|
|
gfx_blit (menulistimages[1][2], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menulistimages[1][2], NULL, gfx.screen, &dest, 10000);
|
|
|
|
// draw the bottom left and right of the list
|
|
|
|
// draw the bottom left and right of the list
|
|
|
|
dest.y = y+29;
|
|
|
|
dest.y = y + 29;
|
|
|
|
gfx_blit (menulistimages[1][8], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menulistimages[1][8], NULL, gfx.screen, &dest, 10000);
|
|
|
|
dest.x = zx;
|
|
|
|
dest.x = zx;
|
|
|
|
gfx_blit (menulistimages[1][6], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menulistimages[1][6], NULL, gfx.screen, &dest, 10000);
|
|
|
|
//top & bottom
|
|
|
|
//top & bottom
|
|
|
|
for (j=4;j<z+4;j+=4) {
|
|
|
|
for (j = 4; j < z + 4; j += 4) {
|
|
|
|
dest.x=j+zx;dest.y=y;
|
|
|
|
dest.x = j + zx;
|
|
|
|
|
|
|
|
dest.y = y;
|
|
|
|
gfx_blit (menulistimages[1][1], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menulistimages[1][1], NULL, gfx.screen, &dest, 10000);
|
|
|
|
dest.y = y+29;
|
|
|
|
dest.y = y + 29;
|
|
|
|
gfx_blit (menulistimages[1][7], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menulistimages[1][7], NULL, gfx.screen, &dest, 10000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//left &right
|
|
|
|
//left &right
|
|
|
|
for (j=4;j<29;j+=4) {
|
|
|
|
for (j = 4; j < 29; j += 4) {
|
|
|
|
dest.x=zx;dest.y=y+j;
|
|
|
|
dest.x = zx;
|
|
|
|
|
|
|
|
dest.y = y + j;
|
|
|
|
gfx_blit (menulistimages[1][3], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menulistimages[1][3], NULL, gfx.screen, &dest, 10000);
|
|
|
|
dest.x = z+zx+4;
|
|
|
|
dest.x = z + zx + 4;
|
|
|
|
gfx_blit (menulistimages[1][5], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menulistimages[1][5], NULL, gfx.screen, &dest, 10000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sprintf (text, "%s", players[i].name);
|
|
|
|
sprintf (text, "%s", players[i].name);
|
|
|
|
font_draw (80, y, text, 0, 4);
|
|
|
|
font_draw (80, y, text, 0, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// calc percentage, this a range from 0 to 255)
|
|
|
|
// calc percentage, this a range from 0 to 255)
|
|
|
|
switch(players[i].net.net_istep){
|
|
|
|
switch (players[i].net.net_istep) {
|
|
|
|
case 3:
|
|
|
|
case 3:
|
|
|
|
sprintf (text, "Getting Tunnel Data %d.", players[i].net.net_status);
|
|
|
|
sprintf (text, "Getting Tunnel Data %d.", players[i].net.net_status);
|
|
|
|
b=(players[i].net.net_status+1)*255/s;
|
|
|
|
b = (players[i].net.net_status + 1) * 255 / s;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
sprintf (text, "Getting Field Data %d of %d.", players[i].net.net_status,
|
|
|
|
sprintf (text, "Getting Field Data %d of %d.",
|
|
|
|
map.size.y);
|
|
|
|
players[i].net.net_status, map.size.y);
|
|
|
|
b=(players[i].net.net_status+1+GAME_MAX_TUNNELS)*255/s;
|
|
|
|
b = (players[i].net.net_status + 1 + GAME_MAX_TUNNELS) * 255 / s;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
sprintf (text, "Getting Player Data %d of %d.", players[i].net.net_status,
|
|
|
|
sprintf (text, "Getting Player Data %d of %d.",
|
|
|
|
MAX_PLAYERS);
|
|
|
|
players[i].net.net_status, MAX_PLAYERS);
|
|
|
|
b=(players[i].net.net_status+1+GAME_MAX_TUNNELS+map.size.y)*255/s;
|
|
|
|
b = (players[i].net.net_status + 1 + GAME_MAX_TUNNELS + map.size.y) * 255 / s;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
sprintf (text, "Ready");
|
|
|
|
sprintf (text, "Ready");
|
|
|
|
b=255;
|
|
|
|
b = 255;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//draw bar
|
|
|
|
//draw bar
|
|
|
|
if (b>0) {
|
|
|
|
if (b > 0) {
|
|
|
|
b1=b*z/255;
|
|
|
|
b1 = b * z / 255;
|
|
|
|
dest.x = zx+4;
|
|
|
|
dest.x = zx + 4;
|
|
|
|
dest.y = y+4;
|
|
|
|
dest.y = y + 4;
|
|
|
|
dest.w = menubuttonimages[2][0]->w;
|
|
|
|
dest.w = menubuttonimages[2][0]->w;
|
|
|
|
dest.h = menubuttonimages[2][0]->h;
|
|
|
|
dest.h = menubuttonimages[2][0]->h;
|
|
|
|
gfx_blit (menubuttonimages[2][0], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menubuttonimages[2][0], NULL, gfx.screen, &dest, 10000);
|
|
|
|
dest.x = zx+4+b1-menubuttonimages[1][2]->w;
|
|
|
|
dest.x = zx + 4 + b1 - menubuttonimages[1][2]->w;
|
|
|
|
if (dest.x<zx+4) dest.x=zx+4;
|
|
|
|
if (dest.x < zx + 4)
|
|
|
|
|
|
|
|
dest.x = zx + 4;
|
|
|
|
dest.w = menubuttonimages[2][2]->w;
|
|
|
|
dest.w = menubuttonimages[2][2]->w;
|
|
|
|
dest.h = menubuttonimages[2][2]->h;
|
|
|
|
dest.h = menubuttonimages[2][2]->h;
|
|
|
|
gfx_blit (menubuttonimages[2][2], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menubuttonimages[2][2], NULL, gfx.screen, &dest, 10000);
|
|
|
|
if (b1>menubuttonimages[2][0]->w+menubuttonimages[2][2]->w) {
|
|
|
|
if (b1 > menubuttonimages[2][0]->w + menubuttonimages[2][2]->w) {
|
|
|
|
dest.w = menubuttonimages[2][1]->w;
|
|
|
|
dest.w = menubuttonimages[2][1]->w;
|
|
|
|
dest.h = menubuttonimages[2][1]->h;
|
|
|
|
dest.h = menubuttonimages[2][1]->h;
|
|
|
|
for(j=menubuttonimages[2][0]->w;j<b1-menubuttonimages[2][2]->w;
|
|
|
|
for (j = menubuttonimages[2][0]->w;
|
|
|
|
j+=menubuttonimages[2][1]->w) {
|
|
|
|
j < b1 - menubuttonimages[2][2]->w; j += menubuttonimages[2][1]->w) {
|
|
|
|
dest.x=j+zx+4;
|
|
|
|
dest.x = j + zx + 4;
|
|
|
|
gfx_blit (menubuttonimages[2][1], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menubuttonimages[2][1], NULL, gfx.screen, &dest, 10000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -405,9 +410,8 @@ draw_netupdatestate (char st)
|
|
|
|
// draw old status in case of debug
|
|
|
|
// draw old status in case of debug
|
|
|
|
if (!players[i].net.net_istep)
|
|
|
|
if (!players[i].net.net_istep)
|
|
|
|
font_draw (80, y + 20, text, 0, 4);
|
|
|
|
font_draw (80, y + 20, text, 0, 4);
|
|
|
|
else
|
|
|
|
else if (debug) {
|
|
|
|
if (debug) {
|
|
|
|
redraw_logo (80, y + 35, gfx.res.x - 80, 15);
|
|
|
|
redraw_logo (80, y+35, gfx.res.x-80, 15);
|
|
|
|
|
|
|
|
font_draw (80, y + 35, text, 0, 4);
|
|
|
|
font_draw (80, y + 35, text, 0, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -432,8 +436,10 @@ net_send_playerid (int pl_nr)
|
|
|
|
for (i = 1; i < MAX_PLAYERS; i++)
|
|
|
|
for (i = 1; i < MAX_PLAYERS; i++)
|
|
|
|
if (NET_CANSEND (i))
|
|
|
|
if (NET_CANSEND (i))
|
|
|
|
send_playerid (&players[i].net.addr, players[pl_nr].name,
|
|
|
|
send_playerid (&players[i].net.addr, players[pl_nr].name,
|
|
|
|
players[pl_nr].net.addr.host, players[pl_nr].net.addr.port,
|
|
|
|
players[pl_nr].net.addr.host,
|
|
|
|
pl_nr, players[pl_nr].gfx_nr, players[pl_nr].team_nr, players[pl_nr].net.flags);
|
|
|
|
players[pl_nr].net.addr.port, pl_nr,
|
|
|
|
|
|
|
|
players[pl_nr].gfx_nr, players[pl_nr].team_nr,
|
|
|
|
|
|
|
|
players[pl_nr].net.flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -442,10 +448,12 @@ net_send_playerid (int pl_nr)
|
|
|
|
if (pl_nr == bman.p_nr || (IS_LPLAYER2 && pl_nr == bman.p2_nr))
|
|
|
|
if (pl_nr == bman.p_nr || (IS_LPLAYER2 && pl_nr == bman.p2_nr))
|
|
|
|
send_playerid (&players[bman.p_servnr].net.addr, players[pl_nr].name,
|
|
|
|
send_playerid (&players[bman.p_servnr].net.addr, players[pl_nr].name,
|
|
|
|
players[pl_nr].net.addr.host, players[pl_nr].net.addr.port,
|
|
|
|
players[pl_nr].net.addr.host, players[pl_nr].net.addr.port,
|
|
|
|
pl_nr, players[pl_nr].gfx_nr, players[pl_nr].team_nr, players[pl_nr].net.flags);
|
|
|
|
pl_nr, players[pl_nr].gfx_nr, players[pl_nr].team_nr,
|
|
|
|
|
|
|
|
players[pl_nr].net.flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((players[pl_nr].gfx_nr >= 0 && players[pl_nr].gfx != &gfx.players[players[pl_nr].gfx_nr]) || (players[pl_nr].gfx_nr == -1 && players[pl_nr].gfx != NULL))
|
|
|
|
if ((players[pl_nr].gfx_nr >= 0 && players[pl_nr].gfx != &gfx.players[players[pl_nr].gfx_nr])
|
|
|
|
|
|
|
|
|| (players[pl_nr].gfx_nr == -1 && players[pl_nr].gfx != NULL))
|
|
|
|
player_set_gfx (&players[pl_nr], players[pl_nr].gfx_nr);
|
|
|
|
player_set_gfx (&players[pl_nr], players[pl_nr].gfx_nr);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -484,7 +492,8 @@ net_transmit_gamedata ()
|
|
|
|
for (x = 0; x < MAX_PLAYERS; x++) {
|
|
|
|
for (x = 0; x < MAX_PLAYERS; x++) {
|
|
|
|
players[x].net.timestamp = 0;
|
|
|
|
players[x].net.timestamp = 0;
|
|
|
|
players[x].net.net_status = -1;
|
|
|
|
players[x].net.net_status = -1;
|
|
|
|
if ((PS_IS_aiplayer (players[x].state)) || (x==bman.p_servnr) || (x == bman.p2_nr) || (players[x].net.flags & NETF_local2) == NETF_local2)
|
|
|
|
if ((PS_IS_aiplayer (players[x].state)) || (x == bman.p_servnr) || (x == bman.p2_nr)
|
|
|
|
|
|
|
|
|| (players[x].net.flags & NETF_local2) == NETF_local2)
|
|
|
|
players[x].net.net_istep = 0;
|
|
|
|
players[x].net.net_istep = 0;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
players[x].net.net_istep = 3;
|
|
|
|
players[x].net.net_istep = 3;
|
|
|
@ -511,10 +520,11 @@ net_transmit_gamedata ()
|
|
|
|
if (GT_MP_PTPM) {
|
|
|
|
if (GT_MP_PTPM) {
|
|
|
|
if (timestamp - downtimestamp > TIME_UPDATEINFO) {
|
|
|
|
if (timestamp - downtimestamp > TIME_UPDATEINFO) {
|
|
|
|
downtimestamp = timestamp;
|
|
|
|
downtimestamp = timestamp;
|
|
|
|
net_send_updateinfo();
|
|
|
|
net_send_updateinfo ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (p = 1, i = 1; p < MAX_PLAYERS; p++)
|
|
|
|
for (p = 0, i = 1; p < MAX_PLAYERS; p++)
|
|
|
|
if (PS_IS_playing (players[p].state) && players[p].net.net_istep != 0)
|
|
|
|
if (PS_IS_playing (players[p].state)
|
|
|
|
|
|
|
|
&& players[p].net.net_istep != 0)
|
|
|
|
i = 0;
|
|
|
|
i = 0;
|
|
|
|
if (i == 1) { /* all players are ready */
|
|
|
|
if (i == 1) { /* all players are ready */
|
|
|
|
done = 1;
|
|
|
|
done = 1;
|
|
|
@ -534,9 +544,10 @@ net_transmit_gamedata ()
|
|
|
|
downtimestamp = timestamp;
|
|
|
|
downtimestamp = timestamp;
|
|
|
|
send_tunneldata (&players[bman.p_servnr].net.addr, y, -1, -1);
|
|
|
|
send_tunneldata (&players[bman.p_servnr].net.addr, y, -1, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (y < GAME_MAX_TUNNELS && y != players[bman.p_nr].net.net_status
|
|
|
|
else if (y < GAME_MAX_TUNNELS
|
|
|
|
&& y >= 0 && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) {
|
|
|
|
&& y != players[bman.p_nr].net.net_status && y >= 0
|
|
|
|
/* we have got no tunnel data*/
|
|
|
|
&& timestamp - downtimestamp > DOWNLOAD_TIMEOUT) {
|
|
|
|
|
|
|
|
/* we have got no tunnel data */
|
|
|
|
y--;
|
|
|
|
y--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (y == GAME_MAX_TUNNELS - 1 && players[bman.p_nr].net.net_status == y) {
|
|
|
|
else if (y == GAME_MAX_TUNNELS - 1 && players[bman.p_nr].net.net_status == y) {
|
|
|
@ -575,14 +586,15 @@ net_transmit_gamedata ()
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
get player data
|
|
|
|
get player data
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if ((y < MAX_PLAYERS - 1 && y == players[bman.p_nr].net.net_status) || y == -1) {
|
|
|
|
if ((y < MAX_PLAYERS - 1 && y == players[bman.p_nr].net.net_status)
|
|
|
|
|
|
|
|
|| y == -1) {
|
|
|
|
/* send player date req */
|
|
|
|
/* send player date req */
|
|
|
|
y++;
|
|
|
|
y++;
|
|
|
|
downtimestamp = timestamp;
|
|
|
|
downtimestamp = timestamp;
|
|
|
|
send_getplayerdata (&players[bman.p_servnr].net.addr, y);
|
|
|
|
send_getplayerdata (&players[bman.p_servnr].net.addr, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (y < MAX_PLAYERS && y != players[bman.p_nr].net.net_status && y >= 0
|
|
|
|
if (y < MAX_PLAYERS && y != players[bman.p_nr].net.net_status
|
|
|
|
&& timestamp - downtimestamp > DOWNLOAD_TIMEOUT) {
|
|
|
|
&& y >= 0 && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) {
|
|
|
|
/* we have got no player data */
|
|
|
|
/* we have got no player data */
|
|
|
|
y--;
|
|
|
|
y--;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -654,12 +666,13 @@ net_game_send_player (int p_nr)
|
|
|
|
|
|
|
|
|
|
|
|
if (GT_MP_PTPM) {
|
|
|
|
if (GT_MP_PTPM) {
|
|
|
|
for (p = 0; p < MAX_PLAYERS; p++)
|
|
|
|
for (p = 0; p < MAX_PLAYERS; p++)
|
|
|
|
if (PS_IS_netplayer (players[p].state) && p != bman.p_nr && p != bman.p2_nr && p != p_nr)
|
|
|
|
if (PS_IS_netplayer (players[p].state) && p != bman.p_nr && p != bman.p2_nr
|
|
|
|
|
|
|
|
&& p != p_nr)
|
|
|
|
send_playerdata (&players[p].net.addr, p_nr, &players[p_nr]);
|
|
|
|
send_playerdata (&players[p].net.addr, p_nr, &players[p_nr]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (p_nr == bman.p_nr || p_nr == bman.p2_nr) {
|
|
|
|
else if (p_nr == bman.p_nr || p_nr == bman.p2_nr) {
|
|
|
|
for (p = 0; p < MAX_PLAYERS; p++)
|
|
|
|
for (p = 0; p < MAX_PLAYERS; p++)
|
|
|
|
if (NET_CANSEND(p))
|
|
|
|
if (NET_CANSEND (p))
|
|
|
|
send_playerdata (&players[p].net.addr, p_nr, &players[p_nr]);
|
|
|
|
send_playerdata (&players[p].net.addr, p_nr, &players[p_nr]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -672,7 +685,7 @@ net_game_send_playermove (int p_nr, int mustsend)
|
|
|
|
_player *pl;
|
|
|
|
_player *pl;
|
|
|
|
|
|
|
|
|
|
|
|
for (p = 0; p < MAX_PLAYERS; p++)
|
|
|
|
for (p = 0; p < MAX_PLAYERS; p++)
|
|
|
|
if (NET_CANSEND(p)) {
|
|
|
|
if (NET_CANSEND (p)) {
|
|
|
|
pl = &players[p_nr];
|
|
|
|
pl = &players[p_nr];
|
|
|
|
|
|
|
|
|
|
|
|
pl->net.pkgopt.send_to--;
|
|
|
|
pl->net.pkgopt.send_to--;
|
|
|
@ -691,7 +704,8 @@ net_game_send_bomb (int p, int b)
|
|
|
|
int pl;
|
|
|
|
int pl;
|
|
|
|
|
|
|
|
|
|
|
|
/* check if we are slave and send something else as dropping a bomb */
|
|
|
|
/* check if we are slave and send something else as dropping a bomb */
|
|
|
|
if (GT_MP_PTPS && players[p].bombs[b].state != BS_ticking && players[p].bombs[b].state != BS_trigger)
|
|
|
|
if (GT_MP_PTPS && players[p].bombs[b].state != BS_ticking
|
|
|
|
|
|
|
|
&& players[p].bombs[b].state != BS_trigger)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
d_printf ("Send BombData %d, %d\n", p, b);
|
|
|
|
d_printf ("Send BombData %d, %d\n", p, b);
|
|
|
@ -700,7 +714,7 @@ net_game_send_bomb (int p, int b)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
for (pl = 0; pl < MAX_PLAYERS; pl++)
|
|
|
|
for (pl = 0; pl < MAX_PLAYERS; pl++)
|
|
|
|
if (NET_CANSEND(pl))
|
|
|
|
if (NET_CANSEND (pl))
|
|
|
|
send_bombdata (&players[pl].net.addr, p, b, &players[p].bombs[b]);
|
|
|
|
send_bombdata (&players[pl].net.addr, p, b, &players[p].bombs[b]);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -716,7 +730,7 @@ net_game_send_field (int x, int y)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
for (pl = 0; pl < MAX_PLAYERS; pl++)
|
|
|
|
for (pl = 0; pl < MAX_PLAYERS; pl++)
|
|
|
|
if (NET_CANSEND(pl))
|
|
|
|
if (NET_CANSEND (pl))
|
|
|
|
send_field (&players[pl].net.addr, x, y, &map.field[x][y]);
|
|
|
|
send_field (&players[pl].net.addr, x, y, &map.field[x][y]);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -725,7 +739,8 @@ net_game_send_field (int x, int y)
|
|
|
|
* send the information about the deleted player to all clients
|
|
|
|
* send the information about the deleted player to all clients
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
void
|
|
|
|
net_game_send_delplayer (int pl_nr) {
|
|
|
|
net_game_send_delplayer (int pl_nr)
|
|
|
|
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
int new_server = bman.p_servnr;
|
|
|
|
int new_server = bman.p_servnr;
|
|
|
|
|
|
|
|
|
|
|
@ -736,16 +751,18 @@ net_game_send_delplayer (int pl_nr) {
|
|
|
|
/* find new server, if needed */
|
|
|
|
/* find new server, if needed */
|
|
|
|
if (pl_nr == bman.p_servnr) {
|
|
|
|
if (pl_nr == bman.p_servnr) {
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++) {
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++) {
|
|
|
|
if (PS_IS_used(players[i].state) && PS_IS_netplayer(players[i].state) && i != bman.p_servnr && players[i].net.flags == 0)
|
|
|
|
if (PS_IS_used (players[i].state)
|
|
|
|
|
|
|
|
&& PS_IS_netplayer (players[i].state) && i != bman.p_servnr
|
|
|
|
|
|
|
|
&& players[i].net.flags == 0)
|
|
|
|
new_server = i;
|
|
|
|
new_server = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
d_printf ("new_game_send_delplayer: new server set to: %d\n", new_server);
|
|
|
|
d_printf ("new_game_send_delplayer: new server set to: %d\n", new_server);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
if (NET_CANSEND(i) && i != bman.p_nr)
|
|
|
|
if (NET_CANSEND (i) && i != bman.p_nr)
|
|
|
|
send_quit (&players[i].net.addr, pl_nr, new_server);
|
|
|
|
send_quit (&players[i].net.addr, pl_nr, new_server);
|
|
|
|
bman.updatestatusbar=1;
|
|
|
|
bman.updatestatusbar = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* we have to send that one if our own players quit */
|
|
|
|
/* we have to send that one if our own players quit */
|
|
|
|
else if (pl_nr == bman.p_nr || pl_nr == bman.p2_nr) {
|
|
|
|
else if (pl_nr == bman.p_nr || pl_nr == bman.p2_nr) {
|
|
|
@ -771,7 +788,8 @@ net_game_fillsockaddr ()
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
if (!PS_IS_aiplayer (players[i].state) && players[i].net.addr.host[0] != 0 && players[i].net.addr.host[0] != 0)
|
|
|
|
if (!PS_IS_aiplayer (players[i].state) && players[i].net.addr.host[0] != 0
|
|
|
|
|
|
|
|
&& players[i].net.addr.host[0] != 0)
|
|
|
|
dns_filladdr (players[i].net.addr.host, LEN_SERVERNAME,
|
|
|
|
dns_filladdr (players[i].net.addr.host, LEN_SERVERNAME,
|
|
|
|
players[i].net.addr.port, LEN_PORT, bman.net_ai_family,
|
|
|
|
players[i].net.addr.port, LEN_PORT, bman.net_ai_family,
|
|
|
|
&players[i].net.addr.sAddr);
|
|
|
|
&players[i].net.addr.sAddr);
|
|
|
@ -784,7 +802,7 @@ net_send_servermode ()
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
if (NET_CANSEND(i))
|
|
|
|
if (NET_CANSEND (i))
|
|
|
|
send_servermode (&players[i].net.addr, i);
|
|
|
|
send_servermode (&players[i].net.addr, i);
|
|
|
|
|
|
|
|
|
|
|
|
if (bman.notifygamemaster && GT_MP_PTPM)
|
|
|
|
if (bman.notifygamemaster && GT_MP_PTPM)
|
|
|
@ -803,8 +821,8 @@ net_send_players ()
|
|
|
|
if (NET_CANSEND (j))
|
|
|
|
if (NET_CANSEND (j))
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
send_playerid (&players[j].net.addr, players[i].name,
|
|
|
|
send_playerid (&players[j].net.addr, players[i].name,
|
|
|
|
players[i].net.addr.host, players[i].net.addr.port, i,
|
|
|
|
players[i].net.addr.host, players[i].net.addr.port,
|
|
|
|
players[i].gfx_nr, players[i].team_nr, players[i].net.flags);
|
|
|
|
i, players[i].gfx_nr, players[i].team_nr, players[i].net.flags);
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -832,7 +850,7 @@ net_send_chat (char *text, signed char notigamesrv)
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
if (NET_CANSEND(i))
|
|
|
|
if (NET_CANSEND (i))
|
|
|
|
send_chat (&players[i].net.addr, text);
|
|
|
|
send_chat (&players[i].net.addr, text);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -845,20 +863,22 @@ net_game_send_ill (int p_nr)
|
|
|
|
d_printf ("net_game_send_ill (%d)\n", p_nr);
|
|
|
|
d_printf ("net_game_send_ill (%d)\n", p_nr);
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
if (NET_CANSEND(i))
|
|
|
|
if (NET_CANSEND (i))
|
|
|
|
send_ill (&players[i].net.addr, p_nr, &players[p_nr]);
|
|
|
|
send_ill (&players[i].net.addr, p_nr, &players[p_nr]);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* send to all players the drop item list */
|
|
|
|
/* send to all players the drop item list */
|
|
|
|
void net_game_send_dropitems (int pl_nr, _flyingitem **fiptr, int cnt) {
|
|
|
|
void
|
|
|
|
|
|
|
|
net_game_send_dropitems (int pl_nr, _flyingitem ** fiptr, int cnt)
|
|
|
|
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
d_printf ("net_game_send_dropitems (%d): %d items droppped\n", pl_nr, cnt);
|
|
|
|
d_printf ("net_game_send_dropitems (%d): %d items droppped\n", pl_nr, cnt);
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
if (NET_CANSEND(i))
|
|
|
|
if (NET_CANSEND (i))
|
|
|
|
send_dropitems (&players[i].net.addr, pl_nr, fiptr, cnt);
|
|
|
|
send_dropitems (&players[i].net.addr, pl_nr, fiptr, cnt);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -904,7 +924,7 @@ net_game_send_special (int pl_nr, int ex_nr, int type)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
for (pl = 0; pl < MAX_PLAYERS; pl++)
|
|
|
|
for (pl = 0; pl < MAX_PLAYERS; pl++)
|
|
|
|
if (NET_CANSEND(pl))
|
|
|
|
if (NET_CANSEND (pl))
|
|
|
|
send_special (&players[pl].net.addr, pl_nr, type, ex_nr);
|
|
|
|
send_special (&players[pl].net.addr, pl_nr, type, ex_nr);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -921,7 +941,7 @@ net_send_updateinfo ()
|
|
|
|
d_printf ("Send Updateinfo\n");
|
|
|
|
d_printf ("Send Updateinfo\n");
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
if (NET_CANSEND(i))
|
|
|
|
if (NET_CANSEND (i))
|
|
|
|
send_updateinfo (&players[i].net.addr);
|
|
|
|
send_updateinfo (&players[i].net.addr);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -938,15 +958,18 @@ net_send_mapinfo ()
|
|
|
|
d_printf ("Send Mapinfo\n");
|
|
|
|
d_printf ("Send Mapinfo\n");
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
if (NET_CANSEND(i))
|
|
|
|
if (NET_CANSEND (i))
|
|
|
|
send_mapinfo (&players[i].net.addr);
|
|
|
|
send_mapinfo (&players[i].net.addr);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* send an update about the game to all clients */
|
|
|
|
/* send an update about the game to all clients */
|
|
|
|
void send_ogc_update () {
|
|
|
|
void
|
|
|
|
int i, j;
|
|
|
|
send_ogc_update ()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i,
|
|
|
|
|
|
|
|
j;
|
|
|
|
char status[10];
|
|
|
|
char status[10];
|
|
|
|
|
|
|
|
|
|
|
|
if (!bman.notifygamemaster || GT_MP_PTPS)
|
|
|
|
if (!bman.notifygamemaster || GT_MP_PTPS)
|
|
|
@ -973,12 +996,15 @@ void send_ogc_update () {
|
|
|
|
sprintf (status, "error");
|
|
|
|
sprintf (status, "error");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ogc_sendgamestatus (bman.sock, "BomberClone", VERSION, bman.gamename, j, bman.maxplayer, status);
|
|
|
|
ogc_sendgamestatus (bman.sock, "BomberClone", VERSION, bman.gamename, j, bman.maxplayer,
|
|
|
|
|
|
|
|
status);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* send the respawn data to all clients and with the new position of the player */
|
|
|
|
/* send the respawn data to all clients and with the new position of the player */
|
|
|
|
void net_game_send_respawn (int pl_nr) {
|
|
|
|
void
|
|
|
|
|
|
|
|
net_game_send_respawn (int pl_nr)
|
|
|
|
|
|
|
|
{
|
|
|
|
int pl;
|
|
|
|
int pl;
|
|
|
|
|
|
|
|
|
|
|
|
d_printf ("Send Respawn Data %d New Position (%d,%d)\n", pl_nr);
|
|
|
|
d_printf ("Send Respawn Data %d New Position (%d,%d)\n", pl_nr);
|
|
|
@ -987,6 +1013,6 @@ void net_game_send_respawn (int pl_nr) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
for (pl = 0; pl < MAX_PLAYERS; pl++)
|
|
|
|
for (pl = 0; pl < MAX_PLAYERS; pl++)
|
|
|
|
if (NET_CANSEND(pl))
|
|
|
|
if (NET_CANSEND (pl))
|
|
|
|
send_respawn (&players[pl].net.addr, pl_nr);
|
|
|
|
send_respawn (&players[pl].net.addr, pl_nr);
|
|
|
|
};
|
|
|
|
};
|
|
|
|