[chocolate-doom] 50/79: Send clients their player number, and indicate on the waiting screen which client we are.

Jonathan Dowland jmtd at moszumanska.debian.org
Mon Jan 30 15:07:24 UTC 2017


This is an automated email from the git hooks/post-receive script.

jmtd pushed a commit to annotated tag chocolate-doom-0.1.3
in repository chocolate-doom.

commit fc969e4981a2365304f88e664d625c3a07d57bee
Author: Simon Howard <fraggle at gmail.com>
Date:   Mon Jan 9 02:03:39 2006 +0000

    Send clients their player number, and indicate on the waiting screen
    which client we are.
    
    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 278
---
 src/net_client.c | 20 ++++++++++++++++----
 src/net_client.h |  7 ++++++-
 src/net_gui.c    | 14 ++++++++++++--
 src/net_server.c | 35 ++++++++++++++++++++++++++++++++++-
 4 files changed, 68 insertions(+), 8 deletions(-)

diff --git a/src/net_client.c b/src/net_client.c
index da29d86..eae95cc 100644
--- a/src/net_client.c
+++ b/src/net_client.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: net_client.c 277 2006-01-09 01:50:51Z fraggle $
+// $Id: net_client.c 278 2006-01-09 02:03:39Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -21,6 +21,10 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.15  2006/01/09 02:03:39  fraggle
+// Send clients their player number, and indicate on the waiting screen
+// which client we are.
+//
 // Revision 1.14  2006/01/09 01:50:51  fraggle
 // Deduce a sane player name by examining environment variables.  Add
 // a "player_name" setting to chocolate-doom.cfg.  Transmit the name
@@ -124,6 +128,10 @@ int net_clients_in_game;
 char net_player_addresses[MAXPLAYERS][MAXPLAYERNAME];
 char net_player_names[MAXPLAYERS][MAXPLAYERNAME];
 
+// Player number
+
+int net_player_number;
+
 // Waiting for the game to start?
 
 boolean net_waiting_for_start = false;
@@ -152,21 +160,24 @@ static void NET_CL_ParseWaitingData(net_packet_t *packet)
 {
     unsigned int num_players;
     unsigned int is_controller;
+    unsigned int player_number;
     char *player_names[MAXPLAYERS];
     char *player_addr[MAXPLAYERS];
     int i;
 
     if (!NET_ReadInt8(packet, &num_players)
-     || !NET_ReadInt8(packet, &is_controller))
+     || !NET_ReadInt8(packet, &is_controller)
+     || !NET_ReadInt8(packet, &player_number))
     {
         // invalid packet
 
         return;
     }
 
-    if (num_players > MAXPLAYERS)
+    if (num_players > MAXPLAYERS 
+     || player_number >= num_players)
     {
-        // Invalid number of players
+        // insane data
 
         return;
     }
@@ -186,6 +197,7 @@ static void NET_CL_ParseWaitingData(net_packet_t *packet)
 
     net_clients_in_game = num_players;
     net_client_controller = is_controller != 0;
+    net_player_number = player_number;
 
     for (i=0; i<num_players; ++i)
     {
diff --git a/src/net_client.h b/src/net_client.h
index 573eae3..80ea111 100644
--- a/src/net_client.h
+++ b/src/net_client.h
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: net_client.h 277 2006-01-09 01:50:51Z fraggle $
+// $Id: net_client.h 278 2006-01-09 02:03:39Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -21,6 +21,10 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.9  2006/01/09 02:03:39  fraggle
+// Send clients their player number, and indicate on the waiting screen
+// which client we are.
+//
 // Revision 1.8  2006/01/09 01:50:51  fraggle
 // Deduce a sane player name by examining environment variables.  Add
 // a "player_name" setting to chocolate-doom.cfg.  Transmit the name
@@ -78,6 +82,7 @@ extern int net_clients_in_game;
 extern boolean net_waiting_for_start;
 extern char net_player_names[MAXPLAYERS][MAXPLAYERNAME];
 extern char net_player_addresses[MAXPLAYERS][MAXPLAYERNAME];
+extern int net_player_number;
 extern char *net_player_name;
 
 #endif /* #ifndef NET_CLIENT_H */
diff --git a/src/net_gui.c b/src/net_gui.c
index 4bead8c..daa7b71 100644
--- a/src/net_gui.c
+++ b/src/net_gui.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: net_gui.c 273 2006-01-08 17:52:45Z fraggle $
+// $Id: net_gui.c 278 2006-01-09 02:03:39Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -21,6 +21,10 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.6  2006/01/09 02:03:39  fraggle
+// Send clients their player number, and indicate on the waiting screen
+// which client we are.
+//
 // Revision 1.5  2006/01/08 17:52:45  fraggle
 // Play some random music for the players while waiting for the game to
 // start.
@@ -107,7 +111,13 @@ static void Drawer(void)
     for (i=0; i<net_clients_in_game; ++i)
     {
         V_DrawPatch(32, y, 0, player_backdrops[i]);
-        V_DrawPatch(32, y, 0, player_face);
+
+        // draw the face to indicate which one we are
+
+        if (i == net_player_number)
+        {
+            V_DrawPatch(32, y, 0, player_face);
+        }
         M_WriteText(80, y+12, net_player_names[i]);
         M_WriteText(200, y+12, net_player_addresses[i]);
         y += 32;
diff --git a/src/net_server.c b/src/net_server.c
index 070d6b6..4ed2e2b 100644
--- a/src/net_server.c
+++ b/src/net_server.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: net_server.c 277 2006-01-09 01:50:51Z fraggle $
+// $Id: net_server.c 278 2006-01-09 02:03:39Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -21,6 +21,10 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.18  2006/01/09 02:03:39  fraggle
+// Send clients their player number, and indicate on the waiting screen
+// which client we are.
+//
 // Revision 1.17  2006/01/09 01:50:51  fraggle
 // Deduce a sane player name by examining environment variables.  Add
 // a "player_name" setting to chocolate-doom.cfg.  Transmit the name
@@ -168,6 +172,31 @@ static int NET_SV_NumClients(void)
     return count;
 }
 
+// Returns the index of a particular client in the list of connected
+// clients.
+
+static int NET_SV_ClientIndex(net_client_t *client)
+{
+    int count;
+    int i;
+
+    count = 0;
+
+    for (i=0; i<MAXNETNODES; ++i)
+    {
+        if (ClientConnected(&clients[i]))
+        {
+            if (client == &clients[i])
+            {
+                return count;
+            }
+            ++count;
+        }
+    }
+
+    return -1;
+}
+
 // returns a pointer to the client which controls the server
 
 static net_client_t *NET_SV_Controller(void)
@@ -429,6 +458,10 @@ static void NET_SV_SendWaitingData(net_client_t *client)
 
     NET_WriteInt8(packet, NET_SV_Controller() == client);
 
+    // send the index of the client
+
+    NET_WriteInt8(packet, NET_SV_ClientIndex(client));
+
     // send the address of all players
 
     for (i=0; i<num_clients; ++i)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/chocolate-doom.git



More information about the Pkg-games-commits mailing list