foxygit / doom Log in
commit f6fdd54a5ffa22f7991490390d19a7fa386af03d
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Thu Feb 23 20:53:03 2006 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Thu Feb 23 20:53:03 2006 +0000

    Detect when clients are disconnected from the server, recover cleanly
    and display a message.

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 383
---
 src/net_client.c | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/src/net_client.c b/src/net_client.c
index a2198200..627561c4 100644
--- a/src/net_client.c
+++ b/src/net_client.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*-
 //-----------------------------------------------------------------------------
 //
-// $Id: net_client.c 382 2006-02-23 20:31:09Z fraggle $
+// $Id: net_client.c 383 2006-02-23 20:53:03Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -21,6 +21,10 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.31  2006/02/23 20:53:03  fraggle
+// Detect when clients are disconnected from the server, recover cleanly
+// and display a message.
+//
 // Revision 1.30  2006/02/23 20:31:09  fraggle
 // Set ticdup from the command line with the -dup parameter.
 //
@@ -279,6 +283,23 @@ static void NET_CL_PlayerQuitGame(player_t *player)
     }
 }

+// Called when we become disconnected from the server
+
+static void NET_CL_Disconnected(void)
+{
+    int i;
+
+    // disconnected from server
+
+    players[consoleplayer].message = "Disconnected from server";
+
+    for (i=0; i<MAXPLAYERS; ++i)
+    {
+        if (i != consoleplayer)
+            playeringame[i] = false;
+    }
+}
+
 // Expand a net_full_ticcmd_t, applying the diffs in cmd->cmds as
 // patches against recvwindow_cmd_base.  Place the results into
 // the d_net.c structures (netcmds/nettics) and save the new ticcmd
@@ -385,8 +406,6 @@ void NET_CL_StartGame(void)
     else
         settings.ticdup = 1;

-
-
     // Start from a ticcmd of all zeros

     memset(&last_ticcmd, 0, sizeof(ticcmd_t));
@@ -888,8 +907,8 @@ void NET_CL_Run(void)
     if (client_connection.state == NET_CONN_STATE_DISCONNECTED
      || client_connection.state == NET_CONN_STATE_DISCONNECTED_SLEEP)
     {
-        // disconnected from server
-
+        NET_CL_Disconnected();
+
         NET_CL_Shutdown();
     }