diff --git a/engine/client/merged.h b/engine/client/merged.h index 270a66bfa..2f5475d7f 100644 --- a/engine/client/merged.h +++ b/engine/client/merged.h @@ -40,7 +40,7 @@ extern void (*Draw_BeginDisc) (void); extern void (*Draw_EndDisc) (void); extern qboolean (*Draw_IsCached) (char *picname); //can be null -extern void (*Draw_Image) (float x, float y, float w, float h, float s1, float t1, float s2, float t2, mpic_t *pic); //gl-style scaled/coloured/subpic +extern void (*Draw_Image) (float x, float y, float w, float h, float s1, float t1, float s2, float t2, mpic_t *pic); //gl-style scaled/coloured/subpic extern void (*Draw_ImageColours) (float r, float g, float b, float a); extern void (*R_Init) (void); @@ -48,7 +48,6 @@ extern void (*R_DeInit) (void); extern void (*R_ReInit) (void); extern void (*R_RenderView) (void); // must set r_refdef first -extern void (*R_InitSky) (struct texture_s *mt); // called at level load extern qboolean (*R_CheckSky) (void); extern void (*R_SetSky) (char *name, float rotate, vec3_t axis); @@ -156,7 +155,6 @@ typedef struct { void (*R_ReInit) (void); void (*R_RenderView) (void); // must set r_refdef first - void (*R_InitSky) (struct texture_s *mt); // called at level load qboolean (*R_CheckSky) (void); void (*R_SetSky) (char *name, float rotate, vec3_t axis); diff --git a/engine/client/renderer.c b/engine/client/renderer.c index de90280e1..4ce01a080 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -562,7 +562,6 @@ void (*R_DeInit) (void); void (*R_ReInit) (void); void (*R_RenderView) (void); // must set r_refdef first -void (*R_InitSky) (struct texture_s *mt); // called at level load qboolean (*R_CheckSky) (void); void (*R_SetSky) (char *name, float rotate, vec3_t axis); @@ -614,6 +613,7 @@ r_qrenderer_t qrenderer=-1; char *q_renderername = "Non-Selected renderer"; + rendererinfo_t dedicatedrendererinfo = { //ALL builds need a 'none' renderer, as 0. "Dedicated server", @@ -625,9 +625,6 @@ rendererinfo_t dedicatedrendererinfo = { }, QR_NONE, - - - NULL, //Draw_PicFromWad; NULL, //Draw_PicFromWad; //Not supported NULL, //Draw_CachePic; @@ -660,7 +657,7 @@ rendererinfo_t dedicatedrendererinfo = { NULL, //R_DeInit; NULL, //R_ReInit; NULL, //R_RenderView; - NULL, //R_InitSky; + NULL, //R_CheckSky; NULL, //R_SetSky; @@ -772,7 +769,6 @@ rendererinfo_t softwarerendererinfo = { NULL,//SWR_ReInit, SWR_RenderView, - SWR_InitSky, SWR_CheckSky, SWR_SetSky, @@ -826,101 +822,100 @@ rendererinfo_t *psoftwarerendererinfo = &softwarerendererinfo; #endif #ifdef RGLQUAKE rendererinfo_t openglrendererinfo = { - "OpenGL", - { - "gl", - "opengl", - "hardware", - }, - QR_OPENGL, + "OpenGL", + { + "gl", + "opengl", + "hardware", + }, + QR_OPENGL, - GLDraw_PicFromWad, - GLDraw_SafePicFromWad, - GLDraw_CachePic, - GLDraw_SafeCachePic, - GLDraw_Init, - GLDraw_ReInit, - GLDraw_Character, - GLDraw_ColouredCharacter, - GLDraw_String, - GLDraw_Alt_String, - GLDraw_Crosshair, - GLDraw_DebugChar, - GLDraw_Pic, - GLDraw_ScalePic, - GLDraw_SubPic, - GLDraw_TransPic, - GLDraw_TransPicTranslate, - GLDraw_ConsoleBackground, - GLDraw_EditorBackground, - GLDraw_TileClear, - GLDraw_Fill, - GLDraw_FadeScreen, - GLDraw_BeginDisc, - GLDraw_EndDisc, + GLDraw_PicFromWad, + GLDraw_SafePicFromWad, + GLDraw_CachePic, + GLDraw_SafeCachePic, + GLDraw_Init, + GLDraw_ReInit, + GLDraw_Character, + GLDraw_ColouredCharacter, + GLDraw_String, + GLDraw_Alt_String, + GLDraw_Crosshair, + GLDraw_DebugChar, + GLDraw_Pic, + GLDraw_ScalePic, + GLDraw_SubPic, + GLDraw_TransPic, + GLDraw_TransPicTranslate, + GLDraw_ConsoleBackground, + GLDraw_EditorBackground, + GLDraw_TileClear, + GLDraw_Fill, + GLDraw_FadeScreen, + GLDraw_BeginDisc, + GLDraw_EndDisc, - GLDraw_Image, - GLDraw_ImageColours, + GLDraw_Image, + GLDraw_ImageColours, - GLR_Init, - GLR_DeInit, - GLR_ReInit, - GLR_RenderView, + GLR_Init, + GLR_DeInit, + GLR_ReInit, + GLR_RenderView, - GLR_InitSky, - GLR_CheckSky, - GLR_SetSky, + GLR_CheckSky, + GLR_SetSky, - GLR_NewMap, - GLR_PreNewMap, - GLR_LightPoint, - GLR_PushDlights, + GLR_NewMap, + GLR_PreNewMap, + GLR_LightPoint, + GLR_PushDlights, - GLR_AddStain, - GLR_LessenStains, + GLR_AddStain, + GLR_LessenStains, - MediaGL_ShowFrameBGR_24_Flip, - MediaGL_ShowFrameRGBA_32, - MediaGL_ShowFrame8bit, + MediaGL_ShowFrameBGR_24_Flip, + MediaGL_ShowFrameRGBA_32, + MediaGL_ShowFrame8bit, - GLMod_Init, - GLMod_ClearAll, - GLMod_ForName, - GLMod_FindName, - GLMod_Extradata, - GLMod_TouchModel, + GLMod_Init, + GLMod_ClearAll, + GLMod_ForName, + GLMod_FindName, + GLMod_Extradata, + GLMod_TouchModel, - GLMod_PointInLeaf, - GLMod_LeafPVS, - GLMod_NowLoadExternal, - GLMod_Think, + GLMod_PointInLeaf, + GLMod_LeafPVS, + GLMod_NowLoadExternal, + GLMod_Think, - GLMod_GetTag, - GLMod_TagNumForName, + GLMod_GetTag, + GLMod_TagNumForName, - GLVID_Init, - GLVID_DeInit, - GLVID_HandlePause, - GLVID_LockBuffer, - GLVID_UnlockBuffer, - GLD_BeginDirectRect, - GLD_EndDirectRect, - GLVID_ForceLockState, - GLVID_ForceUnlockedAndReturnState, - GLVID_SetPalette, - GLVID_ShiftPalette, - GLVID_GetRGBInfo, + GLVID_Init, + GLVID_DeInit, + GLVID_HandlePause, + GLVID_LockBuffer, + GLVID_UnlockBuffer, + GLD_BeginDirectRect, + GLD_EndDirectRect, + GLVID_ForceLockState, + GLVID_ForceUnlockedAndReturnState, + GLVID_SetPalette, + GLVID_ShiftPalette, + GLVID_GetRGBInfo, - NULL, //setcaption + NULL, //setcaption - GLSCR_UpdateScreen, + GLSCR_UpdateScreen, - "" + "" }; rendererinfo_t *popenglrendererinfo = &openglrendererinfo; #endif @@ -1033,7 +1028,7 @@ qboolean M_VideoApply (union menuoption_s *op,struct menu_s *menu,int key) Cbuf_AddText(va("vid_conwidth %s\n", info->customwidth->text), RESTRICT_LOCAL); Cbuf_AddText(va("vid_conheight %s\n", info->customheight->text), RESTRICT_LOCAL); } - + selectedbpp = 16; switch(info->bppcombo->selectedoption) { @@ -1052,7 +1047,7 @@ qboolean M_VideoApply (union menuoption_s *op,struct menu_s *menu,int key) } Cbuf_AddText(va("vid_bpp %i\n", selectedbpp), RESTRICT_LOCAL); - + switch(info->renderer->selectedoption) { #ifdef SWQUAKE @@ -1193,6 +1188,7 @@ void M_Menu_Video_f (void) void R_SetRenderer(int wanted) { rendererinfo_t *ri; + if (wanted<0) { //-1 is used so we know when we've applied something instead of never setting anything. wanted=0; @@ -1205,6 +1201,7 @@ void R_SetRenderer(int wanted) q_renderername = ri->name[0]; + Draw_PicFromWad = ri->Draw_PicFromWad; Draw_SafePicFromWad = ri->Draw_SafePicFromWad; //Not supported Draw_CachePic = ri->Draw_CachePic; @@ -1240,7 +1237,6 @@ void R_SetRenderer(int wanted) R_PreNewMap = ri->R_PreNewMap; R_LightPoint = ri->R_LightPoint; R_PushDlights = ri->R_PushDlights; - R_InitSky = ri->R_InitSky; R_CheckSky = ri->R_CheckSky; R_SetSky = ri->R_SetSky; @@ -1279,8 +1275,6 @@ void R_SetRenderer(int wanted) Mod_GetTag = ri->Mod_GetTag; Mod_TagNumForName = ri->Mod_TagNumForName; - - SCR_UpdateScreen = ri->SCR_UpdateScreen; } diff --git a/engine/client/snd_alsa.c b/engine/client/snd_alsa.c index eb07b9bca..d9782649e 100755 --- a/engine/client/snd_alsa.c +++ b/engine/client/snd_alsa.c @@ -31,6 +31,34 @@ #include #include "quakedef.h" +#include + +static void *alsasharedobject; + +int (*psnd_pcm_open) (snd_pcm_t **pcm, const char *name, snd_pcm_stream_t stream, int mode); +int (*psnd_pcm_close) (snd_pcm_t *pcm); +const char *(*psnd_strerror) (int errnum); +int (*psnd_pcm_hw_params_any) (snd_pcm_t *pcm, snd_pcm_hw_params_t *params); +int (*psnd_pcm_hw_params_set_access) (snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t _access); +int (*psnd_pcm_hw_params_set_format) (snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val); +int (*psnd_pcm_hw_params_set_channels) (snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val); +int (*psnd_pcm_hw_params_set_rate_near) (snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir); +int (*psnd_pcm_hw_params_set_period_size_near) (snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir); +int (*psnd_pcm_hw_params) (snd_pcm_t *pcm, snd_pcm_hw_params_t *params); +int (*psnd_pcm_sw_params_current) (snd_pcm_t *pcm, snd_pcm_sw_params_t *params); +int (*psnd_pcm_sw_params_set_start_threshold) (snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val); +int (*psnd_pcm_sw_params_set_stop_threshold) (snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val); +int (*psnd_pcm_sw_params) (snd_pcm_t *pcm, snd_pcm_sw_params_t *params); +int (*psnd_pcm_hw_params_get_buffer_size) (const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val); +snd_pcm_sframes_t (*psnd_pcm_avail_update) (snd_pcm_t *pcm); +int (*psnd_pcm_mmap_begin) (snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas, snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames); +snd_pcm_sframes_t (*psnd_pcm_mmap_commit) (snd_pcm_t *pcm, snd_pcm_uframes_t offset, snd_pcm_uframes_t frames); +snd_pcm_state_t (*psnd_pcm_state) (snd_pcm_t *pcm); +int (*psnd_pcm_start) (snd_pcm_t *pcm); + +size_t (*psnd_pcm_hw_params_sizeof) (void); +size_t (*psnd_pcm_sw_params_sizeof) (void); + static unsigned int ALSA_GetDMAPos (soundcardinfo_t *sc) @@ -39,8 +67,8 @@ static unsigned int ALSA_GetDMAPos (soundcardinfo_t *sc) snd_pcm_uframes_t offset; snd_pcm_uframes_t nframes = sc->sn.samples / sc->sn.numchannels; - snd_pcm_avail_update (sc->handle); - snd_pcm_mmap_begin (sc->handle, &areas, &offset, &nframes); + psnd_pcm_avail_update (sc->handle); + psnd_pcm_mmap_begin (sc->handle, &areas, &offset, &nframes); offset *= sc->sn.numchannels; nframes *= sc->sn.numchannels; sc->sn.samplepos = offset; @@ -50,7 +78,7 @@ static unsigned int ALSA_GetDMAPos (soundcardinfo_t *sc) static void ALSA_Shutdown (soundcardinfo_t *sc) { - snd_pcm_close (sc->handle); + psnd_pcm_close (sc->handle); } static void ALSA_Submit (soundcardinfo_t *sc) @@ -64,18 +92,18 @@ static void ALSA_Submit (soundcardinfo_t *sc) nframes = count / sc->sn.numchannels; - snd_pcm_avail_update (sc->handle); - snd_pcm_mmap_begin (sc->handle, &areas, &offset, &nframes); + psnd_pcm_avail_update (sc->handle); + psnd_pcm_mmap_begin (sc->handle, &areas, &offset, &nframes); - state = snd_pcm_state (sc->handle); + state = psnd_pcm_state (sc->handle); switch (state) { case SND_PCM_STATE_PREPARED: - snd_pcm_mmap_commit (sc->handle, offset, nframes); - snd_pcm_start (sc->handle); + psnd_pcm_mmap_commit (sc->handle, offset, nframes); + psnd_pcm_start (sc->handle); break; case SND_PCM_STATE_RUNNING: - snd_pcm_mmap_commit (sc->handle, offset, nframes); + psnd_pcm_mmap_commit (sc->handle, offset, nframes); break; default: break; @@ -99,6 +127,68 @@ void S_UpdateCapture(void) { } +static qboolean Alsa_InitAlsa(void) +{ + static qboolean tried; + static qboolean alsaworks; + if (tried) + return alsaworks; + tried = true; + + alsasharedobject = dlopen("libasound.so", RTLD_LAZY|RTLD_LOCAL); + if (!alsasharedobject) + return false; + + + psnd_pcm_open = dlsym(alsasharedobject, "snd_pcm_open"); + psnd_pcm_close = dlsym(alsasharedobject, "snd_pcm_close"); + psnd_strerror = dlsym(alsasharedobject, "snd_strerror"); + psnd_pcm_hw_params_any = dlsym(alsasharedobject, "snd_pcm_hw_params_any"); + psnd_pcm_hw_params_set_access = dlsym(alsasharedobject, "snd_pcm_hw_params_set_access"); + psnd_pcm_hw_params_set_format = dlsym(alsasharedobject, "snd_pcm_hw_params_set_format"); + psnd_pcm_hw_params_set_channels = dlsym(alsasharedobject, "snd_pcm_hw_params_set_channels"); + psnd_pcm_hw_params_set_rate_near = dlsym(alsasharedobject, "snd_pcm_hw_params_set_rate_near"); + psnd_pcm_hw_params_set_period_size_near = dlsym(alsasharedobject, "snd_pcm_hw_params_set_period_size_near"); + psnd_pcm_hw_params = dlsym(alsasharedobject, "snd_pcm_hw_params"); + psnd_pcm_sw_params_current = dlsym(alsasharedobject, "snd_pcm_sw_params_current"); + psnd_pcm_sw_params_set_start_threshold = dlsym(alsasharedobject, "snd_pcm_sw_params_set_start_threshold"); + psnd_pcm_sw_params_set_stop_threshold = dlsym(alsasharedobject, "snd_pcm_sw_params_set_stop_threshold"); + psnd_pcm_sw_params = dlsym(alsasharedobject, "snd_pcm_sw_params"); + psnd_pcm_hw_params_get_buffer_size = dlsym(alsasharedobject, "snd_pcm_hw_params_get_buffer_size"); + psnd_pcm_avail_update = dlsym(alsasharedobject, "snd_pcm_avail_update"); + psnd_pcm_mmap_begin = dlsym(alsasharedobject, "snd_pcm_mmap_begin"); + psnd_pcm_state = dlsym(alsasharedobject, "snd_pcm_state"); + psnd_pcm_mmap_commit = dlsym(alsasharedobject, "snd_pcm_mmap_commit"); + psnd_pcm_start = dlsym(alsasharedobject, "snd_pcm_start"); + psnd_pcm_hw_params_sizeof = dlsym(alsasharedobject, "snd_pcm_hw_params_sizeof"); + psnd_pcm_sw_params_sizeof = dlsym(alsasharedobject, "snd_pcm_sw_params_sizeof"); + + alsaworks = psnd_pcm_open + && psnd_pcm_close + && psnd_strerror + && psnd_pcm_hw_params_any + && psnd_pcm_hw_params_set_access + && psnd_pcm_hw_params_set_format + && psnd_pcm_hw_params_set_channels + && psnd_pcm_hw_params_set_rate_near + && psnd_pcm_hw_params_set_period_size_near + && psnd_pcm_hw_params + && psnd_pcm_sw_params_current + && psnd_pcm_sw_params_set_start_threshold + && psnd_pcm_sw_params_set_stop_threshold + && psnd_pcm_sw_params + && psnd_pcm_hw_params_get_buffer_size + && psnd_pcm_avail_update + && psnd_pcm_mmap_begin + && psnd_pcm_state + && psnd_pcm_mmap_commit + && psnd_pcm_start + && psnd_pcm_hw_params_sizeof + && psnd_pcm_sw_params_sizeof; + + return alsaworks; +} + static int ALSA_InitCard (soundcardinfo_t *sc, int cardnum) { snd_pcm_t *pcm; @@ -115,8 +205,11 @@ static int ALSA_InitCard (soundcardinfo_t *sc, int cardnum) snd_pcm_sw_params_t *sw; snd_pcm_uframes_t frag_size; - snd_pcm_hw_params_alloca (&hw); - snd_pcm_sw_params_alloca (&sw); + if (!Alsa_InitAlsa()) + return 2; + + hw = alloca(psnd_pcm_hw_params_sizeof()); + sw = alloca(psnd_pcm_sw_params_sizeof()); devname = Cvar_Get(va("snd_alsadevice%i", cardnum+1), cardnum==0?"default":"", 0, "Sound controls"); pcmname = devname->string; @@ -161,50 +254,50 @@ static int ALSA_InitCard (soundcardinfo_t *sc, int cardnum) if ((i=COM_CheckParm("-sndstereo")) != 0) stereo=1; - err = snd_pcm_open (&pcm, pcmname, SND_PCM_STREAM_PLAYBACK, + err = psnd_pcm_open (&pcm, pcmname, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); if (0 > err) { - Con_Printf ("Error: audio open error: %s\n", snd_strerror (err)); + Con_Printf ("Error: audio open error: %s\n", psnd_strerror (err)); return 0; } Con_Printf ("ALSA: Using PCM %s.\n", pcmname); - err = snd_pcm_hw_params_any (pcm, hw); + err = psnd_pcm_hw_params_any (pcm, hw); if (0 > err) { Con_Printf ("ALSA: error setting hw_params_any. %s\n", - snd_strerror (err)); + psnd_strerror (err)); goto error; } - err = snd_pcm_hw_params_set_access (pcm, hw, SND_PCM_ACCESS_MMAP_INTERLEAVED); + err = psnd_pcm_hw_params_set_access (pcm, hw, SND_PCM_ACCESS_MMAP_INTERLEAVED); if (0 > err) { Con_Printf ("ALSA: Failure to set noninterleaved PCM access. %s\n" "Note: Interleaved is not supported\n", - snd_strerror (err)); + psnd_strerror (err)); goto error; } switch (bps) { case -1: - err = snd_pcm_hw_params_set_format (pcm, hw, SND_PCM_FORMAT_S16); + err = psnd_pcm_hw_params_set_format (pcm, hw, SND_PCM_FORMAT_S16); if (0 <= err) { bps = 16; - } else if (0 <= (err = snd_pcm_hw_params_set_format (pcm, hw, SND_PCM_FORMAT_U8))) { + } else if (0 <= (err = psnd_pcm_hw_params_set_format (pcm, hw, SND_PCM_FORMAT_U8))) { bps = 8; } else { Con_Printf ("ALSA: no useable formats. %s\n", - snd_strerror (err)); + psnd_strerror (err)); goto error; } break; case 8: case 16: - err = snd_pcm_hw_params_set_format (pcm, hw, bps == 8 ? + err = psnd_pcm_hw_params_set_format (pcm, hw, bps == 8 ? SND_PCM_FORMAT_U8 : SND_PCM_FORMAT_S16); if (0 > err) { Con_Printf ("ALSA: no usable formats. %s\n", - snd_strerror (err)); + psnd_strerror (err)); goto error; } break; @@ -215,23 +308,27 @@ static int ALSA_InitCard (soundcardinfo_t *sc, int cardnum) switch (stereo) { case -1: - err = snd_pcm_hw_params_set_channels (pcm, hw, 2); + err = psnd_pcm_hw_params_set_channels (pcm, hw, 2); if (0 <= err) { stereo = 1; - } else if (0 <= (err = snd_pcm_hw_params_set_channels (pcm, hw, 1))) { + } else if (0 <= (err = psnd_pcm_hw_params_set_channels (pcm, hw, 1))) { stereo = 0; } else { Con_Printf ("ALSA: no usable channels. %s\n", - snd_strerror (err)); + psnd_strerror (err)); goto error; } break; case 0: case 1: - err = snd_pcm_hw_params_set_channels (pcm, hw, stereo ? 2 : 1); + case 2: + case 3: + case 4: + case 5: + err = psnd_pcm_hw_params_set_channels (pcm, hw, stereo+1); if (0 > err) { Con_Printf ("ALSA: no usable channels. %s\n", - snd_strerror (err)); + psnd_strerror (err)); goto error; } break; @@ -243,23 +340,23 @@ static int ALSA_InitCard (soundcardinfo_t *sc, int cardnum) switch (rate) { case 0: rate = 44100; - err = snd_pcm_hw_params_set_rate_near (pcm, hw, &rate, 0); + err = psnd_pcm_hw_params_set_rate_near (pcm, hw, &rate, 0); if (0 <= err) { frag_size = 32 * bps; } else { rate = 22050; - err = snd_pcm_hw_params_set_rate_near (pcm, hw, &rate, 0); + err = psnd_pcm_hw_params_set_rate_near (pcm, hw, &rate, 0); if (0 <= err) { frag_size = 16 * bps; } else { rate = 11025; - err = snd_pcm_hw_params_set_rate_near (pcm, hw, &rate, + err = psnd_pcm_hw_params_set_rate_near (pcm, hw, &rate, 0); if (0 <= err) { frag_size = 8 * bps; } else { Con_Printf ("ALSA: no usable rates. %s\n", - snd_strerror (err)); + psnd_strerror (err)); goto error; } } @@ -268,10 +365,10 @@ static int ALSA_InitCard (soundcardinfo_t *sc, int cardnum) case 11025: case 22050: case 44100: - err = snd_pcm_hw_params_set_rate_near (pcm, hw, &rate, 0); + err = psnd_pcm_hw_params_set_rate_near (pcm, hw, &rate, 0); if (0 > err) { Con_Printf ("ALSA: desired rate %i not supported. %s\n", rate, - snd_strerror (err)); + psnd_strerror (err)); goto error; } frag_size = 8 * bps * rate / 11025; @@ -281,40 +378,40 @@ static int ALSA_InitCard (soundcardinfo_t *sc, int cardnum) goto error; } - err = snd_pcm_hw_params_set_period_size_near (pcm, hw, &frag_size, 0); + err = psnd_pcm_hw_params_set_period_size_near (pcm, hw, &frag_size, 0); if (0 > err) { Con_Printf ("ALSA: unable to set period size near %i. %s\n", - (int) frag_size, snd_strerror (err)); + (int) frag_size, psnd_strerror (err)); goto error; } - err = snd_pcm_hw_params (pcm, hw); + err = psnd_pcm_hw_params (pcm, hw); if (0 > err) { Con_Printf ("ALSA: unable to install hw params: %s\n", - snd_strerror (err)); + psnd_strerror (err)); goto error; } - err = snd_pcm_sw_params_current (pcm, sw); + err = psnd_pcm_sw_params_current (pcm, sw); if (0 > err) { Con_Printf ("ALSA: unable to determine current sw params. %s\n", - snd_strerror (err)); + psnd_strerror (err)); goto error; } - err = snd_pcm_sw_params_set_start_threshold (pcm, sw, ~0U); + err = psnd_pcm_sw_params_set_start_threshold (pcm, sw, ~0U); if (0 > err) { Con_Printf ("ALSA: unable to set playback threshold. %s\n", - snd_strerror (err)); + psnd_strerror (err)); goto error; } - err = snd_pcm_sw_params_set_stop_threshold (pcm, sw, ~0U); + err = psnd_pcm_sw_params_set_stop_threshold (pcm, sw, ~0U); if (0 > err) { Con_Printf ("ALSA: unable to set playback stop threshold. %s\n", - snd_strerror (err)); + psnd_strerror (err)); goto error; } - err = snd_pcm_sw_params (pcm, sw); + err = psnd_pcm_sw_params (pcm, sw); if (0 > err) { Con_Printf ("ALSA: unable to install sw params. %s\n", - snd_strerror (err)); + psnd_strerror (err)); goto error; } @@ -322,10 +419,10 @@ static int ALSA_InitCard (soundcardinfo_t *sc, int cardnum) sc->sn.samplepos = 0; sc->sn.samplebits = bps; - err = snd_pcm_hw_params_get_buffer_size (hw, &buffer_size); + err = psnd_pcm_hw_params_get_buffer_size (hw, &buffer_size); if (0 > err) { Con_Printf ("ALSA: unable to get buffer size. %s\n", - snd_strerror (err)); + psnd_strerror (err)); goto error; } @@ -344,7 +441,7 @@ static int ALSA_InitCard (soundcardinfo_t *sc, int cardnum) return true; error: - snd_pcm_close (pcm); + psnd_pcm_close (pcm); return false; } diff --git a/engine/common/cmd.c b/engine/common/cmd.c index 74b126e2b..0370e699e 100644 --- a/engine/common/cmd.c +++ b/engine/common/cmd.c @@ -8,7 +8,7 @@ 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. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -33,7 +33,7 @@ void Cmd_ForwardToServer (void); typedef struct cmdalias_s { struct cmdalias_s *next; - char name[MAX_ALIAS_NAME]; + char name[MAX_ALIAS_NAME]; char *value; qbyte execlevel; qbyte restriction; @@ -150,7 +150,7 @@ bind g "impulse 5 ; +attack ; wait ; -attack ; impulse 2" */ void Cmd_Wait_f (void) { - cmd_text[Cmd_ExecLevel].waitattime = realtime; + cmd_text[Cmd_ExecLevel].waitattime = realtime; } /* @@ -181,7 +181,7 @@ void Cbuf_AddText (const char *text, int level) Con_Printf("Bad execution level\n"); return; //reject. } - + l = Q_strlen (text); if (!cmd_text[level].buf.maxsize) @@ -239,7 +239,7 @@ void Cbuf_InsertText (const char *text, int level) } else temp = NULL; // shut up compiler - + // add the entire text of the file Cbuf_AddText (text, level); SZ_Write (&cmd_text[level].buf, "\n", 1); @@ -280,11 +280,11 @@ start: Con_Printf("Statement too long\n"); return ""; } - - + + memcpy (line, text, i); line[i] = 0; - + // delete the text from the command buffer and move remaining commands down // this is necessary because commands (exec, alias) can insert data at the // beginning of the text buffer @@ -352,7 +352,7 @@ void Cbuf_ExecuteLevel (int level) i = sizeof(line)-1; memcpy (line, text, i); line[i] = 0; - + // delete the text from the command buffer and move remaining commands down // this is necessary because commands (exec, alias) can insert data at the // beginning of the text buffer @@ -366,7 +366,7 @@ void Cbuf_ExecuteLevel (int level) Q_memcpy (text, text+i, cmd_text[level].buf.cursize); } -// execute the command line +// execute the command line Cmd_ExecuteString (line, level); } } @@ -419,7 +419,7 @@ void Cmd_StuffCmds (void) } if (!s) return; - + text = (char*)Z_Malloc (s+1); text[0] = 0; for (i=1 ; i= line && *end <= ' '; end--) //skip trailing *end = '\0'; if (!strcmp(line, "{")) @@ -862,9 +862,9 @@ void Cmd_AliasLevel_f (void) void Cmd_AliasList_f (void) { cmdalias_t *cmd; - int num=0; + int num=0; for (cmd=cmd_alias ; cmd ; cmd=cmd->next) - { + { if ((cmd->restriction?cmd->restriction:rcon_level.value) > Cmd_ExecLevel) continue; if (!num) @@ -882,9 +882,9 @@ void Cmd_AliasList_f (void) void Alias_WriteAliases (FILE *f) { cmdalias_t *cmd; - int num=0; + int num=0; for (cmd=cmd_alias ; cmd ; cmd=cmd->next) - { + { // if ((cmd->restriction?cmd->restriction:rcon_level.value) > Cmd_ExecLevel) // continue; if (cmd->flags & ALIAS_FROMSERVER) @@ -967,7 +967,7 @@ char *VARGS Cmd_Argv (int arg) { if ( arg >= cmd_argc ) return cmd_null_string; - return cmd_argv[arg]; + return cmd_argv[arg]; } /* @@ -1145,14 +1145,14 @@ Parses the given string into command line tokens. void Cmd_TokenizeString (char *text, qboolean expandmacros, qboolean qctokenize) { int i; - + // clear the args from the last string for (i=0 ; inext) { @@ -1237,7 +1237,7 @@ qboolean Cmd_AddRemCommand (char *cmd_name, xcommand_t function) Con_Printf ("Cmd_AddCommand: %s already defined as a var\n", cmd_name); return false; } - + // fail if the command already exists for (cmd=cmd_functions ; cmd ; cmd=cmd->next) { @@ -1333,7 +1333,7 @@ void Cmd_RestrictCommand_f (void) else if ((cmd->restriction?cmd->restriction:rcon_level.value) > Cmd_ExecLevel) Con_TPrintf(TL_RESTRICTCOMMANDTOOHIGH); else - cmd->restriction = level; + cmd->restriction = level; return; } } @@ -1437,7 +1437,7 @@ void Cmd_CompleteCheck(char *check, match_t *match) //compare cumulative strings { if (*match->result) { - char *r; + char *r; if (match->allowcutdown) { for(r = match->result; *r == *check && *r; r++, check++) @@ -1474,10 +1474,10 @@ char *Cmd_CompleteCommand (char *partial, qboolean fullonly, qboolean caseinsens static match_t match; cvar_group_t *grp; - cvar_t *cvar; - + cvar_t *cvar; + len = Q_strlen(partial); - + if (!len) return NULL; @@ -1532,7 +1532,7 @@ char *Cmd_CompleteCommand (char *partial, qboolean fullonly, qboolean caseinsens void Cmd_List_f (void) { cmd_function_t *cmd; - int num=0; + int num=0; for (cmd=cmd_functions ; cmd ; cmd=cmd->next) { if ((cmd->restriction?cmd->restriction:rcon_level.value) > Cmd_ExecLevel) @@ -1564,7 +1564,7 @@ void Cmd_ForwardToServer (void) Con_TPrintf (TL_CANTXNOTCONNECTED, Cmd_Argv(0)); return; } - + if (cls.demoplayback) return; // not really connected @@ -1595,7 +1595,7 @@ void Cmd_ForwardToServer_f (void) if (SCR_RSShot()) return; } - + if (cls.demoplayback) return; // not really connected @@ -1617,7 +1617,7 @@ FIXME: lookupnoadd the token to speed search? ============ */ void Cmd_ExecuteString (char *text, int level) -{ +{ cmd_function_t *cmd; cmdalias_t *a; @@ -1627,7 +1627,7 @@ void Cmd_ExecuteString (char *text, int level) text = Cmd_ExpandString(text, dest, sizeof(dest), level, !Cmd_IsInsecure()?true:false); Cmd_TokenizeString (text, level == RESTRICT_LOCAL?true:false, false); - + // execute the command line if (!Cmd_Argc()) return; // no tokens @@ -1656,6 +1656,7 @@ void Cmd_ExecuteString (char *text, int level) if (!Q_strcasecmp (cmd_argv[0], a->name)) { int i; + int execlevel; if ((a->restriction?a->restriction:rcon_level.value) > level) { @@ -1663,29 +1664,31 @@ void Cmd_ExecuteString (char *text, int level) return; } if (a->execlevel) - level = a->execlevel; + execlevel = a->execlevel; + else + execlevel = level; - Cbuf_InsertText ("\n", level); + Cbuf_InsertText ("\n", execlevel); // if the alias value is a command or cvar and // the alias is called with parameters, add them - if (Cmd_Argc() > 1 && !strchr(a->value, ' ') && !strchr(a->value, '\t') && + if (Cmd_Argc() > 1 && !strchr(a->value, ' ') && !strchr(a->value, '\t') && (Cvar_FindVar(a->value) || (Cmd_Exists(a->value) && a->value[0] != '+' && a->value[0] != '-')) ) { - Cbuf_InsertText (Cmd_Args(), level); - Cbuf_InsertText (" ", level); + Cbuf_InsertText (Cmd_Args(), execlevel); + Cbuf_InsertText (" ", execlevel); } - Cbuf_InsertText (a->value, level); + Cbuf_InsertText (a->value, execlevel); - if (level>=RESTRICT_SERVER) + if (execlevel>=RESTRICT_SERVER) return; //don't do the cmd_argc/cmd_argv stuff. When it's from the server, we had a tendancy to lock aliases, so don't set them anymore. - Cbuf_InsertText (va("set cmd_argc \"%i\"\n", cmd_argc), level); + Cbuf_InsertText (va("set cmd_argc \"%i\"\n", cmd_argc), execlevel); for (i = 1; i < cmd_argc; i++) - Cbuf_InsertText (va("set cmd_argv%i \"%s\"\n", i, cmd_argv[i]), level); + Cbuf_InsertText (va("set cmd_argv%i \"%s\"\n", i, cmd_argv[i]), execlevel); return; } } @@ -1756,14 +1759,14 @@ where the given parameter apears, or 0 if not present int Cmd_CheckParm (char *parm) { int i; - + if (!parm) Sys_Error ("Cmd_CheckParm: NULL"); for (i = 1; i < Cmd_Argc (); i++) if (! Q_strcasecmp (parm, Cmd_Argv (i))) return i; - + return 0; } @@ -1831,13 +1834,13 @@ const char *retfloat(float f) return ret->str; } qboolean is_numeric (const char *c) -{ +{ return (*c >= '0' && *c <= '9') || ((*c == '-' || *c == '+') && (c[1] == '.' || (c[1]>='0' && c[1]<='9'))) || (*c == '.' && (c[1]>='0' && c[1]<='9'))?true:false; } const char *If_Token(const char *func, const char **end) -{ +{ const char *s, *s2; cvar_t *var; int level; @@ -1861,7 +1864,7 @@ const char *If_Token(const char *func, const char **end) else if (*s2 == '(') level++; s2++; - } + } func = If_Token(s, end); *end = s2+1; s = *end; @@ -1913,7 +1916,7 @@ const char *If_Token(const char *func, const char **end) if ((var->restriction?var->restriction:rcon_level.value) > Cmd_ExecLevel) s2 = "RESTRICTED"; else - s2 = var->string; + s2 = var->string; } else s2 = retstring(com_token); @@ -2010,7 +2013,7 @@ const char *If_Token(const char *func, const char **end) else return retfloat(atoi(s2)|atoi(If_Token(s, end))); } - + return s2; } @@ -2037,7 +2040,7 @@ void Cbuf_ExecBlock(int level) while(*line <= ' ' && *line) //skip leading whitespace. line++; - + for (end = line + strlen(line)-1; end >= line && *end <= ' '; end--) //skip trailing *end = '\0'; @@ -2102,7 +2105,7 @@ void Cbuf_SkipBlock(int level) while(*line <= ' ' && *line) //skip leading whitespace. line++; - + for (end = line + strlen(line)-1; end >= line && *end <= ' '; end--) //skip trailing *end = '\0'; @@ -2167,7 +2170,7 @@ skipws: end+=4; goto skipws; } - + if (!*end) { if (ret && *ret) //equation was true. @@ -2611,7 +2614,7 @@ qboolean Cmd_FilterMessage (char *message, qboolean sameteam) //returns true if filter++; Q_strncpyz(trimmedfilter, filter, sizeof(trimmedfilter)); //might have whitespace. - + for (end = trimmedfilter + strlen(filter)-1; end >= trimmedfilter && *end <= ' '; end--) //skip trailing *end = '\0'; @@ -2654,7 +2657,7 @@ void Cmd_WriteConfig_f(void) Con_Printf ("Couldn't write config %s\n",filename); return; } - + filename = va("%s/configs/%s.cfg",com_gamedir, filename); } COM_DefaultExtension(filename, ".cfg"); diff --git a/engine/common/cvar.c b/engine/common/cvar.c index 009824053..7f2a181af 100644 --- a/engine/common/cvar.c +++ b/engine/common/cvar.c @@ -8,7 +8,7 @@ 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. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -35,7 +35,7 @@ cvar_t *Cvar_FindVar (const char *var_name) { cvar_group_t *grp; cvar_t *var; - + for (grp=cvar_groups ; grp ; grp=grp->next) for (var=grp->cvars ; var ; var=var->next) if (!Q_strcasecmp (var_name, var->name)) @@ -52,7 +52,7 @@ cvar_t *Cvar_FindVar (const char *var_name) cvar_group_t *Cvar_FindGroup (const char *group_name) { cvar_group_t *grp; - + for (grp=cvar_groups ; grp ; grp=grp->next) if (!Q_strcasecmp (group_name, grp->name)) return grp; @@ -104,7 +104,7 @@ Cvar_VariableValue float Cvar_VariableValue (const char *var_name) { cvar_t *var; - + var = Cvar_FindVar (var_name); if (!var) return 0; @@ -120,7 +120,7 @@ Cvar_VariableString char *Cvar_VariableString (const char *var_name) { cvar_t *var; - + var = Cvar_FindVar (var_name); if (!var) return cvar_null_string; @@ -139,12 +139,12 @@ char *Cvar_CompleteVariable (char *partial) cvar_group_t *grp; cvar_t *cvar; int len; - + len = Q_strlen(partial); - + if (!len) return NULL; - + // check exact match for (grp=cvar_groups ; grp ; grp=grp->next) for (cvar=grp->cvars ; cvar ; cvar=cvar->next) @@ -170,7 +170,7 @@ Cvar_Set cvar_t *Cvar_SetCore (cvar_t *var, const char *value, qboolean force) { char *latch=NULL; - + if (!var) return NULL; @@ -252,7 +252,7 @@ cvar_t *Cvar_SetCore (cvar_t *var, const char *value, qboolean force) #endif latch = var->string; - + var->string = (char*)Z_Malloc (Q_strlen(value)+1); Q_strcpy (var->string, value); var->value = Q_atof (var->string); @@ -449,7 +449,7 @@ void Cvar_Register (cvar_t *variable, const char *groupname) Cvar_Free(old); return; } - + Con_Printf ("Can't register variable %s, allready defined\n", variable->name); return; } @@ -478,7 +478,7 @@ void Cvar_Register (cvar_t *variable, const char *groupname) } /* void Cvar_RegisterVariable (cvar_t *variable) -{ +{ Cvar_Register(variable, NULL); } */ @@ -603,9 +603,12 @@ qboolean Cvar_Command (int level) //let cvar_set latch if needed. } else if (Cmd_FromGamecode()) - { - Cvar_LockFromServer(v, str); - return true; + {//it's not latched yet + if (strcmp(v->defaultstr, str)) + { //lock the cvar, unless it's going to it's default value. + Cvar_LockFromServer(v, str); + return true; + } } #endif Cvar_Set (v, str); //will use all, quote included diff --git a/engine/common/net_wins.c b/engine/common/net_wins.c index 1c1666449..3e5eb2fe3 100644 --- a/engine/common/net_wins.c +++ b/engine/common/net_wins.c @@ -8,7 +8,7 @@ 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. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -69,6 +69,10 @@ struct sockaddr; #define closesocket close #define ioctlsocket ioctl +#ifndef INVALID_SOCKET +#define INVALID_SOCKET -1 +#endif + #endif #ifdef _WIN32 @@ -310,7 +314,7 @@ qboolean NET_CompareBaseAdr (netadr_t a, netadr_t b) char *NET_AdrToString (netadr_t a) { static char s[64]; - + switch(a.type) { case NA_BROADCAST_IP: @@ -343,7 +347,7 @@ char *NET_AdrToString (netadr_t a) char *NET_BaseAdrToString (netadr_t a) { static char s[64]; - + switch(a.type) { case NA_BROADCAST_IP: @@ -394,7 +398,7 @@ qboolean NET_StringToSockaddr (char *s, struct sockaddr_qstorage *sadr) struct hostent *h; char *colon; char copy[128]; - + memset (sadr, 0, sizeof(*sadr)); #ifdef USEIPX @@ -441,7 +445,7 @@ qboolean NET_StringToSockaddr (char *s, struct sockaddr_qstorage *sadr) break; port--; } - + if (port == s) port = NULL; if (port) @@ -530,13 +534,13 @@ qboolean NET_StringToAdr (char *s, netadr_t *a) if (!NET_StringToSockaddr (s, &sadr)) return false; - + SockadrToNetadr (&sadr, a); return true; } -// Returns true if we can't bind the address locally--in other words, +// Returns true if we can't bind the address locally--in other words, // the IP is NOT one of our interfaces. qboolean NET_IsClientLegal(netadr_t *adr) { @@ -554,7 +558,7 @@ qboolean NET_IsClientLegal(netadr_t *adr) sadr.sin_port = 0; - if( bind (newsocket, (void *)&sadr, sizeof(sadr)) == -1) + if( bind (newsocket, (void *)&sadr, sizeof(sadr)) == -1) { // It is not a local address close(newsocket); @@ -777,7 +781,7 @@ void NET_SendPacket (netsrc_t netsrc, int length, void *data, netadr_t to) socket = cls.socketip; #endif } - + NetadrToSockadr (&to, &addr); switch(to.type) @@ -863,7 +867,7 @@ int maxport = port + 100; address.sin_port = 0; else address.sin_port = htons((short)port); - + if( bind (newsocket, (void *)&address, sizeof(address)) == -1) { if (!port) @@ -899,7 +903,7 @@ int maxport = port + 100; if (bcast) { -// address.sin6_addr +// address.sin6_addr // _true = true; // if (setsockopt(newsocket, SOL_SOCKET, IP_ADD_MEMBERSHIP, (char *)&_true, sizeof(_true)) == -1) // { @@ -1084,7 +1088,7 @@ NET_Init void NET_Init (void) { #ifdef _WIN32 - WORD wVersionRequested; + WORD wVersionRequested; int r; #ifdef IPPROTO_IPV6 HMODULE ws2_32dll; @@ -1104,7 +1108,7 @@ void NET_Init (void) pgetaddrinfo = NULL; #endif - wVersionRequested = MAKEWORD(1, 1); + wVersionRequested = MAKEWORD(1, 1); r = WSAStartup (MAKEWORD(1, 1), &winsockdata); diff --git a/engine/common/particles.h b/engine/common/particles.h index c12c114e1..04ece5651 100644 --- a/engine/common/particles.h +++ b/engine/common/particles.h @@ -140,7 +140,7 @@ int P_ParticleTypeForName(char *name); int P_AllocateParticleType(char *name); //find one if it exists, or create if it doesn't. int P_FindParticleType(char *name); //checks if particle description 'name' exists, returns -1 if not. -qboolean P_DescriptionIsLoaded(char *name); //returns true if it's usable. +int P_DescriptionIsLoaded(char *name); //returns true if it's usable. void P_SkyTri(float *v1, float *v2, float *v3, struct msurface_s *surf); diff --git a/engine/gl/gl_model.c b/engine/gl/gl_model.c index ade0c7187..3eca31e8a 100644 --- a/engine/gl/gl_model.c +++ b/engine/gl/gl_model.c @@ -982,7 +982,7 @@ TRACE(("dbg: GLMod_LoadTextures: inittexturedescs\n")); if (!Q_strncmp(mt->name,"sky",3)) { tx->offsets[0] = (char *)mt + mt->offsets[0] - (char *)tx; - R_InitSky (tx); + GLR_InitSky (tx); } else #ifdef PEXT_BULLETENS diff --git a/engine/qclib/Makefile b/engine/qclib/Makefile index 1f4f7b1db..eaea47d27 100644 --- a/engine/qclib/Makefile +++ b/engine/qclib/Makefile @@ -3,7 +3,7 @@ GTKGUI_OBJS=qcc_gtk.o qccguistuff.c CC=gcc -Wall -DQCCONLY -DO_CC=$(CC) $(BASE_CFLAGS) -DUSEGUI -o $@ -c $< $(CFLAGS) +DO_CC=$(CC) $(BASE_CFLAGS) -o $@ -c $< $(CFLAGS) all: qcc @@ -48,4 +48,4 @@ qcc_gtk.o: qcc_gtk.c qcc.h $(DO_CC) `pkg-config --cflags gtk+-2.0` gtkgui: $(QCC_OBJS) $(GTKGUI_OBJS) - $(CC) $(BASE_CFLAGS) -DQCCONLY -DUSEGUI -o fteqccgui.bin -O3 $(GTKGUI_OBJS) $(QCC_OBJS) `pkg-config --libs gtk+-2.0` \ No newline at end of file + $(CC) $(BASE_CFLAGS) -DQCCONLY -DUSEGUI -o fteqccgui.bin -O3 $(GTKGUI_OBJS) $(QCC_OBJS) `pkg-config --libs gtk+-2.0` diff --git a/engine/server/net_preparse.c b/engine/server/net_preparse.c index 503b3be32..6d24c8ea4 100644 --- a/engine/server/net_preparse.c +++ b/engine/server/net_preparse.c @@ -36,7 +36,7 @@ static qboolean ignoreprotocol; #define TE_EXPLOSIONSMALL2 20 // org. client_t *Write_GetClient(void); -sizebuf_t *WriteDest (int dest); +sizebuf_t *QWWriteDest (int dest); #ifdef NQPROT sizebuf_t *NQWriteDest (int dest); #endif @@ -57,7 +57,7 @@ void NPP_SetInfo(client_t *cl, char *key, char *value) MSG_WriteString (&sv.reliable_datagram, Info_ValueForKey(cl->userinfo, key)); } -void NPP_Flush(void) +void NPP_NQFlush(void) { if (!bufferlen) return; @@ -67,7 +67,7 @@ void NPP_Flush(void) { case svc_cdtrack: if (bufferlen!=protocollen) - Con_Printf("svc_cdtrack wasn't the right length\n"); + Con_Printf("NQFlush: svc_cdtrack wasn't the right length\n"); else bufferlen-=1; break; @@ -120,7 +120,7 @@ void NPP_Flush(void) writedest = NULL; } break; -// case svc_finale: +// case svc_finale: // bufferlen = 0; // break; case svc_setview: @@ -156,7 +156,7 @@ void NPP_Flush(void) switch (buffer[1]) { case NQTE_EXPLOSION2: //happens with rogue. - bufferlen -= 2; //trim the colour + bufferlen -= 2; //trim the colour buffer[1] = TE_EXPLOSION; break; } @@ -211,17 +211,17 @@ void NPP_Flush(void) multicastpos=0; requireextension=0; } -void NPP_CheckFlush(void) +void NPP_NQCheckFlush(void) { if (bufferlen >= protocollen && protocollen) - NPP_Flush(); + NPP_NQFlush(); } -void NPP_CheckDest(int dest) +void NPP_NQCheckDest(int dest) { if (dest == MSG_ONE) { - client_t *cl = Write_GetClient(); +/* client_t *cl = Write_GetClient(); if (!cl) { Con_Printf("Not a client\n"); @@ -230,17 +230,18 @@ void NPP_CheckDest(int dest) if ((cldest && cldest != cl) || writedest) { Con_Printf("MSG destination changed in the middle of a packet %i.\n", (int)*buffer); - NPP_Flush(); + NPP_NQFlush(); } cldest = cl; +*/ } else { - sizebuf_t *ndest = WriteDest(dest); + sizebuf_t *ndest = QWWriteDest(dest); if (cldest || (writedest && writedest != ndest)) { - Con_Printf("MSG destination changed in the middle of a packet %i.\n", (int)*buffer); - NPP_Flush(); + Con_Printf("NQCheckDest: MSG destination changed in the middle of a packet %i.\n", (int)*buffer); + NPP_NQFlush(); } writedest = ndest; } @@ -250,18 +251,18 @@ void NPP_AddData(void *data, int len) if (bufferlen+len > sizeof(buffer)) Sys_Error("Preparse buffer was filled\n"); memcpy(buffer+bufferlen, data, len); - bufferlen+=len; + bufferlen+=len; } void NPP_NQWriteByte(int dest, qbyte data) //replacement write func (nq to qw) { - NPP_CheckDest(dest); + NPP_NQCheckDest(dest); #ifdef NQPROT if (dest == MSG_ONE) { client_t *cl = Write_GetClient(); if (cl && !ISQWCLIENT(cl)) - { + { ClientReliableCheckBlock(cl, sizeof(qbyte)); ClientReliableWrite_Byte(cl, data); } @@ -269,13 +270,13 @@ void NPP_NQWriteByte(int dest, qbyte data) //replacement write func (nq to qw) MSG_WriteByte (NQWriteDest(dest), data); #endif if (!bufferlen) //new message section - { + { switch(data) { case svcdp_showlmp: case svcdp_hidelmp: break; - case svc_temp_entity: + case svc_temp_entity: break; case svc_setangle: protocollen = sizeof(qbyte)*4; @@ -330,7 +331,7 @@ void NPP_NQWriteByte(int dest, qbyte data) //replacement write func (nq to qw) ignoreprotocol = true; break; default: - Con_Printf("nq: bad protocol %i\n", (int)data); + Con_Printf("NQWriteByte: bad protocol %i\n", (int)data); protocollen = sizeof(buffer); break; } @@ -377,7 +378,7 @@ void NPP_NQWriteByte(int dest, qbyte data) //replacement write func (nq to qw) multicastpos=2; multicasttype=MULTICAST_PVS; protocollen = sizeofcoord*3+sizeof(qbyte)*2; - break; + break; case TE_EXPLOSION3_NEH: protocollen = sizeof(qbyte) + sizeofcoord*6; ignoreprotocol = true; @@ -441,7 +442,7 @@ void NPP_NQWriteByte(int dest, qbyte data) //replacement write func (nq to qw) default: protocollen = sizeof(buffer); - Con_Printf("bad tempentity\n"); + Con_Printf("NQWriteByte: bad tempentity\n"); break; } break; @@ -450,7 +451,7 @@ void NPP_NQWriteByte(int dest, qbyte data) //replacement write func (nq to qw) case svc_centerprint: break; default: - Con_Printf("Non-Implemented svc\n"); + Con_Printf("NQWriteByte: Non-Implemented svc\n"); protocollen = sizeof(buffer); break; } @@ -481,7 +482,7 @@ void NPP_NQWriteByte(int dest, qbyte data) //replacement write func (nq to qw) } NPP_AddData(&data, sizeof(qbyte)); - NPP_CheckFlush(); + NPP_NQCheckFlush(); } void NPP_NQWriteChar(int dest, char data) //replacement write func (nq to qw) @@ -489,7 +490,7 @@ void NPP_NQWriteChar(int dest, char data) //replacement write func (nq to qw) NPP_NQWriteByte(dest, (qbyte)data); return; /* - NPP_CheckDest(dest); + NPP_NQCheckDest(dest); if (!bufferlen) { NPP_NQWriteByte(dest, (qbyte)data); @@ -500,7 +501,7 @@ void NPP_NQWriteChar(int dest, char data) //replacement write func (nq to qw) if (dest == MSG_ONE) { client_t *cl = Write_GetClient(); if (cl && cl->nqprot) - { + { ClientReliableCheckBlock(cl, sizeof(char)); ClientReliableWrite_Char(cl, data); } @@ -509,69 +510,48 @@ void NPP_NQWriteChar(int dest, char data) //replacement write func (nq to qw) #endif NPP_AddData(&data, sizeof(char)); - NPP_CheckFlush();*/ + NPP_NQCheckFlush();*/ } void NPP_NQWriteShort(int dest, short data) //replacement write func (nq to qw) { -NPP_CheckDest(dest); - if (!bufferlen) - Con_Printf("Messages should start with WriteByte\n"); - -#ifdef NQPROT - if (dest == MSG_ONE) { - client_t *cl = Write_GetClient(); - if (cl && !ISQWCLIENT(cl)) - { - ClientReliableCheckBlock(cl, sizeof(short)); - ClientReliableWrite_Short(cl, data); - } - } else - MSG_WriteShort (NQWriteDest(dest), data); -#endif - - data = LittleShort(data); - NPP_AddData(&data, sizeof(short)); - NPP_CheckFlush(); + union { + qbyte b[2]; + short s; + } u; + u.s = LittleShort(data); + NPP_NQWriteByte(dest, u.b[0]); + NPP_NQWriteByte(dest, u.b[1]); } void NPP_NQWriteLong(int dest, long data) //replacement write func (nq to qw) { - NPP_CheckDest(dest); - if (!bufferlen) - Con_Printf("Messages should start with WriteByte\n"); - -#ifdef NQPROT - if (dest == MSG_ONE) { - client_t *cl = Write_GetClient(); - if (cl && !ISQWCLIENT(cl)) - { - ClientReliableCheckBlock(cl, sizeof(long)); - ClientReliableWrite_Long(cl, data); - } - } else - MSG_WriteLong (NQWriteDest(dest), data); -#endif - - data = LittleLong(data); - NPP_AddData(&data, sizeof(long)); - NPP_CheckFlush(); + union { + qbyte b[4]; + int l; + } u; + u.l = LittleLong(data); + NPP_NQWriteByte(dest, u.b[0]); + NPP_NQWriteByte(dest, u.b[1]); + NPP_NQWriteByte(dest, u.b[2]); + NPP_NQWriteByte(dest, u.b[3]); } void NPP_NQWriteAngle(int dest, float in) //replacement write func (nq to qw) { char data = (int)(in*256/360) & 255; -NPP_CheckDest(dest); + NPP_NQCheckDest(dest); if (!bufferlen) - Con_Printf("Messages should start with WriteByte\n"); + Con_Printf("NQWriteAngle: Messages should start with WriteByte\n"); #ifdef NQPROT if (dest == MSG_ONE) { client_t *cl = Write_GetClient(); if (cl && !ISQWCLIENT(cl)) - { + { ClientReliableCheckBlock(cl, sizeof(char)); ClientReliableWrite_Angle(cl, in); + return; } } else @@ -579,23 +559,24 @@ NPP_CheckDest(dest); #endif NPP_AddData(&data, sizeof(char)); - NPP_CheckFlush(); + NPP_NQCheckFlush(); } void NPP_NQWriteCoord(int dest, float in) //replacement write func (nq to qw) { short datas = (int)(in*8); float dataf = in; -NPP_CheckDest(dest); + NPP_NQCheckDest(dest); if (!bufferlen) - Con_Printf("Messages should start with WriteByte\n"); + Con_Printf("NQWriteCoord: Messages should start with WriteByte\n"); #ifdef NQPROT if (dest == MSG_ONE) { client_t *cl = Write_GetClient(); if (cl && !ISQWCLIENT(cl)) - { + { ClientReliableCheckBlock(cl, sizeof(float)); ClientReliableWrite_Coord(cl, in); + return; } } else MSG_WriteCoord (NQWriteDest(dest), in); @@ -611,21 +592,22 @@ NPP_CheckDest(dest); datas = LittleShort(datas); NPP_AddData(&datas, sizeof(short)); } - NPP_CheckFlush(); + NPP_NQCheckFlush(); } void NPP_NQWriteString(int dest, char *data) //replacement write func (nq to qw) { -NPP_CheckDest(dest); + NPP_NQCheckDest(dest); if (!bufferlen) - Con_Printf("Messages should start with WriteByte\n"); + Con_Printf("NQWriteString: Messages should start with WriteByte\n"); #ifdef NQPROT if (dest == MSG_ONE) { client_t *cl = Write_GetClient(); if (cl && !ISQWCLIENT(cl)) - { + { ClientReliableCheckBlock(cl, strlen(data)+1); ClientReliableWrite_String(cl, data); + return; } } else MSG_WriteString (NQWriteDest(dest), data); @@ -645,13 +627,13 @@ NPP_CheckDest(dest); } } - NPP_CheckFlush(); + NPP_NQCheckFlush(); } void NPP_NQWriteEntity(int dest, short data) //replacement write func (nq to qw) { -NPP_CheckDest(dest); + NPP_NQCheckDest(dest); if (!bufferlen) - Con_Printf("Messages should start with WriteByte\n"); + Con_Printf("NQWriteEntity: Messages should start with WriteByte\n"); if (majortype == svc_temp_entity && data >= 0 && data <= sv.allocated_client_slots) if (svs.clients[data-1].viewent) @@ -661,16 +643,17 @@ NPP_CheckDest(dest); if (dest == MSG_ONE) { client_t *cl = Write_GetClient(); if (cl && !ISQWCLIENT(cl)) - { + { ClientReliableCheckBlock(cl, sizeof(short)); ClientReliableWrite_Short(cl, data); + return; } } else MSG_WriteShort (NQWriteDest(dest), data); #endif NPP_AddData(&data, sizeof(short)); - NPP_CheckFlush(); + NPP_NQCheckFlush(); } @@ -699,7 +682,6 @@ void NPP_QWFlush(void) if (!bufferlen) return; - switch(majortype) { case svc_setname: //not a standard feature, but hey, if a progs wants bots. @@ -713,7 +695,7 @@ void NPP_QWFlush(void) break; case svc_cdtrack: if (bufferlen!=protocollen) - Con_Printf("svc_cdtrack wasn't the right length\n"); + Con_Printf("QWFlush: svc_cdtrack wasn't the right length\n"); else { b = 0; @@ -743,7 +725,7 @@ void NPP_QWFlush(void) ClientReliableCheckBlock(cl, 1); ClientReliableWrite_Byte(cl, svc_intermission); - + org[0] = (*(short*)&buffer[1])/8.0f; org[1] = (*(short*)&buffer[1+2])/8.0f; org[2] = (*(short*)&buffer[1+4])/8.0f; @@ -762,7 +744,7 @@ void NPP_QWFlush(void) bufferlen = 0; protocollen=0; writedest = NULL; -// case svc_finale: +// case svc_finale: // bufferlen = 0; break; case svc_setview: @@ -772,21 +754,21 @@ void NPP_QWFlush(void) case svc_muzzleflash: //we need to make a fake muzzleflash position. multicastpos = 4; - { + { short data; float org[3]; edict_t *ent = EDICT_NUM(svprogfuncs, (*(short*)&buffer[1])); VectorCopy(ent->v->origin, org); - + data = LittleShort((short)(org[0]*8)); NPP_AddData(&data, sizeof(short)); data = LittleShort((short)(org[1]*8)); NPP_AddData(&data, sizeof(short)); data = LittleShort((short)(org[2]*8)); NPP_AddData(&data, sizeof(short)); - + } - bufferlen = 0; + bufferlen = 0; //can't send this to nq. :( break; case svc_smallkick: case svc_bigkick: @@ -815,16 +797,23 @@ void NPP_QWFlush(void) case TE_BLOOD: //needs to be converted to a particle { vec3_t org; + qbyte count; + qbyte colour; + char dir[3]; + short s; int v; int i; - org[0] = (*(short*)&buffer[multicastpos])/8.0f; + qbyte svc; + svc = svc_particle; + org[0] = (*(short*)&buffer[multicastpos])/8.0f; org[1] = (*(short*)&buffer[multicastpos+2])/8.0f; org[2] = (*(short*)&buffer[multicastpos+4])/8.0f; + count = buffer[2]*20; + if (minortype == TE_LIGHTNINGBLOOD) + colour = 225; + else + colour = 73; - MSG_WriteByte (&sv.nqmulticast, svc_particle); - MSG_WriteCoord (&sv.nqmulticast, org[0]); - MSG_WriteCoord (&sv.nqmulticast, org[1]); - MSG_WriteCoord (&sv.nqmulticast, org[2]); for (i=0 ; i<3 ; i++) { v = 0*16; @@ -832,19 +821,38 @@ void NPP_QWFlush(void) v = 127; else if (v < -128) v = -128; - MSG_WriteChar (&sv.nqmulticast, v); + dir[i] = v; } - MSG_WriteByte (&sv.nqmulticast, buffer[2]*20); - if (minortype == TE_LIGHTNINGBLOOD) - MSG_WriteByte (&sv.nqmulticast, 225); - else - MSG_WriteByte (&sv.nqmulticast, 73); + + bufferlen = 0; //restart + protocollen = 1000; + + multicastpos = 1; + + NPP_AddData(&svc, sizeof(qbyte)); + for (i = 0; i < 3; i++) + { + if (sizeofcoord == 4) + NPP_AddData(&org[i], sizeof(float)); + else + { + s = org[i]*8; + NPP_AddData(&s, sizeof(short)); + } + } + NPP_AddData(&dir[0], sizeof(char)); + NPP_AddData(&dir[1], sizeof(char)); + NPP_AddData(&dir[2], sizeof(char)); + NPP_AddData(&count, sizeof(qbyte)); + NPP_AddData(&colour, sizeof(qbyte)); } - bufferlen = 0; break; - case TE_GUNSHOT: //needs qbyte 3 removed - memmove(buffer+2, buffer+3, bufferlen-3); - bufferlen--; + case TE_GUNSHOT: //needs byte 3 removed + if (bufferlen >= 3) + { + memmove(buffer+2, buffer+3, bufferlen-3); + bufferlen--; + } break; } } @@ -908,7 +916,7 @@ void NPP_QWCheckDest(int dest) { if (dest == MSG_ONE) { - client_t *cl = Write_GetClient(); + /*client_t *cl = Write_GetClient(); if (!cl) { Con_Printf("Not a client\n"); @@ -920,13 +928,14 @@ void NPP_QWCheckDest(int dest) NPP_QWFlush(); } cldest = cl; + */ } else { sizebuf_t *ndest = NQWriteDest(dest); if (cldest || (writedest && writedest != ndest)) { - Con_Printf("MSG destination changed in the middle of a packet %i.\n", (int)*buffer); + Con_Printf("QWCheckDest: MSG destination changed in the middle of a packet %i.\n", (int)*buffer); NPP_QWFlush(); } writedest = ndest; @@ -944,18 +953,19 @@ void NPP_QWWriteByte(int dest, qbyte data) //replacement write func (nq to qw) if (dest == MSG_ONE) { client_t *cl = Write_GetClient(); if (cl && ISQWCLIENT(cl)) - { + { ClientReliableCheckBlock(cl, sizeof(qbyte)); ClientReliableWrite_Byte(cl, data); + return; } } else - MSG_WriteByte (WriteDest(dest), data); + MSG_WriteByte (QWWriteDest(dest), data); #endif if (!bufferlen) //new message section - { + { switch(data) { - case svc_temp_entity: + case svc_temp_entity: break; case svc_setangle: protocollen = sizeof(qbyte)*4; @@ -1013,7 +1023,7 @@ void NPP_QWWriteByte(int dest, qbyte data) //replacement write func (nq to qw) protocollen = 6; break; default: - Con_Printf("bad protocol %i\n", (int)data); + Con_Printf("QWWriteByte: bad protocol %i\n", (int)data); protocollen = sizeof(buffer); break; } @@ -1033,7 +1043,7 @@ void NPP_QWWriteByte(int dest, qbyte data) //replacement write func (nq to qw) multicastpos=4; multicasttype=MULTICAST_PHS; protocollen = sizeofcoord*6+sizeof(short)+sizeof(qbyte)*2; - break; + break; case TE_BLOOD: //needs to be converted to a particle case TE_GUNSHOT: //needs qbyte 2 removed multicastpos=3; @@ -1064,12 +1074,12 @@ void NPP_QWWriteByte(int dest, qbyte data) //replacement write func (nq to qw) break; default: protocollen = sizeof(buffer); - Con_Printf("bad tempentity - %i\n", data); + Con_Printf("QWWriteByte: bad tempentity - %i\n", data); break; } break; default: - Con_Printf("Non-Implemented svc\n"); + Con_Printf("QWWriteByte: Non-Implemented svc\n"); protocollen = sizeof(buffer); break; } @@ -1084,144 +1094,87 @@ void NPP_QWWriteByte(int dest, qbyte data) //replacement write func (nq to qw) void NPP_QWWriteChar(int dest, char data) //replacement write func (nq to qw) { - NPP_QWCheckDest(dest); - if (!bufferlen) - Con_Printf("Messages should start with WriteByte (last was %i)\n", majortype); - -#ifdef NQPROT - if (dest == MSG_ONE) { - client_t *cl = Write_GetClient(); - if (cl && ISQWCLIENT(cl)) - { - ClientReliableCheckBlock(cl, sizeof(char)); - ClientReliableWrite_Char(cl, data); - } - } else - MSG_WriteChar (WriteDest(dest), data); -#endif - - NPP_AddData(&data, sizeof(char)); - if (!data && bufferlen>=protocollen) - if (nullterms) - nullterms--; - NPP_QWCheckFlush(); + NPP_QWWriteByte(dest, (qbyte)data); } void NPP_QWWriteShort(int dest, short data) //replacement write func (nq to qw) { -NPP_QWCheckDest(dest); - if (!bufferlen) - Con_Printf("Messages should start with WriteByte (last was %i)\n", majortype); + union { + qbyte b[2]; + short s; + } u; + u.s = LittleShort(data); + NPP_QWWriteByte(dest, u.b[0]); + NPP_QWWriteByte(dest, u.b[1]); +} -#ifdef NQPROT - if (dest == MSG_ONE) { - client_t *cl = Write_GetClient(); - if (cl && ISQWCLIENT(cl)) - { - ClientReliableCheckBlock(cl, sizeof(short)); - ClientReliableWrite_Short(cl, data); - } - } else - MSG_WriteShort (WriteDest(dest), data); -#endif - - data = LittleShort(data); - NPP_AddData(&data, sizeof(short)); - NPP_QWCheckFlush(); +void NPP_QWWriteFloat(int dest, float data) //replacement write func (nq to qw) +{ + union { + qbyte b[4]; + short f; + } u; + u.f = LittleFloat(data); + NPP_QWWriteByte(dest, u.b[0]); + NPP_QWWriteByte(dest, u.b[1]); + NPP_QWWriteByte(dest, u.b[2]); + NPP_QWWriteByte(dest, u.b[3]); } void NPP_QWWriteLong(int dest, long data) //replacement write func (nq to qw) { - NPP_QWCheckDest(dest); - if (!bufferlen) - Con_Printf("Messages should start with WriteByte (last was %i)\n", majortype); - -#ifdef NQPROT - if (dest == MSG_ONE) { - client_t *cl = Write_GetClient(); - if (cl && ISQWCLIENT(cl)) - { - ClientReliableCheckBlock(cl, sizeof(long)); - ClientReliableWrite_Long(cl, data); - } - } else - MSG_WriteLong (WriteDest(dest), data); -#endif - - data = LittleLong(data); - NPP_AddData(&data, sizeof(long)); - NPP_QWCheckFlush(); + union { + qbyte b[4]; + int l; + } u; + u.l = LittleLong(data); + NPP_QWWriteByte(dest, u.b[0]); + NPP_QWWriteByte(dest, u.b[1]); + NPP_QWWriteByte(dest, u.b[2]); + NPP_QWWriteByte(dest, u.b[3]); } void NPP_QWWriteAngle(int dest, float in) //replacement write func (nq to qw) { - char data = (int)(in*256/360) & 255; -NPP_QWCheckDest(dest); - if (!bufferlen) - Con_Printf("Messages should start with WriteByte (last was %i)\n", majortype); - -#ifdef NQPROT - if (dest == MSG_ONE) { - client_t *cl = Write_GetClient(); - if (cl && ISQWCLIENT(cl)) - { - ClientReliableCheckBlock(cl, sizeof(char)); - ClientReliableWrite_Angle(cl, in); - } - } else - MSG_WriteAngle (WriteDest(dest), in); -#endif - - NPP_AddData(&data, sizeof(char)); - NPP_QWCheckFlush(); + if (sizeofangle==1) + { + char data = (int)(in*256/360) & 255; + NPP_NQWriteChar(dest, data); + } + else + { + short data = (int)(in*0xffff/360) & 0xffff; + NPP_NQWriteShort(dest, data); + } } void NPP_QWWriteCoord(int dest, float in) //replacement write func (nq to qw) { - short datas = (int)(in*8); - float dataf = in; + if (sizeofcoord==4) + { + NPP_QWWriteFloat(dest, in); + } + else + { + short datas = (int)(in*8); + NPP_QWWriteShort(dest, datas); + } +} +void NPP_QWWriteString(int dest, char *data) //replacement write func (nq to qw) +{ NPP_QWCheckDest(dest); if (!bufferlen) - Con_Printf("Messages should start with WriteByte (last was %i)\n", majortype); + Con_Printf("QWWriteString: Messages should start with WriteByte (last was %i)\n", majortype); #ifdef NQPROT if (dest == MSG_ONE) { client_t *cl = Write_GetClient(); if (cl && ISQWCLIENT(cl)) { - ClientReliableCheckBlock(cl, sizeof(float)); - ClientReliableWrite_Coord(cl, in); - } - } else - MSG_WriteCoord (WriteDest(dest), in); -#endif - - if (sizeofcoord==4) - { - dataf = LittleFloat(dataf); - NPP_AddData(&dataf, sizeof(float)); - } - else - { - datas = LittleShort(datas); - NPP_AddData(&datas, sizeof(short)); - } - NPP_QWCheckFlush(); -} -void NPP_QWWriteString(int dest, char *data) //replacement write func (nq to qw) -{ - NPP_QWCheckDest(dest); - if (!bufferlen) - Con_Printf("Messages should start with WriteByte (last was %i)\n", majortype); - -#ifdef NQPROT - if (dest == MSG_ONE) { - client_t *cl = Write_GetClient(); - if (cl && ISQWCLIENT(cl)) - { ClientReliableCheckBlock(cl, strlen(data)+1); ClientReliableWrite_String(cl, data); + return; } } else - MSG_WriteString (WriteDest(dest), data); + MSG_WriteString (QWWriteDest(dest), data); #endif NPP_AddData(data, strlen(data)+1); @@ -1231,24 +1184,13 @@ void NPP_QWWriteString(int dest, char *data) //replacement write func (nq to qw) } void NPP_QWWriteEntity(int dest, short data) //replacement write func (nq to qw) { -NPP_QWCheckDest(dest); - if (!bufferlen) - Con_Printf("Messages should start with WriteByte (last was %i)\n", majortype); - -#ifdef NQPROT - if (dest == MSG_ONE) { - client_t *cl = Write_GetClient(); - if (cl && ISQWCLIENT(cl)) - { - ClientReliableCheckBlock(cl, sizeof(short)); - ClientReliableWrite_Short(cl, data); - } - } else - MSG_WriteShort (WriteDest(dest), data); -#endif - - NPP_AddData(&data, sizeof(short)); - NPP_QWCheckFlush(); + union { + qbyte b[2]; + short s; + } u; + u.s = LittleShort(data); + NPP_QWWriteByte(dest, u.b[0]); + NPP_QWWriteByte(dest, u.b[1]); } @@ -1479,7 +1421,7 @@ void NPP_MVDFlush(void) { //new entity, reset to baseline memcpy(ents, &sv.demobaselines[entnum], sizeof(mvdentity_state_t)); } - + if (s & U_MOREBITS) { s |= buffer[i]; @@ -1491,7 +1433,7 @@ void NPP_MVDFlush(void) ents->modelindex = buffer[i]; i++; } - + if (s & U_FRAME) { ents->frame = buffer[i]; @@ -1521,7 +1463,7 @@ void NPP_MVDFlush(void) ents->origin[0] = (short)(buffer[i]+buffer[i+1]*256) /8.0f; i+=2; } - + if (s & U_ANGLE1) { ents->angles[0] = (unsigned char)(buffer[i]);// * (360.0/256); @@ -1533,7 +1475,7 @@ void NPP_MVDFlush(void) ents->origin[1] = (short)(buffer[i]+buffer[i+1]*256) /8.0f; i+=2; } - + if (s & U_ANGLE2) { ents->angles[1] = (unsigned char)(buffer[i]);// * (360.0/256); @@ -1545,7 +1487,7 @@ void NPP_MVDFlush(void) ents->origin[2] = (short)(buffer[i]+buffer[i+1]*256) /8.0f; i+=2; } - + if (s & U_ANGLE3) { ents->angles[2] = (unsigned char)(buffer[i]);// * (360.0/256); @@ -1746,7 +1688,7 @@ void NPP_MVDFlush(void) writedest = &sv.multicast; multicasttype = MULTICAST_ALL_R; } - + if (bufferlen) SZ_Write(writedest, buffer, bufferlen); @@ -1822,7 +1764,7 @@ void NPP_MVDWriteByte(qbyte data, client_t *to, int broadcast) //replacement wri NPP_MVDCheckDest(to, broadcast); if (!bufferlen) //new message section - { + { switch(data) { case svc_temp_entity://depends on following bytes @@ -1830,7 +1772,7 @@ void NPP_MVDWriteByte(qbyte data, client_t *to, int broadcast) //replacement wri case svc_serverinfo: case svc_print: case svc_sound: - case svc_serverdata: + case svc_serverdata: case svc_stufftext: case svc_modellist: case svc_soundlist: @@ -1938,7 +1880,7 @@ void NPP_MVDWriteByte(qbyte data, client_t *to, int broadcast) //replacement wri multicastpos=4; multicasttype=MULTICAST_PHS; protocollen = sizeof(short)*6+sizeof(short)+sizeof(qbyte)*2; - break; + break; case TE_BLOOD: //needs to be converted to a particle case TE_GUNSHOT: //needs qbyte 2 removed multicastpos=3; @@ -1961,7 +1903,7 @@ void NPP_MVDWriteByte(qbyte data, client_t *to, int broadcast) //replacement wri multicastpos=2; multicasttype=MULTICAST_PVS; protocollen = sizeof(short)*3+sizeof(qbyte)*2; - break; + break; default: protocollen = sizeof(buffer); Con_Printf("bad tempentity\n"); @@ -2015,7 +1957,7 @@ void NPP_MVDWriteByte(qbyte data, client_t *to, int broadcast) //replacement wri for (j=0 ; j<3 ; j++) if (pflags & (DF_ORIGIN << j)) protocollen += 2; - + for (j=0 ; j<3 ; j++) if (pflags & (DF_ANGLES << j)) protocollen += 2; @@ -2093,7 +2035,7 @@ void NPP_MVDWriteByte(qbyte data, client_t *to, int broadcast) //replacement wri if (s & U_MODEL) i++; - + if (s & U_FRAME) i++; @@ -2108,19 +2050,19 @@ void NPP_MVDWriteByte(qbyte data, client_t *to, int broadcast) //replacement wri if (s & U_ORIGIN1) i+=2; - + if (s & U_ANGLE1) i++; if (s & U_ORIGIN2) i+=2; - + if (s & U_ANGLE2) i++; if (s & U_ORIGIN3) i+=2; - + if (s & U_ANGLE3) i++; } @@ -2214,4 +2156,14 @@ void NPP_MVDWriteByte(qbyte data, client_t *to, int broadcast) //replacement wri NPP_MVDCheckFlush(); } + +void NPP_Flush(void) +{ + if (progstype == PROG_NQ) + NPP_NQFlush(); +#ifdef NQPROT + else + NPP_QWFlush(); +#endif +} #endif diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index 20ab05971..5b3b780a2 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -4190,7 +4190,7 @@ MESSAGE WRITING #define MSG_INIT 3 // write to the init string #define MSG_MULTICAST 4 // for multicast() -sizebuf_t *WriteDest (int dest) +sizebuf_t *QWWriteDest (int dest) { switch (dest) { @@ -4337,7 +4337,7 @@ void PF_WriteByte (progfuncs_t *prinst, struct globalvars_s *pr_globals) ClientReliableWrite_Byte(cl, G_FLOAT(OFS_PARM1)); } else - MSG_WriteByte (WriteDest(G_FLOAT(OFS_PARM0)), G_FLOAT(OFS_PARM1)); + MSG_WriteByte (QWWriteDest(G_FLOAT(OFS_PARM0)), G_FLOAT(OFS_PARM1)); #endif } @@ -4374,7 +4374,7 @@ void PF_WriteChar (progfuncs_t *prinst, struct globalvars_s *pr_globals) ClientReliableWrite_Char(cl, G_FLOAT(OFS_PARM1)); } else - MSG_WriteChar (WriteDest(G_FLOAT(OFS_PARM0)), G_FLOAT(OFS_PARM1)); + MSG_WriteChar (QWWriteDest(G_FLOAT(OFS_PARM0)), G_FLOAT(OFS_PARM1)); #endif } @@ -4393,13 +4393,13 @@ void PF_WriteShort (progfuncs_t *prinst, struct globalvars_s *pr_globals) pr_netglob = pr_globals; if (progstype == PROG_NQ || progstype == PROG_H2) { - NPP_NQWriteShort(G_FLOAT(OFS_PARM0), (short)G_FLOAT(OFS_PARM1)); + NPP_NQWriteShort(G_FLOAT(OFS_PARM0), (int)G_FLOAT(OFS_PARM1)); return; } #ifdef NQPROT else { - NPP_QWWriteShort(G_FLOAT(OFS_PARM0), (short)G_FLOAT(OFS_PARM1)); + NPP_QWWriteShort(G_FLOAT(OFS_PARM0), (int)G_FLOAT(OFS_PARM1)); return; } #else @@ -4412,7 +4412,7 @@ void PF_WriteShort (progfuncs_t *prinst, struct globalvars_s *pr_globals) ClientReliableWrite_Short(cl, G_FLOAT(OFS_PARM1)); } else - MSG_WriteShort (WriteDest(G_FLOAT(OFS_PARM0)), G_FLOAT(OFS_PARM1)); + MSG_WriteShort (QWWriteDest(G_FLOAT(OFS_PARM0)), G_FLOAT(OFS_PARM1)); #endif } @@ -4450,7 +4450,7 @@ void PF_WriteLong (progfuncs_t *prinst, struct globalvars_s *pr_globals) ClientReliableWrite_Long(cl, G_FLOAT(OFS_PARM1)); } else - MSG_WriteLong (WriteDest(G_FLOAT(OFS_PARM0)), G_FLOAT(OFS_PARM1)); + MSG_WriteLong (QWWriteDest(G_FLOAT(OFS_PARM0)), G_FLOAT(OFS_PARM1)); #endif } @@ -4487,7 +4487,7 @@ void PF_WriteAngle (progfuncs_t *prinst, struct globalvars_s *pr_globals) ClientReliableWrite_Angle(cl, G_FLOAT(OFS_PARM1)); } else - MSG_WriteAngle (WriteDest(G_FLOAT(OFS_PARM0)), G_FLOAT(OFS_PARM1)); + MSG_WriteAngle (QWWriteDest(G_FLOAT(OFS_PARM0)), G_FLOAT(OFS_PARM1)); #endif } @@ -4525,7 +4525,7 @@ void PF_WriteCoord (progfuncs_t *prinst, struct globalvars_s *pr_globals) ClientReliableWrite_Coord(cl, G_FLOAT(OFS_PARM1)); } else - MSG_WriteCoord (WriteDest(G_FLOAT(OFS_PARM0)), G_FLOAT(OFS_PARM1)); + MSG_WriteCoord (QWWriteDest(G_FLOAT(OFS_PARM0)), G_FLOAT(OFS_PARM1)); #endif } @@ -4564,7 +4564,7 @@ void PF_WriteString (progfuncs_t *prinst, struct globalvars_s *pr_globals) ClientReliableWrite_String(cl, str); } else - MSG_WriteString (WriteDest(G_FLOAT(OFS_PARM0)), str); + MSG_WriteString (QWWriteDest(G_FLOAT(OFS_PARM0)), str); #endif } @@ -4584,13 +4584,13 @@ void PF_WriteEntity (progfuncs_t *prinst, struct globalvars_s *pr_globals) pr_netglob = pr_globals; if (progstype == PROG_NQ || progstype == PROG_H2) { - NPP_NQWriteEntity(G_FLOAT(OFS_PARM0), (short)G_EDICTNUM(prinst, OFS_PARM1)); + NPP_NQWriteEntity(G_FLOAT(OFS_PARM0), G_EDICTNUM(prinst, OFS_PARM1)); return; } #ifdef NQPROT else { - NPP_QWWriteEntity(G_FLOAT(OFS_PARM0), (short)G_EDICTNUM(prinst, OFS_PARM1)); + NPP_QWWriteEntity(G_FLOAT(OFS_PARM0), G_EDICTNUM(prinst, OFS_PARM1)); return; } #else @@ -4603,7 +4603,7 @@ void PF_WriteEntity (progfuncs_t *prinst, struct globalvars_s *pr_globals) ClientReliableWrite_Short(cl, G_EDICTNUM(prinst, OFS_PARM1)); } else - MSG_WriteShort (WriteDest(G_FLOAT(OFS_PARM0)), G_EDICTNUM(prinst, OFS_PARM1)); + MSG_WriteShort (QWWriteDest(G_FLOAT(OFS_PARM0)), G_EDICTNUM(prinst, OFS_PARM1)); #endif } @@ -4745,7 +4745,9 @@ void SV_point_tempentity (vec3_t o, int type, int count) //count (usually 1) is SV_Error("SV_point_tempentity - type is a beam\n"); default: MSG_WriteByte (&sv.multicast, type); +#ifdef NQPROT MSG_WriteByte (&sv.nqmulticast, type); +#endif } MSG_WriteCoord (&sv.multicast, o[0]); MSG_WriteCoord (&sv.multicast, o[1]); @@ -4927,7 +4929,8 @@ void PF_setspawnparms (progfuncs_t *prinst, struct globalvars_s *pr_globals) client = svs.clients + (i-1); for (i=0 ; i< NUM_SPAWN_PARMS ; i++) - *spawnparamglobals[i] = client->spawn_parms[i]; + if (spawnparamglobals[i]) + *spawnparamglobals[i] = client->spawn_parms[i]; } /* @@ -5100,7 +5103,6 @@ void(vector where, float set) multicast */ void PF_multicast (progfuncs_t *prinst, struct globalvars_s *pr_globals) { -#if !defined(NQPROT) && !defined(PREPARSE) //these make multicasts issue when message is compleate, making the multicast builtin useless. float *o; int to; @@ -5108,7 +5110,6 @@ void PF_multicast (progfuncs_t *prinst, struct globalvars_s *pr_globals) to = G_FLOAT(OFS_PARM1); SV_Multicast (o, to); -#endif } @@ -7333,13 +7334,21 @@ void PF_plaque_draw(progfuncs_t *prinst, struct globalvars_s *pr_globals) } else { - MSG_WriteByte (WriteDest(G_FLOAT(OFS_PARM0)), svc_centerprint); + MSG_WriteByte (QWWriteDest(G_FLOAT(OFS_PARM0)), svc_centerprint); if (*s) { - MSG_WriteByte (WriteDest(G_FLOAT(OFS_PARM0)), '/'); - MSG_WriteByte (WriteDest(G_FLOAT(OFS_PARM0)), 'P'); + MSG_WriteByte (QWWriteDest(G_FLOAT(OFS_PARM0)), '/'); + MSG_WriteByte (QWWriteDest(G_FLOAT(OFS_PARM0)), 'P'); } - MSG_WriteString (WriteDest(G_FLOAT(OFS_PARM0)), s); + MSG_WriteString (QWWriteDest(G_FLOAT(OFS_PARM0)), s); + + MSG_WriteByte (NQWriteDest(G_FLOAT(OFS_PARM0)), svc_centerprint); + if (*s) + { + MSG_WriteByte (NQWriteDest(G_FLOAT(OFS_PARM0)), '/'); + MSG_WriteByte (NQWriteDest(G_FLOAT(OFS_PARM0)), 'P'); + } + MSG_WriteString (NQWriteDest(G_FLOAT(OFS_PARM0)), s); } } diff --git a/engine/server/savegame.c b/engine/server/savegame.c index b3472d0bd..936357211 100644 --- a/engine/server/savegame.c +++ b/engine/server/savegame.c @@ -11,7 +11,7 @@ extern cvar_t deathmatch; extern cvar_t coop; extern cvar_t teamplay; -//Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current +//Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current void SV_SavegameComment (char *text) { int i; @@ -30,11 +30,13 @@ void SV_SavegameComment (char *text) i = SAVEGAME_COMMENT_LENGTH; memcpy (text, mapname, i); } +#ifdef Q2SERVER if (ge) //q2 { sprintf (kills,""); } else +#endif sprintf (kills,"kills:%3i/%3i", (int)pr_global_struct->killed_monsters, (int)pr_global_struct->total_monsters); memcpy (text+22, kills, strlen(kills)); // convert space to _ to make stdio happy @@ -105,7 +107,7 @@ void SV_Savegame_f (void) } } - + fprintf (f, "%i\n", version); SV_SavegameComment (comment); fprintf (f, "%s\n", comment); @@ -200,7 +202,7 @@ void SV_Loadgame_f(void) sprintf (filename, "%s/saves/%s", com_gamedir, Cmd_Argv(1)); COM_DefaultExtension (filename, ".sav"); - + // we can't call SCR_BeginLoadingPlaque, because too much stack space has // been used. The menu calls it before stuffing loadgame command // SCR_BeginLoadingPlaque (); @@ -232,7 +234,7 @@ void SV_Loadgame_f(void) else Con_Printf("loading FTE saved game\n"); - + for (clnum = 0; clnum < MAX_CLIENTS; clnum++) //clear the server for the level change. { @@ -295,7 +297,7 @@ void SV_Loadgame_f(void) strcpy(cl->name, com_token); cl->state = cs_zombie; cl->connection_started = realtime+20; - cl->istobeloaded = true; + cl->istobeloaded = true; for (i=0 ; ispawn_parms[i]); @@ -346,8 +348,8 @@ void SV_Loadgame_f(void) Cvar_SetValue ("teamplay", tfloat); } fscanf (f, "%s\n",mapname); - fscanf (f, "%f\n",&time); - + fscanf (f, "%f\n",&time); + SV_SpawnServer (mapname, NULL, false, false); //always inits MAX_CLIENTS slots. That's okay, because we can cut the max easily. if (sv.state != ss_active) { @@ -385,7 +387,7 @@ void SV_Loadgame_f(void) progstype = pt; //presumably the progs.dat will be what they were before. } - filepos = ftell(f); + filepos = ftell(f); fseek(f, 0, SEEK_END); filelen = ftell(f); fseek(f, filepos, SEEK_SET); @@ -394,7 +396,7 @@ void SV_Loadgame_f(void) memset(file, 0, filelen+1+8); strcpy(file, "loadgame"); clnum=fread(file+8, 1, filelen, f); - file[filelen+8]='\0'; + file[filelen+8]='\0'; pr_edict_size=svprogfuncs->load_ents(svprogfuncs, file, 0); BZ_Free(file); @@ -512,7 +514,7 @@ qboolean SV_LoadLevelCache(char *level, char *startspot, qboolean ignoreplayers) return true; } #endif - + // we can't call SCR_BeginLoadingPlaque, because too much stack space has // been used. The menu calls it before stuffing loadgame command // SCR_BeginLoadingPlaque (); @@ -551,8 +553,8 @@ qboolean SV_LoadLevelCache(char *level, char *startspot, qboolean ignoreplayers) Cvar_SetValue (&teamplay, tfloat); fscanf (f, "%s\n",mapname); - fscanf (f, "%f\n",&time); - + fscanf (f, "%f\n",&time); + SV_SpawnServer (mapname, startspot, false, false); if (svs.gametype != gametype) { @@ -589,7 +591,7 @@ qboolean SV_LoadLevelCache(char *level, char *startspot, qboolean ignoreplayers) PR_RegisterFields(); PR_InitEnts(svprogfuncs, sv.max_edicts); - filepos = ftell(f); + filepos = ftell(f); fseek(f, 0, SEEK_END); filelen = ftell(f); fseek(f, filepos, SEEK_SET); @@ -597,7 +599,7 @@ qboolean SV_LoadLevelCache(char *level, char *startspot, qboolean ignoreplayers) file = BZ_Malloc(filelen+1); memset(file, 0, filelen+1); clnum=fread(file, 1, filelen, f); - file[filelen]='\0'; + file[filelen]='\0'; pr_edict_size=svprogfuncs->load_ents(svprogfuncs, file, 0); BZ_Free(file); @@ -626,7 +628,7 @@ qboolean SV_LoadLevelCache(char *level, char *startspot, qboolean ignoreplayers) if (eval) for (i=0 ; imapname); COM_DefaultExtension (name, ".lvc"); @@ -1024,7 +1026,7 @@ void SV_Loadgame_f (void) } } - + fgets(str, sizeof(str)-1, f); for (trim = str+strlen(str)-1; trim>=str && *trim <= ' '; trim--) *trim='\0'; diff --git a/engine/server/sv_ccmds.c b/engine/server/sv_ccmds.c index 9883132ec..72fa9549e 100644 --- a/engine/server/sv_ccmds.c +++ b/engine/server/sv_ccmds.c @@ -8,7 +8,7 @@ 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. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -80,9 +80,9 @@ client_t *SV_GetClientForString(char *name, int *id) return cl; } } - + return NULL; - } + } for (i = first, cl = svs.clients+first; i < sv.allocated_client_slots; i++, cl++) { @@ -293,7 +293,7 @@ void SV_God_f (void) if ((int)sv_player->v->flags & FL_GODMODE) SV_ClientTPrintf (host_client, PRINT_HIGH, STL_GODON); else - SV_ClientTPrintf (host_client, PRINT_HIGH, STL_GODOFF); + SV_ClientTPrintf (host_client, PRINT_HIGH, STL_GODOFF); } @@ -330,13 +330,13 @@ void SV_Give_f (void) { char *t; int v; - + if (!sv_allow_cheats) { Con_TPrintf (STL_NEEDCHEATPARM); return; } - + if (!SV_SetPlayer ()) { int oldself; @@ -352,7 +352,7 @@ void SV_Give_f (void) t = Cmd_Argv(2); v = atoi (Cmd_Argv(3)); - + switch (t[0]) { case '2': @@ -365,19 +365,19 @@ void SV_Give_f (void) case '9': sv_player->v->items = (int)sv_player->v->items | IT_SHOTGUN<< (t[0] - '2'); break; - + case 's': sv_player->v->ammo_shells = v; - break; + break; case 'n': sv_player->v->ammo_nails = v; - break; + break; case 'r': sv_player->v->ammo_rockets = v; - break; + break; case 'h': sv_player->v->health = v; - break; + break; case 'c': sv_player->v->ammo_cells = v; break; @@ -408,7 +408,7 @@ void SV_MapList_f(void) ====================== SV_Map_f -handle a +handle a map command from the console or progs. ====================== @@ -459,7 +459,7 @@ void SV_Map_f (void) startspot = NULL; if (!strcmp(level, ".")) //restart current - { + { COM_StripExtension(COM_SkipPath(sv.modelname), level); issamelevel = true; @@ -505,6 +505,7 @@ void SV_Map_f (void) if (startspot && !issamelevel && !newunit) { +#ifdef Q2SERVER if (ge) { qboolean savedinuse[MAX_CLIENTS]; @@ -520,6 +521,7 @@ void SV_Map_f (void) } } else +#endif SV_SaveLevelCache(false); } @@ -534,7 +536,7 @@ void SV_Map_f (void) #ifndef SERVERONLY S_StopAllSounds (true); - SCR_BeginLoadingPlaque(); + SCR_BeginLoadingPlaque(); #endif if (newunit || !startspot || !SV_LoadLevelCache(level, startspot, false)) @@ -571,7 +573,7 @@ Kick a user off of the server ================== */ void SV_Kick_f (void) -{ +{ client_t *cl; int clnum=-1; @@ -581,8 +583,8 @@ void SV_Kick_f (void) // print directly, because the dropped client won't get the // SV_BroadcastPrintf message SV_ClientTPrintf (cl, PRINT_HIGH, STL_YOUWEREKICKED); - SV_DropClient (cl); - } + SV_DropClient (cl); + } if (clnum == -1) Con_TPrintf (STL_USERDOESNTEXIST, Cmd_Argv(1)); @@ -639,7 +641,7 @@ void SV_BanName_f (void) } else Con_Printf("User is not using an account\n"); - SV_DropClient (cl); + SV_DropClient (cl); } if (clnum == -1) @@ -696,7 +698,7 @@ void SV_CripplePlayer_f (void) { cl->iscrippled = false; SV_ClientTPrintf (cl, PRINT_HIGH, STL_YOUARNTCRIPPLED); - } + } } if (clnum == -1) @@ -931,7 +933,7 @@ void SV_Status_f (void) Con_Printf ("%6i %5i", cl->userid, (int)cl->old_frags); if (cl->spectator) Con_Printf(" (s)\n"); - else + else Con_Printf("\n"); s = NET_BaseAdrToString ( cl->netchan.remote_address); @@ -970,7 +972,7 @@ void SV_Status_f (void) l = 16 - strlen(s); for (j=0 ; jname); l = 16 - strlen(cl->name); for (j=0 ; jspectator) Con_Printf(" (s)\n"); - else + else Con_Printf("\n"); - + } } Con_Printf ("\n"); @@ -1145,12 +1147,12 @@ void SV_Serverinfo_f (void) Info_SetValueForKey (svs.info, Cmd_Argv(1), value, MAX_SERVERINFO_STRING); - // if this is a cvar, change it too + // if this is a cvar, change it too var = Cvar_FindVar (Cmd_Argv(1)); if (var) { Cvar_Set(var, value); -/* Z_Free (var->string); // free the old value string +/* Z_Free (var->string); // free the old value string var->string = CopyString (value); var->value = Q_atof (var->string); */ } @@ -1262,11 +1264,11 @@ Sets the gamedir and path to a different directory. void SV_Floodprot_f (void) { int arg1, arg2, arg3; - + if (Cmd_Argc() == 1) { if (fp_messages) { - Con_TPrintf (STL_FLOODPROTSETTINGS, + Con_TPrintf (STL_FLOODPROTSETTINGS, fp_messages, fp_persecond, fp_secondsdead); return; } else @@ -1287,7 +1289,7 @@ void SV_Floodprot_f (void) Con_TPrintf (STL_NONEGATIVEVALUES); return; } - + if (arg1 > 10) { Con_TPrintf (STL_TRACK10PLUSSMESSAGES); return; @@ -1309,7 +1311,7 @@ void SV_Floodprotmsg_f (void) } sprintf(fp_msg, "%s", Cmd_Argv(1)); } - + /* ================ @@ -1392,7 +1394,7 @@ SV_Snap void SV_Snap (int uid) { client_t *cl; - char pcxname[80]; + char pcxname[80]; char checkname[MAX_OSPATH]; int i; @@ -1418,16 +1420,16 @@ void SV_Snap (int uid) sprintf(checkname, "%s/snap", gamedirfile); Sys_mkdir(gamedirfile); Sys_mkdir(checkname); - - for (i=0 ; i<=99 ; i++) - { - pcxname[strlen(pcxname) - 6] = i/10 + '0'; - pcxname[strlen(pcxname) - 5] = i%10 + '0'; + + for (i=0 ; i<=99 ; i++) + { + pcxname[strlen(pcxname) - 6] = i/10 + '0'; + pcxname[strlen(pcxname) - 5] = i%10 + '0'; sprintf (checkname, "%s/snap/%s", gamedirfile, pcxname); if (Sys_FileTime(checkname) == -1) break; // file doesn't exist - } - if (i==100) + } + if (i==100) { Con_TPrintf (STL_SNAPTOOMANYFILES); return; @@ -1619,7 +1621,7 @@ void SV_InitOperatorCommands (void) Cmd_AddCommand ("heartbeat", SV_Heartbeat_f); - Cmd_AddCommand ("localinfo", SV_Localinfo_f); + Cmd_AddCommand ("localinfo", SV_Localinfo_f); Cmd_AddCommand ("gamedir", SV_Gamedir_f); Cmd_AddCommand ("sv_gamedir", SV_Gamedir); Cmd_AddCommand ("floodprot", SV_Floodprot_f); diff --git a/engine/server/sv_init.c b/engine/server/sv_init.c index f48ba5948..e4870d403 100644 --- a/engine/server/sv_init.c +++ b/engine/server/sv_init.c @@ -8,7 +8,7 @@ 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. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -48,7 +48,7 @@ SV_ModelIndex int SV_ModelIndex (char *name) { int i; - + if (!name || !name[0]) return 0; @@ -73,7 +73,7 @@ int SV_ModelIndex (char *name) int SV_SafeModelIndex (char *name) { int i; - + if (!name || !name[0]) return 0; @@ -134,8 +134,8 @@ baseline will be transmitted { int i; edict_t *svent; - int entnum; - + int entnum; + for (entnum = 0; entnum < sv.num_edicts ; entnum++) { svent = EDICT_NUM(entnum); @@ -180,7 +180,7 @@ baseline will be transmitted // // add to the message // - MSG_WriteByte (&sv.signon,svc_spawnbaseline); + MSG_WriteByte (&sv.signon,svc_spawnbaseline); MSG_WriteShort (&sv.signon,entnum); MSG_WriteByte (&sv.signon, svent->baseline.modelindex); @@ -198,10 +198,10 @@ baseline will be transmitted void SVNQ_CreateBaseline (void) { edict_t *svent; - int entnum; + int entnum; int playermodel = SV_SafeModelIndex("progs/player.mdl"); - + for (entnum = 0; entnum < sv.num_edicts ; entnum++) { svent = EDICT_NUM(svprogfuncs, entnum); @@ -253,7 +253,7 @@ void SVNQ_CreateBaseline (void) ================ SV_SaveSpawnparms -Grabs the current state of the progs serverinfo flags +Grabs the current state of the progs serverinfo flags and each client for saving across the transition to another level ================ @@ -290,7 +290,7 @@ void SV_SaveSpawnparms (qboolean dontsave) char *buf; for (j=0 ; jspawn_parms[j] = 0; - + buf = svprogfuncs->saveent(svprogfuncs, buffer, &bufsize, host_client->edict); if (host_client->spawninfo) @@ -307,7 +307,7 @@ void SV_SaveSpawnparms (qboolean dontsave) { if (spawnparamglobals[j]) host_client->spawn_parms[j] = *spawnparamglobals[j]; - else + else host_client->spawn_parms[j] = 0; } } @@ -498,7 +498,7 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us int spawnflagmask; #ifndef SERVERONLY - if (!isDedicated && !qrenderer) + if (!isDedicated && (!qrenderer || qrenderer == -1)) { R_RestartRenderer_f(); } @@ -603,7 +603,7 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us sv.nqreliable_datagram.maxsize = sizeof(sv.nqreliable_datagram_buf); sv.nqreliable_datagram.data = sv.nqreliable_datagram_buf; - + sv.nqmulticast.maxsize = sizeof(sv.nqmulticast_buf); sv.nqmulticast.data = sv.nqmulticast_buf; #endif @@ -614,13 +614,13 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us sv.q2reliable_datagram.maxsize = sizeof(sv.q2reliable_datagram_buf); sv.q2reliable_datagram.data = sv.q2reliable_datagram_buf; - + sv.q2multicast.maxsize = sizeof(sv.q2multicast_buf); sv.q2multicast.data = sv.q2multicast_buf; sv.master.maxsize = sizeof(sv.master_buf); sv.master.data = sv.master_buf; - + sv.signon.maxsize = sizeof(sv.signon_buffers[0]); sv.signon.data = sv.signon_buffers[0]; sv.num_signon_buffers = 1; @@ -794,6 +794,7 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us sv.model_player_checksum = SV_CheckModel("progs/player.mdl"); sv.eyes_player_checksum = SV_CheckModel("progs/eyes.mdl"); } +#ifdef Q2SERVER else if (svs.gametype == GT_QUAKE2) { memset(sv.configstring, 0, sizeof(sv.configstring)); @@ -804,6 +805,7 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us sv.models[i+1] = Mod_ForName (localmodels[i], false); } } +#endif @@ -823,7 +825,7 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us case GT_PROGS: ent = EDICT_NUM(svprogfuncs, 0); ent->isfree = false; - + // leave slots at start for clients only // sv.num_edicts = MAX_CLIENTS+1; for (i=0 ; iold_frags); - + MSG_WriteByte (buf, svc_updateping); MSG_WriteByte (buf, i); MSG_WriteShort (buf, SV_CalcPing (client)); - + MSG_WriteByte (buf, svc_updatepl); MSG_WriteByte (buf, i); MSG_WriteByte (buf, client->lossage); @@ -592,7 +592,7 @@ void SV_FullClientUpdate (client_t *client, sizebuf_t *buf) strcpy (info, client->userinfo); Info_RemoveKey(info, "password"); //main password key - Info_RemovePrefixedKeys (info, '_'); // server passwords, etc + Info_RemovePrefixedKeys (info, '_'); // server passwords, etc MSG_WriteByte (buf, svc_updateuserinfo); MSG_WriteByte (buf, i); @@ -711,18 +711,18 @@ void SVC_Status (void) bottom = (bottom < 0) ? 0 : ((bottom > 13) ? 13 : bottom); ping = SV_CalcPing (cl); if (!cl->state) //show bots differently. Just to be courteous. - Con_Printf ("%i %i %i %i \"BOT:%s\" \"%s\" %i %i\n", cl->userid, + Con_Printf ("%i %i %i %i \"BOT:%s\" \"%s\" %i %i\n", cl->userid, cl->old_frags, (int)(realtime - cl->connection_started)/60, ping, cl->name, Info_ValueForKey (cl->userinfo, "skin"), top, bottom); else - Con_Printf ("%i %i %i %i \"%s\" \"%s\" %i %i\n", cl->userid, + Con_Printf ("%i %i %i %i \"%s\" \"%s\" %i %i\n", cl->userid, cl->old_frags, (int)(realtime - cl->connection_started)/60, ping, cl->name, Info_ValueForKey (cl->userinfo, "skin"), top, bottom); } else slots++; } - + //No. Not a good idea. /* if (slots>16) Con_Printf ("5016 35 54 114 \"annigilator\" \"soldier\" 0 0\n"); @@ -738,6 +738,7 @@ void SVC_Status (void) SV_EndRedirect (); } +#ifdef NQPROT void SVC_GetInfo (char *challenge) { //dpmaster support @@ -776,7 +777,9 @@ void SVC_GetInfo (char *challenge) NET_SendPacket (NS_SERVER, strlen(resp), resp, net_from); } +#endif +#ifdef Q2SERVER void SVC_InfoQ2 (void) { char string[64]; @@ -802,6 +805,7 @@ void SVC_InfoQ2 (void) Netchan_OutOfBandPrint (NS_SERVER, net_from, "info\n%s", string); } +#endif /* =================== @@ -1017,7 +1021,7 @@ void SVC_GetChallenge (void) } } -// Netchan_OutOfBandPrint (net_from, "%c%i", S2C_CHALLENGE, +// Netchan_OutOfBandPrint (net_from, "%c%i", S2C_CHALLENGE, // svs.challenges[i].challenge); } @@ -1032,7 +1036,7 @@ void SV_GetNewSpawnParms(client_t *cl) for (i=0 ; ispawn_parms[i] = *spawnparamglobals[i]; + cl->spawn_parms[i] = *spawnparamglobals[i]; else cl->spawn_parms[i] = 0; } @@ -1223,7 +1227,7 @@ client_t *SVC_DirectConnect(void) int protocol; unsigned int protextsupported=0; - + char *name; @@ -1350,7 +1354,7 @@ client_t *SVC_DirectConnect(void) s = Info_ValueForKey (userinfo[0], "spectator"); if (s[0] && strcmp(s, "0")) { - if (spectator_password.string[0] && + if (spectator_password.string[0] && stricmp(spectator_password.string, "none") && strcmp(spectator_password.string, s) ) { // failed @@ -1365,7 +1369,7 @@ client_t *SVC_DirectConnect(void) else { s = Info_ValueForKey (userinfo[0], "password"); - if (password.string[0] && + if (password.string[0] && stricmp(password.string, "none") && strcmp(password.string, s) ) { @@ -1414,7 +1418,7 @@ client_t *SVC_DirectConnect(void) if (cl->state == cs_free) continue; if (NET_CompareBaseAdr (adr, cl->netchan.remote_address) - && ( cl->netchan.qport == qport + && ( cl->netchan.qport == qport || adr.port == cl->netchan.remote_address.port )) { if (cl->state == cs_connected) { @@ -1567,7 +1571,7 @@ client_t *SVC_DirectConnect(void) edictnum = (newcl-svs.clients)+1; if (svprogfuncs) { - ent = EDICT_NUM(svprogfuncs, edictnum); + ent = EDICT_NUM(svprogfuncs, edictnum); #ifdef Q2SERVER temp.q2edict = NULL; #endif @@ -1595,7 +1599,7 @@ client_t *SVC_DirectConnect(void) #ifdef Q2SERVER else { - q2ent = Q2EDICT_NUM(edictnum); + q2ent = Q2EDICT_NUM(edictnum); temp.edict = NULL; temp.q2edict = q2ent; @@ -1614,7 +1618,7 @@ client_t *SVC_DirectConnect(void) temp.q2frames = Z_Malloc(sizeof(q2client_frame_t)*Q2UPDATE_BACKUP); } #endif - + { char *n, *t; @@ -1628,7 +1632,7 @@ client_t *SVC_DirectConnect(void) newcl->zquake_extensions = atoi(Info_ValueForKey(newcl->userinfo, "*z_ext")); //dmw - delayed - Netchan_OutOfBandPrint (adr, "%c", S2C_CONNECTION ); - + Netchan_Setup (NS_SERVER, &newcl->netchan , adr, qport); if (huffcrc) @@ -1637,7 +1641,9 @@ client_t *SVC_DirectConnect(void) newcl->netchan.compress = false; newcl->protocol = protocol; +#ifdef NQNET newcl->netchan.isnqprotocol = ISNQCLIENT(newcl); +#endif newcl->state = cs_connected; @@ -1647,7 +1653,7 @@ client_t *SVC_DirectConnect(void) // spectator mode can ONLY be set at join time newcl->spectator = spectator; - + // parse some info from the info strings SV_ExtractFromUserinfo (newcl); @@ -1692,7 +1698,7 @@ client_t *SVC_DirectConnect(void) } if (rs.flags1 & RANK_BANNED) - { + { SV_RejectMessage (protocol, "You were banned.\nContact the administrator to complain.\n"); Con_Printf("banned player %s is trying to connect\n", newcl->name); newcl->name[0] = 0; @@ -1703,16 +1709,16 @@ client_t *SVC_DirectConnect(void) if (rs.flags1 & RANK_MUTED) { - SV_BroadcastTPrintf(PRINT_MEDIUM, STL_CLIENTISSTILLMUTED, newcl->name); + SV_BroadcastTPrintf(PRINT_MEDIUM, STL_CLIENTISSTILLMUTED, newcl->name); } if (rs.flags1 & RANK_CUFFED) { - SV_BroadcastTPrintf(PRINT_LOW, STL_CLIENTISSTILLCUFFED, newcl->name); + SV_BroadcastTPrintf(PRINT_LOW, STL_CLIENTISSTILLCUFFED, newcl->name); } if (rs.flags1 & RANK_CRIPPLED) { - SV_BroadcastTPrintf(PRINT_HIGH, STL_CLIENTISSTILLCRIPPLED, newcl->name); - } + SV_BroadcastTPrintf(PRINT_HIGH, STL_CLIENTISSTILLCRIPPLED, newcl->name); + } if (rs.timeonserver) { @@ -1909,7 +1915,7 @@ void SVC_RemoteCommand (void) if (!Rank_GetPlayerStats(rid, &stats)) return; - + Con_Printf ("Rcon from %s:\n%s\n" , NET_AdrToString (net_from), net_message.data+4); @@ -2019,8 +2025,10 @@ qboolean SV_ConnectionlessPacket (void) SVC_Status (); else if (!strcmp(c,"log")) SVC_Log (); +#ifdef Q2SERVER else if (!strcmp(c, "info")) SVC_InfoQ2 (); +#endif else if (!strncmp(c,"connect", 7)) { #ifdef Q3SERVER @@ -2029,7 +2037,7 @@ qboolean SV_ConnectionlessPacket (void) SVQ3_DirectConnect(); return true; } - else + else #endif if (secure.value) //FIXME: possible problem for nq clients when enabled Netchan_OutOfBandPrint (NS_SERVER, net_from, "%c\nThis server requires client validation.\nPlease use the "DISTRIBUTION" validation program\n", A2C_PRINT); @@ -2043,8 +2051,10 @@ qboolean SV_ConnectionlessPacket (void) { SVC_GetChallenge (); } +#ifdef NQPROT else if (!strcmp(c, "getinfo")) SVC_GetInfo(Cmd_Args()); +#endif else if (!strcmp(c, "rcon")) SVC_RemoteCommand (); else @@ -2117,7 +2127,7 @@ void SVNQ_ConnectionlessPacket(void) ============================================================================== PACKET FILTERING - + You can add or remove addresses from the filter list with: @@ -2169,13 +2179,13 @@ qboolean StringToFilter (char *s, ipfilter_t *f) int i, j; qbyte b[4]; qbyte m[4]; - + for (i=0 ; i<4 ; i++) { b[i] = 0; m[i] = 0; } - + for (i=0 ; i<4 ; i++) { if (*s < '0' || *s > '9') @@ -2183,7 +2193,7 @@ qboolean StringToFilter (char *s, ipfilter_t *f) Con_Printf ("Bad filter address: %s\n", s); return false; } - + j = 0; while (*s >= '0' && *s <= '9') { @@ -2198,10 +2208,10 @@ qboolean StringToFilter (char *s, ipfilter_t *f) break; s++; } - + f->mask = *(unsigned *)m; f->compare = *(unsigned *)b; - + return true; } @@ -2213,7 +2223,7 @@ SV_AddIP_f void SV_AddIP_f (void) { int i; - + for (i=0 ; inetchan.last_received < droptime && cl->netchan.remote_address.type != NA_LOOPBACK && cl->protocol != SCP_BAD) { SV_BroadcastTPrintf (PRINT_HIGH, STL_CLIENTTIMEDOUT, cl->name); - SV_DropClient (cl); + SV_DropClient (cl); cl->state = cs_free; // don't bother with zombie state } } - if (cl->state == cs_zombie && + if (cl->state == cs_zombie && realtime - cl->connection_started > zombietime.value) { if (cl->connection_started == -1) @@ -2649,7 +2659,7 @@ void SV_Impulse_f (void) PR_ExecuteProgram (svprogfuncs, pr_global_struct->ClientConnect); pr_global_struct->time = sv.time; - pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, svs.clients[i].edict); + pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, svs.clients[i].edict); PR_ExecuteProgram (svprogfuncs, pr_global_struct->PutClientInServer); pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, svs.clients[i].edict); @@ -2682,11 +2692,11 @@ void SV_Frame (float time) { extern cvar_t pr_imitatemvdsv; static double start, end; - + start = Sys_DoubleTime (); svs.stats.idle += start - end; end = start; - + // keep the random time dependent rand (); @@ -2852,7 +2862,7 @@ void SV_InitLocal (void) SV_InitOperatorCommands (); SV_UserInit (); - + #ifndef SERVERONLY if (isDedicated) #endif @@ -2862,7 +2872,7 @@ void SV_InitLocal (void) Cvar_Register (&password, cvargroup_servercontrol); Cvar_Register (&rcon_password, cvargroup_servercontrol); } - rcon_password.restriction = RESTRICT_MAX; //no cheatie rconers changing rcon passwords... + rcon_password.restriction = RESTRICT_MAX; //no cheatie rconers changing rcon passwords... Cvar_Register (&spectator_password, cvargroup_servercontrol); Cvar_Register (&sv_mintic, cvargroup_servercontrol); @@ -2886,8 +2896,8 @@ void SV_InitLocal (void) Cvar_Register (&mirrors, cvargroup_serverinfo); Cvar_Register (&allow_luma, cvargroup_serverinfo); Cvar_Register (&allow_bump, cvargroup_serverinfo); - Cvar_Register (&allow_skybox, cvargroup_serverinfo); - Cvar_Register (&sv_allow_splitscreen, cvargroup_serverinfo); + Cvar_Register (&allow_skybox, cvargroup_serverinfo); + Cvar_Register (&sv_allow_splitscreen, cvargroup_serverinfo); Cvar_Register (&fbskins, cvargroup_serverinfo); Cvar_Register (&timeout, cvargroup_servercontrol); @@ -2937,7 +2947,7 @@ void SV_InitLocal (void) Cvar_Register (&sv_masterport, cvargroup_servercontrol); Cvar_Register (&filterban, cvargroup_servercontrol); - + Cvar_Register (&allow_download, cvargroup_serverpermissions); Cvar_Register (&allow_download_skins, cvargroup_serverpermissions); Cvar_Register (&allow_download_models, cvargroup_serverpermissions); @@ -3025,7 +3035,7 @@ void SV_InitLocal (void) #ifdef PEXT_TE_BULLET svs.fteprotocolextensions |= PEXT_TE_BULLET; #endif -#ifdef PEXT_HULLSIZE +#ifdef PEXT_HULLSIZE svs.fteprotocolextensions |= PEXT_HULLSIZE; #endif #ifdef PEXT_SETVIEW @@ -3048,10 +3058,10 @@ void SV_InitLocal (void) // svs.fteprotocolextensions |= PEXT_64PLAYERS; svs.fteprotocolextensions |= PEXT_SHOWPIC; svs.fteprotocolextensions |= PEXT_SETATTACHMENT; - + #ifdef PEXT_PK3DOWNLOADS svs.fteprotocolextensions |= PEXT_PK3DOWNLOADS; -#endif +#endif #ifdef PEXT_CHUNKEDDOWNLOADS svs.fteprotocolextensions |= PEXT_CHUNKEDDOWNLOADS; @@ -3399,9 +3409,9 @@ void SV_ExtractFromUserinfo (client_t *cl) } else break; } - + if (strncmp(newname, cl->name, sizeof(cl->namebuf)-1)) - { + { if (cl->ismuted) SV_ClientTPrintf (cl, PRINT_HIGH, STL_NONAMEASMUTE); else @@ -3415,13 +3425,13 @@ void SV_ExtractFromUserinfo (client_t *cl) } else if (cl->lastnamecount++ > 4) { SV_BroadcastTPrintf (PRINT_HIGH, STL_CLIENTKICKEDNAMESPAM, cl->name); SV_ClientTPrintf (cl, PRINT_HIGH, STL_YOUWEREKICKEDNAMESPAM); - SV_DropClient (cl); + SV_DropClient (cl); return; } } if (cl->state >= cs_spawned && !cl->spectator) - { + { SV_BroadcastTPrintf (PRINT_HIGH, STL_CLIENTNAMECHANGE, cl->name, val); } Q_strncpyz (cl->name, newname, sizeof(cl->namebuf)); @@ -3542,7 +3552,7 @@ void SV_Init (quakeparms_t *parms) // if (parms->memsize < MINIMUM_MEMORY) // SV_Error ("Only %4.1f megs of memory reported, can't execute game", parms->memsize / (float)0x100000); - Memory_Init (parms->membase, parms->memsize); + Memory_Init (parms->membase, parms->memsize); COM_ParsePlusSets(); @@ -3554,7 +3564,7 @@ void SV_Init (quakeparms_t *parms) COM_Init (); Mod_Init (); } - PR_Init (); + PR_Init (); SV_InitNet (); @@ -3563,7 +3573,7 @@ void SV_Init (quakeparms_t *parms) #ifdef IWEB_H__ IWebInit(); #endif - + SV_Demo_Init(); #ifdef SVRANKING @@ -3581,16 +3591,16 @@ void SV_Init (quakeparms_t *parms) host_hunklevel = Hunk_LowMark (); host_initialized = true; - + Con_TPrintf (TL_EXEDATETIME, __DATE__, __TIME__); - Con_TPrintf (TL_HEAPSIZE,parms->memsize/ (1024*1024.0)); + Con_TPrintf (TL_HEAPSIZE,parms->memsize/ (1024*1024.0)); Con_TPrintf (TL_SERVERVERSION, DISTRIBUTION, VERSION, build_number()); Con_TPrintf (STL_INITED); - Cbuf_InsertText ("exec server.cfg\nexec ftesrv.cfg\n", RESTRICT_LOCAL); - + Cbuf_InsertText ("exec server.cfg\nexec ftesrv.cfg\n", RESTRICT_LOCAL); + // process command line arguments Cbuf_Execute (); diff --git a/engine/server/sv_mvd.c b/engine/server/sv_mvd.c index dc91948ee..365662532 100644 --- a/engine/server/sv_mvd.c +++ b/engine/server/sv_mvd.c @@ -8,7 +8,7 @@ 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. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the included (GNU.txt) GNU General Public License for more details. @@ -62,6 +62,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define closesocket close #define ioctlsocket ioctl #endif + +#ifndef INVALID_SOCKET +#define INVALID_SOCKET -1 +#endif + #endif @@ -234,7 +239,7 @@ void SV_TimeOfDay(date_t *date) { struct tm *newtime; time_t long_time; - + time( &long_time ); newtime = localtime( &long_time ); @@ -291,7 +296,7 @@ dir_t Sys_listdir (char *path, char *ext, qboolean usesorting) { return dir; } - + do { if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) @@ -364,7 +369,7 @@ dir_t Sys_listdir (char *path, char *ext, qboolean usesorting) for(;;) { oneentry=readdir(dir); - if(!oneentry) + if(!oneentry) break; #ifndef __CYGWIN__ @@ -884,7 +889,7 @@ void SV_MVDWritePackets (int num) for (j=0 ; j<3 ; j++) if (flags & (DF_ORIGIN << j)) MSG_WriteCoord (&msg, origin[j]); - + for (j=0 ; j<3 ; j++) if (flags & (DF_ANGLES << j)) MSG_WriteAngle16 (&msg, angles[j]); @@ -980,20 +985,20 @@ static char *SV_PrintTeams(void) } // create output - + if (numcl == 2) // duel { _snprintf(buf, sizeof(buf), "team1 %s\nteam2 %s\n", clients[0]->name, clients[1]->name); - } + } else if (!teamplay.value) // ffa - { + { _snprintf(buf, sizeof(buf), "players:\n"); for (i = 0; i < numcl; i++) _snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %s\n", clients[i]->name); - } - else + } + else { // teamplay - for (j = 0; j < numt; j++) + for (j = 0; j < numt; j++) { _snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "team %s:\n", teams[j]); for (i = 0; i < numcl; i++) @@ -1037,7 +1042,7 @@ mvddest_t *SV_InitRecordFile (char *name) dst->file = file; dst->maxcachesize = 0; } - else + else { dst->desttype = DEST_BUFFEREDFILE; dst->file = file; @@ -1051,7 +1056,7 @@ mvddest_t *SV_InitRecordFile (char *name) while (*s != '/') s--; Q_strncpyz(dst->name, s+1, sizeof(dst->name)); Q_strncpyz(dst->path, sv_demoDir.string, sizeof(dst->path)); - + if (!*demo.path) Q_strncpyz(demo.path, ".", MAX_OSPATH); @@ -1079,7 +1084,7 @@ mvddest_t *SV_InitRecordFile (char *name) fclose(f); } } - else + else Sys_remove(path); @@ -1225,7 +1230,7 @@ void SV_WriteSetMVDMessage (void) c = dem_set; DemoWrite (&c, sizeof(c)); - + len = LittleLong(0); DemoWrite (&len, 4); len = LittleLong(0); @@ -1345,7 +1350,7 @@ static qboolean SV_MVD_Record (mvddest_t *dest) MSG_WriteByte (&buf, 0); MSG_WriteByte (&buf, n); SV_WriteRecordMVDMessage (&buf, seq++); - SZ_Clear (&buf); + SZ_Clear (&buf); MSG_WriteByte (&buf, svc_soundlist); MSG_WriteByte (&buf, n + 1); } @@ -1358,7 +1363,7 @@ static qboolean SV_MVD_Record (mvddest_t *dest) MSG_WriteByte (&buf, 0); MSG_WriteByte (&buf, 0); SV_WriteRecordMVDMessage (&buf, seq++); - SZ_Clear (&buf); + SZ_Clear (&buf); } // modellist @@ -1375,7 +1380,7 @@ static qboolean SV_MVD_Record (mvddest_t *dest) MSG_WriteByte (&buf, 0); MSG_WriteByte (&buf, n); SV_WriteRecordMVDMessage (&buf, seq++); - SZ_Clear (&buf); + SZ_Clear (&buf); MSG_WriteByte (&buf, svc_modellist); MSG_WriteByte (&buf, n + 1); } @@ -1387,7 +1392,7 @@ static qboolean SV_MVD_Record (mvddest_t *dest) MSG_WriteByte (&buf, 0); MSG_WriteByte (&buf, 0); SV_WriteRecordMVDMessage (&buf, seq++); - SZ_Clear (&buf); + SZ_Clear (&buf); } // baselines @@ -1450,7 +1455,7 @@ static qboolean SV_MVD_Record (mvddest_t *dest) if (buf.cursize > MAX_QWMSGLEN/2) { SV_WriteRecordMVDMessage (&buf, seq++); - SZ_Clear (&buf); + SZ_Clear (&buf); } } } @@ -1459,24 +1464,24 @@ static qboolean SV_MVD_Record (mvddest_t *dest) for (n = 0; n < sv.num_signon_buffers; n++) { - SZ_Write (&buf, + SZ_Write (&buf, sv.signon_buffers[n], sv.signon_buffer_size[n]); if (buf.cursize > MAX_QWMSGLEN/2) { SV_WriteRecordMVDMessage (&buf, seq++); - SZ_Clear (&buf); + SZ_Clear (&buf); } } MSG_WriteByte (&buf, svc_stufftext); MSG_WriteString (&buf, va("cmd spawn %i\n",svs.spawncount) ); - + if (buf.cursize) { SV_WriteRecordMVDMessage (&buf, seq++); - SZ_Clear (&buf); + SZ_Clear (&buf); } // send current status of all other players @@ -1512,10 +1517,10 @@ static qboolean SV_MVD_Record (mvddest_t *dest) if (buf.cursize > MAX_QWMSGLEN/2) { SV_WriteRecordMVDMessage (&buf, seq++); - SZ_Clear (&buf); + SZ_Clear (&buf); } } - + // send all current light styles for (i=0 ; iname[0] || client->spectator) continue; - if (strcmp(t, Info_ValueForKey(client->userinfo, "team"))==0) + if (strcmp(t, Info_ValueForKey(client->userinfo, "team"))==0) { if (sep >= 1) Q_strncatz (n, "_", sizeof(n)); @@ -1840,8 +1845,8 @@ void SV_MVDEasyRecord_f (void) // -> scream /* if (c == 2) Q_strncpyz (name, Cmd_Argv(1), sizeof(name)); - - else { + + else { // guess game type and write demo name i = Dem_CountPlayers(); if (teamplay.value && i > 2) @@ -1867,7 +1872,7 @@ void SV_MVDEasyRecord_f (void) } }*/ - + if (c == 2) Q_strncpyz (name, Cmd_Argv(1), sizeof(name)); else @@ -1879,8 +1884,8 @@ void SV_MVDEasyRecord_f (void) _snprintf (name, sizeof(name), "%don%d_", Dem_CountTeamPlayers(Dem_Team(1)), Dem_CountTeamPlayers(Dem_Team(2))); if (sv_demoExtraNames.value > 0) { - Q_strncatz (name, va("[%s]_%s_vs_[%s]_%s_%s", - Dem_Team(1), Dem_PlayerNameTeam(Dem_Team(1)), + Q_strncatz (name, va("[%s]_%s_vs_[%s]_%s_%s", + Dem_Team(1), Dem_PlayerNameTeam(Dem_Team(1)), Dem_Team(2), Dem_PlayerNameTeam(Dem_Team(2)), sv.name), sizeof(name)); } else @@ -1913,7 +1918,7 @@ void SV_MVDEasyRecord_f (void) strcat (name2, ".mvd"); if ((f = fopen (name2, "rb")) == 0) f = fopen(va("%s.gz", name2), "rb"); - + if (f) { i = 1; @@ -1934,7 +1939,7 @@ void SV_MVDEasyRecord_f (void) int MVD_StreamStartListening(int port) { int sock; - + struct sockaddr_in address; // int fromlen; @@ -1954,13 +1959,13 @@ int MVD_StreamStartListening(int port) { Sys_Error ("FTP_TCP_OpenSocket: ioctl FIONBIO:", strerror(qerrno)); } - + if( bind (sock, (void *)&address, sizeof(address)) == -1) { closesocket(sock); return INVALID_SOCKET; } - + listen(sock, 2); return sock; @@ -2004,7 +2009,7 @@ void SV_MVDStream_Poll(void) if (client == INVALID_SOCKET) return; - + if (sv.mvdrecording) { //sorry closesocket(client); @@ -2084,7 +2089,7 @@ char *SV_MVDNum(int num) while (list->name[0] && num) {list++; num--;}; - if (list->name[0]) + if (list->name[0]) return list->name; return NULL; @@ -2151,7 +2156,7 @@ void SV_MVDRemove_f (void) Con_Printf("removing %s...\n", list->name); i++; } - + Sys_remove(SV_MVDName2Txt(path)); } } @@ -2180,7 +2185,7 @@ void SV_MVDRemove_f (void) { Con_Printf("demo %s successfully removed\n", name); } - else + else Con_Printf("unable to remove demo %s\n", name); Sys_remove(SV_MVDName2Txt(path)); @@ -2219,7 +2224,7 @@ void SV_MVDRemoveNum_f (void) { Con_Printf("demo %s succesfully removed\n", name); } - else + else Con_Printf("unable to remove demo %s\n", name); Sys_remove(SV_MVDName2Txt(path)); diff --git a/engine/server/sv_user.c b/engine/server/sv_user.c index df6ce3c20..2677c0955 100644 --- a/engine/server/sv_user.c +++ b/engine/server/sv_user.c @@ -8,7 +8,7 @@ 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. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -138,7 +138,7 @@ void SV_New_f (void) //spawns. These functions are written to not overflow /* if (host_client->num_backbuf) { - Con_TPrintf(STL_BACKBUFSET, host_client->name, host_client->netchan.message.cursize); + Con_TPrintf(STL_BACKBUFSET, host_client->name, host_client->netchan.message.cursize); host_client->num_backbuf = 0; SZ_Clear(&host_client->netchan.message); } @@ -212,7 +212,7 @@ void SV_New_f (void) // // game server - // + // #ifdef Q2SERVER if (ISQ2CLIENT(host_client)) { @@ -275,7 +275,7 @@ void SVNQ_New_f (void) MSG_WriteByte (&host_client->netchan.message, svc_print); #ifdef DISTRIBUTION - sprintf (message, "%c\n" DISTRIBUTION " QuakeWorld version %4.2f server\n", 2, VERSION); + sprintf (message, "%c\n" DISTRIBUTION " QuakeWorld version %4.2f server\n", 2, VERSION); #else sprintf (message, "%c\nQUAKEWORLD VERSION %4.2f SERVER\n", 2, VERSION); #endif @@ -284,6 +284,7 @@ void SVNQ_New_f (void) MSG_WriteByte (&host_client->netchan.message, svc_serverdata); switch(host_client->protocol) { +#ifdef NQPROT case SCP_NETQUAKE: MSG_WriteLong (&host_client->netchan.message, NQ_PROTOCOL_VERSION); MSG_WriteByte (&host_client->netchan.message, 16); @@ -296,6 +297,7 @@ void SVNQ_New_f (void) MSG_WriteLong (&host_client->netchan.message, DP7_PROTOCOL_VERSION); MSG_WriteByte (&host_client->netchan.message, sv.allocated_client_slots); break; +#endif default: host_client->drop = true; break; @@ -324,7 +326,7 @@ void SVNQ_New_f (void) MSG_WriteByte (&host_client->netchan.message, sv.edicts->v->sounds); MSG_WriteByte (&host_client->netchan.message, sv.edicts->v->sounds); -// set view +// set view MSG_WriteByte (&host_client->netchan.message, svc_setview); MSG_WriteShort (&host_client->netchan.message, NUM_FOR_EDICT(svprogfuncs, host_client->edict)); @@ -376,7 +378,7 @@ void SVQ2_ConfigStrings_f (void) // write a packet full of data - while ( host_client->netchan.message.cursize < MAX_QWMSGLEN/2 + while ( host_client->netchan.message.cursize < MAX_QWMSGLEN/2 && start < Q2MAX_CONFIGSTRINGS) { str = sv.configstring[start]; @@ -537,7 +539,7 @@ void SVQ2_BaseLines_f (void) Con_Printf ("baselines not valid -- already spawned\n"); return; } - + // handle the case of a level changing while a client was connecting if ( atoi(Cmd_Argv(1)) != svs.spawncount ) { @@ -545,7 +547,7 @@ void SVQ2_BaseLines_f (void) SV_New_f (); return; } - + start = atoi(Cmd_Argv(2)); memset (&nullstate, 0, sizeof(nullstate)); @@ -604,7 +606,7 @@ void SV_PK3List_f (void) int crc; char *name; int i; - + if (host_client->state != cs_connected) { //fixme: send prints instead @@ -621,12 +623,12 @@ void SV_PK3List_f (void) } i = atoi(Cmd_Argv(2)); - + //NOTE: This doesn't go through ClientReliableWrite since it's before the user //spawns. These functions are written to not overflow if (host_client->num_backbuf) { - Con_Printf("WARNING %s: [SV_Soundlist] Back buffered (%d), clearing", host_client->name, host_client->netchan.message.cursize); + Con_Printf("WARNING %s: [SV_Soundlist] Back buffered (%d), clearing", host_client->name, host_client->netchan.message.cursize); host_client->num_backbuf = 0; SZ_Clear(&host_client->netchan.message); } @@ -688,11 +690,11 @@ void SV_Soundlist_f (void) } n = atoi(Cmd_Argv(2)); - + //NOTE: This doesn't go through ClientReliableWrite since it's before the user //spawns. These functions are written to not overflow if (host_client->num_backbuf) { - Con_Printf("WARNING %s: [SV_Soundlist] Back buffered (%d), clearing", host_client->name, host_client->netchan.message.cursize); + Con_Printf("WARNING %s: [SV_Soundlist] Back buffered (%d), clearing", host_client->name, host_client->netchan.message.cursize); host_client->num_backbuf = 0; SZ_Clear(&host_client->netchan.message); } @@ -710,18 +712,18 @@ void SV_Soundlist_f (void) if (sv.democausesreconnect) //read the list from somewhere else { for (i = 1+n; - *sv.demsound_precache[i] && host_client->netchan.message.cursize < (MAX_QWMSGLEN/2); + *sv.demsound_precache[i] && host_client->netchan.message.cursize < (MAX_QWMSGLEN/2); i++, n++) MSG_WriteString (&host_client->netchan.message, sv.demsound_precache[i]); - + if (!*sv.demsound_precache[i]) n = 0; } else { for (i = 1+n; - *sv.sound_precache[i] && host_client->netchan.message.cursize < (MAX_QWMSGLEN/2); + *sv.sound_precache[i] && host_client->netchan.message.cursize < (MAX_QWMSGLEN/2); i++, n++) MSG_WriteString (&host_client->netchan.message, sv.sound_precache[i]); @@ -749,7 +751,7 @@ void SV_Modellist_f (void) Con_Printf ("modellist not valid -- allready spawned\n"); return; } - + // handle the case of a level changing while a client was connecting if ( atoi(Cmd_Argv(1)) != svs.spawncount && !sv.msgfromdemo) { @@ -763,7 +765,7 @@ void SV_Modellist_f (void) //NOTE: This doesn't go through ClientReliableWrite since it's before the user //spawns. These functions are written to not overflow if (host_client->num_backbuf) { - Con_Printf("WARNING %s: [SV_Modellist] Back buffered (%d), clearing", host_client->name, host_client->netchan.message.cursize); + Con_Printf("WARNING %s: [SV_Modellist] Back buffered (%d), clearing", host_client->name, host_client->netchan.message.cursize); host_client->num_backbuf = 0; SZ_Clear(&host_client->netchan.message); } @@ -831,7 +833,7 @@ void SV_PreSpawn_f (void) Con_Printf ("prespawn not valid -- allready spawned\n"); return; } - + // handle the case of a level changing while a client was connecting if ( atoi(Cmd_Argv(1)) != svs.spawncount && !sv.msgfromdemo) { @@ -866,10 +868,10 @@ void SV_PreSpawn_f (void) check != LittleLong(sv.worldmodel->checksum2)) if (!sv.demofile || (sv.demofile && !sv.democausesreconnect)) //demo playing causes no check. If it's the return level, check anyway to avoid that loophole. { - SV_ClientTPrintf (host_client, PRINT_HIGH, + SV_ClientTPrintf (host_client, PRINT_HIGH, STL_MAPCHEAT, sv.modelname, check, sv.worldmodel->checksum, sv.worldmodel->checksum2); - SV_DropClient (host_client); + SV_DropClient (host_client); return; } host_client->checksum = check; @@ -878,7 +880,7 @@ void SV_PreSpawn_f (void) //NOTE: This doesn't go through ClientReliableWrite since it's before the user //spawns. These functions are written to not overflow if (host_client->num_backbuf) { - Con_Printf("WARNING %s: [SV_PreSpawn] Back buffered (%d), clearing", host_client->name, host_client->netchan.message.cursize); + Con_Printf("WARNING %s: [SV_PreSpawn] Back buffered (%d), clearing", host_client->name, host_client->netchan.message.cursize); host_client->num_backbuf = 0; SZ_Clear(&host_client->netchan.message); } @@ -1027,7 +1029,7 @@ void SV_PreSpawn_f (void) { if (host_client->netchan.message.cursize+sv.signon_buffer_size[buf]+30 < host_client->netchan.message.maxsize) { - SZ_Write (&host_client->netchan.message, + SZ_Write (&host_client->netchan.message, sv.demosignon_buffers[buf], sv.demosignon_buffer_size[buf]); buf++; @@ -1037,7 +1039,7 @@ void SV_PreSpawn_f (void) { if (host_client->netchan.message.cursize+sv.signon_buffer_size[buf]+30 < host_client->netchan.message.maxsize) { - SZ_Write (&host_client->netchan.message, + SZ_Write (&host_client->netchan.message, sv.signon_buffers[buf], sv.signon_buffer_size[buf]); buf++; @@ -1052,7 +1054,7 @@ void SV_PreSpawn_f (void) else { // need to prespawn more MSG_WriteByte (&host_client->netchan.message, svc_stufftext); - MSG_WriteString (&host_client->netchan.message, + MSG_WriteString (&host_client->netchan.message, va("cmd prespawn %i %i\n", svs.spawncount, buf) ); } } @@ -1082,7 +1084,7 @@ void SV_Spawn_f (void) SV_New_f (); return; } - + // send all current names, colors, and frag counts // FIXME: is this a good thing? SZ_Clear (&host_client->netchan.message); @@ -1098,7 +1100,7 @@ void SV_Spawn_f (void) { if (sv.democausesreconnect) { - ClientReliableWrite_Begin (host_client, svc_lightstyle, + ClientReliableWrite_Begin (host_client, svc_lightstyle, 3 + (sv.demolightstyles[i] ? strlen(sv.demolightstyles[i]) : 1)); ClientReliableWrite_Byte (host_client, (char)i); ClientReliableWrite_String (host_client, sv.demolightstyles[i]); @@ -1107,7 +1109,7 @@ void SV_Spawn_f (void) #ifdef PEXT_LIGHTSTYLECOL if (host_client->fteprotocolextensions & PEXT_LIGHTSTYLECOL && sv.lightstylecolours[i]!=7) { - ClientReliableWrite_Begin (host_client, svc_lightstylecol, + ClientReliableWrite_Begin (host_client, svc_lightstylecol, 3 + (sv.lightstyles[i] ? strlen(sv.lightstyles[i]) : 1)); ClientReliableWrite_Byte (host_client, (char)i); ClientReliableWrite_Char (host_client, sv.lightstylecolours[i]); @@ -1116,7 +1118,7 @@ void SV_Spawn_f (void) else #endif { - ClientReliableWrite_Begin (host_client, svc_lightstyle, + ClientReliableWrite_Begin (host_client, svc_lightstyle, 3 + (sv.lightstyles[i] ? strlen(sv.lightstyles[i]) : 1)); ClientReliableWrite_Byte (host_client, (char)i); ClientReliableWrite_String (host_client, sv.lightstyles[i]); @@ -1231,8 +1233,9 @@ void SV_Begin_f (void) ge->ClientBegin(split->q2edict); split->istobeloaded = false; } + else #endif - else if (split->istobeloaded) + if (split->istobeloaded) { sendangles = true; split->istobeloaded = false; @@ -1303,7 +1306,7 @@ void SV_Begin_f (void) // actually spawn the player pr_global_struct->time = sv.time; - pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, split->edict); + pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, split->edict); PR_ExecuteProgram (svprogfuncs, pr_global_struct->PutClientInServer); oh = host_client; @@ -1362,7 +1365,7 @@ void SV_Begin_f (void) // Never send a roll angle, because savegames can catch the server // in a state where it is expecting the client to correct the angle // and it won't happen if the game was just loaded, so you wind up -// with a permanent head tilt +// with a permanent head tilt MSG_WriteByte (&host_client->netchan.message, svc_setangle); MSG_WriteAngle (&host_client->netchan.message, 0 ); MSG_WriteAngle (&host_client->netchan.message, host_client->edict->v->angles[1] ); @@ -1458,7 +1461,7 @@ void VARGS OutofBandPrintf(netadr_t where, char *fmt, ...) { va_list argptr; char send[1024]; - + send[0] = 0xff; send[1] = 0xff; send[2] = 0xff; @@ -1537,7 +1540,7 @@ Con_DPrintf ("UPLOAD: %d received\n", size); p++; else p = host_client->uploadfn; - OutofBandPrintf(host_client->snap_from, "%s upload completed.\nTo download, enter:\ndownload %s\n", + OutofBandPrintf(host_client->snap_from, "%s upload completed.\nTo download, enter:\ndownload %s\n", host_client->uploadfn, p); } } @@ -1750,7 +1753,7 @@ void SV_SayOne_f (void) SV_ClientTPrintf(host_client, PRINT_CHAT, STL_YOUAREMUTED); return; - } + } for (i = 2; ; i++) @@ -1842,7 +1845,7 @@ void SV_Say (qboolean team) if (!sv.paused && realtimelockedtill) { SV_ClientTPrintf(host_client, PRINT_CHAT, - STL_FLOODPROTTIME, + STL_FLOODPROTTIME, (int) (host_client->lockedtill - realtime)); return; } @@ -1953,7 +1956,7 @@ void SV_Say (qboolean team) { MVDWrite_Begin (dem_all, 0, strlen(text)+3); } - else + else MVDWrite_Begin (dem_multiple, cls, strlen(text)+3); MSG_WriteByte ((sizebuf_t*)demo.dbuf, svc_print); @@ -2042,7 +2045,7 @@ void SV_Kill_f (void) SV_ClientTPrintf (host_client, PRINT_HIGH, STL_NOSUISIDEWHENDEAD); return; } - + pr_global_struct->time = sv.time; pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, sv_player); @@ -2115,7 +2118,7 @@ void SV_Drop_f (void) SV_EndRedirect (); if (!host_client->spectator) SV_BroadcastTPrintf (PRINT_HIGH, STL_CLIENTDROPPED, host_client->name); - SV_DropClient (host_client); + SV_DropClient (host_client); } /* @@ -2129,7 +2132,7 @@ void SV_PTrack_f (void) { int i; edict_t *ent, *tent; - + if (!host_client->spectator && !sv.demofile) return; @@ -2142,7 +2145,7 @@ void SV_PTrack_f (void) ent->v->goalentity = EDICT_TO_PROG(svprogfuncs, tent); return; } - + i = atoi(Cmd_Argv(1)); if (*sv.recordedplayer[i].userinfo) { @@ -2176,7 +2179,7 @@ Change the bandwidth estimate for a client ================= */ void SV_Rate_f (void) -{ +{ if (Cmd_Argc() != 2) { SV_ClientPrintf (host_client, PRINT_HIGH, "Effective rate %i\n", SV_RateForClient(host_client)); @@ -2197,14 +2200,14 @@ Change the message level for a client ================= */ void SV_Msg_f (void) -{ +{ if (Cmd_Argc() != 2) { SV_ClientTPrintf (host_client, PRINT_HIGH, STL_CURRENTMSGLEVEL, host_client->messagelevel); return; } - + host_client->messagelevel = atoi(Cmd_Argv(1)); SV_ClientTPrintf (host_client, PRINT_HIGH, STL_MSGLEVELSET, host_client->messagelevel); @@ -2244,7 +2247,7 @@ void SV_SetInfo_f (void) Info_SetValueForKey (host_client->userinfo, Cmd_Argv(1), Cmd_Argv(2), sizeof(host_client->userinfo)); // name is extracted below in ExtractFromUserInfo // strncpy (host_client->name, Info_ValueForKey (host_client->userinfo, "name") -// , sizeof(host_client->name)-1); +// , sizeof(host_client->name)-1); // SV_FullClientUpdate (host_client, &sv.reliable_datagram); // host_client->sendinfo = true; @@ -2398,7 +2401,7 @@ void SV_Vote_f (void) base = command; while(*base>' ') base++; - if (*base) + if (*base) *base = '\0'; else base = NULL; @@ -2417,7 +2420,7 @@ void SV_Vote_f (void) } - VoteCheckTimes(); + VoteCheckTimes(); for (num = 0; num < sv.allocated_client_slots; num++) if (svs.clients[num].state == cs_spawned) @@ -2525,19 +2528,19 @@ void Cmd_Give_f (void) case 's': sv_player->v->ammo_shells = v; - break; + break; case 'n': sv_player->v->ammo_nails = v; - break; + break; case 'r': sv_player->v->ammo_rockets = v; - break; + break; case 'h': sv_player->v->health = v; - break; + break; case 'c': sv_player->v->ammo_cells = v; - break; + break; } } else if (host_client->netchan.remote_address.type == NA_LOOPBACK) //we don't want clients doing nasty things... like setting movetype 3123 @@ -2548,7 +2551,7 @@ void Cmd_Give_f (void) Con_Printf("Result: %s\n", svprogfuncs->EvaluateDebugString(svprogfuncs, Cmd_Args())); pr_global_struct->self = oldself; } - + } void Cmd_Noclip_f (void) @@ -2607,7 +2610,7 @@ By Alex Shadowalker (and added to fte because he kept winging) ==================== */ void Cmd_SetPos_f(void) -{ +{ if (!sv_allow_cheats) { Con_Printf ("Cheats are not allowed on this server\n"); @@ -2639,7 +2642,7 @@ void SetUpClientEdict (client_t *cl, edict_t *ent) ED_ClearEdict(svprogfuncs, ent); ED_Spawned(ent); ent->isfree = false; - + ent->v->colormap = NUM_FOR_EDICT(svprogfuncs, ent); ent->v->netname = PR_SetString(svprogfuncs, cl->name); @@ -2724,11 +2727,11 @@ void Cmd_Join_f (void) pr_global_struct->time = sv.time; pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, sv_player); PR_ExecuteProgram (svprogfuncs, pr_global_struct->ClientConnect); - + // actually spawn the player pr_global_struct->time = sv.time; pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, sv_player); - PR_ExecuteProgram (svprogfuncs, pr_global_struct->PutClientInServer); + PR_ExecuteProgram (svprogfuncs, pr_global_struct->PutClientInServer); // send notification to all clients host_client->sendinfo = true; @@ -2803,7 +2806,7 @@ void Cmd_Observe_f (void) } SV_SpawnSpectator (); - + // call the spawn function if (SpectatorConnect) { @@ -2847,7 +2850,7 @@ ucmd_t ucmds[] = {"disconnect", SV_Drop_f}, {"pings", SV_Pings_f}, -// issued by hand at client consoles +// issued by hand at client consoles {"rate", SV_Rate_f}, {"kill", SV_Kill_f}, {"pause", SV_Pause_f}, @@ -2884,7 +2887,7 @@ ucmd_t ucmds[] = // {"stopdownload", SV_StopDownload_f}, {"demolist", SV_MVDList_f}, {"demoinfo", SV_MVDInfo_f}, - + {NULL, NULL} }; @@ -2929,7 +2932,7 @@ void SV_ExecuteUserCommand (char *s, qboolean fromQC) client_t *oldhost = host_client; Con_DPrintf("Client command: %s\n", s); - + Cmd_TokenizeString (s, false, false); sv_player = host_client->edict; @@ -3051,11 +3054,11 @@ void SVNQ_Spawn_f (void) // normally this could overflow, but no need to check due to backbuf for (i=0, client = svs.clients; iv->team = 0; // FIXME ent->v->netname = PR_SetString(svprogfuncs, host_client->name); - host_client->entgravity = ent->v->gravity = 1.0; + host_client->entgravity = ent->v->gravity = 1.0; host_client->entgravity*=sv_gravity.value; host_client->maxspeed = ent->v->maxspeed = sv_maxspeed.value; } @@ -3105,14 +3108,14 @@ void SVNQ_Spawn_f (void) ClientReliableWrite_Long (host_client, pr_global_struct->killed_monsters); - + SZ_Write (&host_client->netchan.message, sv.signon.data, sv.signon.cursize); MSG_WriteByte (&host_client->netchan.message, svc_signonnum); MSG_WriteByte (&host_client->netchan.message, 3); - + host_client->send_message = true; - + } void SVNQ_Begin_f (void) { @@ -3167,8 +3170,8 @@ void SVNQ_Begin_f (void) // actually spawn the player pr_global_struct->time = sv.time; - pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, sv_player); - PR_ExecuteProgram (svprogfuncs, pr_global_struct->PutClientInServer); + pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, sv_player); + PR_ExecuteProgram (svprogfuncs, pr_global_struct->PutClientInServer); } } @@ -3189,7 +3192,7 @@ void SVNQ_Begin_f (void) emodel != sv.eyes_player_checksum) SV_BroadcastTPrintf (PRINT_HIGH, STL_POSSIBLEMODELCHEAT, host_client->name); } - + // if we are paused, tell the client if (sv.paused) @@ -3209,7 +3212,7 @@ void SVNQ_Begin_f (void) // Never send a roll angle, because savegames can catch the server // in a state where it is expecting the client to correct the angle // and it won't happen if the game was just loaded, so you wind up -// with a permanent head tilt +// with a permanent head tilt MSG_WriteByte (&host_client->netchan.message, svc_setangle); MSG_WriteAngle (&host_client->netchan.message, 0 ); MSG_WriteAngle (&host_client->netchan.message, host_client->edict->v->angles[1] ); @@ -3217,11 +3220,11 @@ void SVNQ_Begin_f (void) } - + SZ_Write (&host_client->netchan.message, sv.signon.data, sv.signon.cursize); // MSG_WriteByte (&host_client->netchan.message, svc_signonnum); // MSG_WriteByte (&host_client->netchan.message, 4); - + host_client->send_message = true; } @@ -3293,20 +3296,20 @@ void SVNQ_PreSpawn_f (void) } } } - + for (i = 0; i < sv.num_signon_buffers; i++) SZ_Write (&host_client->netchan.message, sv.signon_buffers[i], sv.signon_buffer_size[i]); - + MSG_WriteByte (&host_client->netchan.message, svc_signonnum); MSG_WriteByte (&host_client->netchan.message, 2); - + host_client->send_message = true; } void SVNQ_NQInfo_f (void) { Cmd_TokenizeString(va("setinfo \"%s\" \"%s\"\n", Cmd_Argv(0), Cmd_Argv(1)), false, false); - SV_SetInfo_f(); + SV_SetInfo_f(); } void SVNQ_NQColour_f (void) @@ -3330,9 +3333,9 @@ void SVNQ_NQColour_f (void) bottom &= 15; if (bottom > 13) bottom = 13; - + playercolor = top*16 + bottom; - + if (progstype != PROG_QW) host_client->edict->v->team = bottom + 1; @@ -3352,7 +3355,7 @@ void SVNQ_NQColour_f (void) } SV_ExtractFromUserinfo (host_client); - + MSG_WriteByte (&sv.reliable_datagram, svc_setinfo); MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients); MSG_WriteString (&sv.reliable_datagram, "topcolor"); @@ -3421,7 +3424,7 @@ ucmd_t nqucmds[] = #ifdef SVRANKING {"topten", Rank_ListTop10_f}, #endif - + {NULL, NULL} }; @@ -3429,7 +3432,7 @@ void SVNQ_ExecuteUserCommand (char *s) { client_t *oldhost = host_client; ucmd_t *u; - + Cmd_TokenizeString (s, false, false); sv_player = host_client->edict; @@ -3533,21 +3536,21 @@ float V_CalcRoll (vec3_t angles, vec3_t velocity) float sign; float side; float value; - + AngleVectors (angles, forward, right, up); side = DotProduct (velocity, right); sign = side < 0 ? -1 : 1; side = fabs(side); - + value = cl_rollangle.value; if (side < cl_rollspeed.value) side = side * value / cl_rollspeed.value; else side = value; - + return side*sign; - + } #endif @@ -3575,7 +3578,7 @@ void AddLinksToPmove ( areanode_t *node ) hull_t *hull; vec3_t offset; - pl = EDICT_TO_PROG(svprogfuncs, sv_player); + pl = EDICT_TO_PROG(svprogfuncs, sv_player); // touch linked edicts for (l = node->solid_edicts.next ; l != &node->solid_edicts ; l = next) @@ -3585,8 +3588,8 @@ vec3_t offset; if (check->v->owner == pl) continue; // player's own missile - if (check->v->solid == SOLID_BSP - || check->v->solid == SOLID_BBOX + if (check->v->solid == SOLID_BSP + || check->v->solid == SOLID_BBOX || check->v->solid == SOLID_SLIDEBOX) { if (check == sv_player) @@ -3649,7 +3652,7 @@ vec3_t offset; omt = check->v->movetype; check->v->solid = SOLID_BSP; check->v->movetype = MOVETYPE_PUSH; - hull = SV_HullForEntity (check, 0, sv_player->v->mins, sv_player->v->maxs, offset); + hull = SV_HullForEntity (check, 0, sv_player->v->mins, sv_player->v->maxs, offset); check->v->movetype = omt; check->v->solid = os; @@ -3658,7 +3661,7 @@ vec3_t offset; sv_player->v->fteflags = (int)sv_player->v->fteflags | FF_LADDER; //touch that ladder! } } - + // recurse down both sides if (node->axis == -1) return; @@ -3693,8 +3696,8 @@ void AddAllEntsToPmove (void) continue; if (check->v->owner == pl) continue; - if (check->v->solid == SOLID_BSP - || check->v->solid == SOLID_BBOX + if (check->v->solid == SOLID_BSP + || check->v->solid == SOLID_BBOX || check->v->solid == SOLID_SLIDEBOX) { if (check == sv_player) @@ -3800,9 +3803,9 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse) qboolean jumpable; extern cvar_t sv_gravity; - + // DMW copied this KK hack copied from QuakeForge anti-cheat - // (also extra inside parm on all SV_RunCmds that follow) + // (also extra inside parm on all SV_RunCmds that follow) // To prevent a infinite loop if (!recurse) { @@ -3812,14 +3815,14 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse) tmp_time = tmp_time * 1000.0 * sv_cheatpc.value/100.0; if (host_client->msecs > tmp_time) { host_client->msec_cheating++; - SV_BroadcastTPrintf(PRINT_HIGH, + SV_BroadcastTPrintf(PRINT_HIGH, STL_SPEEDCHEATPOSSIBLE, host_client->msecs, tmp_time, host_client->msec_cheating, host_client->name); if (host_client->msec_cheating >= 2) { - SV_BroadcastTPrintf(PRINT_HIGH, - STL_SPEEDCHEATKICKED, + SV_BroadcastTPrintf(PRINT_HIGH, + STL_SPEEDCHEATKICKED, host_client->name, NET_AdrToString(host_client->netchan.remote_address)); SV_DropClient(host_client); } @@ -3851,7 +3854,7 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse) host_frametime *= sv.gamespeed; if (host_frametime > 0.1) host_frametime = 0.1; - + if (sv.demostatevalid) { //spectators watching MVDs do not affect the running progs. player_mins[0] = -16; @@ -3865,7 +3868,7 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse) pmove.angles[0] = SHORT2ANGLE(ucmd->angles[0]); pmove.angles[1] = SHORT2ANGLE(ucmd->angles[1]); pmove.angles[2] = SHORT2ANGLE(ucmd->angles[2]); - + VectorCopy (host_client->specorigin, pmove.origin); VectorCopy (host_client->specvelocity, pmove.velocity); @@ -3897,7 +3900,7 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse) } PM_PlayerMove (sv.gamespeed); - + VectorCopy (pmove.origin, host_client->specorigin); VectorCopy (pmove.velocity, host_client->specvelocity); @@ -3952,7 +3955,7 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse) // // angles -// show 1/3 the pitch angle and all the roll angle +// show 1/3 the pitch angle and all the roll angle if (sv_player->v->health > 0) { if (!sv_player->v->fixangle) @@ -3960,7 +3963,7 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse) sv_player->v->angles[PITCH] = -sv_player->v->v_angle[PITCH]/3; sv_player->v->angles[YAW] = sv_player->v->v_angle[YAW]; } - sv_player->v->angles[ROLL] = + sv_player->v->angles[ROLL] = V_CalcRoll (sv_player->v->angles, sv_player->v->velocity)*4; } @@ -3995,7 +3998,7 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse) else jumpable = false; PR_ExecuteProgram (svprogfuncs, pr_global_struct->PlayerPreThink); - + if (progstype != PROG_QW) { if (sv_player->v->velocity[2] == 225 && sv_player->v->teleport_time > sv.time) @@ -4231,11 +4234,11 @@ void SV_ExecuteClientMessage (client_t *cl) return; //shouldn't happen... // make sure the reply sequence number matches the incoming - // sequence number + // sequence number if (cl->netchan.incoming_sequence >= cl->netchan.outgoing_sequence) cl->netchan.outgoing_sequence = cl->netchan.incoming_sequence; else - cl->send_message = false; // don't reply, sequences have slipped + cl->send_message = false; // don't reply, sequences have slipped // save time for ping calculations if (cl->frames) @@ -4260,7 +4263,7 @@ void SV_ExecuteClientMessage (client_t *cl) Con_Printf ("SV_ReadClientMessage: badread\n"); SV_DropClient (cl); return; - } + } c = MSG_ReadByte (); haveannothergo: @@ -4315,7 +4318,7 @@ haveannothergo: if (calculatedChecksum != checksum) { - Con_DPrintf ("Failed command checksum for %s(%d) (%d != %d)\n", + Con_DPrintf ("Failed command checksum for %s(%d) (%d != %d)\n", cl->name, cl->netchan.incoming_sequence, checksum, calculatedChecksum); for (; cl; cl = cl->controlled) //FIXME @@ -4436,7 +4439,7 @@ haveannothergo: break; - case clc_stringcmd: + case clc_stringcmd: s = MSG_ReadString (); SV_ExecuteUserCommand (s, false); @@ -4493,11 +4496,11 @@ void SVQ2_ExecuteClientMessage (client_t *cl) frame = &cl->q2frames[cl->netchan.incoming_acknowledged & Q2UPDATE_MASK]; // make sure the reply sequence number matches the incoming - // sequence number + // sequence number if (cl->netchan.incoming_sequence >= cl->netchan.outgoing_sequence) cl->netchan.outgoing_sequence = cl->netchan.incoming_sequence; else - cl->send_message = false; // don't reply, sequences have slipped + cl->send_message = false; // don't reply, sequences have slipped // save time for ping calculations cl->q2frames[cl->netchan.outgoing_sequence & Q2UPDATE_MASK].senttime = realtime; @@ -4519,7 +4522,7 @@ void SVQ2_ExecuteClientMessage (client_t *cl) Con_Printf ("SVQ2_ExecuteClientMessage: badread\n"); SV_DropClient (cl); return; - } + } c = MSG_ReadByte (); if (c == -1) @@ -4544,7 +4547,7 @@ void SVQ2_ExecuteClientMessage (client_t *cl) checksumIndex = MSG_GetReadCount(); checksum = (qbyte)MSG_ReadByte (); - + lastframe = MSG_ReadLong(); if (lastframe != host_client->delta_sequence) { cl->delta_sequence = lastframe; @@ -4565,7 +4568,7 @@ void SVQ2_ExecuteClientMessage (client_t *cl) if (calculatedChecksum != checksum) { - Con_DPrintf ("Failed command checksum for %s(%d) (%d != %d)\n", + Con_DPrintf ("Failed command checksum for %s(%d) (%d != %d)\n", cl->name, cl->netchan.incoming_sequence, checksum, calculatedChecksum); return; } @@ -4611,7 +4614,7 @@ void SVQ2_ExecuteClientMessage (client_t *cl) SV_ExtractFromUserinfo(cl); //let the server routines know break; - case clcq2_stringcmd: + case clcq2_stringcmd: s = MSG_ReadString (); SV_ExecuteUserCommand (s, false); @@ -4627,8 +4630,8 @@ void SVNQ_ReadClientMove (usercmd_t *move) { int i; int bits; - client_frame_t *frame; - + client_frame_t *frame; + frame = &host_client->frames[host_client->netchan.incoming_acknowledged & UPDATE_MASK]; if (host_client->protocol == SCP_DARKPLACES7) @@ -4636,29 +4639,29 @@ void SVNQ_ReadClientMove (usercmd_t *move) else host_client->last_sequence = 0; frame->ping_time = sv.time - MSG_ReadFloat (); - -// read current angles + +// read current angles for (i=0 ; i<3 ; i++) { host_client->edict->v->v_angle[i] = MSG_ReadAngle (); move->angles[i] = (host_client->edict->v->v_angle[i] * 256*256)/360; } - + // read movement move->forwardmove = MSG_ReadShort (); move->sidemove = MSG_ReadShort (); move->upmove = MSG_ReadShort (); move->msec=100; - + // read buttons if (host_client->protocol == SCP_DARKPLACES6 || host_client->protocol == SCP_DARKPLACES7) bits = MSG_ReadLong(); else bits = MSG_ReadByte (); - move->buttons = bits; + move->buttons = bits; i = MSG_ReadByte (); if (i) @@ -4711,7 +4714,7 @@ void SVNQ_ExecuteClientMessage (client_t *cl) { int c; char *s; - client_frame_t *frame; + client_frame_t *frame; int seq_hash; cl->netchan.outgoing_sequence++; @@ -4722,11 +4725,11 @@ void SVNQ_ExecuteClientMessage (client_t *cl) frame->ping_time = 999; // make sure the reply sequence number matches the incoming - // sequence number + // sequence number // if (cl->netchan.incoming_sequence >= cl->netchan.outgoing_sequence) cl->netchan.outgoing_sequence = cl->netchan.incoming_sequence; // else -// cl->send_message = false; // don't reply, sequences have slipped +// cl->send_message = false; // don't reply, sequences have slipped // save time for ping calculations cl->frames[cl->netchan.outgoing_sequence & UPDATE_MASK].senttime = realtime; @@ -4735,7 +4738,7 @@ void SVNQ_ExecuteClientMessage (client_t *cl) host_client = cl; sv_player = host_client->edict; - seq_hash = cl->netchan.incoming_sequence; + seq_hash = cl->netchan.incoming_sequence; // mark time so clients will know how much to predict // other players @@ -4747,7 +4750,7 @@ void SVNQ_ExecuteClientMessage (client_t *cl) Con_Printf ("SV_ReadClientMessage: badread\n"); SV_DropClient (cl); return; - } + } c = MSG_ReadByte (); if (c == -1) @@ -4776,7 +4779,7 @@ void SVNQ_ExecuteClientMessage (client_t *cl) // SV_ClientThink(); break; - case clc_stringcmd: + case clc_stringcmd: s = MSG_ReadString (); SVNQ_ExecuteUserCommand (s); break; @@ -4791,7 +4794,7 @@ SV_UserInit ============== */ void SV_UserInit (void) -{ +{ #ifdef SERVERONLY Cvar_Register (&cl_rollspeed, "Prediction stuff"); Cvar_Register (&cl_rollangle, "Prediction stuff"); @@ -4899,9 +4902,9 @@ void SV_UserFriction (void) vec3_t start, stop; float friction; trace_t trace; - + vel = velocity; - + speed = sqrt(vel[0]*vel[0] +vel[1]*vel[1]); if (!speed) return; @@ -4923,10 +4926,10 @@ void SV_UserFriction (void) // if (val && val->_float) // friction *= val->_float; -// apply friction +// apply friction control = speed < sv_stopspeed.value ? sv_stopspeed.value : speed; newspeed = speed - host_frametime*control*friction; - + if (newspeed < 0) newspeed = 0; newspeed /= speed; @@ -4948,16 +4951,16 @@ void SV_Accelerate (void) accelspeed = sv_accelerate.value*host_frametime*wishspeed; if (accelspeed > addspeed) accelspeed = addspeed; - + for (i=0 ; i<3 ; i++) - velocity[i] += accelspeed*wishdir[i]; + velocity[i] += accelspeed*wishdir[i]; } void SV_AirAccelerate (vec3_t wishveloc) { int i; float addspeed, wishspd, accelspeed, currentspeed; - + wishspd = VectorNormalize (wishveloc); if (wishspd > 30) wishspd = 30; @@ -4969,9 +4972,9 @@ void SV_AirAccelerate (vec3_t wishveloc) accelspeed = sv_accelerate.value*wishspeed * host_frametime; if (accelspeed > addspeed) accelspeed = addspeed; - + for (i=0 ; i<3 ; i++) - velocity[i] += accelspeed*wishveloc[i]; + velocity[i] += accelspeed*wishveloc[i]; } /* @@ -4991,11 +4994,11 @@ void SV_AirMove (void) fmove = cmd.forwardmove; smove = cmd.sidemove; - + // hack to not let you back into teleporter if (sv.time < sv_player->v->teleport_time && fmove < 0) fmove = 0; - + for (i=0 ; i<3 ; i++) wishvel[i] = forward[i]*fmove + right[i]*smove; @@ -5021,7 +5024,7 @@ void SV_AirMove (void) VectorScale (wishvel, maxspeed/wishspeed, wishvel); wishspeed = maxspeed*scale; } - + if ( sv_player->v->movetype == MOVETYPE_NOCLIP) { // noclip VectorCopy (wishvel, velocity); @@ -5034,7 +5037,7 @@ void SV_AirMove (void) else { // not on ground, so little effect on velocity SV_AirAccelerate (wishvel); - } + } } void SV_WaterMove (void) @@ -5089,12 +5092,12 @@ void SV_WaterMove (void) // else newspeed = speed - host_frametime * speed * sv_friction.value; if (newspeed < 0) - newspeed = 0; + newspeed = 0; VectorScale (velocity, newspeed/speed, velocity); } else newspeed = 0; - + // // water acceleration // @@ -5149,14 +5152,14 @@ void SV_ClientThink (void) if (sv_player->v->movetype == MOVETYPE_NONE) return; - + onground = (int)sv_player->v->flags & FL_ONGROUND; origin = sv_player->v->origin; velocity = sv_player->v->velocity; // DropPunchAngle (); - + // // if dead, behave differently // @@ -5167,7 +5170,7 @@ void SV_ClientThink (void) // angles // show 1/3 the pitch angle and all the roll angle angles = sv_player->v->angles; - + VectorCopy (sv_player->v->v_angle, v_angle); // VectorAdd (sv_player->v->v_angle, sv_player->v->punchangle, v_angle); angles[ROLL] = V_CalcRoll (sv_player->v->angles, sv_player->v->velocity)*4; diff --git a/engine/server/svmodel.c b/engine/server/svmodel.c index 92db8e026..ca2019e62 100644 --- a/engine/server/svmodel.c +++ b/engine/server/svmodel.c @@ -8,7 +8,7 @@ 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. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -83,7 +83,7 @@ int Mod_LeafForPoint (vec3_t p, model_t *model) else node = node->children[1]; } - + return 0; // never reached } @@ -110,7 +110,7 @@ qbyte *Mod_DecompressVis (qbyte *in, model_t *model, qbyte *decompressed) qbyte *out; int row; - row = (model->numleafs+7)>>3; + row = (model->numleafs+7)>>3; out = decompressed; #if 0 @@ -123,7 +123,7 @@ qbyte *Mod_DecompressVis (qbyte *in, model_t *model, qbyte *decompressed) *out++ = 0xff; row--; } - return decompressed; + return decompressed; } do @@ -133,7 +133,7 @@ qbyte *Mod_DecompressVis (qbyte *in, model_t *model, qbyte *decompressed) *out++ = *in++; continue; } - + c = in[1]; in += 2; while (c) @@ -143,7 +143,7 @@ qbyte *Mod_DecompressVis (qbyte *in, model_t *model, qbyte *decompressed) } } while (out - decompressed < row); #endif - + return decompressed; } @@ -174,7 +174,7 @@ void Mod_ClearAll (void) { int i; model_t *mod; - + for (i=0 , mod=mod_known ; itype != mod_alias) mod->needload = true; @@ -190,17 +190,17 @@ model_t *Mod_FindName (char *name) { int i; model_t *mod; - + if (!name[0]) SV_Error ("Mod_ForName: NULL name"); - + // // search the currently loaded models // for (i=0 , mod=mod_known ; iname, name) ) break; - + if (i == mod_numknown) { if (mod_numknown == MAX_MOD_KNOWN) @@ -238,7 +238,7 @@ model_t *Mod_LoadModel (model_t *mod, qboolean crash) else return mod; // not cached at all } - + // // load the file // @@ -249,12 +249,12 @@ model_t *Mod_LoadModel (model_t *mod, qboolean crash) SV_Error ("Mod_NumForName: %s not found", mod->name); return NULL; } - + // // allocate a new model // COM_FileBase (mod->name, loadname); - + loadmodel = mod; // @@ -263,11 +263,11 @@ model_t *Mod_LoadModel (model_t *mod, qboolean crash) // call the apropriate loader mod->needload = false; - - + + switch (LittleLong(*(unsigned *)buf)) { #if defined(Q2BSPS) @@ -301,9 +301,9 @@ Loads in a model for the given name model_t *Mod_ForName (char *name, qboolean crash) { model_t *mod; - + mod = Mod_FindName (name); - + return Mod_LoadModel (mod, crash); } @@ -342,9 +342,9 @@ void Mod_LoadTextures (lump_t *l) return; } m = (dmiptexlump_t *)(mod_base + l->fileofs); - + m->nummiptex = LittleLong (m->nummiptex); - + loadmodel->numtextures = m->nummiptex; loadmodel->textures = Hunk_AllocName (m->nummiptex * sizeof(*loadmodel->textures) , loadname); @@ -358,7 +358,7 @@ void Mod_LoadTextures (lump_t *l) mt->height = LittleLong (mt->height); for (j=0 ; joffsets[j] = LittleLong (mt->offsets[j]); - + if ( (mt->width & 15) || (mt->height & 15) ) SV_Error ("Texture %s is not 16 aligned", mt->name); pixels = mt->width*mt->height/64*85; @@ -438,7 +438,7 @@ void Mod_LoadTextures (lump_t *l) else SV_Error ("Bad animating texture %s", tx->name); } - + #define ANIM_CYCLE 2 // link them all together for (j=0 ; jlightdata = NULL; return; } - loadmodel->lightdata = Hunk_AllocName ( l->filelen, loadname); + loadmodel->lightdata = Hunk_AllocName ( l->filelen, loadname); memcpy (loadmodel->lightdata, mod_base + l->fileofs, l->filelen); } @@ -497,7 +497,7 @@ void Mod_LoadVisibility (lump_t *l) loadmodel->visdata = NULL; return; } - loadmodel->visdata = Hunk_AllocName ( l->filelen, loadname); + loadmodel->visdata = Hunk_AllocName ( l->filelen, loadname); memcpy (loadmodel->visdata, mod_base + l->fileofs, l->filelen); } @@ -514,7 +514,7 @@ void Mod_LoadEntities (lump_t *l) loadmodel->entities = NULL; return; } - loadmodel->entities = Hunk_AllocName ( l->filelen, loadname); + loadmodel->entities = Hunk_AllocName ( l->filelen, loadname); memcpy (loadmodel->entities, mod_base + l->fileofs, l->filelen); } @@ -534,7 +534,7 @@ void Mod_LoadVertexes (lump_t *l) if (l->filelen % sizeof(*in)) SV_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Hunk_AllocName ( count*sizeof(*out), loadname); + out = Hunk_AllocName ( count*sizeof(*out), loadname); loadmodel->vertexes = out; loadmodel->numvertexes = count; @@ -570,7 +570,7 @@ void Mod_LoadSubmodels (lump_t *l) if (l->filelen % sizeof(*inh)) Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*inh); - out = Hunk_AllocName ( count*sizeof(*out), loadname); + out = Hunk_AllocName ( count*sizeof(*out), loadname); loadmodel->submodels = out; loadmodel->numsubmodels = count; @@ -605,7 +605,7 @@ void Mod_LoadSubmodels (lump_t *l) if (l->filelen % sizeof(*inq)) Sys_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*inq); - out = Hunk_AllocName ( count*sizeof(*out), loadname); + out = Hunk_AllocName ( count*sizeof(*out), loadname); loadmodel->submodels = out; loadmodel->numsubmodels = count; @@ -650,7 +650,7 @@ void Mod_LoadEdges (lump_t *l) if (l->filelen % sizeof(*in)) SV_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Hunk_AllocName ( (count + 1) * sizeof(*out), loadname); + out = Hunk_AllocName ( (count + 1) * sizeof(*out), loadname); loadmodel->edges = out; loadmodel->numedges = count; @@ -679,7 +679,7 @@ void Mod_LoadTexinfo (lump_t *l) if (l->filelen % sizeof(*in)) SV_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Hunk_AllocName ( count*sizeof(*out), loadname); + out = Hunk_AllocName ( count*sizeof(*out), loadname); loadmodel->texinfo = out; loadmodel->numtexinfo = count; @@ -706,7 +706,7 @@ void Mod_LoadTexinfo (lump_t *l) miptex = LittleLong (in->miptex); out->flags = LittleLong (in->flags); - + if (!loadmodel->textures) { out->texture = r_notexture_mip; // checkerboard texture @@ -734,10 +734,8 @@ Fills in s->texturemins[] and s->extents[] ================ */ -void CalcSurfaceExtents (msurface_t *s) -#ifdef Q2BSPS - ; -#else +void CalcSurfaceExtents (msurface_t *s); +/* { float mins[2], maxs[2], val; int i,j, e; @@ -749,7 +747,7 @@ void CalcSurfaceExtents (msurface_t *s) maxs[0] = maxs[1] = -99999; tex = s->texinfo; - + for (i=0 ; inumedges ; i++) { e = loadmodel->surfedges[s->firstedge+i]; @@ -757,10 +755,10 @@ void CalcSurfaceExtents (msurface_t *s) v = &loadmodel->vertexes[loadmodel->edges[e].v[0]]; else v = &loadmodel->vertexes[loadmodel->edges[-e].v[1]]; - + for (j=0 ; j<2 ; j++) { - val = v->position[0] * tex->vecs[j][0] + + val = v->position[0] * tex->vecs[j][0] + v->position[1] * tex->vecs[j][1] + v->position[2] * tex->vecs[j][2] + tex->vecs[j][3]; @@ -772,7 +770,7 @@ void CalcSurfaceExtents (msurface_t *s) } for (i=0 ; i<2 ; i++) - { + { bmins[i] = floor(mins[i]/16); bmaxs[i] = ceil(maxs[i]/16); @@ -782,7 +780,7 @@ void CalcSurfaceExtents (msurface_t *s) // SV_Error ("Bad surface extents"); } } -#endif +*/ /* ================= @@ -800,7 +798,7 @@ void Mod_LoadFaces (lump_t *l) if (l->filelen % sizeof(*in)) SV_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Hunk_AllocName ( count*sizeof(*out), loadname); + out = Hunk_AllocName ( count*sizeof(*out), loadname); loadmodel->surfaces = out; loadmodel->numsurfaces = count; @@ -808,20 +806,20 @@ void Mod_LoadFaces (lump_t *l) for ( surfnum=0 ; surfnumfirstedge = LittleLong(in->firstedge); - out->numedges = LittleShort(in->numedges); + out->numedges = LittleShort(in->numedges); out->flags = 0; planenum = LittleShort(in->planenum); side = LittleShort(in->side); if (side) - out->flags |= SURF_PLANEBACK; + out->flags |= SURF_PLANEBACK; out->plane = loadmodel->planes + planenum; out->texinfo = loadmodel->texinfo + LittleShort (in->texinfo); CalcSurfaceExtents (out); - + // lighting info for (i=0 ; isamples = NULL; else out->samples = loadmodel->lightdata + i; - + // set the drawing flags flag - + if (!Q_strncmp(out->texinfo->texture->name,"sky",3)) // sky { out->flags |= (SURF_DRAWSKY | SURF_DRAWTILED); continue; } - + if (!Q_strncmp(out->texinfo->texture->name,"*",1)) // turbulent { out->flags |= (SURF_DRAWTURB | SURF_DRAWTILED); @@ -883,7 +881,7 @@ void Mod_LoadNodes (lump_t *l) if (l->filelen % sizeof(*in)) SV_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Hunk_AllocName ( count*sizeof(*out), loadname); + out = Hunk_AllocName ( count*sizeof(*out), loadname); loadmodel->nodes = out; loadmodel->numnodes = count; @@ -895,13 +893,13 @@ void Mod_LoadNodes (lump_t *l) out->minmaxs[j] = LittleShort (in->mins[j]); out->minmaxs[3+j] = LittleShort (in->maxs[j]); } - + p = LittleLong(in->planenum); out->plane = loadmodel->planes + p; out->firstsurface = LittleShort (in->firstface); out->numsurfaces = LittleShort (in->numfaces); - + for (j=0 ; j<2 ; j++) { p = LittleShort (in->children[j]); @@ -911,7 +909,7 @@ void Mod_LoadNodes (lump_t *l) out->children[j] = (mnode_t *)(loadmodel->leafs + (-1 - p)); } } - + Mod_SetParent (loadmodel->nodes, NULL); // sets nodes and leafs } @@ -930,7 +928,7 @@ void Mod_LoadLeafs (lump_t *l) if (l->filelen % sizeof(*in)) SV_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Hunk_AllocName ( count*sizeof(*out), loadname); + out = Hunk_AllocName ( count*sizeof(*out), loadname); loadmodel->leafs = out; loadmodel->numleafs = count; @@ -949,17 +947,17 @@ void Mod_LoadLeafs (lump_t *l) out->firstmarksurface = loadmodel->marksurfaces + LittleShort(in->firstmarksurface); out->nummarksurfaces = LittleShort(in->nummarksurfaces); - + p = LittleLong(in->visofs); if (p == -1) out->compressed_vis = NULL; else out->compressed_vis = loadmodel->visdata + p; out->efrags = NULL; - + for (j=0 ; j<4 ; j++) out->ambient_sound_level[j] = in->ambient_level[j]; - } + } } /* @@ -977,7 +975,7 @@ void Mod_LoadClipnodes (lump_t *l) if (l->filelen % sizeof(*in)) SV_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Hunk_AllocName ( count*sizeof(*out), loadname); + out = Hunk_AllocName ( count*sizeof(*out), loadname); loadmodel->clipnodes = out; loadmodel->numclipnodes = count; @@ -1086,12 +1084,12 @@ void Mod_MakeHull0 (void) dclipnode_t *out; int i, j, count; hull_t *hull; - - hull = &loadmodel->hulls[0]; - + + hull = &loadmodel->hulls[0]; + in = loadmodel->nodes; count = loadmodel->numnodes; - out = Hunk_AllocName ( count*sizeof(*out), loadname); + out = Hunk_AllocName ( count*sizeof(*out), loadname); hull->clipnodes = out; hull->firstclipnode = 0; @@ -1118,16 +1116,16 @@ Mod_LoadMarksurfaces ================= */ void Mod_LoadMarksurfaces (lump_t *l) -{ +{ int i, j, count; short *in; msurface_t **out; - + in = (void *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) SV_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Hunk_AllocName ( count*sizeof(*out), loadname); + out = Hunk_AllocName ( count*sizeof(*out), loadname); loadmodel->marksurfaces = out; loadmodel->nummarksurfaces = count; @@ -1147,15 +1145,15 @@ Mod_LoadSurfedges ================= */ void Mod_LoadSurfedges (lump_t *l) -{ +{ int i, count; int *in, *out; - + in = (void *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) SV_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Hunk_AllocName ( count*sizeof(*out), loadname); + out = Hunk_AllocName ( count*sizeof(*out), loadname); loadmodel->surfedges = out; loadmodel->numsurfedges = count; @@ -1176,13 +1174,13 @@ void Mod_LoadPlanes (lump_t *l) dplane_t *in; int count; int bits; - + in = (void *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) SV_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Hunk_AllocName ( count*2*sizeof(*out), loadname); - + out = Hunk_AllocName ( count*2*sizeof(*out), loadname); + loadmodel->planes = out; loadmodel->numplanes = count; @@ -1216,9 +1214,9 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer) int i, j; dheader_t *header; mmodel_t *bm; - + loadmodel->type = mod_brush; - + header = (dheader_t *)buffer; i = LittleLong (header->version); @@ -1246,12 +1244,12 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer) for (i = 0; i < HEADER_LUMPS; i++) { if (i == LUMP_ENTITIES) continue; - mod->checksum ^= LittleLong(Com_BlockChecksum(mod_base + header->lumps[i].fileofs, + mod->checksum ^= LittleLong(Com_BlockChecksum(mod_base + header->lumps[i].fileofs, header->lumps[i].filelen)); if (i == LUMP_VISIBILITY || i == LUMP_LEAFS || i == LUMP_NODES) continue; - mod->checksum2 ^= Com_BlockChecksum(mod_base + header->lumps[i].fileofs, + mod->checksum2 ^= Com_BlockChecksum(mod_base + header->lumps[i].fileofs, header->lumps[i].filelen); } @@ -1283,8 +1281,8 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer) mod->funcs.LeafForPoint = Mod_LeafForPoint; mod->funcs.LeafPVS = Mod_LeafnumPVS; - - mod->numframes = 2; // regular and alternate animation + + mod->numframes = 2; // regular and alternate animation // // set up the submodels (FIXME: this is confusing) // @@ -1300,13 +1298,13 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer) mod->hulls[j].lastclipnode = mod->numclipnodes-1; Q1BSP_SetHullFuncs(&mod->hulls[j]); } - + mod->firstmodelsurface = bm->firstface; mod->nummodelsurfaces = bm->numfaces; - + VectorCopy (bm->maxs, mod->maxs); VectorCopy (bm->mins, mod->mins); - + mod->numleafs = bm->visleafs; if (i < mod->numsubmodels-1)