Improved handling of multi level sync and exit smoothly back to the menus; Fixed another small bug in lite_info broadcasting which was sending full info; By broadcasting full info, host could cripple Netgame so a new security measure is implemented to protect host from letting his game be overwritten from outside

This commit is contained in:
zicodxx 2010-06-29 20:51:38 +00:00
parent 97e20ee74c
commit 47091a3d5e
3 changed files with 26 additions and 25 deletions

View file

@ -4,6 +4,7 @@ D1X-Rebirth Changelog
--------
main/net_ipx.c, main/net_udp.c: Aligned default width for IPX-Netlist menu to fit possible items a bit better; Fixed two small bugs when sending and receiving lite_info in UDP; Allowed broadcast on UDP sockets (for later use)
main/menu.c, main/new_udp.c, main/net_udp.h: Added UDP Netlist to join LAN games discovered/announced via broadcast
main/net_ipx.c, main/net_udp.c: Improved handling of multi level sync and exit smoothly back to the menus; Fixed another small bug in lite_info broadcasting which was sending full info; By broadcasting full info, host could cripple Netgame so a new security measure is implemented to protect host from letting his game be overwritten from outside
20100627
--------

View file

@ -2748,8 +2748,6 @@ net_ipx_send_sync(void)
if (NumNetPlayerPositions < MaxNumNetPlayers) {
nm_messagebox(TXT_ERROR, 1, TXT_OK, "Not enough start positions\n(need %d got %d)\nNetgame aborted", MaxNumNetPlayers, NumNetPlayerPositions);
net_ipx_abort_game();
if (Game_wind)
window_close(Game_wind);
return -1;
}
@ -3334,8 +3332,7 @@ int net_ipx_request_poll( newmenu *menu, d_event *event, void *userdata )
return 0;
}
void
net_ipx_wait_for_requests(void)
int net_ipx_wait_for_requests(void)
{
// Wait for other players to load the level before we send the sync
int choice, i;
@ -3358,7 +3355,7 @@ menu:
// User aborted
choice = nm_messagebox(NULL, 3, TXT_YES, TXT_NO, TXT_START_NOWAIT, TXT_QUITTING_NOW);
if (choice == 2)
return;
return 0;
if (choice != 0)
goto menu;
@ -3368,11 +3365,12 @@ menu:
if ((Players[i].connected != CONNECT_DISCONNECTED) && (i != Player_num))
net_ipx_dump_player(Netgame.players[i].protocol.ipx.server, Netgame.players[i].protocol.ipx.node, DUMP_ABORTED);
if (Game_wind)
window_close(Game_wind);
return -1;
}
else if (choice != -2)
goto menu;
return 0;
}
int
@ -3380,7 +3378,7 @@ net_ipx_level_sync(void)
{
// Do required syncing between (before) levels
int result;
int result = 0;
MySyncPackInitialized = 0;
@ -3392,10 +3390,9 @@ net_ipx_level_sync(void)
result = net_ipx_wait_for_sync();
else if (multi_i_am_master())
{
net_ipx_wait_for_requests();
result = net_ipx_send_sync();
if (result)
return -1;
result = net_ipx_wait_for_requests();
if (!result)
result = net_ipx_send_sync();
}
else
result = net_ipx_wait_for_sync();
@ -3406,6 +3403,8 @@ net_ipx_level_sync(void)
net_ipx_send_endlevel_packet();
if (Game_wind)
window_close(Game_wind);
show_menus();
return -1;
}
return(0);
}

View file

@ -2197,6 +2197,8 @@ void net_udp_process_packet(ubyte *data, struct _sockaddr sender_addr, int lengt
break;
}
case UPID_GAME_INFO:
if (multi_i_am_master())
break;
net_udp_process_game_info(data, length, sender_addr, 0);
break;
case UPID_GAME_INFO_LITE_REQ:
@ -3104,8 +3106,6 @@ int net_udp_send_sync(void)
net_udp_send_game_info(Netgame.players[i].protocol.udp.addr, UPID_GAME_INFO);
}
net_udp_send_game_info(GBcast, UPID_GAME_INFO_LITE);
if (Game_wind)
window_close(Game_wind);
return -1;
}
@ -3469,8 +3469,7 @@ int net_udp_request_poll( newmenu *menu, d_event *event, void *userdata )
return 0;
}
void
net_udp_wait_for_requests(void)
int net_udp_wait_for_requests(void)
{
// Wait for other players to load the level before we send the sync
int choice, i;
@ -3493,7 +3492,7 @@ menu:
// User aborted
choice = nm_messagebox(NULL, 3, TXT_YES, TXT_NO, TXT_START_NOWAIT, TXT_QUITTING_NOW);
if (choice == 2)
return;
return 0;
if (choice != 0)
goto menu;
@ -3503,11 +3502,12 @@ menu:
if ((Players[i].connected != CONNECT_DISCONNECTED) && (i != Player_num))
net_udp_dump_player(Netgame.players[i].protocol.udp.addr, DUMP_ABORTED);
if (Game_wind)
window_close(Game_wind);
return -1;
}
else if (choice != -2)
goto menu;
return 0;
}
int
@ -3515,7 +3515,7 @@ net_udp_level_sync(void)
{
// Do required syncing between (before) levels
int result;
int result = 0;
memset(&UDP_MData, 0, sizeof(UDP_mdata_info));
net_udp_noloss_init_mdata_queue();
@ -3528,10 +3528,9 @@ net_udp_level_sync(void)
result = net_udp_wait_for_sync();
else if (multi_i_am_master())
{
net_udp_wait_for_requests();
result = net_udp_send_sync();
if (result)
return -1;
result = net_udp_wait_for_requests();
if (!result)
result = net_udp_send_sync();
}
else
result = net_udp_wait_for_sync();
@ -3542,6 +3541,8 @@ net_udp_level_sync(void)
net_udp_send_endlevel_packet();
if (Game_wind)
window_close(Game_wind);
show_menus();
return -1;
}
return(0);
}
@ -3778,7 +3779,7 @@ void net_udp_do_frame(int force, int listen)
if (time>=last_bcast_time+(F1_0*10) || (time < last_bcast_time))
{
last_bcast_time = time;
net_udp_send_game_info(GBcast, UPID_GAME_INFO);
net_udp_send_game_info(GBcast, UPID_GAME_INFO_LITE);
}
if (listen)