|
|
|
@ -45,7 +45,7 @@ send_error (_net_addr * addr, char *text)
|
|
|
|
|
strncpy (p_err.text, text, 127);
|
|
|
|
|
p_err.h.typ = PKG_error;
|
|
|
|
|
p_err.h.flags = 0;
|
|
|
|
|
p_err.h.len = sizeof (struct pkg_error);
|
|
|
|
|
p_err.h.len = HTON16 (sizeof (struct pkg_error));
|
|
|
|
|
p_err.nr = 0;
|
|
|
|
|
|
|
|
|
|
send_pkg ((struct pkg *) &p_err, addr);
|
|
|
|
@ -85,8 +85,9 @@ do_playerid (struct pkg_playerid *p_id, _net_addr * addr)
|
|
|
|
|
send_error (addr, text);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
d_printf ("do_playerid (From:%s:%s pl_nr=%d) Player(name:%s [%s:%s], pl_nr:%d)\n", addr->host,
|
|
|
|
|
addr->port, addr->pl_nr, p_id->name, p_id->host, p_id->port, p_id->pl_nr);
|
|
|
|
|
d_printf
|
|
|
|
|
("do_playerid (From:%s:%s pl_nr=%d) Player(name:%s [%s:%s], pl_nr:%d)\n",
|
|
|
|
|
addr->host, addr->port, addr->pl_nr, p_id->name, p_id->host, p_id->port, p_id->pl_nr);
|
|
|
|
|
|
|
|
|
|
/* As Server/Master Only change settings, or do ignore them if we are not in GS_wait */
|
|
|
|
|
if (((GT_MP_PTPM && (bman.state == GS_wait && addr->pl_nr != -1)) || // PTPM change setting
|
|
|
|
@ -115,8 +116,8 @@ do_playerid (struct pkg_playerid *p_id, _net_addr * addr)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GT_MP_PTPS) {
|
|
|
|
|
pl->points = p_id->points;
|
|
|
|
|
pl->wins = p_id->wins;
|
|
|
|
|
pl->points = NTOH16 (p_id->points);
|
|
|
|
|
pl->wins = NTOH16 (p_id->wins);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -153,20 +154,21 @@ do_playerid (struct pkg_playerid *p_id, _net_addr * addr)
|
|
|
|
|
|
|
|
|
|
strncpy (pl->net.addr.host, addr->host, LEN_SERVERNAME);
|
|
|
|
|
strncpy (pl->net.addr.port, addr->port, LEN_PORT);
|
|
|
|
|
dns_filladdr (pl->net.addr.host, LEN_SERVERNAME, pl->net.addr.port, LEN_PORT,
|
|
|
|
|
bman.net_ai_family, &pl->net.addr.sAddr);
|
|
|
|
|
dns_filladdr (pl->net.addr.host, LEN_SERVERNAME, pl->net.addr.port,
|
|
|
|
|
LEN_PORT, bman.net_ai_family, &pl->net.addr.sAddr);
|
|
|
|
|
pl->net.flags = p_id->netflags;
|
|
|
|
|
pl->net.addr.pl_nr = i;
|
|
|
|
|
bman.players_nr_s++;
|
|
|
|
|
|
|
|
|
|
/* send to the new client the servermode and the complete playerlist */
|
|
|
|
|
send_servermode (addr, i);
|
|
|
|
|
send_mapinfo (addr);
|
|
|
|
|
send_mapinfo (addr);
|
|
|
|
|
for (j = 0; j < MAX_PLAYERS; j++)
|
|
|
|
|
if (bman.players[j].net.addr.host[0] != 0 || bman.players[j].name[0] != 0)
|
|
|
|
|
send_playerid (addr, bman.players[j].name, bman.players[j].net.addr.host,
|
|
|
|
|
bman.players[j].net.addr.port, j, bman.players[j].gfx_nr,
|
|
|
|
|
bman.players[i].net.flags);
|
|
|
|
|
send_playerid (addr, bman.players[j].name,
|
|
|
|
|
bman.players[j].net.addr.host,
|
|
|
|
|
bman.players[j].net.addr.port, j,
|
|
|
|
|
bman.players[j].gfx_nr, bman.players[i].net.flags);
|
|
|
|
|
|
|
|
|
|
addr->pl_nr = i;
|
|
|
|
|
for (j = 0, i = 0; i < bman.maxplayer; i++)
|
|
|
|
@ -198,21 +200,21 @@ do_playerid (struct pkg_playerid *p_id, _net_addr * addr)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
send_playerid (_net_addr * addr, char *name, char *pladdr, char *plport, int pl_nr, int gfx_nr,
|
|
|
|
|
signed char netflags)
|
|
|
|
|
send_playerid (_net_addr * addr, char *name, char *pladdr, char *plport,
|
|
|
|
|
int pl_nr, int gfx_nr, signed char netflags)
|
|
|
|
|
{
|
|
|
|
|
struct pkg_playerid p_id;
|
|
|
|
|
int vmi,
|
|
|
|
|
vma,
|
|
|
|
|
vsu;
|
|
|
|
|
|
|
|
|
|
d_printf ("send_playerid SendTo: %s:%s (Name:%16s p_nr:%d)\n", addr->host, addr->port, name,
|
|
|
|
|
pl_nr);
|
|
|
|
|
d_printf ("send_playerid SendTo: %s:%s (Name:%16s p_nr:%d)\n", addr->host,
|
|
|
|
|
addr->port, name, pl_nr);
|
|
|
|
|
sscanf (VERSION, "%d.%d.%d", &vma, &vmi, &vsu);
|
|
|
|
|
|
|
|
|
|
p_id.h.typ = PKG_playerid;
|
|
|
|
|
p_id.h.flags = PKGF_ackreq;
|
|
|
|
|
p_id.h.len = sizeof (struct pkg_playerid);
|
|
|
|
|
p_id.h.len = HTON16 (sizeof (struct pkg_playerid));
|
|
|
|
|
p_id.ver_sub = vsu;
|
|
|
|
|
p_id.ver_major = vma;
|
|
|
|
|
p_id.ver_minor = vmi;
|
|
|
|
@ -233,8 +235,8 @@ send_playerid (_net_addr * addr, char *name, char *pladdr, char *plport, int pl_
|
|
|
|
|
p_id.pl_nr = pl_nr;
|
|
|
|
|
p_id.gfx_nr = gfx_nr;
|
|
|
|
|
if (pl_nr != -1) {
|
|
|
|
|
p_id.points = bman.players[pl_nr].points;
|
|
|
|
|
p_id.wins = bman.players[pl_nr].wins;
|
|
|
|
|
p_id.points = HTON16 (bman.players[pl_nr].points);
|
|
|
|
|
p_id.wins = HTON16 (bman.players[pl_nr].wins);
|
|
|
|
|
p_id.state = bman.players[pl_nr].state;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
@ -267,7 +269,7 @@ do_servermode (struct pkg_servermode *s_mod, _net_addr * addr)
|
|
|
|
|
bman.gametype = GT_single;
|
|
|
|
|
|
|
|
|
|
bman.state = s_mod->state;
|
|
|
|
|
map.state = s_mod->mapstate;
|
|
|
|
|
map.state = s_mod->mapstate;
|
|
|
|
|
if (s_mod->multitype == MT_ptpm)
|
|
|
|
|
bman.multitype = MT_ptps;
|
|
|
|
|
|
|
|
|
@ -279,7 +281,7 @@ do_servermode (struct pkg_servermode *s_mod, _net_addr * addr)
|
|
|
|
|
map.size.y = s_mod->fieldsize_y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strncpy (map.tileset, s_mod->tileset, LEN_TILESETNAME);
|
|
|
|
|
strncpy (map.tileset, s_mod->tileset, LEN_TILESETNAME);
|
|
|
|
|
|
|
|
|
|
bman.updatestatusbar = 1;
|
|
|
|
|
};
|
|
|
|
@ -292,14 +294,14 @@ send_servermode (_net_addr * addr, int pl_nr)
|
|
|
|
|
d_printf ("Send ServerMode\n");
|
|
|
|
|
|
|
|
|
|
s_mod.h.typ = PKG_servermode;
|
|
|
|
|
s_mod.h.len = sizeof (struct pkg_servermode);
|
|
|
|
|
s_mod.h.len = HTON16 (sizeof (struct pkg_servermode));
|
|
|
|
|
s_mod.h.flags = PKGF_ackreq;
|
|
|
|
|
s_mod.type = bman.gametype;
|
|
|
|
|
s_mod.mapstate = map.state;
|
|
|
|
|
if (bman.state == GS_quit) /* do not send GS_quit */
|
|
|
|
|
s_mod.state = GS_startup;
|
|
|
|
|
else
|
|
|
|
|
s_mod.state = bman.state;
|
|
|
|
|
s_mod.mapstate = map.state;
|
|
|
|
|
if (bman.state == GS_quit) /* do not send GS_quit */
|
|
|
|
|
s_mod.state = GS_startup;
|
|
|
|
|
else
|
|
|
|
|
s_mod.state = bman.state;
|
|
|
|
|
s_mod.multitype = bman.multitype;
|
|
|
|
|
s_mod.players = bman.players_nr_s;
|
|
|
|
|
s_mod.maxplayer = bman.maxplayer;
|
|
|
|
@ -307,7 +309,7 @@ send_servermode (_net_addr * addr, int pl_nr)
|
|
|
|
|
s_mod.last_winner = bman.lastwinner;
|
|
|
|
|
s_mod.fieldsize_x = map.size.x;
|
|
|
|
|
s_mod.fieldsize_y = map.size.y;
|
|
|
|
|
strncpy (s_mod.tileset, map.tileset, LEN_TILESETNAME);
|
|
|
|
|
strncpy (s_mod.tileset, map.tileset, LEN_TILESETNAME);
|
|
|
|
|
send_pkg ((struct pkg *) &s_mod, addr);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -320,7 +322,7 @@ send_field (_net_addr * addr, int x, int y, _field * field)
|
|
|
|
|
d_printf ("send_field [%d,%d]\n", x, y);
|
|
|
|
|
|
|
|
|
|
f_dat.h.typ = PKG_field;
|
|
|
|
|
f_dat.h.len = sizeof (struct pkg_field);
|
|
|
|
|
f_dat.h.len = HTON16 (sizeof (struct pkg_field));
|
|
|
|
|
f_dat.h.flags = PKGF_ackreq;
|
|
|
|
|
|
|
|
|
|
f_dat.x = x;
|
|
|
|
@ -341,16 +343,21 @@ do_field (struct pkg_field *f_dat, _net_addr * addr)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (f_dat->x < map.size.x && f_dat->y < map.size.y) {
|
|
|
|
|
/* convert the fielddata */
|
|
|
|
|
memcpy (&map.field[f_dat->x][f_dat->y], &f_dat->field, sizeof (_field));
|
|
|
|
|
map.field[f_dat->x][f_dat->y].frame = NTOH16 (map.field[f_dat->x][f_dat->y].frame);
|
|
|
|
|
map.field[f_dat->x][f_dat->y].frameto = NTOH32 (map.field[f_dat->x][f_dat->y].frameto);
|
|
|
|
|
map.field[f_dat->x][f_dat->y].ex_nr = NTOH32 (map.field[f_dat->x][f_dat->y].ex_nr);
|
|
|
|
|
}
|
|
|
|
|
if (bman.state == GS_running)
|
|
|
|
|
stonelist_add (f_dat->x, f_dat->y);
|
|
|
|
|
|
|
|
|
|
if (f_dat->field.ex_nr > bman.last_ex_nr)
|
|
|
|
|
bman.last_ex_nr = f_dat->field.ex_nr;
|
|
|
|
|
if (NTOH32 (f_dat->field.ex_nr) > bman.last_ex_nr)
|
|
|
|
|
bman.last_ex_nr = NTOH32 (f_dat->field.ex_nr);
|
|
|
|
|
|
|
|
|
|
d_printf ("do_field (%d,%d) ex_nr = %d, special = %d, type = %d\n", f_dat->x, f_dat->y,
|
|
|
|
|
f_dat->field.ex_nr, f_dat->field.special, f_dat->field.type);
|
|
|
|
|
d_printf ("do_field (%d,%d) ex_nr = %d, special = %d, type = %d\n",
|
|
|
|
|
f_dat->x, f_dat->y, NTOH32 (f_dat->field.ex_nr),
|
|
|
|
|
f_dat->field.special, f_dat->field.type);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -362,14 +369,14 @@ do_ping (struct pkg_ping *p_dat, _net_addr * addr)
|
|
|
|
|
|
|
|
|
|
if (p_dat->h.typ == PKG_pingack)
|
|
|
|
|
/* ping was an answer */
|
|
|
|
|
bman.players[addr->pl_nr].net.pingack = p_dat->data;
|
|
|
|
|
bman.players[addr->pl_nr].net.pingack = NTOH32 (p_dat->data);
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
/* send the answer */
|
|
|
|
|
send_ping (addr, p_dat->data, PKG_pingack);
|
|
|
|
|
send_ping (addr, NTOH32 (p_dat->data), PKG_pingack);
|
|
|
|
|
|
|
|
|
|
d_printf ("do_ping pl_nr[%d] (%s:%s) req=%d, ack=%d\n", addr->pl_nr, addr->host,
|
|
|
|
|
addr->port, bman.players[addr->pl_nr].net.pingreq,
|
|
|
|
|
d_printf ("do_ping pl_nr[%d] (%s:%s) req=%d, ack=%d\n", addr->pl_nr,
|
|
|
|
|
addr->host, addr->port, bman.players[addr->pl_nr].net.pingreq,
|
|
|
|
|
bman.players[addr->pl_nr].net.pingack);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -382,23 +389,23 @@ send_ping (_net_addr * addr, int data, unsigned char typ)
|
|
|
|
|
if (addr->pl_nr == -1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
p_dat.h.len = sizeof (struct pkg_ping);
|
|
|
|
|
p_dat.h.len = HTON16 (sizeof (struct pkg_ping));
|
|
|
|
|
p_dat.h.flags = 0;
|
|
|
|
|
|
|
|
|
|
if (typ == PKG_pingack) {
|
|
|
|
|
p_dat.h.typ = typ;
|
|
|
|
|
p_dat.data = data;
|
|
|
|
|
p_dat.data = HTON32 (data);
|
|
|
|
|
send_pkg ((struct pkg *) &p_dat, addr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (typ == PKG_pingreq) {
|
|
|
|
|
p_dat.h.typ = typ;
|
|
|
|
|
p_dat.data = data;
|
|
|
|
|
p_dat.data = HTON32 (data);
|
|
|
|
|
send_pkg ((struct pkg *) &p_dat, addr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
d_printf ("send_ping Player[%d] (%s:%s) req=%d, ack=%d\n", addr->pl_nr, addr->host,
|
|
|
|
|
addr->port, bman.players[addr->pl_nr].net.pingreq,
|
|
|
|
|
d_printf ("send_ping Player[%d] (%s:%s) req=%d, ack=%d\n", addr->pl_nr,
|
|
|
|
|
addr->host, addr->port, bman.players[addr->pl_nr].net.pingreq,
|
|
|
|
|
bman.players[addr->pl_nr].net.pingack);
|
|
|
|
|
|
|
|
|
|
bman.players[addr->pl_nr].net.timestamp = timestamp; /* we need to set it here, so we can check
|
|
|
|
@ -412,22 +419,22 @@ send_playerdata (_net_addr * addr, int p_nr, _player * pl)
|
|
|
|
|
struct pkg_playerdata p_dat;
|
|
|
|
|
|
|
|
|
|
p_dat.h.typ = PKG_playerdata;
|
|
|
|
|
p_dat.h.len = sizeof (struct pkg_playerdata);
|
|
|
|
|
p_dat.h.len = HTON16 (sizeof (struct pkg_playerdata));
|
|
|
|
|
|
|
|
|
|
if (bman.state == GS_update)
|
|
|
|
|
p_dat.h.flags = 0;
|
|
|
|
|
else
|
|
|
|
|
p_dat.h.flags = PKGF_ackreq;
|
|
|
|
|
|
|
|
|
|
p_dat.pos.x = pl->pos.x;
|
|
|
|
|
p_dat.pos.y = pl->pos.y;
|
|
|
|
|
p_dat.pos.x = HTON16 (pl->pos.x);
|
|
|
|
|
p_dat.pos.y = HTON16 (pl->pos.y);
|
|
|
|
|
p_dat.bombs_n = pl->bombs_n;
|
|
|
|
|
p_dat.d = pl->d;
|
|
|
|
|
p_dat.range = pl->range;
|
|
|
|
|
p_dat.gfx_nr = pl->gfx_nr;
|
|
|
|
|
p_dat.state = pl->state;
|
|
|
|
|
p_dat.wins = pl->wins;
|
|
|
|
|
p_dat.points = pl->points;
|
|
|
|
|
p_dat.wins = HTON16 (pl->wins);
|
|
|
|
|
p_dat.points = HTON16 (pl->points);
|
|
|
|
|
p_dat.dead_by = pl->dead_by;
|
|
|
|
|
p_dat.frame = pl->frame;
|
|
|
|
|
p_dat.p_nr = p_nr;
|
|
|
|
@ -454,14 +461,14 @@ do_playerdata (struct pkg_playerdata *p_dat, _net_addr * addr)
|
|
|
|
|
player_set_gfx (pl, p_dat->gfx_nr);
|
|
|
|
|
|
|
|
|
|
if (bman.state == GS_running && bman.p_nr != p_dat->p_nr) {
|
|
|
|
|
pl->points = p_dat->points;
|
|
|
|
|
pl->dead_by = p_dat->dead_by;
|
|
|
|
|
pl->points = NTOH16 (p_dat->points);
|
|
|
|
|
pl->dead_by = NTOH16 (p_dat->dead_by);
|
|
|
|
|
}
|
|
|
|
|
else if (bman.state != GS_running || bman.p_nr != p_dat->p_nr) {
|
|
|
|
|
pl->pos.x = p_dat->pos.x;
|
|
|
|
|
pl->pos.y = p_dat->pos.y;
|
|
|
|
|
pl->pos.x = NTOH16 (p_dat->pos.x);
|
|
|
|
|
pl->pos.y = NTOH16 (p_dat->pos.y);
|
|
|
|
|
pl->dead_by = p_dat->dead_by;
|
|
|
|
|
pl->points = p_dat->points;
|
|
|
|
|
pl->points = NTOH16 (p_dat->points);
|
|
|
|
|
pl->d = p_dat->d;
|
|
|
|
|
pl->bombs_n = p_dat->bombs_n;
|
|
|
|
|
pl->range = p_dat->range;
|
|
|
|
@ -506,16 +513,16 @@ send_playermove (_net_addr * addr, int p_nr, _player * pl)
|
|
|
|
|
struct pkg_playermove p_dat;
|
|
|
|
|
|
|
|
|
|
p_dat.h.typ = PKG_playermove;
|
|
|
|
|
p_dat.h.len = sizeof (struct pkg_playermove);
|
|
|
|
|
p_dat.h.len = HTON16 (sizeof (struct pkg_playermove));
|
|
|
|
|
p_dat.h.flags = 0;
|
|
|
|
|
|
|
|
|
|
p_dat.pos.x = pl->pos.x;
|
|
|
|
|
p_dat.pos.y = pl->pos.y;
|
|
|
|
|
p_dat.pos.x = HTON16 (pl->pos.x);
|
|
|
|
|
p_dat.pos.y = HTON16 (pl->pos.y);
|
|
|
|
|
p_dat.m = pl->m;
|
|
|
|
|
p_dat.d = pl->d;
|
|
|
|
|
p_dat.p_nr = p_nr;
|
|
|
|
|
p_dat.speed = pl->speed;
|
|
|
|
|
p_dat.tunnelto = pl->tunnelto;
|
|
|
|
|
p_dat.tunnelto = HTON16 (pl->tunnelto);
|
|
|
|
|
|
|
|
|
|
send_pkg ((struct pkg *) &p_dat, addr);
|
|
|
|
|
};
|
|
|
|
@ -534,7 +541,7 @@ do_ill (struct pkg_ill *ill, _net_addr * addr)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < PI_max; i++)
|
|
|
|
|
bman.players[ill->pl_nr].ill[i].to = ill->to[i];
|
|
|
|
|
bman.players[ill->pl_nr].ill[i].to = NTOH16 (ill->to[i]);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -546,12 +553,12 @@ send_ill (_net_addr * addr, int p_nr, _player * pl)
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
ill.h.typ = PKG_ill;
|
|
|
|
|
ill.h.len = sizeof (struct pkg_ill);
|
|
|
|
|
ill.h.len = HTON16 (sizeof (struct pkg_ill));
|
|
|
|
|
ill.h.flags = PKGF_ackreq;
|
|
|
|
|
|
|
|
|
|
ill.pl_nr = p_nr;
|
|
|
|
|
for (i = 0; i < PI_max; i++)
|
|
|
|
|
ill.to[i] = pl->ill[i].to;
|
|
|
|
|
ill.to[i] = HTON16 (pl->ill[i].to);
|
|
|
|
|
|
|
|
|
|
send_pkg ((struct pkg *) &ill, addr);
|
|
|
|
|
};
|
|
|
|
@ -576,9 +583,9 @@ do_playermove (struct pkg_playermove *p_dat, _net_addr * addr)
|
|
|
|
|
pl->m = p_dat->m;
|
|
|
|
|
pl->d = p_dat->d;
|
|
|
|
|
pl->speed = p_dat->speed;
|
|
|
|
|
pl->pos.x = p_dat->pos.x;
|
|
|
|
|
pl->pos.y = p_dat->pos.y;
|
|
|
|
|
pl->tunnelto = p_dat->tunnelto;
|
|
|
|
|
pl->pos.x = HTON16 (p_dat->pos.x);
|
|
|
|
|
pl->pos.y = HTON16 (p_dat->pos.y);
|
|
|
|
|
pl->tunnelto = HTON16 (p_dat->tunnelto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -598,8 +605,9 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr)
|
|
|
|
|
if (b_dat->state == BS_off)
|
|
|
|
|
return; // if there was a bomb let it explose don't delete the bomb
|
|
|
|
|
|
|
|
|
|
d_printf ("do_bombdata [%d,%d] Player: %d Bomb: %d, ex_nr:%d\n", b_dat->x, b_dat->y,
|
|
|
|
|
b_dat->p_nr, b_dat->b_nr, b_dat->ex_nr);
|
|
|
|
|
d_printf ("do_bombdata [%d,%d] Player: %d Bomb: %d, ex_nr:%d\n",
|
|
|
|
|
NTOH16 (b_dat->x) >> 8, NTOH16 (b_dat->y) >> 8, b_dat->p_nr,
|
|
|
|
|
b_dat->b_nr, NTOH32 (b_dat->ex_nr));
|
|
|
|
|
|
|
|
|
|
bomb = &bman.players[b_dat->p_nr].bombs[b_dat->b_nr];
|
|
|
|
|
if (bomb->state == BS_exploding) {
|
|
|
|
@ -607,35 +615,35 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((bomb->pos.x != b_dat->x || bomb->pos.y != b_dat->y) && bomb->state == BS_exploding
|
|
|
|
|
&& b_dat->state != BS_exploding)
|
|
|
|
|
if ((bomb->pos.x != NTOH16 (b_dat->x) || bomb->pos.y != NTOH16 (b_dat->y))
|
|
|
|
|
&& bomb->state == BS_exploding && b_dat->state != BS_exploding)
|
|
|
|
|
d_printf ("do_bombdata WARNING : bomb explosion haven't finished\n");
|
|
|
|
|
|
|
|
|
|
if (bomb->state != BS_off) { // handle push & kick special
|
|
|
|
|
map.bfield[(bomb->pos.x >> 8)][(bomb->pos.y >> 8)] = 0; //remove bomb at old location
|
|
|
|
|
map.bfield[(bomb->pos.x >> 8)][(bomb->pos.y >> 8)] = 0; //remove bomb at old location
|
|
|
|
|
stonelist_add (bomb->pos.x >> 8, bomb->pos.y >> 8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bomb->state == BS_off && (b_dat->state == BS_ticking || b_dat->state == BS_trigger))
|
|
|
|
|
snd_play (SND_bombdrop);
|
|
|
|
|
|
|
|
|
|
bomb->pos.x = b_dat->x;
|
|
|
|
|
bomb->pos.y = b_dat->y;
|
|
|
|
|
bomb->pos.x = NTOH16 (b_dat->x);
|
|
|
|
|
bomb->pos.y = NTOH16 (b_dat->y);
|
|
|
|
|
|
|
|
|
|
if (bomb->state != b_dat->state && bomb->state != BS_ticking)
|
|
|
|
|
bomb->to = b_dat->to; /* only set if the bomb isn't already ticking
|
|
|
|
|
to make sure the timeout won't be resetted
|
|
|
|
|
by an old network packet */
|
|
|
|
|
if (bomb->state != b_dat->state && bomb->state != BS_ticking)
|
|
|
|
|
bomb->to = NTOH32 (b_dat->to); /* only set if the bomb isn't already ticking
|
|
|
|
|
to make sure the timeout won't be resetted
|
|
|
|
|
by an old network packet */
|
|
|
|
|
|
|
|
|
|
map.bfield[bomb->pos.x >> 8][bomb->pos.y >> 8] = 1; // keep the bfield up to date
|
|
|
|
|
map.bfield[bomb->pos.x >> 8][bomb->pos.y >> 8] = 1; // keep the bfield up to date
|
|
|
|
|
|
|
|
|
|
bomb->r = b_dat->r;
|
|
|
|
|
bomb->ex_nr = b_dat->ex_nr;
|
|
|
|
|
bomb->ex_nr = NTOH32 (b_dat->ex_nr);
|
|
|
|
|
bomb->state = b_dat->state & 0x0F;
|
|
|
|
|
bomb->mode = b_dat->state >> 4;
|
|
|
|
|
bomb->speed = b_dat->speed;
|
|
|
|
|
bomb->dest.x = b_dat->destx;
|
|
|
|
|
bomb->dest.y = b_dat->desty;
|
|
|
|
|
bomb->mode = b_dat->state >> 4;
|
|
|
|
|
bomb->speed = NTOH16 (b_dat->speed);
|
|
|
|
|
bomb->dest.x = NTOH16 (b_dat->destx);
|
|
|
|
|
bomb->dest.y = NTOH16 (b_dat->desty);
|
|
|
|
|
|
|
|
|
|
if (bomb->state == BS_exploding)
|
|
|
|
|
bomb_explode (b_dat->p_nr, b_dat->b_nr, 0);
|
|
|
|
@ -651,66 +659,76 @@ send_bombdata (_net_addr * addr, int p, int b, _bomb * bomb)
|
|
|
|
|
struct pkg_bombdata b_dat;
|
|
|
|
|
|
|
|
|
|
b_dat.h.typ = PKG_bombdata;
|
|
|
|
|
b_dat.h.len = sizeof (struct pkg_bombdata);
|
|
|
|
|
b_dat.x = bomb->pos.x;
|
|
|
|
|
b_dat.y = bomb->pos.y;
|
|
|
|
|
b_dat.to = bomb->to;
|
|
|
|
|
b_dat.h.len = HTON16 (sizeof (struct pkg_bombdata));
|
|
|
|
|
b_dat.x = HTON16 (bomb->pos.x);
|
|
|
|
|
b_dat.y = HTON16 (bomb->pos.y);
|
|
|
|
|
b_dat.to = HTON32 (bomb->to);
|
|
|
|
|
b_dat.r = bomb->r;
|
|
|
|
|
b_dat.ex_nr = bomb->ex_nr;
|
|
|
|
|
b_dat.ex_nr = HTON32 (bomb->ex_nr);
|
|
|
|
|
b_dat.state = (bomb->mode << 4) | (bomb->state);
|
|
|
|
|
b_dat.b_nr = b;
|
|
|
|
|
b_dat.p_nr = p;
|
|
|
|
|
b_dat.h.flags = PKGF_ackreq;
|
|
|
|
|
b_dat.speed = bomb->speed;
|
|
|
|
|
b_dat.destx = bomb->dest.x;
|
|
|
|
|
b_dat.desty = bomb->dest.y;
|
|
|
|
|
b_dat.speed = HTON16 (bomb->speed);
|
|
|
|
|
b_dat.destx = HTON16 (bomb->dest.x);
|
|
|
|
|
b_dat.desty = HTON16 (bomb->dest.y);
|
|
|
|
|
|
|
|
|
|
send_pkg ((struct pkg *) &b_dat, addr);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* recive a request for some tunneldata or receive tunneldata */
|
|
|
|
|
void do_tunneldata (struct pkg_tunneldata *tun_pkg, _net_addr *addr) {
|
|
|
|
|
d_printf ("do_tunneldata: From %d [%s:%s] (Tunnel %d Target [%d,%d])\n", addr->pl_nr, addr->host, addr->port, tun_pkg->tunnel_nr, tun_pkg->target.x, tun_pkg->target.y);
|
|
|
|
|
|
|
|
|
|
if (addr->pl_nr != 0 && GT_MP_PTPM && tun_pkg->target.y == -1 && tun_pkg->target.x == -1) {
|
|
|
|
|
send_tunneldata (addr, tun_pkg->tunnel_nr, map.tunnel[tun_pkg->tunnel_nr].x, map.tunnel[tun_pkg->tunnel_nr].y);
|
|
|
|
|
void
|
|
|
|
|
do_tunneldata (struct pkg_tunneldata *tun_pkg, _net_addr * addr)
|
|
|
|
|
{
|
|
|
|
|
d_printf ("do_tunneldata: From %d [%s:%s] (Tunnel %d Target [%d,%d])\n",
|
|
|
|
|
addr->pl_nr, addr->host, addr->port, tun_pkg->tunnel_nr,
|
|
|
|
|
NTOH16 (tun_pkg->target.x), NTOH16 (tun_pkg->target.y));
|
|
|
|
|
|
|
|
|
|
if (addr->pl_nr != 0 && GT_MP_PTPM && NTOH16 (tun_pkg->target.y) == -1
|
|
|
|
|
&& NTOH16 (tun_pkg->target.x) == -1) {
|
|
|
|
|
send_tunneldata (addr, tun_pkg->tunnel_nr,
|
|
|
|
|
map.tunnel[tun_pkg->tunnel_nr].x, map.tunnel[tun_pkg->tunnel_nr].y);
|
|
|
|
|
bman.players[addr->pl_nr].net.net_status = tun_pkg->tunnel_nr;
|
|
|
|
|
bman.players[addr->pl_nr].net.net_istep = 3;
|
|
|
|
|
}
|
|
|
|
|
else if (addr->pl_nr == 0 && tun_pkg->tunnel_nr < GAME_MAX_TUNNELS) {
|
|
|
|
|
if (tun_pkg->target.x >= 0 && tun_pkg->target.x < map.size.x && tun_pkg->target.y >= 0 && tun_pkg->target.y < map.size.y) {
|
|
|
|
|
map.tunnel[tun_pkg->tunnel_nr].x = tun_pkg->target.x;
|
|
|
|
|
map.tunnel[tun_pkg->tunnel_nr].y = tun_pkg->target.y;
|
|
|
|
|
}
|
|
|
|
|
else if (addr->pl_nr == 0 && tun_pkg->tunnel_nr < GAME_MAX_TUNNELS) {
|
|
|
|
|
if (NTOH16 (tun_pkg->target.x) >= 0 && NTOH16 (tun_pkg->target.x) < map.size.x
|
|
|
|
|
&& NTOH16 (tun_pkg->target.y) >= 0 && NTOH16 (tun_pkg->target.y) < map.size.y) {
|
|
|
|
|
map.tunnel[tun_pkg->tunnel_nr].x = NTOH16 (tun_pkg->target.x);
|
|
|
|
|
map.tunnel[tun_pkg->tunnel_nr].y = NTOH16 (tun_pkg->target.y);
|
|
|
|
|
bman.players[bman.p_nr].net.net_status = tun_pkg->tunnel_nr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
d_printf (" values out of range\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
d_printf (" values out of range\n");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* send a tunneldata request (x && y == -1) or send tunneldata */
|
|
|
|
|
void send_tunneldata (_net_addr *addr, int tunnelnr, int x, int y) {
|
|
|
|
|
struct pkg_tunneldata tun_pkg;
|
|
|
|
|
void
|
|
|
|
|
send_tunneldata (_net_addr * addr, int tunnelnr, int x, int y)
|
|
|
|
|
{
|
|
|
|
|
struct pkg_tunneldata tun_pkg;
|
|
|
|
|
|
|
|
|
|
d_printf ("send_tunneldata (Tunnel %d Target [%d,%d])\n", tunnelnr, x, y);
|
|
|
|
|
d_printf ("send_tunneldata (Tunnel %d Target [%d,%d])\n", tunnelnr, x, y);
|
|
|
|
|
|
|
|
|
|
tun_pkg.h.typ = PKG_tunneldata;
|
|
|
|
|
tun_pkg.h.flags = PKGF_ackreq;
|
|
|
|
|
tun_pkg.h.len = sizeof (struct pkg_tunneldata);
|
|
|
|
|
tun_pkg.h.typ = PKG_tunneldata;
|
|
|
|
|
tun_pkg.h.flags = PKGF_ackreq;
|
|
|
|
|
tun_pkg.h.len = HTON16 (sizeof (struct pkg_tunneldata));
|
|
|
|
|
|
|
|
|
|
if ((GT_MP_PTPM && x != -1 && y != -1) || (GT_MP_PTPS && x == -1 && y == -1)) {
|
|
|
|
|
tun_pkg.tunnel_nr = tunnelnr;
|
|
|
|
|
tun_pkg.target.x = x;
|
|
|
|
|
tun_pkg.target.y = y;
|
|
|
|
|
if ((GT_MP_PTPM && x != -1 && y != -1)
|
|
|
|
|
|| (GT_MP_PTPS && x == -1 && y == -1)) {
|
|
|
|
|
tun_pkg.tunnel_nr = tunnelnr;
|
|
|
|
|
tun_pkg.target.x = HTON16 (x);
|
|
|
|
|
tun_pkg.target.y = HTON16 (y);
|
|
|
|
|
|
|
|
|
|
send_pkg ((struct pkg*) &tun_pkg, addr);
|
|
|
|
|
}
|
|
|
|
|
send_pkg ((struct pkg *) &tun_pkg, addr);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
send_quit (_net_addr * addr, char *plhost, char *plport)
|
|
|
|
|
send_quit (_net_addr * addr, char *plhost, char * plport)
|
|
|
|
|
{
|
|
|
|
|
struct pkg_quit q_dat;
|
|
|
|
|
|
|
|
|
@ -718,13 +736,12 @@ send_quit (_net_addr * addr, char *plhost, char *plport)
|
|
|
|
|
|
|
|
|
|
q_dat.h.typ = PKG_quit;
|
|
|
|
|
q_dat.h.flags = 0;
|
|
|
|
|
q_dat.h.len = sizeof (struct pkg_quit);
|
|
|
|
|
q_dat.h.len = HTON16 (sizeof (struct pkg_quit));
|
|
|
|
|
|
|
|
|
|
if (plhost == NULL) {
|
|
|
|
|
q_dat.host[0] = 0;
|
|
|
|
|
q_dat.port[0] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
strncpy (q_dat.host, plhost, LEN_SERVERNAME);
|
|
|
|
|
strncpy (q_dat.port, plport, LEN_PORT);
|
|
|
|
@ -734,10 +751,12 @@ send_quit (_net_addr * addr, char *plhost, char *plport)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
do_quit (struct pkg_quit *q_dat, _net_addr * addr)
|
|
|
|
|
{
|
|
|
|
|
d_printf ("do_quit (%s:%s) pl_nr = %d\n", addr->host, addr->port, addr->pl_nr);
|
|
|
|
|
|
|
|
|
|
if (addr->pl_nr == -1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
@ -747,6 +766,7 @@ do_quit (struct pkg_quit *q_dat, _net_addr * addr)
|
|
|
|
|
else {
|
|
|
|
|
/* delete the player with the giving address */
|
|
|
|
|
int pl_nr = get_player_nr (q_dat->host, q_dat->port);
|
|
|
|
|
|
|
|
|
|
if (pl_nr == -1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
@ -754,14 +774,13 @@ do_quit (struct pkg_quit *q_dat, _net_addr * addr)
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
send_getfield (_net_addr * addr, int line)
|
|
|
|
|
{
|
|
|
|
|
struct pkg_getfield gf_dat;
|
|
|
|
|
|
|
|
|
|
gf_dat.h.typ = PKG_getfield;
|
|
|
|
|
gf_dat.h.len = sizeof (struct pkg_getfield);
|
|
|
|
|
gf_dat.h.len = HTON16 (sizeof (struct pkg_getfield));
|
|
|
|
|
gf_dat.h.flags = 0;
|
|
|
|
|
gf_dat.line = line;
|
|
|
|
|
send_pkg ((struct pkg *) &gf_dat, addr);
|
|
|
|
@ -783,7 +802,6 @@ do_getfield (struct pkg_getfield *gf_dat, _net_addr * addr)
|
|
|
|
|
bman.players[addr->pl_nr].net.net_istep = 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
send_fieldline (addr, gf_dat->line);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -796,7 +814,7 @@ send_fieldline (_net_addr * addr, int line)
|
|
|
|
|
struct pkg_fieldline f_dat;
|
|
|
|
|
|
|
|
|
|
f_dat.h.typ = PKG_fieldline;
|
|
|
|
|
f_dat.h.len = sizeof (struct pkg_fieldline);
|
|
|
|
|
f_dat.h.len = HTON16 (sizeof (struct pkg_fieldline));
|
|
|
|
|
f_dat.h.flags = 0;
|
|
|
|
|
f_dat.line = line;
|
|
|
|
|
|
|
|
|
@ -830,7 +848,6 @@ do_fieldline (struct pkg_fieldline *f_dat, _net_addr * addr)
|
|
|
|
|
d_printf ("do_fieldline: the data we have got are not from the server\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (f_dat->line < 0 || f_dat->line >= MAX_FIELDSIZE_Y) {
|
|
|
|
|
/* the line number is wrong */
|
|
|
|
|
d_printf ("do_fieldline: the line number is not correct\n");
|
|
|
|
@ -843,8 +860,8 @@ do_fieldline (struct pkg_fieldline *f_dat, _net_addr * addr)
|
|
|
|
|
for (i = 0; i < MAX_FIELDSIZE_X; i++) {
|
|
|
|
|
map.field[i][f_dat->line].type = f_dat->type[i];
|
|
|
|
|
map.field[i][f_dat->line].special = f_dat->special[i];
|
|
|
|
|
map.field[i][f_dat->line].frameto = 0;
|
|
|
|
|
map.field[i][f_dat->line].frame = 0;
|
|
|
|
|
map.field[i][f_dat->line].frameto = 0;
|
|
|
|
|
map.field[i][f_dat->line].frame = 0;
|
|
|
|
|
for (d = 0; d < 4; d++)
|
|
|
|
|
map.field[i][f_dat->line].ex[d].frame = map.field[i][f_dat->line].ex[d].count = 0;
|
|
|
|
|
}
|
|
|
|
@ -855,8 +872,9 @@ void
|
|
|
|
|
send_getplayerdata (_net_addr * addr, int pl)
|
|
|
|
|
{
|
|
|
|
|
struct pkg_getplayerdata gp_dat;
|
|
|
|
|
|
|
|
|
|
gp_dat.h.typ = PKG_getplayerdata;
|
|
|
|
|
gp_dat.h.len = sizeof (struct pkg_getplayerdata);
|
|
|
|
|
gp_dat.h.len = HTON16 (sizeof (struct pkg_getplayerdata));
|
|
|
|
|
gp_dat.pl_nr = pl;
|
|
|
|
|
gp_dat.h.flags = 0;
|
|
|
|
|
send_pkg ((struct pkg *) &gp_dat, addr);
|
|
|
|
@ -894,9 +912,8 @@ do_playerstatus (struct pkg_playerstatus *stat, _net_addr * addr)
|
|
|
|
|
d_printf ("do_playerstatus: the data we have got are not from the server\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stat->pl_nr < 0 || stat->pl_nr >= MAX_PLAYERS) {
|
|
|
|
|
/* the line number is wrong */
|
|
|
|
|
/* the player number is wrong */
|
|
|
|
|
d_printf ("do_playerstatus: playernumber not correct\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -906,8 +923,8 @@ do_playerstatus (struct pkg_playerstatus *stat, _net_addr * addr)
|
|
|
|
|
if (GT_MP_PTPM)
|
|
|
|
|
for (i = 0; i < MAX_PLAYERS; i++)
|
|
|
|
|
if (bman.players[i].net.addr.host[0] != 0)
|
|
|
|
|
send_playerstatus (&bman.players[i].net.addr, stat->pl_nr, stat->net_istep,
|
|
|
|
|
stat->status);
|
|
|
|
|
send_playerstatus (&bman.players[i].net.addr, stat->pl_nr,
|
|
|
|
|
stat->net_istep, stat->status);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -916,12 +933,12 @@ send_playerstatus (_net_addr * addr, int pl_nr, int net_istep, int status)
|
|
|
|
|
{
|
|
|
|
|
struct pkg_playerstatus stat;
|
|
|
|
|
|
|
|
|
|
d_printf ("send_playerstatus (%s,%s) %d, %d, %d\n", addr->host, addr->port, pl_nr, net_istep,
|
|
|
|
|
status);
|
|
|
|
|
d_printf ("send_playerstatus (%s,%s) %d, %d, %d\n", addr->host,
|
|
|
|
|
addr->port, pl_nr, net_istep, status);
|
|
|
|
|
|
|
|
|
|
stat.h.typ = PKG_playerstatus;
|
|
|
|
|
stat.h.flags = 0;
|
|
|
|
|
stat.h.len = sizeof (struct pkg_playerstatus);
|
|
|
|
|
stat.h.len = HTON16 (sizeof (struct pkg_playerstatus));
|
|
|
|
|
stat.pl_nr = pl_nr;
|
|
|
|
|
stat.net_istep = net_istep;
|
|
|
|
|
stat.status = status;
|
|
|
|
@ -948,7 +965,7 @@ send_chat (_net_addr * addr, char *text)
|
|
|
|
|
|
|
|
|
|
chat_pkg.h.typ = PKG_chat;
|
|
|
|
|
chat_pkg.h.flags = 0;
|
|
|
|
|
chat_pkg.h.len = sizeof (struct pkg_chat);
|
|
|
|
|
chat_pkg.h.len = HTON16 (sizeof (struct pkg_chat));
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof (chat_pkg.text); i++)
|
|
|
|
|
chat_pkg.text[i] = 0;
|
|
|
|
@ -965,8 +982,8 @@ send_pkgack (_net_addr * addr, unsigned char typ, short int id)
|
|
|
|
|
|
|
|
|
|
p_ack.h.typ = PKG_pkgack;
|
|
|
|
|
p_ack.h.flags = 0;
|
|
|
|
|
p_ack.h.len = sizeof (struct pkg_pkgack);
|
|
|
|
|
p_ack.id = id;
|
|
|
|
|
p_ack.h.len = HTON16 (sizeof (struct pkg_pkgack));
|
|
|
|
|
p_ack.id = HTON16 (id);
|
|
|
|
|
p_ack.typ = typ;
|
|
|
|
|
|
|
|
|
|
send_pkg ((struct pkg *) &p_ack, addr);
|
|
|
|
@ -977,7 +994,7 @@ void
|
|
|
|
|
do_pkgack (struct pkg_pkgack *p_ack, _net_addr * addr)
|
|
|
|
|
{
|
|
|
|
|
d_printf ("do_pkgack (%s:%s)\n", addr->host, addr->port);
|
|
|
|
|
if (rscache_getpos (addr, p_ack->typ, p_ack->id) == -1)
|
|
|
|
|
if (rscache_getpos (addr, p_ack->typ, NTOH16 (p_ack->id)) == -1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
rscache_del ();
|
|
|
|
@ -1000,7 +1017,7 @@ do_special (struct pkg_special *sp_pkg, _net_addr * addr)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bman.players[sp_pkg->pl_nr].special.type = sp_pkg->typ;
|
|
|
|
|
bman.last_ex_nr = sp_pkg->ex_nr;
|
|
|
|
|
bman.last_ex_nr = NTOH32 (sp_pkg->ex_nr);
|
|
|
|
|
special_use (sp_pkg->pl_nr);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -1011,11 +1028,11 @@ send_special (_net_addr * addr, int p_nr, int typ, int ex_nr)
|
|
|
|
|
struct pkg_special sp_dat;
|
|
|
|
|
|
|
|
|
|
sp_dat.h.typ = PKG_special;
|
|
|
|
|
sp_dat.h.len = sizeof (struct pkg_special);
|
|
|
|
|
sp_dat.h.len = HTON16 (sizeof (struct pkg_special));
|
|
|
|
|
sp_dat.h.flags = PKGF_ackreq;
|
|
|
|
|
sp_dat.pl_nr = p_nr;
|
|
|
|
|
sp_dat.typ = typ;
|
|
|
|
|
sp_dat.ex_nr = ex_nr;
|
|
|
|
|
sp_dat.ex_nr = HTON32 (ex_nr);
|
|
|
|
|
send_pkg ((struct pkg *) &sp_dat, addr);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -1027,10 +1044,10 @@ do_bcmservchat (struct pkg_bcmservchat *packet, _net_addr * addr)
|
|
|
|
|
if (strstr (packet->data, "BC:BC:") == packet->data)
|
|
|
|
|
return; // ignore packet
|
|
|
|
|
|
|
|
|
|
if (bman.notifygamemaster && bman.broadcasted_chat) {
|
|
|
|
|
chat_addline (packet->data);
|
|
|
|
|
net_send_chat (packet->data, 0);
|
|
|
|
|
}
|
|
|
|
|
if (bman.notifygamemaster && bman.broadcasted_chat) {
|
|
|
|
|
chat_addline (packet->data);
|
|
|
|
|
net_send_chat (packet->data, 0);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1040,58 +1057,58 @@ send_mapinfo (_net_addr * addr)
|
|
|
|
|
struct pkg_mapinfo map_pkg;
|
|
|
|
|
|
|
|
|
|
map_pkg.h.typ = PKG_mapinfo;
|
|
|
|
|
map_pkg.h.len = sizeof (struct pkg_mapinfo);
|
|
|
|
|
map_pkg.h.len = HTON16 (sizeof (struct pkg_mapinfo));
|
|
|
|
|
map_pkg.h.flags = PKGF_ackreq;
|
|
|
|
|
map_pkg.size_x = map.size.x;
|
|
|
|
|
map_pkg.size_y = map.size.y;
|
|
|
|
|
map_pkg.bombs = map.bombs;
|
|
|
|
|
map_pkg.fire = map.fire;
|
|
|
|
|
map_pkg.shoes = map.shoes;
|
|
|
|
|
map_pkg.mixed = map.mixed;
|
|
|
|
|
map_pkg.death = map.death;
|
|
|
|
|
map_pkg.sp_trigger = map.sp_trigger;
|
|
|
|
|
map_pkg.sp_row = map.sp_row;
|
|
|
|
|
map_pkg.sp_push = map.sp_push;
|
|
|
|
|
if (map.random_tileset)
|
|
|
|
|
map_pkg.tileset[0] = 0;
|
|
|
|
|
else
|
|
|
|
|
strcpy (map_pkg.tileset, map.tileset);
|
|
|
|
|
map_pkg.size_x = map.size.x;
|
|
|
|
|
map_pkg.size_y = map.size.y;
|
|
|
|
|
map_pkg.bombs = map.bombs;
|
|
|
|
|
map_pkg.fire = map.fire;
|
|
|
|
|
map_pkg.shoes = map.shoes;
|
|
|
|
|
map_pkg.mixed = map.mixed;
|
|
|
|
|
map_pkg.death = map.death;
|
|
|
|
|
map_pkg.sp_trigger = map.sp_trigger;
|
|
|
|
|
map_pkg.sp_row = map.sp_row;
|
|
|
|
|
map_pkg.sp_push = map.sp_push;
|
|
|
|
|
if (map.random_tileset)
|
|
|
|
|
map_pkg.tileset[0] = 0;
|
|
|
|
|
else
|
|
|
|
|
strcpy (map_pkg.tileset, map.tileset);
|
|
|
|
|
map_pkg.map_selection = map.map_selection;
|
|
|
|
|
strcpy (map_pkg.mapname, map.map);
|
|
|
|
|
strcpy (map_pkg.mapname, map.map);
|
|
|
|
|
|
|
|
|
|
send_pkg ((struct pkg *) &map_pkg, addr);
|
|
|
|
|
send_pkg ((struct pkg *) &map_pkg, addr);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
do_mapinfo (struct pkg_mapinfo *map_pkg, _net_addr * addr)
|
|
|
|
|
{
|
|
|
|
|
d_printf ("do_mapinfo (addr %d) size[%d,%d]\n", addr->pl_nr,map_pkg->size_x,map_pkg->size_y);
|
|
|
|
|
d_printf ("do_mapinfo (addr %d) size[%d,%d]\n", addr->pl_nr, map_pkg->size_x, map_pkg->size_y);
|
|
|
|
|
|
|
|
|
|
/* check if the server send this information */
|
|
|
|
|
/* check if the server send this information */
|
|
|
|
|
if (addr->pl_nr != 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (map_pkg->tileset[0] == 0) {
|
|
|
|
|
map.random_tileset = 1;
|
|
|
|
|
map.tileset[0] = 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
map.random_tileset = 0;
|
|
|
|
|
strcpy(map.tileset, map_pkg->tileset);
|
|
|
|
|
}
|
|
|
|
|
strcpy (map.map, map_pkg->mapname);
|
|
|
|
|
map.map_selection = map_pkg->map_selection;
|
|
|
|
|
map.size.x = map_pkg->size_x;
|
|
|
|
|
map.size.y = map_pkg->size_y;
|
|
|
|
|
map.bombs = map_pkg->bombs;
|
|
|
|
|
map.fire = map_pkg->fire;
|
|
|
|
|
map.shoes = map_pkg->shoes;
|
|
|
|
|
map.mixed = map_pkg->mixed;
|
|
|
|
|
map.death = map_pkg->death;
|
|
|
|
|
map.sp_trigger = map_pkg->sp_trigger;
|
|
|
|
|
map.sp_push = map_pkg->sp_push;
|
|
|
|
|
map.sp_row = map_pkg->sp_row;
|
|
|
|
|
if (map_pkg->tileset[0] == 0) {
|
|
|
|
|
map.random_tileset = 1;
|
|
|
|
|
map.tileset[0] = 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
map.random_tileset = 0;
|
|
|
|
|
strcpy (map.tileset, map_pkg->tileset);
|
|
|
|
|
}
|
|
|
|
|
strcpy (map.map, map_pkg->mapname);
|
|
|
|
|
map.map_selection = map_pkg->map_selection;
|
|
|
|
|
map.size.x = map_pkg->size_x;
|
|
|
|
|
map.size.y = map_pkg->size_y;
|
|
|
|
|
map.bombs = map_pkg->bombs;
|
|
|
|
|
map.fire = map_pkg->fire;
|
|
|
|
|
map.shoes = map_pkg->shoes;
|
|
|
|
|
map.mixed = map_pkg->mixed;
|
|
|
|
|
map.death = map_pkg->death;
|
|
|
|
|
map.sp_trigger = map_pkg->sp_trigger;
|
|
|
|
|
map.sp_push = map_pkg->sp_push;
|
|
|
|
|
map.sp_row = map_pkg->sp_row;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1115,7 +1132,6 @@ inpkg_check (unsigned char typ, short int id, _net_addr * addr)
|
|
|
|
|
inpkg_index[inpkg_index_pos].typ = typ;
|
|
|
|
|
inpkg_index[inpkg_index_pos].id = id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -1124,10 +1140,10 @@ inpkg_check (unsigned char typ, short int id, _net_addr * addr)
|
|
|
|
|
void
|
|
|
|
|
send_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
|
{
|
|
|
|
|
packet->h.id = pkg_lastid++;
|
|
|
|
|
packet->h.id = HTON16 (pkg_lastid++);
|
|
|
|
|
if (bman.net_ai_family != PF_INET)
|
|
|
|
|
packet->h.flags = packet->h.flags | PKGF_ipv6;
|
|
|
|
|
udp_send (bman.sock, (char *) packet, packet->h.len, &addr->sAddr, bman.net_ai_family);
|
|
|
|
|
udp_send (bman.sock, (char *) packet, NTOH16 (packet->h.len), &addr->sAddr, bman.net_ai_family);
|
|
|
|
|
|
|
|
|
|
/* test if we have any important packet if so put it in the resend_cache */
|
|
|
|
|
if (packet->h.flags & PKGF_ackreq) {
|
|
|
|
@ -1136,6 +1152,7 @@ send_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* forward the packet to all who are behind a firewall */
|
|
|
|
|
void
|
|
|
|
|
fwd_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
@ -1152,8 +1169,8 @@ fwd_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
|
for (pl = 1; pl < MAX_PLAYERS; pl++)
|
|
|
|
|
if (PS_IS_netplayer (bman.players[pl].state)
|
|
|
|
|
&& ((bman.players[pl].net.flags & NETF_firewall) == NETF_firewall
|
|
|
|
|
|| (bman.players[addr->pl_nr].net.flags & NETF_firewall) == NETF_firewall)
|
|
|
|
|
&& pl != addr->pl_nr)
|
|
|
|
|
|| (bman.players[addr->pl_nr].net.flags & NETF_firewall) ==
|
|
|
|
|
NETF_firewall) && pl != addr->pl_nr)
|
|
|
|
|
send_pkg (packet, &bman.players[pl].net.addr);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -1161,13 +1178,12 @@ fwd_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
|
int
|
|
|
|
|
do_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
|
{
|
|
|
|
|
if ((((packet->h.flags & PKGF_ipv6) == 0 && bman.net_ai_family != PF_INET) ||
|
|
|
|
|
((packet->h.flags & PKGF_ipv6) != 0 && bman.net_ai_family == PF_INET)) &&
|
|
|
|
|
packet->h.typ != PKG_bcmservchat) {
|
|
|
|
|
if ((((packet->h.flags & PKGF_ipv6) == 0 && bman.net_ai_family != PF_INET)
|
|
|
|
|
|| ((packet->h.flags & PKGF_ipv6) != 0 && bman.net_ai_family == PF_INET))
|
|
|
|
|
&& packet->h.typ != PKG_bcmservchat) {
|
|
|
|
|
d_printf ("-----packet comes from the wrong network type\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* get the addr and set the ping timeout value */
|
|
|
|
|
addr->pl_nr = get_player_nr (addr->host, addr->port);
|
|
|
|
|
bman.players[addr->pl_nr].net.timestamp = timestamp;
|
|
|
|
@ -1175,10 +1191,10 @@ do_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
|
|
|
|
|
|
/* test if we have any important packet */
|
|
|
|
|
if (packet->h.flags & PKGF_ackreq && packet->h.typ != PKG_bcmservchat)
|
|
|
|
|
send_pkgack (addr, packet->h.typ, packet->h.id);
|
|
|
|
|
send_pkgack (addr, packet->h.typ, NTOH16 (packet->h.id));
|
|
|
|
|
|
|
|
|
|
/* check the packet with the index */
|
|
|
|
|
if (packet->h.typ != PKG_bcmservchat && inpkg_check (packet->h.typ, packet->h.id, addr) != -1) {
|
|
|
|
|
if (packet->h.typ != PKG_bcmservchat && inpkg_check (packet->h.typ, NTOH16 (packet->h.id), addr) != -1) {
|
|
|
|
|
/* we have got this packet already */
|
|
|
|
|
d_printf ("-----packet ignored\n");
|
|
|
|
|
if (addr->pl_nr >= 0 && addr->pl_nr < MAX_PLAYERS)
|
|
|
|
@ -1187,7 +1203,7 @@ do_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* check if the incoming packet have the right size */
|
|
|
|
|
if (packet->h.typ == PKG_servermode && packet->h.len != sizeof (struct pkg_servermode))
|
|
|
|
|
if (packet->h.typ == PKG_servermode && NTOH16 (packet->h.len) != sizeof (struct pkg_servermode))
|
|
|
|
|
send_error (addr, "pkg_servermode: packetsize incorrect.");
|
|
|
|
|
|
|
|
|
|
/* forward packet */
|
|
|
|
@ -1253,12 +1269,12 @@ do_pkg (struct pkg *packet, _net_addr * addr)
|
|
|
|
|
case (PKG_special):
|
|
|
|
|
do_special ((struct pkg_special *) packet, addr);
|
|
|
|
|
break;
|
|
|
|
|
case (PKG_mapinfo):
|
|
|
|
|
do_mapinfo ((struct pkg_mapinfo *) packet, addr);
|
|
|
|
|
break;
|
|
|
|
|
case (PKG_tunneldata):
|
|
|
|
|
do_tunneldata ((struct pkg_tunneldata *) packet, addr);
|
|
|
|
|
break;
|
|
|
|
|
case (PKG_mapinfo):
|
|
|
|
|
do_mapinfo ((struct pkg_mapinfo *) packet, addr);
|
|
|
|
|
break;
|
|
|
|
|
case (PKG_tunneldata):
|
|
|
|
|
do_tunneldata ((struct pkg_tunneldata *) packet, addr);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
send_error (addr, "BomberClone: unknown data packet");
|
|
|
|
|
break;
|
|
|
|
|