|
|
@ -1,4 +1,4 @@
|
|
|
|
/* $Id: network.c,v 1.60 2004/02/02 23:30:35 patty21 Exp $ */
|
|
|
|
/* $Id: network.c,v 1.61 2004/02/04 22:56:55 patty21 Exp $ */
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
network routines.
|
|
|
|
network routines.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -284,18 +284,22 @@ void
|
|
|
|
draw_netupdatestate (char st)
|
|
|
|
draw_netupdatestate (char st)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char text[255];
|
|
|
|
char text[255];
|
|
|
|
|
|
|
|
unsigned char b;
|
|
|
|
int y = 0,
|
|
|
|
int y = 0,
|
|
|
|
|
|
|
|
b1,
|
|
|
|
z,
|
|
|
|
z,
|
|
|
|
|
|
|
|
zx=200,
|
|
|
|
i,
|
|
|
|
i,
|
|
|
|
j;
|
|
|
|
j,
|
|
|
|
|
|
|
|
s=map.size.y+MAX_PLAYERS+GAME_MAX_TUNNELS;
|
|
|
|
SDL_Rect src,
|
|
|
|
SDL_Rect src,
|
|
|
|
dest;
|
|
|
|
dest;
|
|
|
|
z=gfx.res.x-110;
|
|
|
|
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 += 48;
|
|
|
|
y += 50;
|
|
|
|
if (st) {
|
|
|
|
if (st) {
|
|
|
|
redraw_logo (0, y, gfx.res.x, y + 48);
|
|
|
|
redraw_logo (0, y, gfx.res.x, y + 50);
|
|
|
|
|
|
|
|
|
|
|
|
if (players[i].gfx_nr != -1) {
|
|
|
|
if (players[i].gfx_nr != -1) {
|
|
|
|
dest.w = src.w = players[i].gfx->smal_size.x;
|
|
|
|
dest.w = src.w = players[i].gfx->smal_size.x;
|
|
|
@ -310,56 +314,89 @@ draw_netupdatestate (char st)
|
|
|
|
gfx_blitupdaterectadd (&dest);
|
|
|
|
gfx_blitupdaterectadd (&dest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dest.x = 70;
|
|
|
|
dest.x = zx;
|
|
|
|
dest.y = y+20;
|
|
|
|
dest.y = y;
|
|
|
|
dest.w = menu.listimages[1][0]->w;
|
|
|
|
dest.w = menu.listimages[1][0]->w;
|
|
|
|
dest.h = menu.listimages[1][0]->h;
|
|
|
|
dest.h = menu.listimages[1][0]->h;
|
|
|
|
gfx_blit (menu.listimages[1][0], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menu.listimages[1][0], NULL, gfx.screen, &dest, 10000);
|
|
|
|
dest.x = z+70+6;
|
|
|
|
dest.x = z+zx+4;
|
|
|
|
gfx_blit (menu.listimages[1][2], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menu.listimages[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+36;
|
|
|
|
dest.y = y+29;
|
|
|
|
gfx_blit (menu.listimages[1][8], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menu.listimages[1][8], NULL, gfx.screen, &dest, 10000);
|
|
|
|
dest.x = 70;
|
|
|
|
dest.x = zx;
|
|
|
|
gfx_blit (menu.listimages[1][6], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menu.listimages[1][6], NULL, gfx.screen, &dest, 10000);
|
|
|
|
//top & bottom
|
|
|
|
//top & bottom
|
|
|
|
for (j=4;j<z;j+=4) {
|
|
|
|
for (j=4;j<z+4;j+=4) {
|
|
|
|
dest.x=j+70;dest.y=y+20;
|
|
|
|
dest.x=j+zx;dest.y=y;
|
|
|
|
gfx_blit (menu.listimages[1][1], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menu.listimages[1][1], NULL, gfx.screen, &dest, 10000);
|
|
|
|
dest.y = y+36;
|
|
|
|
dest.y = y+29;
|
|
|
|
gfx_blit (menu.listimages[1][7], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menu.listimages[1][7], NULL, gfx.screen, &dest, 10000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//left &right
|
|
|
|
//left &right
|
|
|
|
for (j=4;j<16;j+=4) {
|
|
|
|
for (j=4;j<29;j+=4) {
|
|
|
|
dest.x=70;dest.y=y+20+j;
|
|
|
|
dest.x=zx;dest.y=y+j;
|
|
|
|
gfx_blit (menu.listimages[1][3], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menu.listimages[1][3], NULL, gfx.screen, &dest, 10000);
|
|
|
|
dest.x = z+70+6;
|
|
|
|
dest.x = z+zx+4;
|
|
|
|
gfx_blit (menu.listimages[1][5], NULL, gfx.screen, &dest, 10000);
|
|
|
|
gfx_blit (menu.listimages[1][5], NULL, gfx.screen, &dest, 10000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
redraw_logo(75,y+30,75+z-10,y+40);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (players[i].net.net_istep == 0)
|
|
|
|
|
|
|
|
sprintf (text, "%s", players[i].name);
|
|
|
|
sprintf (text, "%s", players[i].name);
|
|
|
|
else
|
|
|
|
font_draw (80, y, text, 0, 4);
|
|
|
|
sprintf (text, "%s", players[i].name);
|
|
|
|
}
|
|
|
|
font_draw (80, y, text, 0, 4);
|
|
|
|
// calc percentage, this a range from 0 to 255)
|
|
|
|
text[0] = 0;
|
|
|
|
switch(players[i].net.net_istep){
|
|
|
|
if (players[i].net.net_istep == 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;
|
|
|
|
if (players[i].net.net_istep == 2)
|
|
|
|
break;
|
|
|
|
sprintf (text, "Getting Field Data %d of %d.", players[i].net.net_status,
|
|
|
|
case 2:
|
|
|
|
map.size.x);
|
|
|
|
sprintf (text, "Getting Field Data %d of %d.", players[i].net.net_status,
|
|
|
|
|
|
|
|
map.size.y);
|
|
|
|
if (players[i].net.net_istep == 1)
|
|
|
|
b=(players[i].net.net_status+1+GAME_MAX_TUNNELS)*255/s;
|
|
|
|
sprintf (text, "Getting Player Data %d of %d.", players[i].net.net_status,
|
|
|
|
break;
|
|
|
|
MAX_PLAYERS);
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
sprintf (text, "Getting Player Data %d of %d.", players[i].net.net_status,
|
|
|
|
|
|
|
|
MAX_PLAYERS);
|
|
|
|
|
|
|
|
b=(players[i].net.net_status+1+GAME_MAX_TUNNELS+map.size.y)*255/s;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
sprintf (text, "Ready");
|
|
|
|
|
|
|
|
b=255;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
font_draw (80, y + 32, text, 0, 4);
|
|
|
|
//draw bar
|
|
|
|
}
|
|
|
|
if (b>0) {
|
|
|
|
|
|
|
|
b1=b*z/255;
|
|
|
|
|
|
|
|
dest.x = zx+4;
|
|
|
|
|
|
|
|
dest.y = y+4;
|
|
|
|
|
|
|
|
dest.w = menu.buttonimages[2][0]->w;
|
|
|
|
|
|
|
|
dest.h = menu.buttonimages[2][0]->h;
|
|
|
|
|
|
|
|
gfx_blit (menu.buttonimages[2][0], NULL, gfx.screen, &dest, 10000);
|
|
|
|
|
|
|
|
dest.x = zx+4+b1-menu.buttonimages[1][2]->w;
|
|
|
|
|
|
|
|
if (dest.x<zx+4) dest.x=zx+4;
|
|
|
|
|
|
|
|
dest.w = menu.buttonimages[2][2]->w;
|
|
|
|
|
|
|
|
dest.h = menu.buttonimages[2][2]->h;
|
|
|
|
|
|
|
|
gfx_blit (menu.buttonimages[2][2], NULL, gfx.screen, &dest, 10000);
|
|
|
|
|
|
|
|
if (b1>menu.buttonimages[2][0]->w+menu.buttonimages[2][2]->w) {
|
|
|
|
|
|
|
|
dest.w = menu.buttonimages[2][1]->w;
|
|
|
|
|
|
|
|
dest.h = menu.buttonimages[2][1]->h;
|
|
|
|
|
|
|
|
for(j=menu.buttonimages[2][0]->w;j<b1-menu.buttonimages[2][2]->w;
|
|
|
|
|
|
|
|
j+=menu.buttonimages[2][1]->w) {
|
|
|
|
|
|
|
|
dest.x=j+zx+4;
|
|
|
|
|
|
|
|
gfx_blit (menu.buttonimages[2][1], NULL, gfx.screen, &dest, 10000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// draw old status in case of debug
|
|
|
|
|
|
|
|
if (!players[i].net.net_istep)
|
|
|
|
|
|
|
|
font_draw (80, y + 20, text, 0, 4);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if (debug) {
|
|
|
|
|
|
|
|
redraw_logo (80, y+35, gfx.res.x-80, 15);
|
|
|
|
|
|
|
|
font_draw (80, y + 35, text, 0, 4);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
gfx_blitdraw ();
|
|
|
|
gfx_blitdraw ();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -422,15 +459,13 @@ net_transmit_gamedata ()
|
|
|
|
else
|
|
|
|
else
|
|
|
|
font_draw (100, 0, "Downloading Data", 1, 0);
|
|
|
|
font_draw (100, 0, "Downloading Data", 1, 0);
|
|
|
|
|
|
|
|
|
|
|
|
SDL_Flip (gfx.screen);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
prepare everything for the loop
|
|
|
|
prepare everything for the loop
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
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))
|
|
|
|
if ((PS_IS_aiplayer (players[x].state)) || (x==bman.p_servnr))
|
|
|
|
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;
|
|
|
@ -442,8 +477,9 @@ net_transmit_gamedata ()
|
|
|
|
else
|
|
|
|
else
|
|
|
|
net_istep = 3;
|
|
|
|
net_istep = 3;
|
|
|
|
|
|
|
|
|
|
|
|
draw_netupdatestate (1);
|
|
|
|
draw_netupdatestate (1);
|
|
|
|
SDL_Flip (gfx.screen);
|
|
|
|
SDL_Flip (gfx.screen);
|
|
|
|
|
|
|
|
downtimestamp = timestamp;
|
|
|
|
while (!done && (bman.state == GS_update || (GT_MP_PTPS && net_istep != 0))) {
|
|
|
|
while (!done && (bman.state == GS_update || (GT_MP_PTPS && net_istep != 0))) {
|
|
|
|
/* the network thing */
|
|
|
|
/* the network thing */
|
|
|
|
|
|
|
|
|
|
|
@ -451,6 +487,10 @@ net_transmit_gamedata ()
|
|
|
|
|
|
|
|
|
|
|
|
/* if PTPM check if all players are ready */
|
|
|
|
/* if PTPM check if all players are ready */
|
|
|
|
if (GT_MP_PTPM) {
|
|
|
|
if (GT_MP_PTPM) {
|
|
|
|
|
|
|
|
if (timestamp - downtimestamp > TIME_UPDATEINFO) {
|
|
|
|
|
|
|
|
downtimestamp = timestamp;
|
|
|
|
|
|
|
|
net_send_updateinfo();
|
|
|
|
|
|
|
|
}
|
|
|
|
for (p = 1, i = 1; p < MAX_PLAYERS; p++)
|
|
|
|
for (p = 1, 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;
|
|
|
@ -539,11 +579,10 @@ net_transmit_gamedata ()
|
|
|
|
downtimestamp = timestamp;
|
|
|
|
downtimestamp = timestamp;
|
|
|
|
send_playerstatus (&players[bman.p_servnr].net.addr, bman.p_nr, 0, 0);
|
|
|
|
send_playerstatus (&players[bman.p_servnr].net.addr, bman.p_nr, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* do the grafik work */
|
|
|
|
/* do the grafik work */
|
|
|
|
draw_netupdatestate (0);
|
|
|
|
draw_netupdatestate (0);
|
|
|
|
SDL_Flip (gfx.screen);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (SDL_PollEvent (&event) != 0)
|
|
|
|
if (SDL_PollEvent (&event) != 0)
|
|
|
|
switch (event.type) {
|
|
|
|
switch (event.type) {
|
|
|
@ -829,6 +868,23 @@ net_game_send_special (int pl_nr, int ex_nr)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Send update informations to all clients */
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
|
|
net_send_updateinfo ()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (GT_MP_PTPS)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
d_printf ("Send Updateinfo\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
|
|
|
|
if (!PS_IS_aiplayer (players[i].state) && PS_IS_netplayer (players[i].state) && i != bman.p_nr && NET_CANSEND(i))
|
|
|
|
|
|
|
|
send_updateinfo (&players[i].net.addr);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Send mapinformations to all clients */
|
|
|
|
/* Send mapinformations to all clients */
|
|
|
|
void
|
|
|
|
void
|
|
|
|
net_send_mapinfo ()
|
|
|
|
net_send_mapinfo ()
|
|
|
|