shithub: choc

Download patch

ref: 4c5d0e68a46ae1f1baf3d9407b0dbd08eda9b987
parent: cd2a2a8d21ebcd5192f7c79793cf4c99790f6f11
author: Simon Howard <[email protected]>
date: Thu Mar 30 13:17:58 EST 2006

Dedicated server mode.

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

--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,7 +4,6 @@
 games_PROGRAMS = chocolate-doom
 
 AM_CFLAGS = -I../textscreen @SDL_CFLAGS@ @SDLMIXER_CFLAGS@ @SDLNET_CFLAGS@ -Wall
-chocolate_doom_LDADD = ../textscreen/libtextscreen.a @LDFLAGS@ @SDL_LIBS@ @SDLMIXER_LIBS@ @SDLNET_LIBS@ 
 
 SOURCE_FILES=\
 am_map.c             am_map.h              \
@@ -58,6 +57,7 @@
 m_swap.c             m_swap.h              \
 net_client.c         net_client.h          \
 net_common.c         net_common.h          \
+net_dedicated.c      net_dedicated.h       \
 net_defs.h                                 \
 net_gui.c            net_gui.h             \
 net_io.c             net_io.h              \
@@ -113,6 +113,8 @@
 else
 chocolate_doom_SOURCES=$(SOURCE_FILES)
 endif
+
+chocolate_doom_LDADD = ../textscreen/libtextscreen.a @LDFLAGS@ @SDL_LIBS@ @SDLMIXER_LIBS@ @SDLNET_LIBS@ 
 
 EXTRA_DIST = convert-icon chocolate_doom_icon.c
 
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: d_main.c 444 2006-03-25 21:50:32Z fraggle $
+// $Id: d_main.c 454 2006-03-30 18:17:58Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -184,7 +184,7 @@
 //-----------------------------------------------------------------------------
 
 
-static const char rcsid[] = "$Id: d_main.c 444 2006-03-25 21:50:32Z fraggle $";
+static const char rcsid[] = "$Id: d_main.c 454 2006-03-30 18:17:58Z fraggle $";
 
 #define	BGCOLOR		7
 #define	FGCOLOR		8
@@ -238,6 +238,7 @@
 #include "st_stuff.h"
 #include "am_map.h"
 #include "net_client.h"
+#include "net_dedicated.h"
 
 #include "p_setup.h"
 #include "r_local.h"
@@ -1347,6 +1348,14 @@
 
     printf (DEH_String("Z_Init: Init zone memory allocation daemon. \n"));
     Z_Init ();
+
+    if (M_CheckParm("-dedicated") > 0)
+    {
+        printf("Dedicated server mode.\n");
+        NET_DedicatedServer();
+
+        // Never returns
+    }
 
 #ifdef FEATURE_DEHACKED
     printf("DEH_Init: Init Dehacked support.\n");
--- /dev/null
+++ b/src/net_dedicated.c
@@ -1,0 +1,48 @@
+// Emacs style mode select   -*- C++ -*- 
+//-----------------------------------------------------------------------------
+//
+// $Id: $
+//
+// Copyright(C) 2005 Simon Howard
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+//-----------------------------------------------------------------------------
+//
+// Dedicated server code.
+// 
+
+#include "doomtype.h"
+
+#include "i_system.h"
+
+#include "net_defs.h"
+#include "net_sdl.h"
+#include "net_server.h"
+
+void NET_DedicatedServer(void)
+{
+    NET_SV_Init();
+
+    NET_SV_AddModule(&net_sdl_module);
+
+    while (true)
+    {
+        NET_SV_Run();
+        I_Sleep(10);
+    }
+}
+
--- /dev/null
+++ b/src/net_dedicated.h
@@ -1,0 +1,35 @@
+// Emacs style mode select   -*- C++ -*- 
+//-----------------------------------------------------------------------------
+//
+// $Id: $
+//
+// Copyright(C) 2005 Simon Howard
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+//-----------------------------------------------------------------------------
+//
+// Dedicated server code.
+// 
+
+#ifndef NET_DEDICATED_H
+#define NET_DEDICATED_H
+
+void NET_DedicatedServer(void);
+
+#endif /* #ifndef NET_DEDICATED_H */
+
+