From: havoc Date: Tue, 17 Sep 2002 23:23:45 +0000 (+0000) Subject: you can now build a darkplaces-dedicated executable as well as a darkplaces-glx execu... X-Git-Tag: RELEASE_0_2_0_RC1~229 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b82d346b06f2dbd3d4fff3ef6b7ad986739d6cf7;p=xonotic%2Fdarkplaces.git you can now build a darkplaces-dedicated executable as well as a darkplaces-glx executable (and infact this is done automatically :) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2387 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_video.c b/cl_video.c index 58f367f4..b509234a 100644 --- a/cl_video.c +++ b/cl_video.c @@ -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 cc7102a8..18b5c1a0 100644 --- 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]); } diff --git a/makefile b/makefile index fff672e4..90ad547d 100644 --- 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 diff --git a/snd_dma.c b/snd_dma.c index 2639611d..0e91d010 100644 --- 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; +} diff --git a/snd_null.c b/snd_null.c index bb8bc224..546b0e8a 100755 --- a/snd_null.c +++ b/snd_null.c @@ -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 561272ba..e20714bf 100644 --- 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 265d6e0d..f3da2f42 100644 --- 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 diff --git a/vid_glx.c b/vid_glx.c index de6c7c44..33ecded7 100644 --- 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 index 00000000..2b4d3b02 --- /dev/null +++ b/vid_null.c @@ -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 +#include +#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) +{ +} diff --git a/vid_wgl.c b/vid_wgl.c index f5e2b38d..2562f488 100644 --- 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 +int cl_available = true; + int (WINAPI *qwglChoosePixelFormat)(HDC, CONST PIXELFORMATDESCRIPTOR *); int (WINAPI *qwglDescribePixelFormat)(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR); //int (WINAPI *qwglGetPixelFormat)(HDC);