]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
you can now build a darkplaces-dedicated executable as well as a darkplaces-glx execu...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 17 Sep 2002 23:23:45 +0000 (23:23 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 17 Sep 2002 23:23:45 +0000 (23:23 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2387 d7cf8633-e32d-0410-b094-e92efae38249

cl_video.c
host.c
makefile
snd_dma.c
snd_null.c
sound.h
vid.h
vid_glx.c
vid_null.c [new file with mode: 0644]
vid_wgl.c

index 58f367f4a60fcc2bb5a0c2403d062c8be5c7e9c1..b509234a6cf106e54e4c23a6c6618ab7350b9c31 100644 (file)
@@ -59,7 +59,7 @@ void CL_VideoFrame(void)
                Con_Printf("%i = S_RawSamples_QueueWantsMore()\n", samples);
 
                // calculate how much source data we need to fill the output...
-               s = samples * cl_videosoundrate / shm->speed;
+               s = samples * cl_videosoundrate / S_RawSamples_SampleRate();
 
                // reallocate processing buffer if needed
                if (cl_videosoundresamplelength < samples)
diff --git a/host.c b/host.c
index cc7102a8014636ac8cf11e0c81f3f4516d2920f9..18b5c1a04df8627a777a6c7fad1401697da05cd3 100644 (file)
--- a/host.c
+++ b/host.c
@@ -184,26 +184,42 @@ void Host_ServerOptions (void)
 {
        int i, numplayers;
 
-       numplayers = 1;
-
-       i = COM_CheckParm ("-dedicated");
-       if (i)
+       if (cl_available)
        {
-               cls.state = ca_dedicated;
-               numplayers = 0;
-               if (i != (com_argc - 1))
-                       numplayers = atoi (com_argv[i+1]);
+               // client exists, check what mode the user wants
+               i = COM_CheckParm ("-dedicated");
+               if (i)
+               {
+                       cls.state = ca_dedicated;
+                       numplayers = 8;
+                       if (i != (com_argc - 1))
+                               numplayers = atoi (com_argv[i+1]);
+                       if (COM_CheckParm ("-listen"))
+                               Sys_Error ("Only one of -dedicated or -listen can be specified");
+               }
+               else
+               {
+                       numplayers = 1;
+                       cls.state = ca_disconnected;
+                       i = COM_CheckParm ("-listen");
+                       if (i)
+                       {
+                               numplayers = 8;
+                               if (i != (com_argc - 1))
+                                       numplayers = atoi (com_argv[i+1]);
+                       }
+               }
        }
        else
-               cls.state = ca_disconnected;
-
-       i = COM_CheckParm ("-listen");
-       if (i)
        {
-               if (cls.state == ca_dedicated)
-                       Sys_Error ("Only one of -dedicated or -listen can be specified");
-               numplayers = 0;
-               if (i != (com_argc - 1))
+               // no client in the executable, start dedicated server
+               if (COM_CheckParm ("-listen"))
+                       Sys_Error ("-listen not available in a dedicated server executable");
+               numplayers = 8;
+               cls.state = ca_dedicated;
+               // check for -dedicated specifying how many players
+               i = COM_CheckParm ("-dedicated");
+               if (i && i != (com_argc - 1))
                        numplayers = atoi (com_argv[i+1]);
        }
 
index fff672e45fb2990f6a1881991216f76c63979afc..90ad547dc20958295b807e9b9518300e6592b7f5 100644 (file)
--- a/makefile
+++ b/makefile
@@ -22,7 +22,10 @@ SOUNDLIB=
 #if you want no CD audio
 CD=cd_null.o
 
-OBJECTS= builddate.o chase.o cl_demo.o cl_input.o cl_main.o cl_parse.o cl_tent.o cmd.o common.o console.o crc.o cvar.o fractalnoise.o gl_draw.o r_sky.o gl_rmain.o gl_rsurf.o host.o host_cmd.o image.o keys.o mathlib.o menu.o model_alias.o model_brush.o model_shared.o model_sprite.o net_bsd.o net_udp.o net_dgrm.o net_loop.o net_main.o pr_cmds.o pr_edict.o pr_exec.o r_light.o r_explosion.o sbar.o sv_main.o sv_move.o sv_phys.o sv_user.o sv_light.o sys_linux.o transform.o view.o wad.o world.o zone.o vid_shared.o palette.o r_crosshairs.o gl_textures.o gl_models.o r_sprites.o r_modules.o r_explosion.o r_lerpanim.o protocol.o quakeio.o ui.o portals.o sys_shared.o cl_light.o gl_backend.o cl_particles.o cl_screen.o cgamevm.o cgame.o filematch.o collision.o cl_collision.o matrixlib.o cl_video.o dpvsimpledecode.o wavefile.o meshqueue.o
+CLIENTOBJECTS= cgame.o cgamevm.o chase.o cl_collision.o cl_demo.o cl_input.o cl_light.o cl_main.o cl_parse.o cl_particles.o cl_screen.o cl_tent.o cl_video.o console.o dpvsimpledecode.o fractalnoise.o gl_backend.o gl_draw.o gl_models.o gl_rmain.o gl_rsurf.o gl_textures.o keys.o menu.o meshqueue.o r_crosshairs.o r_explosion.o r_explosion.o r_lerpanim.o r_light.o r_modules.o r_sky.o r_sprites.o sbar.o ui.o vid_shared.o view.o wavefile.o
+SERVEROBJECTS= pr_cmds.o pr_edict.o pr_exec.o sv_light.o sv_main.o sv_move.o sv_phys.o sv_user.o
+SHAREDOBJECTS= builddate.o cmd.o collision.o common.o crc.o cvar.o filematch.o host.o host_cmd.o image.o mathlib.o matrixlib.o model_alias.o model_brush.o model_shared.o model_sprite.o net_bsd.o net_dgrm.o net_loop.o net_main.o net_udp.o palette.o portals.o protocol.o quakeio.o sys_linux.o sys_shared.o transform.o world.o wad.o zone.o $(NETOBJECTS) $(SERVEROBJECTS)
+
 
 #K6/athlon optimizations
 #CPUOPTIMIZATIONS=-march=k6
@@ -37,40 +40,41 @@ CPUOPTIMIZATIONS=
 
 #use this line for profiling
 PROFILEOPTION=-pg -g
-NOPROFILEOPTIMIZATIONS=
 #use this line for no profiling
 #PROFILEOPTION=
-#NOPROFILEOPTIMIZATIONS=-fomit-frame-pointer
-#use these lines for debugging without profiling
-#PROFILEOPTION=
-#NOPROFILEOPTIMIZATIONS=
 
 #note:
 #the -Werror can be removed to compile even if there are warnings,
 #this is used to ensure that all released versions are free of warnings.
 
 #normal compile
-OPTIMIZATIONS= -O6 -fno-strict-aliasing -ffast-math -funroll-loops $(NOPROFILEOPTIMIZATIONS) -fexpensive-optimizations $(CPUOPTIMIZATIONS)
-CFLAGS= -MD -Wall -Werror -I/usr/X11R6/include $(OPTIMIZATIONS) $(PROFILEOPTION)
+OPTIMIZATIONS= -O6 -fno-strict-aliasing -ffast-math -funroll-loops -fexpensive-optimizations $(CPUOPTIMIZATIONS)
+CFLAGS= -MD -Wall -Werror $(OPTIMIZATIONS) $(PROFILEOPTION)
 #debug compile
 #OPTIMIZATIONS=
-#CFLAGS= -MD -Wall -Werror -I/usr/X11R6/include -ggdb $(OPTIMIZATIONS) $(PROFILEOPTION)
+#CFLAGS= -MD -Wall -Werror -ggdb $(OPTIMIZATIONS) $(PROFILEOPTION)
 
-LDFLAGS= -L/usr/X11R6/lib -lm -lX11 -lXext -lXxf86dga -lXxf86vm -ldl $(SOUNDLIB) $(PROFILEOPTION)
+LDFLAGS= $(PROFILEOPTION) -lm -ldl
 
-all: builddate darkplaces-glx
+all: builddate darkplaces-dedicated darkplaces-glx
 
 builddate:
        touch builddate.c
 
+vid_glx.o: vid_glx.c
+       gcc $(CFLAGS) -c vid_glx.c -I/usr/X11R6/include
+
 .c.o:
        gcc $(CFLAGS) -c $*.c
 
-darkplaces-glx: vid_glx.o $(CD) $(SND) $(OBJECTS)
+darkplaces-glx:  $(SHAREDOBJECTS) $(CLIENTOBJECTS) $(SERVEROBJECTS) vid_glx.o $(CD) $(SND)
+       gcc -o $@ $^ $(LDFLAGS) -L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm $(SOUNDLIB)
+
+darkplaces-dedicated: $(SHAREDOBJECTS) $(CLIENTOBJECTS) $(SERVEROBJECTS) vid_null.o cd_null.o snd_null.o
        gcc -o $@ $^ $(LDFLAGS)
 
 clean:
-       -rm -f darkplaces-glx *.o *.d
+       -rm -f darkplaces-glx darkplaces-dedicated *.o *.d
 
 .PHONY: clean builddate
 
index 2639611d7bb7aabef66e27093d7d7914e40b9329..0e91d01085ea880e64c443fef90e0f35c872fc60 100644 (file)
--- a/snd_dma.c
+++ b/snd_dma.c
@@ -1135,3 +1135,8 @@ void S_ResampleBuffer16Stereo(short *input, int inputlength, short *output, int
        else
                memcpy(output, input, inputlength * sizeof(short[2]));
 }
+
+int S_RawSamples_SampleRate(void)
+{
+       return shm != NULL ? shm->speed : 0;
+}
index bb8bc2245a8b8cada23e308b8c902ab34ecb9fe6..546b0e8af5a54db42d8f9ee1149ac064ce9bd098 100755 (executable)
@@ -98,3 +98,28 @@ void S_LocalSound (char *s)
 {
 }
 
+void S_RawSamples_Enqueue(short *samples, unsigned int length)
+{
+}
+
+void S_RawSamples_Dequeue(int *samples, unsigned int length)
+{
+}
+
+void S_RawSamples_ClearQueue(void)
+{
+}
+
+int S_RawSamples_QueueWantsMore(void)
+{
+       return 0;
+}
+
+void S_ResampleBuffer16Stereo(short *input, int inputlength, short *output, int outputlength)
+{
+}
+
+int S_RawSamples_SampleRate(void)
+{
+       return 0;
+}
diff --git a/sound.h b/sound.h
index 561272ba51d336203de9c7e0d1d6993f461c8dab..e20714bffb593cf61d065a258e3a9f329b6b55ab 100644 (file)
--- a/sound.h
+++ b/sound.h
@@ -192,5 +192,8 @@ int S_RawSamples_QueueWantsMore(void);
 // resamples one sound buffer into another, while changing the length
 void S_ResampleBuffer16Stereo(short *input, int inputlength, short *output, int outputlength);
 
+// returns the rate that the rawsamples system is running at
+int S_RawSamples_SampleRate(void);
+
 #endif
 
diff --git a/vid.h b/vid.h
index 265d6e0de615f8a04edd06b73c18e18eb12d4d89..f3da2f4289b1ab064f672daa9027738be4ba66bc 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #ifndef VID_H
 #define VID_H
 
+extern int cl_available;
+
 typedef struct
 {
        // these are set with VID_GetWindowSize and can change from frame to frame
index de6c7c443df1a83568b12b1b952bc1e0e5788cbe..33ecded764021e3467925582cc2b502a23a05663 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -40,6 +40,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 
+int cl_available = true;
+
 //GLX prototypes
 XVisualInfo *(GLAPIENTRY *qglXChooseVisual)(Display *dpy, int screen, int *attribList);
 GLXContext (GLAPIENTRY *qglXCreateContext)(Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
diff --git a/vid_null.c b/vid_null.c
new file mode 100644 (file)
index 0000000..2b4d3b0
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+Copyright (C) 1996-1997 Id Software, Inc.
+
+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.
+*/
+
+#include <signal.h>
+#include <dlfcn.h>
+#include "quakedef.h"
+
+int cl_available = false;
+
+// global video state
+viddef_t vid;
+
+void VID_Shutdown(void)
+{
+}
+
+void signal_handler(int sig)
+{
+       printf("Received signal %d, exiting...\n", sig);
+       Sys_Quit();
+       exit(0);
+}
+
+void InitSig(void)
+{
+       signal(SIGHUP, signal_handler);
+       signal(SIGINT, signal_handler);
+       signal(SIGQUIT, signal_handler);
+       signal(SIGILL, signal_handler);
+       signal(SIGTRAP, signal_handler);
+       signal(SIGIOT, signal_handler);
+       signal(SIGBUS, signal_handler);
+       signal(SIGFPE, signal_handler);
+       signal(SIGSEGV, signal_handler);
+       signal(SIGTERM, signal_handler);
+}
+
+void VID_GetWindowSize (int *x, int *y, int *width, int *height)
+{
+       *x = *y = 0;
+       *width = 1;
+       *height = 1;
+}
+
+void VID_Finish (void)
+{
+}
+
+int VID_SetGamma(float prescale, float gamma, float scale, float base)
+{
+       return FALSE;
+}
+
+void VID_Init(int fullscreen, int width, int height)
+{
+       InitSig(); // trap evil signals
+}
+
+int GL_OpenLibrary(const char *name)
+{
+       return false;
+}
+
+void GL_CloseLibrary(void)
+{
+}
+
+void *GL_GetProcAddress(const char *name)
+{
+       return NULL;
+}
+
+void Sys_SendKeyEvents(void)
+{
+}
+
+void IN_Commands(void)
+{
+}
+
+void IN_Init(void)
+{
+}
+
+void IN_Shutdown(void)
+{
+}
+
+void IN_Move(usercmd_t *cmd)
+{
+}
index f5e2b38d8586caa1fa386dd3436d1fe1b9568356..2562f48893ced2bdbcf5bc26032b6d73eb1808fd 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -24,6 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "resource.h"
 #include <commctrl.h>
 
+int cl_available = true;
+
 int (WINAPI *qwglChoosePixelFormat)(HDC, CONST PIXELFORMATDESCRIPTOR *);
 int (WINAPI *qwglDescribePixelFormat)(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
 //int (WINAPI *qwglGetPixelFormat)(HDC);