Improved hanlding for closing sockets - doing via closing of Game_wind when available or in specific multi menus; Also handling GM_GAME_OVER setting over Game_wind closing as well if apprpriate - cleaner and helps to cleanup multi when mission is over

This commit is contained in:
zicodxx 2010-07-08 09:35:59 +00:00
parent cb1b0bdb26
commit 1093aa0d07
6 changed files with 14 additions and 17 deletions

View file

@ -3,6 +3,7 @@ D2X-Rebirth Changelog
20100708
--------
main/net_udp.c, main/net_udp.h: Reworked handling of Netlist now also showing full game info; Prevent Clients from sending lite_info; Make lite_info show numconnected instead of numplayers as this would show disconnected ones as well; Removed reusing ports on different instances in Windows build - only screws up several games running on one machine
main/game.c, main/gameseq.c, main/multi.c, main/net_udp.c, main/net_ipx.c: Improved hanlding for closing sockets - doing via closing of Game_wind when available or in specific multi menus; Also handling GM_GAME_OVER setting over Game_wind closing as well if apprpriate - cleaner and helps to cleanup multi when mission is over
20100705
--------

View file

@ -1279,6 +1279,7 @@ int game_handler(window *wind, d_event *event, void *data)
clear_warn_func(game_show_warning); //don't use this func anymore
game_disable_cheats();
Game_mode = GM_GAME_OVER;
show_menus();
Game_wind = NULL;
return 0; // continue closing

View file

@ -515,7 +515,6 @@ void DoGameOver()
if (PLAYING_BUILTIN_MISSION)
scores_maybe_add_player(0);
Game_mode = GM_GAME_OVER;
if (Game_wind)
window_close(Game_wind); // Exit out of game loop
}
@ -1347,9 +1346,6 @@ void DoEndGame(void)
scores_maybe_add_player(0);
}
Game_mode = GM_GAME_OVER;
if (Game_wind)
window_close(Game_wind); // Exit out of game loop
}

View file

@ -982,8 +982,6 @@ multi_leave_game(void)
break;
}
}
Game_mode |= GM_GAME_OVER;
}
void

View file

@ -3907,9 +3907,11 @@ int net_ipx_join_poll( newmenu *menu, d_event *event, void *menu_text )
case EVENT_WINDOW_CLOSE:
d_free(menu_text);
d_free(menus);
ipxdrv_close();
if (!Game_wind)
{
ipxdrv_close();
Network_status = NETSTAT_MENU; // they cancelled
}
break;
default:
@ -4067,10 +4069,10 @@ net_ipx_level_sync(void)
{
Players[Player_num].connected = CONNECT_DISCONNECTED;
net_ipx_send_endlevel_packet();
ipxdrv_close();
if (Game_wind)
window_close(Game_wind);
show_menus();
ipxdrv_close();
return -1;
}
return(0);
@ -4389,7 +4391,6 @@ void net_ipx_leave_game()
Players[Player_num].connected = CONNECT_DISCONNECTED;
net_ipx_send_endlevel_packet();
change_playernum_to(0);
Game_mode = GM_GAME_OVER;
write_player_file();
net_ipx_flush();

View file

@ -470,6 +470,8 @@ static int manual_join_game_handler(newmenu *menu, d_event *event, direct_join *
}
case EVENT_WINDOW_CLOSE:
if (!Game_wind) // they cancelled
net_udp_close();
d_free(dj);
break;
@ -484,7 +486,7 @@ void net_udp_manual_join_game()
{
direct_join *dj;
newmenu_item m[7];
int nitems = 0, i = 0;
int nitems = 0;
MALLOC(dj, direct_join, 1);
if (!dj)
@ -518,9 +520,7 @@ void net_udp_manual_join_game()
m[nitems].type = NM_TYPE_INPUT; m[nitems].text=UDP_MyPort; m[nitems].text_len=5; nitems++;
m[nitems].type = NM_TYPE_TEXT; m[nitems].text=blank; nitems++; // for connecting_txt
i = newmenu_do1( NULL, "ENTER GAME ADDRESS", nitems, m, (int (*)(newmenu *, d_event *, void *))manual_join_game_handler, dj, 0 );
if (i != -2)
net_udp_close();
newmenu_do1( NULL, "ENTER GAME ADDRESS", nitems, m, (int (*)(newmenu *, d_event *, void *))manual_join_game_handler, dj, 0 );
}
static char *ljtext = "";
@ -607,9 +607,11 @@ int net_udp_list_join_poll( newmenu *menu, d_event *event, direct_join *dj )
d_free(ljtext);
d_free(menus);
d_free(dj);
net_udp_close();
if (!Game_wind)
{
net_udp_close();
Network_status = NETSTAT_MENU; // they cancelled
}
break;
default:
@ -1045,7 +1047,6 @@ net_udp_disconnect_player(int playernum)
multi_quit_game = 1;
game_leave_menus();
multi_reset_stuff();
net_udp_close();
}
}
@ -3842,10 +3843,10 @@ net_udp_level_sync(void)
{
Players[Player_num].connected = CONNECT_DISCONNECTED;
net_udp_send_endlevel_packet();
net_udp_close();
if (Game_wind)
window_close(Game_wind);
show_menus();
net_udp_close();
return -1;
}
return(0);
@ -3954,7 +3955,6 @@ void net_udp_leave_game()
Players[Player_num].connected = CONNECT_DISCONNECTED;
net_udp_send_endlevel_packet();
change_playernum_to(0);
Game_mode = GM_GAME_OVER;
write_player_file();
net_udp_flush();