|
|
@ -21,14 +21,12 @@ struct _inpkg_index inpkg_index[PKG_IN_INDEX_NUM];
|
|
|
|
int inpkg_index_pos = 0;
|
|
|
|
int inpkg_index_pos = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
/*
|
|
|
|
*** help function to get the playernumber from the address.
|
|
|
|
* help function to get the playernumber from the address.
|
|
|
|
*** this function does not indicate which player it is, this function only checks
|
|
|
|
* this function does not indicate which player it is, this function only checks
|
|
|
|
*** if the packet comed from a known player
|
|
|
|
* if the packet comed from a known player
|
|
|
|
***/
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
int get_player_nr (char *host, char *port) {
|
|
|
|
get_player_nr (char *host, char *port)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i,
|
|
|
|
int i,
|
|
|
|
res;
|
|
|
|
res;
|
|
|
|
|
|
|
|
|
|
|
@ -42,12 +40,10 @@ get_player_nr (char *host, char *port)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
/*
|
|
|
|
*** Packettype: error
|
|
|
|
* Packettype: error
|
|
|
|
***/
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
void send_error (_net_addr * addr, char *text) {
|
|
|
|
send_error (_net_addr * addr, char *text)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
struct pkg_error p_err;
|
|
|
|
struct pkg_error p_err;
|
|
|
|
|
|
|
|
|
|
|
|
d_printf ("Send Network Error : %s\n", text);
|
|
|
|
d_printf ("Send Network Error : %s\n", text);
|
|
|
@ -61,9 +57,7 @@ send_error (_net_addr * addr, char *text)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void do_error (struct pkg_error *data, _net_addr * addr) {
|
|
|
|
do_error (struct pkg_error *data, _net_addr * addr)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
d_printf ("Network Error from %s:%s : '%s'\n", addr->host, addr->port, data->text);
|
|
|
|
d_printf ("Network Error from %s:%s : '%s'\n", addr->host, addr->port, data->text);
|
|
|
|
|
|
|
|
|
|
|
|
/* check if the packet comes from the server, the server
|
|
|
|
/* check if the packet comes from the server, the server
|
|
|
@ -78,19 +72,17 @@ do_error (struct pkg_error *data, _net_addr * addr)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
/*
|
|
|
|
*** Packettype: joingame
|
|
|
|
* Packettype: joingame
|
|
|
|
*** client sends this to the server if he want's to join
|
|
|
|
* client sends this to the server if he want's to join
|
|
|
|
***
|
|
|
|
*
|
|
|
|
*** 1) check if this package comes from a already joined and known player
|
|
|
|
* 1) check if this package comes from a already joined and known player
|
|
|
|
*** if so: just send the current playerlist back.
|
|
|
|
* if so: just send the current playerlist back.
|
|
|
|
*** else:
|
|
|
|
* else:
|
|
|
|
*** 2) find free playerslot and add the player there
|
|
|
|
* 2) find free playerslot and add the player there
|
|
|
|
*** 3) send to all players the new playerid
|
|
|
|
* 3) send to all players the new playerid
|
|
|
|
***/
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
void do_joingame (struct pkg_joingame *p_jg, _net_addr * addr) {
|
|
|
|
do_joingame (struct pkg_joingame *p_jg, _net_addr * addr)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_player *pl;
|
|
|
|
_player *pl;
|
|
|
|
int i,
|
|
|
|
int i,
|
|
|
|
vma,
|
|
|
|
vma,
|
|
|
@ -208,9 +200,7 @@ do_joingame (struct pkg_joingame *p_jg, _net_addr * addr)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void send_joingame (_net_addr * addr, char *name, int secondplayer) {
|
|
|
|
send_joingame (_net_addr * addr, char *name, int secondplayer)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
struct pkg_joingame p_jg;
|
|
|
|
struct pkg_joingame p_jg;
|
|
|
|
int vmi,
|
|
|
|
int vmi,
|
|
|
|
vma,
|
|
|
|
vma,
|
|
|
@ -999,12 +989,10 @@ do_playermove (struct pkg_playermove *p_dat, _net_addr * addr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
/*
|
|
|
|
*** Packettype: bombdata
|
|
|
|
* Packettype: bombdata
|
|
|
|
***/
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
void do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr) {
|
|
|
|
do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_bomb *bomb;
|
|
|
|
_bomb *bomb;
|
|
|
|
|
|
|
|
|
|
|
|
if (addr->pl_nr == -1)
|
|
|
|
if (addr->pl_nr == -1)
|
|
|
@ -1057,6 +1045,11 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr)
|
|
|
|
bomb->r = b_dat->r;
|
|
|
|
bomb->r = b_dat->r;
|
|
|
|
bomb->ex_nr = NTOH32 (b_dat->ex_nr);
|
|
|
|
bomb->ex_nr = NTOH32 (b_dat->ex_nr);
|
|
|
|
bomb->state = b_dat->state & 0x0F;
|
|
|
|
bomb->state = b_dat->state & 0x0F;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bomb->mode != b_dat->state >> 4) { // bombmode changed set source to current position
|
|
|
|
|
|
|
|
bomb->source.x = bomb->pos.x;
|
|
|
|
|
|
|
|
bomb->source.y = bomb->pos.y;
|
|
|
|
|
|
|
|
}
|
|
|
|
bomb->mode = b_dat->state >> 4;
|
|
|
|
bomb->mode = b_dat->state >> 4;
|
|
|
|
bomb->fdata = I16TOF (NTOH16 (b_dat->fdata));
|
|
|
|
bomb->fdata = I16TOF (NTOH16 (b_dat->fdata));
|
|
|
|
bomb->dest.x = NTOH16 (b_dat->destx);
|
|
|
|
bomb->dest.x = NTOH16 (b_dat->destx);
|
|
|
@ -1535,9 +1528,7 @@ do_dropitems (struct pkg_dropitem *di_pkg, _net_addr * addr)
|
|
|
|
*** Packettype: special
|
|
|
|
*** Packettype: special
|
|
|
|
*** moves/bombs... whatever will be send as we use it
|
|
|
|
*** moves/bombs... whatever will be send as we use it
|
|
|
|
***/
|
|
|
|
***/
|
|
|
|
void
|
|
|
|
void do_special (struct pkg_special *sp_pkg, _net_addr * addr) {
|
|
|
|
do_special (struct pkg_special *sp_pkg, _net_addr * addr)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
d_printf ("do_special (addr %d, pl_nr %d, typ %d)\n", addr->pl_nr, sp_pkg->pl_nr, sp_pkg->typ);
|
|
|
|
d_printf ("do_special (addr %d, pl_nr %d, typ %d)\n", addr->pl_nr, sp_pkg->pl_nr, sp_pkg->typ);
|
|
|
|
if (addr->pl_nr == -1 || sp_pkg->pl_nr == -1 || sp_pkg->pl_nr == bman.p_nr
|
|
|
|
if (addr->pl_nr == -1 || sp_pkg->pl_nr == -1 || sp_pkg->pl_nr == bman.p_nr
|
|
|
|
|| sp_pkg->pl_nr == bman.p2_nr)
|
|
|
|
|| sp_pkg->pl_nr == bman.p2_nr)
|
|
|
@ -1550,9 +1541,9 @@ do_special (struct pkg_special *sp_pkg, _net_addr * addr)
|
|
|
|
special_use (sp_pkg->pl_nr);
|
|
|
|
special_use (sp_pkg->pl_nr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* cleas special */
|
|
|
|
/* clear special */
|
|
|
|
else if (sp_pkg->typ == SP_clear)
|
|
|
|
else if (sp_pkg->typ == SP_clear)
|
|
|
|
special_clear (sp_pkg->pl_nr);
|
|
|
|
players[sp_pkg->pl_nr].special.clear = 1;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|