Removing reset of Game_screen_mode while change_res Fullscreen toggle (wtf is the point?); Adding a third valid state for UDP peers so we can get more order in handshaking process - should fix problem when two clients join (and shake) simultaniously

This commit is contained in:
zicodxx 2008-10-22 15:31:24 +00:00
parent b2fbaf7829
commit a26e5e3284
4 changed files with 15 additions and 6 deletions

View file

@ -1,5 +1,9 @@
D1X-Rebirth Changelog
20081022
--------
main/menu.c, main/netdrv_udp.c, main/netdrv_udp.h: Removing reset of Game_screen_mode while change_res Fullscreen toggle (wtf is the point?); Adding a third valid state for UDP peers so we can get more order in handshaking process - should fix problem when two clients join (and shake) simultaniously
20081021
--------
iff/iff.c, main/inferno.c: Fix some gcc 4.0 warnings (-wall flag)

View file

@ -483,6 +483,7 @@ void change_res()
u_int32_t screen_mode = 0, aspect_mode = 0;
// the list of pre-defined resolutions
// TODO: You know, since we currently have SDL, we could use it to build a list of supported resolutions
m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x200 (16x10)"; m[mc].value = (Game_screen_mode == SM(320,200)); m[mc].group = 0; modes[mc] = SM(320,200); mc++;
m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x480 (4x3)"; m[mc].value = (Game_screen_mode == SM(640,480)); m[mc].group = 0; modes[mc] = SM(640,480); mc++;
m[mc].type = NM_TYPE_RADIO; m[mc].text = "800x600 (4x3)"; m[mc].value = (Game_screen_mode == SM(800,600)); m[mc].group = 0; modes[mc] = SM(800,600); mc++;
@ -519,10 +520,7 @@ void change_res()
// now check for fullscreen toggle and apply if necessary
if (m[fullscreenc].value != gr_check_fullscreen())
{
gr_toggle_fullscreen();
Game_screen_mode = -1;
}
// check which preset field was selected
for (i = 0; (m[i].value == 0) && (i < num_presets); i++);

View file

@ -169,6 +169,7 @@ int UDPHandshakeFrame(struct _sockaddr *sAddr, char *inbuf)
{
checkid=i;
UDPPeers[checkid].valid=2;
break;
}
}
@ -181,7 +182,7 @@ int UDPHandshakeFrame(struct _sockaddr *sAddr, char *inbuf)
// send Handshake init to all valid players except the new one (checkid)
for (i=1; i<MAX_CONNECTIONS; i++)
{
if (UDPPeers[i].valid>1 && i != checkid && !UDPPeers[i].relay && UDPPeers[i].hs_list[0] && memcmp(sAddr,(struct sockaddr*)&UDPPeers[i].addr,sizeof(struct _sockaddr)))
if (UDPPeers[i].valid == 3 && i != checkid && !UDPPeers[i].relay && memcmp(sAddr,(struct sockaddr*)&UDPPeers[i].addr,sizeof(struct _sockaddr)))
{
char outbuf[6+sizeof(struct _sockaddr)];
@ -193,10 +194,14 @@ int UDPHandshakeFrame(struct _sockaddr *sAddr, char *inbuf)
}
}
// check if that client is already fully joined
if (UDPPeers[checkid].valid == 3)
return 1;
// Now check if Handshake was successful on requesting player - if not, return 0
for (i=1; i<MAX_CONNECTIONS; i++)
{
if (UDPPeers[i].valid>1 && memcmp(sAddr,(struct _sockaddr *)&UDPPeers[i].addr,sizeof(struct _sockaddr)))
if (UDPPeers[i].valid == 3 && memcmp(sAddr,(struct _sockaddr *)&UDPPeers[i].addr,sizeof(struct _sockaddr)))
{
if (UDPPeers[checkid].hs_list[i] != 1 && !UDPPeers[i].relay)
{
@ -207,6 +212,7 @@ int UDPHandshakeFrame(struct _sockaddr *sAddr, char *inbuf)
con_printf(CON_NORMAL,"UDP: Relaying Client #%i over Host\n",checkid);
UDPPeers[checkid].relay=1;
memset(UDPPeers[checkid].hs_list,1,MAX_CONNECTIONS);
UDPPeers[checkid].valid=3;
return 1;
}
}
@ -219,6 +225,7 @@ int UDPHandshakeFrame(struct _sockaddr *sAddr, char *inbuf)
// Set all vals to true since this could be the first client in our list that had no need to Handshake.
// However in that case this should be true for the next client joning
memset(UDPPeers[checkid].hs_list,1,MAX_CONNECTIONS);
UDPPeers[checkid].valid=3;
return 1;
}

View file

@ -52,7 +52,7 @@
typedef struct peer_list
{
struct _sockaddr addr; // real address information about this peer
int valid; // 1 = client connected / 2 = client ready for handshaking
int valid; // 1 = client connected / 2 = client ready for handshaking / 3 = client done with handshake and fully joined
fix timestamp; // time of received packet - used for timeout
char hs_list[MAX_CONNECTIONS]; // list to store all handshake results from clients assigned to this peer
int hstimeout; // counts the number of tries the client tried to connect - if reached 10, client put to relay if allowed