Clears all connections Server and Client
| 843 | // Clears all connections |
| 844 | // Server and Client |
| 845 | void MultiCloseGame() { |
| 846 | mprintf(0, "Multi close game!\n"); |
| 847 | |
| 848 | if (!(Game_mode & GM_NETWORK)) { |
| 849 | mprintf(0, "Not network game!\n"); |
| 850 | return; |
| 851 | } |
| 852 | |
| 853 | #if !defined(RELEASE) |
| 854 | // Write our packet tracking |
| 855 | CFILE *outfile; |
| 856 | outfile = cfopen("PacketTracking", "wt"); |
| 857 | if (!outfile) { |
| 858 | mprintf(0, "Couldn't open packet tracking file!\n"); |
| 859 | } else { |
| 860 | for (int i = 0; i < 255; i++) { |
| 861 | cfprintf(outfile, "Packet %d = %d\n", i, Multi_packet_tracking[i]); |
| 862 | } |
| 863 | cfclose(outfile); |
| 864 | } |
| 865 | #endif |
| 866 | |
| 867 | Sleep(1000); // Sleep for one second |
| 868 | |
| 869 | if (Netgame.local_role == LR_SERVER) { |
| 870 | int i; |
| 871 | |
| 872 | for (i = 0; i < MAX_NET_PLAYERS; i++) { |
| 873 | if (i == Player_num) |
| 874 | continue; |
| 875 | |
| 876 | if (NetPlayers[i].flags & NPF_CONNECTED) { |
| 877 | MultiDisconnectPlayer(i); |
| 878 | } |
| 879 | } |
| 880 | |
| 881 | for (i = 0; i < 100; i++) { |
| 882 | nw_DoNetworkIdle(); |
| 883 | Sleep(10); |
| 884 | } |
| 885 | |
| 886 | NetPlayers[Player_num].flags &= ~NPF_CONNECTED; |
| 887 | MultiFlushAllIncomingBuffers(); |
| 888 | } else { |
| 889 | if (NetPlayers[Player_num].flags & NPF_CONNECTED) { |
| 890 | MultiFlushAllIncomingBuffers(); |
| 891 | nw_CloseSocket(&NetPlayers[Player_num].reliable_socket); |
| 892 | NetPlayers[Player_num].flags &= ~NPF_CONNECTED; |
| 893 | } |
| 894 | } |
| 895 | |
| 896 | Game_mode &= ~GM_MULTI; |
| 897 | if (Player_num != 0 && Player_object) |
| 898 | SetObjectControlType(Player_object, CT_NONE); |
| 899 | Player_num = 0; |
| 900 | Player_object = Viewer_object = &Objects[Players[0].objnum]; |
| 901 | } |
| 902 |
no test coverage detected