|
|
@ -128,7 +128,9 @@ do_joingame (struct pkg_joingame *p_jg, _net_addr * addr)
|
|
|
|
for (i = -1, freeslot = -1, j = 0; j < MAX_PLAYERS; j++) {
|
|
|
|
for (i = -1, freeslot = -1, j = 0; j < MAX_PLAYERS; j++) {
|
|
|
|
if (!PS_IS_used (players[j].state) && freeslot == -1) freeslot = j;
|
|
|
|
if (!PS_IS_used (players[j].state) && freeslot == -1) freeslot = j;
|
|
|
|
if (strncmp (players[j].net.addr.host, addr->host, LEN_SERVERNAME) == 0
|
|
|
|
if (strncmp (players[j].net.addr.host, addr->host, LEN_SERVERNAME) == 0
|
|
|
|
&& strncmp (players[j].net.addr.port, addr->port, LEN_PORT) == 0) i = j;
|
|
|
|
&& strncmp (players[j].net.addr.port, addr->port, LEN_PORT) == 0
|
|
|
|
|
|
|
|
&& ((p_jg->secondplayer && (players[j].net.flags & NETF_local2) != 0)
|
|
|
|
|
|
|
|
|| (!p_jg->secondplayer && (players[j].net.flags & NETF_local2) == 0))) i = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (i == -1) i = freeslot;
|
|
|
|
if (i == -1) i = freeslot;
|
|
|
@ -172,7 +174,8 @@ do_joingame (struct pkg_joingame *p_jg, _net_addr * addr)
|
|
|
|
bman.players_nr_s++;
|
|
|
|
bman.players_nr_s++;
|
|
|
|
|
|
|
|
|
|
|
|
/* send to the new client the servermode and the complete playerlist */
|
|
|
|
/* send to the new client the servermode and the complete playerlist */
|
|
|
|
send_mapinfo (addr);
|
|
|
|
if ((!p_jg->secondplayer) && !(players[j].net.flags & NETF_local2))
|
|
|
|
|
|
|
|
send_mapinfo (addr);
|
|
|
|
send_servermode (addr, i); // with this packet the client know it'S pl_nr
|
|
|
|
send_servermode (addr, i); // with this packet the client know it'S pl_nr
|
|
|
|
|
|
|
|
|
|
|
|
addr->pl_nr = i;
|
|
|
|
addr->pl_nr = i;
|
|
|
@ -331,10 +334,13 @@ do_playerid (struct pkg_playerid *p_id, _net_addr * addr)
|
|
|
|
memcpy (&pl->net.addr.sAddr, &players[bman.p_servnr].net.addr.sAddr, sizeof (struct _sockaddr));
|
|
|
|
memcpy (&pl->net.addr.sAddr, &players[bman.p_servnr].net.addr.sAddr, sizeof (struct _sockaddr));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Check if we have to make a network test.. only client to client */
|
|
|
|
/* Check if we have to make a network test.. only client to client
|
|
|
|
|
|
|
|
* we won't check 2 players too because i't won't be possible to send
|
|
|
|
|
|
|
|
* something to them. */
|
|
|
|
if (GT_MP_PTPS && !(PS_IS_netplayer (pl->state)) && (PS_IS_netplayer (p_id->state))
|
|
|
|
if (GT_MP_PTPS && !(PS_IS_netplayer (pl->state)) && (PS_IS_netplayer (p_id->state))
|
|
|
|
&& p_id->pl_nr != bman.p_servnr && p_id->pl_nr != bman.p_nr) {
|
|
|
|
&& p_id->pl_nr != bman.p_servnr && p_id->pl_nr != bman.p_nr
|
|
|
|
|
|
|
|
&& !(pl->net.flags & NETF_local2) && p_id->pl_nr != bman.p2_nr) {
|
|
|
|
|
|
|
|
|
|
|
|
send_contest (&pl->net.addr, bman.p_nr, -1, 0); // send contest without ackreq.
|
|
|
|
send_contest (&pl->net.addr, bman.p_nr, -1, 0); // send contest without ackreq.
|
|
|
|
/* make sure we still get messages from the server, this is a
|
|
|
|
/* make sure we still get messages from the server, this is a
|
|
|
|
* work around for some hardware routers */
|
|
|
|
* work around for some hardware routers */
|
|
|
@ -454,6 +460,9 @@ do_servermode (struct pkg_servermode *s_mod, _net_addr * addr)
|
|
|
|
players[bman.p_nr].net.flags = NETF_firewall;
|
|
|
|
players[bman.p_nr].net.flags = NETF_firewall;
|
|
|
|
players[bman.p_nr].state &= (0xFF - PSF_net);
|
|
|
|
players[bman.p_nr].state &= (0xFF - PSF_net);
|
|
|
|
strncpy (players[s_mod->p_nr].name, bman.playername, LEN_PLAYERNAME);
|
|
|
|
strncpy (players[s_mod->p_nr].name, bman.playername, LEN_PLAYERNAME);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* send playerid with p_nr -1 so we get the whole playerlist */
|
|
|
|
|
|
|
|
send_playerid (addr, NULL, NULL, NULL, -1, -1, -1, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (s_mod->p_nr >= 0 && s_mod->p_nr < MAX_PLAYERS && bman.p2_nr == -1 && s_mod->lplayer2 == 1) {
|
|
|
|
else if (s_mod->p_nr >= 0 && s_mod->p_nr < MAX_PLAYERS && bman.p2_nr == -1 && s_mod->lplayer2 == 1) {
|
|
|
|
bman.p2_nr = s_mod->p_nr;
|
|
|
|
bman.p2_nr = s_mod->p_nr;
|
|
|
@ -461,9 +470,6 @@ do_servermode (struct pkg_servermode *s_mod, _net_addr * addr)
|
|
|
|
players[bman.p2_nr].state &= (0xFF - PSF_net);
|
|
|
|
players[bman.p2_nr].state &= (0xFF - PSF_net);
|
|
|
|
strncpy (players[s_mod->p_nr].name, bman.player2name, LEN_PLAYERNAME);
|
|
|
|
strncpy (players[s_mod->p_nr].name, bman.player2name, LEN_PLAYERNAME);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* send playerid with p_nr -1 so we get the whole playerlist */
|
|
|
|
|
|
|
|
send_playerid (addr, NULL, NULL, NULL, -1, -1, -1, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* do the normal update */
|
|
|
|
/* do the normal update */
|
|
|
@ -1029,7 +1035,7 @@ do_quit (struct pkg_quit *q_dat, _net_addr * addr)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
/* the player who send this quit */
|
|
|
|
/* the player who send this quit */
|
|
|
|
if (addr->pl_nr == bman.p_servnr && q_dat->new_server != bman.p_servnr) {
|
|
|
|
if (q_dat->pl_nr == bman.p_servnr && q_dat->new_server != bman.p_servnr) {
|
|
|
|
d_printf ("do_quit: new server is set to: %d\n", q_dat->new_server);
|
|
|
|
d_printf ("do_quit: new server is set to: %d\n", q_dat->new_server);
|
|
|
|
bman.p_servnr = q_dat->new_server;
|
|
|
|
bman.p_servnr = q_dat->new_server;
|
|
|
|
|
|
|
|
|
|
|
@ -1044,6 +1050,9 @@ do_quit (struct pkg_quit *q_dat, _net_addr * addr)
|
|
|
|
send_ogc_update ();
|
|
|
|
send_ogc_update ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (q_dat->pl_nr == bman.p_servnr && q_dat->new_server == bman.p_servnr)
|
|
|
|
|
|
|
|
menu_displaymessage ("Server Quit", "The game closed because you are the only one who is left."
|
|
|
|
|
|
|
|
" Or the server could not find any other possible new server.");
|
|
|
|
|
|
|
|
|
|
|
|
bman.updatestatusbar=1;
|
|
|
|
bman.updatestatusbar=1;
|
|
|
|
player_delete (q_dat->pl_nr);
|
|
|
|
player_delete (q_dat->pl_nr);
|
|
|
|