shithub: choc

Download patch

ref: cd2a2a8d21ebcd5192f7c79793cf4c99790f6f11
parent: 68ea842e257864919bf166a360a4a1a6bb65805a
author: Simon Howard <[email protected]>
date: Wed Mar 29 19:23:20 EST 2006

Remove hard-coded use of network modules from server code.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 453

--- a/src/d_net.c
+++ b/src/d_net.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: d_net.c 444 2006-03-25 21:50:32Z fraggle $
+// $Id: d_net.c 453 2006-03-30 00:23:20Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -117,7 +117,7 @@
 //-----------------------------------------------------------------------------
 
 
-static const char rcsid[] = "$Id: d_net.c 444 2006-03-25 21:50:32Z fraggle $";
+static const char rcsid[] = "$Id: d_net.c 453 2006-03-30 00:23:20Z fraggle $";
 
 #include "doomfeatures.h"
 
@@ -297,6 +297,8 @@
         if (M_CheckParm("-server") > 0)
         {
             NET_SV_Init();
+            NET_SV_AddModule(&net_loop_server_module);
+            NET_SV_AddModule(&net_sdl_module);
 
             connect_module = &net_loop_client_module;
             connect_addr = "";
--- a/src/net_server.c
+++ b/src/net_server.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: net_server.c 440 2006-03-24 21:43:43Z fraggle $
+// $Id: net_server.c 453 2006-03-30 00:23:20Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -1282,19 +1282,23 @@
     }
 }
 
-// Initialise server and wait for connections
+// Add a network module to the server context
+
+void NET_SV_AddModule(net_module_t *module)
+{
+    NET_AddModule(server_context, module);
+    module->InitServer();
+}
 
+// Initialise server and wait for connections
+
 void NET_SV_Init(void)
 {
     int i;
 
-    // initialise send/receive context, with loopback send/recv
+    // initialise send/receive context
 
     server_context = NET_NewContext();
-    NET_AddModule(server_context, &net_loop_server_module);
-    net_loop_server_module.InitServer();
-    NET_AddModule(server_context, &net_sdl_module);
-    net_sdl_module.InitServer();
 
     // no clients yet
    
--- a/src/net_server.h
+++ b/src/net_server.h
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: net_server.h 250 2006-01-02 21:04:10Z fraggle $
+// $Id: net_server.h 453 2006-03-30 00:23:20Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -52,6 +52,10 @@
 // Blocks until all clients disconnect, or until a 5 second timeout
 
 void NET_SV_Shutdown(void);
+
+// Add a network module to the context used by the server
+
+void NET_SV_AddModule(net_module_t *module);
 
 #endif /* #ifndef NET_SERVER_H */