fixes which had to do with the local second player on network games

origin
stpohle 21 years ago
parent c6bfd775d1
commit 889bf3ce0d

@ -1,7 +1,13 @@
$Id: ChangeLog,v 1.88 2004/12/01 02:41:53 stpohle Exp $ $Id: ChangeLog,v 1.89 2004/12/05 19:43:34 stpohle Exp $
* FINISH TEAM MODE. * FINISH TEAM MODE.
* Team Data won't be send by changes.
- Fixed: Problems with the second local player join and
leaving. Also the second local player won't get
informations which the first local player already had.
- Bombs will not explode right on slow computers.. it - Bombs will not explode right on slow computers.. it
seems they jump one field to far. seems they jump one field to far.
fixed: rewrote part of the do_explosion stuff and fixed: rewrote part of the do_explosion stuff and

@ -1,4 +1,4 @@
/* $Id: network.c,v 1.69 2004/11/30 14:30:37 stpohle Exp $ */ /* $Id: network.c,v 1.70 2004/12/05 19:43:37 stpohle Exp $ */
/* /*
network routines. network routines.
*/ */
@ -740,6 +740,10 @@ net_game_send_delplayer (int pl_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 of our own players quit */
else if (pl_nr == bman.p_nr || pl_nr == bman.p2_nr) {
send_quit (&players[bman.p_servnr].net.addr, pl_nr, -1);
}
if (GT_MP_PTPM && bman.notifygamemaster) if (GT_MP_PTPM && bman.notifygamemaster)
send_ogc_update (); send_ogc_update ();

@ -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,9 +334,12 @@ 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
@ -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);

@ -1,4 +1,4 @@
/* $Id: player.c,v 1.94 2004/11/30 23:08:08 stpohle Exp $ /* $Id: player.c,v 1.95 2004/12/05 19:43:37 stpohle Exp $
* player.c - everything what have to do with the player */ * player.c - everything what have to do with the player */
#include <SDL.h> #include <SDL.h>
@ -972,9 +972,6 @@ void player_check (int pl_nr) {
*/ */
void void
player_delete (int pl_nr) { player_delete (int pl_nr) {
char host[LEN_SERVERNAME];
char port[LEN_PORT];
d_printf ("player_delete (%d)\n", pl_nr); d_printf ("player_delete (%d)\n", pl_nr);
bman.updatestatusbar = 1; // force an update bman.updatestatusbar = 1; // force an update
@ -985,10 +982,7 @@ player_delete (int pl_nr) {
bman.state = GS_startup; bman.state = GS_startup;
} }
else { else {
strncpy (host, players[pl_nr].net.addr.host, LEN_SERVERNAME); player_set_gfx (&players[pl_nr], -1);
strncpy (port, players[pl_nr].net.addr.port, LEN_PORT);
player_set_gfx (&players[pl_nr], -1);
players[pl_nr].state &= (0xFF - (PSF_used + PSF_net + PSF_alife + PSF_ai)); /* delete players[pl_nr].state &= (0xFF - (PSF_used + PSF_net + PSF_alife + PSF_ai)); /* delete
player flags */ player flags */
players[pl_nr].net.net_istep = 0; // needed for disconnect during the update players[pl_nr].net.net_istep = 0; // needed for disconnect during the update

@ -1,4 +1,4 @@
/* $Id: playermenu.c,v 1.13 2004/12/01 22:02:43 patty21 Exp $ /* $Id: playermenu.c,v 1.14 2004/12/05 19:43:37 stpohle Exp $
*/ */
#include "bomberclone.h" #include "bomberclone.h"
@ -212,7 +212,7 @@ void playermenu () {
_menuitem *detail_Flags; _menuitem *detail_Flags;
_charlist playerlist[MAX_PLAYERS + 1]; _charlist playerlist[MAX_PLAYERS + 1];
_charlist *playerlist_sel = &playerlist[0]; _charlist *playerlist_sel = &playerlist[0];
int i, done = 0, eventstate, pl_nr, sel_pl_nr; int i, done = 0, eventstate, pl_nr, sel_pl_nr, old_2pl_btn = -1;
SDL_Event event; SDL_Event event;
/* delete the playerlist */ /* delete the playerlist */
@ -301,12 +301,15 @@ void playermenu () {
player_delete (bman.p2_nr); player_delete (bman.p2_nr);
else else
player2_join (); player2_join ();
}
if (old_2pl_btn != IS_LPLAYER2) {
if (IS_LPLAYER2) if (IS_LPLAYER2)
sprintf (btn_SecondPlayer->label, "Del 2 Player"); sprintf (btn_SecondPlayer->label, "Del 2 Player");
else else
sprintf (btn_SecondPlayer->label,"Add 2 Player"); sprintf (btn_SecondPlayer->label,"Add 2 Player");
btn_SecondPlayer->changed = 1; btn_SecondPlayer->changed = 1;
old_2pl_btn = IS_LPLAYER2;
} }
if (done == 1 && menu->focus->id == 2) { /* create ai player */ if (done == 1 && menu->focus->id == 2) { /* create ai player */

Loading…
Cancel
Save