|
|
@ -227,6 +227,7 @@ send_joingame (_net_addr * addr, char *name, int secondplayer)
|
|
|
|
strncpy (p_jg.name, name, LEN_PLAYERNAME);
|
|
|
|
strncpy (p_jg.name, name, LEN_PLAYERNAME);
|
|
|
|
strncpy (p_jg.password, bman.password, LEN_PASSWORD);
|
|
|
|
strncpy (p_jg.password, bman.password, LEN_PASSWORD);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bman.firewall = 1;
|
|
|
|
send_pkg ((struct pkg *) &p_jg, addr);
|
|
|
|
send_pkg ((struct pkg *) &p_jg, addr);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -261,19 +262,21 @@ void do_contest (struct pkg_contest *ct_pkg, _net_addr *addr) {
|
|
|
|
|
|
|
|
|
|
|
|
/* if a client get this packet we send a packet
|
|
|
|
/* if a client get this packet we send a packet
|
|
|
|
* to the server that we have got this packet. */
|
|
|
|
* to the server that we have got this packet. */
|
|
|
|
else
|
|
|
|
else {
|
|
|
|
send_contest (&players[bman.p_servnr].net.addr, ct_pkg->from, bman.p_nr, 1);
|
|
|
|
send_contest (&players[bman.p_servnr].net.addr, ct_pkg->from, bman.p_nr, 1);
|
|
|
|
|
|
|
|
bman.firewall = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void send_contest (_net_addr * addr, int from, int to, int ackreq) {
|
|
|
|
void send_contest (_net_addr * addr, int from, int to, int ackreq) {
|
|
|
|
struct pkg_contest ct_pkg;
|
|
|
|
struct pkg_contest ct_pkg;
|
|
|
|
|
|
|
|
|
|
|
|
d_printf ("send_contest addr->id%d, from:%d, to:%d\n", addr->pl_nr, from, to);
|
|
|
|
d_printf ("send_contest addr->id:%d, from:%d, to:%d\n", addr->pl_nr, from, to);
|
|
|
|
|
|
|
|
|
|
|
|
ct_pkg.h.typ = PKG_contest;
|
|
|
|
ct_pkg.h.typ = PKG_contest;
|
|
|
|
if (ackreq) ct_pkg.h.flags = PKGF_ackreq;
|
|
|
|
if (ackreq) ct_pkg.h.flags = PKGF_ackreq;
|
|
|
|
else ct_pkg.h.flags = 0;
|
|
|
|
else ct_pkg.h.flags = 0;
|
|
|
|
ct_pkg.h.len = HTON16 (sizeof (struct pkg_contest));
|
|
|
|
ct_pkg.h.len = HTON16 (sizeof (struct pkg_contest));
|
|
|
|
|
|
|
|
|
|
|
|
ct_pkg.from = from;
|
|
|
|
ct_pkg.from = from;
|
|
|
@ -304,8 +307,9 @@ do_playerid (struct pkg_playerid *p_id, _net_addr * addr)
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* check if we have to send the whole playerlist to a client
|
|
|
|
* check if we have to send the whole playerlist to a client
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (GT_MP_PTPM && p_id->pl_nr == -1) {
|
|
|
|
if (GT_MP_PTPM && p_id->pl_nr == -1 && addr->pl_nr >= 0 && addr->pl_nr < MAX_PLAYERS) {
|
|
|
|
/* Send all connected players the new PlayerID, except to the new player */
|
|
|
|
/* Send all connected players the new PlayerID, except to the new player */
|
|
|
|
|
|
|
|
pl = &players[addr->pl_nr];
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
if (NET_CANSEND(i) && addr->pl_nr != i)
|
|
|
|
if (NET_CANSEND(i) && addr->pl_nr != i)
|
|
|
|
send_playerid (&players[i].net.addr, pl->name, pl->net.addr.host,
|
|
|
|
send_playerid (&players[i].net.addr, pl->name, pl->net.addr.host,
|
|
|
@ -438,6 +442,66 @@ send_playerid (_net_addr * addr, char *name, char *pladdr, char *plport,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
|
|
|
*** Packettype: teamdata
|
|
|
|
|
|
|
|
*** Server Side:
|
|
|
|
|
|
|
|
*** Send all teamdata to the client.
|
|
|
|
|
|
|
|
*** Client Side:
|
|
|
|
|
|
|
|
*** Get all Teamdata
|
|
|
|
|
|
|
|
***/
|
|
|
|
|
|
|
|
void do_teamdata (struct pkg_teamdata *td, _net_addr * addr) {
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (addr->pl_nr == -1)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
d_printf ("do_teamdata (addr->pl_nr: %d): team:%d col:%d wins:%d\n", addr->pl_nr, td->team_nr, td->col, td->wins);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (addr->pl_nr == bman.p_servnr) { /* packet comes from the server */
|
|
|
|
|
|
|
|
if (td->team_nr >= 0 && td->team_nr < MAX_TEAMS) {
|
|
|
|
|
|
|
|
strncpy (teams[td->team_nr].name, td->name, LEN_PLAYERNAME);
|
|
|
|
|
|
|
|
teams[td->team_nr].col = td->col;
|
|
|
|
|
|
|
|
teams[td->team_nr].wins = td->wins;
|
|
|
|
|
|
|
|
bman.updatestatusbar = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
if (td->team_nr < 0 || td->team_nr >= MAX_TEAMS) {
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_TEAMS; i++)
|
|
|
|
|
|
|
|
send_teamdata (addr, i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
send_teamdata (addr, td->team_nr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void send_teamdata (_net_addr * addr, int team_nr) {
|
|
|
|
|
|
|
|
struct pkg_teamdata td;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
d_printf ("send_teamdata (%s:%s) team:%d\n", addr->host, addr->port, team_nr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
td.h.typ = PKG_teamdata;
|
|
|
|
|
|
|
|
td.h.flags = PKGF_ackreq;
|
|
|
|
|
|
|
|
td.h.len = HTON16 (sizeof (struct pkg_teamdata));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
td.team_nr = team_nr;
|
|
|
|
|
|
|
|
if (team_nr >= 0 && team_nr < MAX_PLAYERS) {
|
|
|
|
|
|
|
|
strncpy (td.name, teams[team_nr].name, LEN_PLAYERNAME);
|
|
|
|
|
|
|
|
td.wins = teams[team_nr].wins;
|
|
|
|
|
|
|
|
td.col = teams[team_nr].col;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
td.name[0] = 0;
|
|
|
|
|
|
|
|
td.wins = 0;
|
|
|
|
|
|
|
|
td.col = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
send_pkg ((struct pkg *) &td, addr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
/***
|
|
|
|
*** Packettype: servermode
|
|
|
|
*** Packettype: servermode
|
|
|
|
***/
|
|
|
|
***/
|
|
|
@ -469,8 +533,10 @@ do_servermode (struct pkg_servermode *s_mod, _net_addr * addr)
|
|
|
|
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 with p_nr -1 so we get the whole playerlist
|
|
|
|
|
|
|
|
* do the same with the teamdata */
|
|
|
|
send_playerid (addr, NULL, NULL, NULL, -1, -1, -1, 0);
|
|
|
|
send_playerid (addr, NULL, NULL, NULL, -1, -1, -1, 0);
|
|
|
|
|
|
|
|
send_teamdata (addr, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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;
|
|
|
@ -481,7 +547,7 @@ do_servermode (struct pkg_servermode *s_mod, _net_addr * addr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* do the normal update */
|
|
|
|
/* do the normal update */
|
|
|
|
if (GT_MP_PTPS) {
|
|
|
|
if (GT_MP_PTPS && addr->pl_nr == bman.p_servnr) {
|
|
|
|
bman.state = s_mod->state;
|
|
|
|
bman.state = s_mod->state;
|
|
|
|
bman.gametype = s_mod->gametype;
|
|
|
|
bman.gametype = s_mod->gametype;
|
|
|
|
bman.dropitemsondeath = s_mod->dropitemsondeath;
|
|
|
|
bman.dropitemsondeath = s_mod->dropitemsondeath;
|
|
|
@ -505,6 +571,29 @@ send_servermode (_net_addr * addr, int pl_nr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct pkg_servermode s_mod;
|
|
|
|
struct pkg_servermode s_mod;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (bman.state) {
|
|
|
|
|
|
|
|
case (GS_startup):
|
|
|
|
|
|
|
|
d_printf ("Send ServerMode : startup\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (GS_ready):
|
|
|
|
|
|
|
|
d_printf ("Send ServerMode : ready\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (GS_running):
|
|
|
|
|
|
|
|
d_printf ("Send ServerMode : running\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (GS_quit):
|
|
|
|
|
|
|
|
d_printf ("Send ServerMode : quit\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (GS_wait):
|
|
|
|
|
|
|
|
d_printf ("Send ServerMode : wait\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (GS_update):
|
|
|
|
|
|
|
|
d_printf ("Send ServerMode : update\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
d_printf ("Send ServerMode : mode %d\n", s_mod.state);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
s_mod.h.typ = PKG_servermode;
|
|
|
|
s_mod.h.typ = PKG_servermode;
|
|
|
|
s_mod.h.len = HTON16 (sizeof (struct pkg_servermode));
|
|
|
|
s_mod.h.len = HTON16 (sizeof (struct pkg_servermode));
|
|
|
|
s_mod.h.flags = PKGF_ackreq;
|
|
|
|
s_mod.h.flags = PKGF_ackreq;
|
|
|
@ -527,26 +616,6 @@ send_servermode (_net_addr * addr, int pl_nr)
|
|
|
|
s_mod.fieldsize_x = map.size.x;
|
|
|
|
s_mod.fieldsize_x = map.size.x;
|
|
|
|
s_mod.fieldsize_y = map.size.y;
|
|
|
|
s_mod.fieldsize_y = map.size.y;
|
|
|
|
strncpy (s_mod.tileset, map.tileset, LEN_TILESETNAME);
|
|
|
|
strncpy (s_mod.tileset, map.tileset, LEN_TILESETNAME);
|
|
|
|
switch (s_mod.state) {
|
|
|
|
|
|
|
|
case (GS_startup):
|
|
|
|
|
|
|
|
d_printf ("Send ServerMode : startup\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (GS_ready):
|
|
|
|
|
|
|
|
d_printf ("Send ServerMode : ready\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (GS_running):
|
|
|
|
|
|
|
|
d_printf ("Send ServerMode : running\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (GS_quit):
|
|
|
|
|
|
|
|
d_printf ("Send ServerMode : quit\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (GS_wait):
|
|
|
|
|
|
|
|
d_printf ("Send ServerMode : wait\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (GS_update):
|
|
|
|
|
|
|
|
d_printf ("Send ServerMode : wait\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
send_pkg ((struct pkg *) &s_mod, addr);
|
|
|
|
send_pkg ((struct pkg *) &s_mod, addr);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -1039,11 +1108,14 @@ send_quit (_net_addr * addr, int pl_nr, int new_server)
|
|
|
|
void
|
|
|
|
void
|
|
|
|
do_quit (struct pkg_quit *q_dat, _net_addr * addr)
|
|
|
|
do_quit (struct pkg_quit *q_dat, _net_addr * addr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d_printf ("do_quit (%s:%s) pl_nr = %d\n", addr->host, addr->port, q_dat->pl_nr);
|
|
|
|
d_printf ("do_quit (%s:%s) pl_nr=%d new_server=%d\n", addr->host, addr->port, q_dat->pl_nr, q_dat->new_server);
|
|
|
|
|
|
|
|
|
|
|
|
if (addr->pl_nr == -1)
|
|
|
|
if (addr->pl_nr == -1)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bman.updatestatusbar=1;
|
|
|
|
|
|
|
|
player_delete (q_dat->pl_nr);
|
|
|
|
|
|
|
|
|
|
|
|
/* the player who send this quit */
|
|
|
|
/* the player who send this quit */
|
|
|
|
if (q_dat->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);
|
|
|
@ -1063,9 +1135,6 @@ do_quit (struct pkg_quit *q_dat, _net_addr * addr)
|
|
|
|
else if (q_dat->pl_nr == bman.p_servnr && q_dat->new_server == bman.p_servnr)
|
|
|
|
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."
|
|
|
|
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.");
|
|
|
|
" Or the server could not find any other possible new server.");
|
|
|
|
|
|
|
|
|
|
|
|
bman.updatestatusbar=1;
|
|
|
|
|
|
|
|
player_delete (q_dat->pl_nr);
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1786,6 +1855,9 @@ do_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
case (PKG_updateinfo):
|
|
|
|
case (PKG_updateinfo):
|
|
|
|
do_updateinfo ((struct pkg_updateinfo *) packet, addr);
|
|
|
|
do_updateinfo ((struct pkg_updateinfo *) packet, addr);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (PKG_teamdata):
|
|
|
|
|
|
|
|
do_teamdata ((struct pkg_teamdata *) packet, addr);
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
send_error (addr, "BomberClone: unknown data packet");
|
|
|
|
send_error (addr, "BomberClone: unknown data packet");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|