From 3eb77ef2e0bbe7c7b71548b4279beba2e7585297 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 23 Nov 2019 22:05:30 -0600 Subject: [PATCH 01/42] Allow speeding up and disabling digital turn easing If anyone complains about this being an unfair advantage, you can literally get the same result in the base game by building a custom controller that maps digital keypresses to an analog joystick. Ask Tyrone about his hitbox. All this does is remove the hardware differential between keyboard and controller. --- src/d_netcmd.c | 1 + src/g_game.c | 2 +- src/g_game.h | 2 +- src/g_input.c | 2 ++ src/g_input.h | 2 +- src/m_menu.c | 3 ++- 6 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7d94d2ed2..d66ff16dc 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -906,6 +906,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_mouse2opt); #endif CV_RegisterVar(&cv_controlperkey); + CV_RegisterVar(&cv_turnsmooth); CV_RegisterVar(&cv_usemouse); CV_RegisterVar(&cv_usemouse2); diff --git a/src/g_game.c b/src/g_game.c index bf0557d02..01506a196 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1356,7 +1356,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) th = 0; if (th < SLOWTURNTICS) - tspeed = 2; // slow turn + tspeed = cv_turnsmooth.value == 2 ? 2 : 0; // slow turn else tspeed = speed; diff --git a/src/g_game.h b/src/g_game.h index 0edc13c74..0c5e2f365 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -139,7 +139,7 @@ typedef enum // mouseaiming (looking up/down with the mouse or keyboard) #define KB_LOOKSPEED (1<<25) #define MAXPLMOVE (50) -#define SLOWTURNTICS (6) +#define SLOWTURNTICS (cv_turnsmooth.value * 3) // build an internal map name MAPxx from map number const char *G_BuildMapName(INT32 map); diff --git a/src/g_input.c b/src/g_input.c index 08a323c78..b13eaca2f 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -23,6 +23,7 @@ static CV_PossibleValue_t mousesens_cons_t[] = {{1, "MIN"}, {MAXMOUSESENSITIVITY, "MAX"}, {0, NULL}}; static CV_PossibleValue_t onecontrolperkey_cons_t[] = {{1, "One"}, {2, "Several"}, {0, NULL}}; +static CV_PossibleValue_t turnsmooth_cons_t[] = {{2, "Slow"}, {1, "Fast"}, {0, "Off"}, {0, NULL}}; // mouse values are used once consvar_t cv_mousesens = {"mousesens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -30,6 +31,7 @@ consvar_t cv_mousesens2 = {"mousesens2", "20", CV_SAVE, mousesens_cons_t, NULL, consvar_t cv_mouseysens = {"mouseysens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mouseysens2 = {"mouseysens2", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_controlperkey = {"controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_turnsmooth = {"turnsmoothing", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; INT32 mousex, mousey; INT32 mlooky; // like mousey but with a custom sensitivity for mlook diff --git a/src/g_input.h b/src/g_input.h index 6d0c7e2c8..3d170ba1d 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -127,7 +127,7 @@ typedef enum // mouse values are used once extern consvar_t cv_mousesens, cv_mouseysens; extern consvar_t cv_mousesens2, cv_mouseysens2; -extern consvar_t cv_controlperkey; +extern consvar_t cv_controlperkey, cv_turnsmooth; extern INT32 mousex, mousey; extern INT32 mlooky; //mousey with mlookSensitivity diff --git a/src/m_menu.c b/src/m_menu.c index e08a53c56..7c01a0e9b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1091,7 +1091,8 @@ static menuitem_t OP_ControlsMenu[] = {IT_CALL | IT_STRING, NULL, "Player 3 Controls...", &M_Setup3PControlsMenu, 30}, {IT_CALL | IT_STRING, NULL, "Player 4 Controls...", &M_Setup4PControlsMenu, 40}, - {IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 60}, + {IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 60}, + {IT_STRING | IT_CVAR, NULL, "Digital turn easing", &cv_turnsmooth, 70}, }; static menuitem_t OP_AllControlsMenu[] = From 5398c10be1aeac471207bbb1472323246f596fcc Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Wed, 12 Feb 2020 00:19:47 +0200 Subject: [PATCH 02/42] Command line parameters -width and -height now accept custom resolutions --- src/sdl/i_video.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index a740ef84d..e74892c0e 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -166,6 +166,10 @@ static INT32 windowedModes[MAXWINMODES][2] = { 320, 200}, // 1.60,1.00 }; +#define CUSTOMMODENUM 9999 +static INT32 custom_width = 0; +static INT32 custom_height = 0; + static void Impl_VideoSetupSDLBuffer(void); static void Impl_VideoSetupBuffer(void); static SDL_bool Impl_CreateWindow(SDL_bool fullscreen); @@ -1512,6 +1516,16 @@ INT32 VID_GetModeForSize(INT32 w, INT32 h) return i; } } + // did not find mode from list, make custom resolution if the values somewhat make sense + // opengl mode does not mind about max resolution defined in screen.h + // if not using opengl, check against the maximum as well + if ((w >= BASEVIDWIDTH && h >= BASEVIDHEIGHT) && + (rendermode == render_opengl || (w <= MAXVIDWIDTH && h <= MAXVIDHEIGHT))) + { + custom_width = w; + custom_height = h; + return CUSTOMMODENUM; + } return -1; #if 0 INT32 matchMode = -1, i; @@ -1625,6 +1639,13 @@ INT32 VID_SetMode(INT32 modeNum) vid.height = windowedModes[modeNum][1]; vid.modenum = modeNum; } + else if (modeNum == CUSTOMMODENUM && custom_width && custom_height) + { + // at this point these values are assumed to be okay + vid.width = custom_width; + vid.height = custom_height; + vid.modenum = modeNum; + } else { // just set the desktop resolution as a fallback From f3c2e5d045c0ed0373f7517b78b1188c2321a0b3 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Fri, 15 May 2020 14:22:03 -0400 Subject: [PATCH 03/42] Fix screen texture size scaling --- src/hardware/r_opengl/r_opengl.c | 78 +++++++++++++------------------- 1 file changed, 32 insertions(+), 46 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 5dc460996..d62471006 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3152,7 +3152,7 @@ EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]) INT32 x, y; float float_x, float_y, float_nextx, float_nexty; float xfix, yfix; - INT32 texsize = 2048; + INT32 texsize = 512; const float blackBack[16] = { @@ -3162,11 +3162,9 @@ EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]) 16.0f, -16.0f, 6.0f }; - // Use a power of two texture - if(screen_width <= 1024) - texsize = 1024; - if(screen_width <= 512) - texsize = 512; + // look for power of two that is large enough for the screen + while (texsize < screen_width || texsize < screen_height) + texsize <<= 1; // X/Y stretch fix for all resolutions(!) xfix = (float)(texsize)/((float)((screen_width)/(float)(SCREENVERTS-1))); @@ -3250,14 +3248,12 @@ EXPORT void HWRAPI(FlushScreenTextures) (void) // Create Screen to fade from EXPORT void HWRAPI(StartScreenWipe) (void) { - INT32 texsize = 2048; + INT32 texsize = 512; boolean firstTime = (startScreenWipe == 0); - // Use a power of two texture, dammit - if(screen_width <= 512) - texsize = 512; - else if(screen_width <= 1024) - texsize = 1024; + // look for power of two that is large enough for the screen + while (texsize < screen_width || texsize < screen_height) + texsize <<= 1; // Create screen texture if (firstTime) @@ -3281,14 +3277,12 @@ EXPORT void HWRAPI(StartScreenWipe) (void) // Create Screen to fade to EXPORT void HWRAPI(EndScreenWipe)(void) { - INT32 texsize = 2048; + INT32 texsize = 512; boolean firstTime = (endScreenWipe == 0); - // Use a power of two texture, dammit - if(screen_width <= 512) - texsize = 512; - else if(screen_width <= 1024) - texsize = 1024; + // look for power of two that is large enough for the screen + while (texsize < screen_width || texsize < screen_height) + texsize <<= 1; // Create screen texture if (firstTime) @@ -3313,7 +3307,7 @@ EXPORT void HWRAPI(EndScreenWipe)(void) EXPORT void HWRAPI(DrawIntermissionBG)(void) { float xfix, yfix; - INT32 texsize = 2048; + INT32 texsize = 512; const float screenVerts[12] = { @@ -3325,10 +3319,9 @@ EXPORT void HWRAPI(DrawIntermissionBG)(void) float fix[8]; - if(screen_width <= 1024) - texsize = 1024; - if(screen_width <= 512) - texsize = 512; + // look for power of two that is large enough for the screen + while (texsize < screen_width || texsize < screen_height) + texsize <<= 1; xfix = 1/((float)(texsize)/((float)((screen_width)))); yfix = 1/((float)(texsize)/((float)((screen_height)))); @@ -3355,7 +3348,7 @@ EXPORT void HWRAPI(DrawIntermissionBG)(void) // Do screen fades! EXPORT void HWRAPI(DoScreenWipe)(void) { - INT32 texsize = 2048; + INT32 texsize = 512; float xfix, yfix; INT32 fademaskdownloaded = tex_downloaded; // the fade mask that has been set @@ -3378,11 +3371,9 @@ EXPORT void HWRAPI(DoScreenWipe)(void) 1.0f, 1.0f }; - // Use a power of two texture, dammit - if(screen_width <= 1024) - texsize = 1024; - if(screen_width <= 512) - texsize = 512; + // look for power of two that is large enough for the screen + while (texsize < screen_width || texsize < screen_height) + texsize <<= 1; xfix = 1/((float)(texsize)/((float)((screen_width)))); yfix = 1/((float)(texsize)/((float)((screen_height)))); @@ -3441,14 +3432,12 @@ EXPORT void HWRAPI(DoScreenWipe)(void) // Create a texture from the screen. EXPORT void HWRAPI(MakeScreenTexture) (void) { - INT32 texsize = 2048; + INT32 texsize = 512; boolean firstTime = (screentexture == 0); - // Use a power of two texture, dammit - if(screen_width <= 512) - texsize = 512; - else if(screen_width <= 1024) - texsize = 1024; + // look for power of two that is large enough for the screen + while (texsize < screen_width || texsize < screen_height) + texsize <<= 1; // Create screen texture if (firstTime) @@ -3471,14 +3460,12 @@ EXPORT void HWRAPI(MakeScreenTexture) (void) EXPORT void HWRAPI(MakeScreenFinalTexture) (void) { - INT32 texsize = 2048; + INT32 texsize = 512; boolean firstTime = (finalScreenTexture == 0); - // Use a power of two texture, dammit - if(screen_width <= 512) - texsize = 512; - else if(screen_width <= 1024) - texsize = 1024; + // look for power of two that is large enough for the screen + while (texsize < screen_width || texsize < screen_height) + texsize <<= 1; // Create screen texture if (firstTime) @@ -3505,15 +3492,14 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height) float origaspect, newaspect; float xoff = 1, yoff = 1; // xoffset and yoffset for the polygon to have black bars around the screen FRGBAFloat clearColour; - INT32 texsize = 2048; + INT32 texsize = 512; float off[12]; float fix[8]; - if(screen_width <= 1024) - texsize = 1024; - if(screen_width <= 512) - texsize = 512; + // look for power of two that is large enough for the screen + while (texsize < screen_width || texsize < screen_height) + texsize <<= 1; xfix = 1/((float)(texsize)/((float)((screen_width)))); yfix = 1/((float)(texsize)/((float)((screen_height)))); From 866fd73a4fe298eb4e0b018fc9eb7023c9f3a3c3 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Wed, 12 Feb 2020 00:19:47 +0200 Subject: [PATCH 04/42] Command line parameters -width and -height now accept custom resolutions --- src/sdl/i_video.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index a740ef84d..e74892c0e 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -166,6 +166,10 @@ static INT32 windowedModes[MAXWINMODES][2] = { 320, 200}, // 1.60,1.00 }; +#define CUSTOMMODENUM 9999 +static INT32 custom_width = 0; +static INT32 custom_height = 0; + static void Impl_VideoSetupSDLBuffer(void); static void Impl_VideoSetupBuffer(void); static SDL_bool Impl_CreateWindow(SDL_bool fullscreen); @@ -1512,6 +1516,16 @@ INT32 VID_GetModeForSize(INT32 w, INT32 h) return i; } } + // did not find mode from list, make custom resolution if the values somewhat make sense + // opengl mode does not mind about max resolution defined in screen.h + // if not using opengl, check against the maximum as well + if ((w >= BASEVIDWIDTH && h >= BASEVIDHEIGHT) && + (rendermode == render_opengl || (w <= MAXVIDWIDTH && h <= MAXVIDHEIGHT))) + { + custom_width = w; + custom_height = h; + return CUSTOMMODENUM; + } return -1; #if 0 INT32 matchMode = -1, i; @@ -1625,6 +1639,13 @@ INT32 VID_SetMode(INT32 modeNum) vid.height = windowedModes[modeNum][1]; vid.modenum = modeNum; } + else if (modeNum == CUSTOMMODENUM && custom_width && custom_height) + { + // at this point these values are assumed to be okay + vid.width = custom_width; + vid.height = custom_height; + vid.modenum = modeNum; + } else { // just set the desktop resolution as a fallback From 506d06b86e3b5fd30de810f7b74613c10d3b04e9 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Fri, 15 May 2020 16:19:00 -0400 Subject: [PATCH 05/42] Fix MAXVID height and width --- src/screen.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/screen.h b/src/screen.h index 2e4d29b95..9ecf564c7 100644 --- a/src/screen.h +++ b/src/screen.h @@ -53,8 +53,8 @@ #define MAXVIDWIDTH 640 #define MAXVIDHEIGHT 480 #else -#define MAXVIDWIDTH 1920 // don't set this too high because actually -#define MAXVIDHEIGHT 1200 // lots of tables are allocated with the MAX size. +#define MAXVIDWIDTH 3840 // don't set this too high because actually +#define MAXVIDHEIGHT 2160 // lots of tables are allocated with the MAX size. #endif #define BASEVIDWIDTH 320 // NEVER CHANGE THIS! This is the original #define BASEVIDHEIGHT 200 // resolution of the graphics. From 6c6fc4b69b154495b3a977ce79292067c9403931 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Tue, 2 Jun 2020 22:22:07 -0400 Subject: [PATCH 06/42] Dedicated server replays netdemo_record must be set to "Auto Save" to work --- src/d_netcmd.c | 10 +++++----- src/p_setup.c | 5 +++-- src/p_tick.c | 6 ++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7d94d2ed2..a431595be 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -708,6 +708,9 @@ void D_RegisterServerCommands(void) #endif CV_RegisterVar(&cv_dummyconsvar); + + CV_RegisterVar(&cv_recordmultiplayerdemos); + CV_RegisterVar(&cv_netdemosyncquality); } // ========================================================================= @@ -830,9 +833,6 @@ void D_RegisterClientCommands(void) COM_AddCommand("displayplayer", Command_Displayplayer_f); - CV_RegisterVar(&cv_recordmultiplayerdemos); - CV_RegisterVar(&cv_netdemosyncquality); - // FIXME: not to be here.. but needs be done for config loading CV_RegisterVar(&cv_usegamma); @@ -2667,8 +2667,8 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) if (metalrecording) G_BeginMetal(); - if (demo.recording) // Okay, level loaded, character spawned and skinned, - G_BeginRecording(); // I AM NOW READY TO RECORD. + //if (demo.recording) // Okay, level loaded, character spawned and skinned, + // G_BeginRecording(); // I AM NOW READY TO RECORD. demo.deferstart = true; } diff --git a/src/p_setup.c b/src/p_setup.c index decdc5291..09b61f3e8 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3235,14 +3235,15 @@ boolean P_SetupLevel(boolean skipprecip) : mapheaderinfo[gamemap - 1]->numlaps); // Start recording replay in multiplayer with a temp filename - //@TODO I'd like to fix dedis crashing when recording replays for the future too... - if (!demo.playback && multiplayer && !dedicated) { + //Ensure dedis only record a replay if there is a player at the start of the map, otherwise we get invalid replays! + if (!demo.playback && multiplayer && D_NumPlayers()) { static char buf[256]; sprintf(buf, "replay"PATHSEP"online"PATHSEP"%d-%s", (int) (time(NULL)), G_BuildMapName(gamemap)); I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); I_mkdir(va("%s"PATHSEP"replay"PATHSEP"online", srb2home), 0755); G_RecordDemo(buf); + G_BeginRecording(); //this has to move here, since dedicated servers dont run got_mapcmd } // =========== diff --git a/src/p_tick.c b/src/p_tick.c index eaa8b4628..8edc86e32 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -761,6 +761,12 @@ void P_Ticker(boolean run) if (cv_recordmultiplayerdemos.value && (demo.savemode == DSM_NOTSAVING || demo.savemode == DSM_WILLAUTOSAVE)) if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && InputDown(gc_lookback, 1)) demo.savemode = DSM_TITLEENTRY; + + //if there are no players left at all, stop demo recording + //Demos that that dont have any players crash during playback,w chich can happen with dedicated servers + // + if (cv_recordmultiplayerdemos.value && demo.savemode == DSM_WILLAUTOSAVE && !D_NumPlayers()) + G_SaveDemo(); } else if (demo.playback) // Use Ghost data for consistency checks. { From d66b51bff6ea4b702405e4b3afdd20abc985535e Mon Sep 17 00:00:00 2001 From: Ashnal Date: Tue, 2 Jun 2020 22:28:18 -0400 Subject: [PATCH 07/42] Fix comment formatting --- src/p_tick.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 8edc86e32..6d3876eda 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -763,8 +763,7 @@ void P_Ticker(boolean run) demo.savemode = DSM_TITLEENTRY; //if there are no players left at all, stop demo recording - //Demos that that dont have any players crash during playback,w chich can happen with dedicated servers - // + //Demos that that dont have any players crash during playback, which can happen with dedicated servers if (cv_recordmultiplayerdemos.value && demo.savemode == DSM_WILLAUTOSAVE && !D_NumPlayers()) G_SaveDemo(); } From e9847336d9b472a470a24515ded0c157b4fc24f8 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sat, 13 Jun 2020 17:48:58 +0300 Subject: [PATCH 08/42] Fix indentation and compiler warnings --- src/hardware/r_opengl/r_opengl.c | 48 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index d62471006..4baf7972c 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3162,9 +3162,9 @@ EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]) 16.0f, -16.0f, 6.0f }; - // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + // look for power of two that is large enough for the screen + while (texsize < screen_width || texsize < screen_height) + texsize <<= 1; // X/Y stretch fix for all resolutions(!) xfix = (float)(texsize)/((float)((screen_width)/(float)(SCREENVERTS-1))); @@ -3251,9 +3251,9 @@ EXPORT void HWRAPI(StartScreenWipe) (void) INT32 texsize = 512; boolean firstTime = (startScreenWipe == 0); - // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + // look for power of two that is large enough for the screen + while (texsize < screen_width || texsize < screen_height) + texsize <<= 1; // Create screen texture if (firstTime) @@ -3280,9 +3280,9 @@ EXPORT void HWRAPI(EndScreenWipe)(void) INT32 texsize = 512; boolean firstTime = (endScreenWipe == 0); - // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + // look for power of two that is large enough for the screen + while (texsize < screen_width || texsize < screen_height) + texsize <<= 1; // Create screen texture if (firstTime) @@ -3319,9 +3319,9 @@ EXPORT void HWRAPI(DrawIntermissionBG)(void) float fix[8]; - // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + // look for power of two that is large enough for the screen + while (texsize < screen_width || texsize < screen_height) + texsize <<= 1; xfix = 1/((float)(texsize)/((float)((screen_width)))); yfix = 1/((float)(texsize)/((float)((screen_height)))); @@ -3371,9 +3371,9 @@ EXPORT void HWRAPI(DoScreenWipe)(void) 1.0f, 1.0f }; - // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + // look for power of two that is large enough for the screen + while (texsize < screen_width || texsize < screen_height) + texsize <<= 1; xfix = 1/((float)(texsize)/((float)((screen_width)))); yfix = 1/((float)(texsize)/((float)((screen_height)))); @@ -3435,9 +3435,9 @@ EXPORT void HWRAPI(MakeScreenTexture) (void) INT32 texsize = 512; boolean firstTime = (screentexture == 0); - // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + // look for power of two that is large enough for the screen + while (texsize < screen_width || texsize < screen_height) + texsize <<= 1; // Create screen texture if (firstTime) @@ -3463,9 +3463,9 @@ EXPORT void HWRAPI(MakeScreenFinalTexture) (void) INT32 texsize = 512; boolean firstTime = (finalScreenTexture == 0); - // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + // look for power of two that is large enough for the screen + while (texsize < screen_width || texsize < screen_height) + texsize <<= 1; // Create screen texture if (firstTime) @@ -3497,9 +3497,9 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height) float off[12]; float fix[8]; - // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + // look for power of two that is large enough for the screen + while (texsize < screen_width || texsize < screen_height) + texsize <<= 1; xfix = 1/((float)(texsize)/((float)((screen_width)))); yfix = 1/((float)(texsize)/((float)((screen_height)))); From 8e46eabf8c325e1109fc502c6001f1aa82272112 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Fri, 17 Jul 2020 00:14:03 -0400 Subject: [PATCH 09/42] Make sure G_BeginRecording gets called for time attack --- src/m_menu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index e08a53c56..579175e1e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7966,6 +7966,7 @@ static void M_ChooseTimeAttack(INT32 choice) I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); I_mkdir(va("%s"PATHSEP"replay"PATHSEP"%s", srb2home, timeattackfolder), 0755); + if ((gpath = malloc(glen)) == NULL) I_Error("Out of memory for replay filepath\n"); @@ -7975,7 +7976,10 @@ static void M_ChooseTimeAttack(INT32 choice) if (!cv_autorecord.value) remove(va("%s"PATHSEP"%s.lmp", srb2home, nameofdemo)); else + { G_RecordDemo(nameofdemo); + G_BeginRecording(); + } G_DeferedInitNew(false, G_BuildMapName(cv_nextmap.value), (UINT8)(cv_chooseskin.value-1), 0, false); } From 42dacffb1221bdb4af59ad519a883513ecb8477f Mon Sep 17 00:00:00 2001 From: AJ Martinez Date: Fri, 14 Aug 2020 03:21:53 -0500 Subject: [PATCH 10/42] Add command to save replay midrace --- src/d_netcmd.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7d94d2ed2..42f9e040b 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -141,6 +141,8 @@ static void Command_RunSOC(void); static void Command_Pause(void); static void Command_Respawn(void); +static void Command_ReplayMarker(void); + static void Command_Version_f(void); #ifdef UPDATE_ALERT static void Command_ModDetails_f(void); @@ -608,6 +610,8 @@ void D_RegisterServerCommands(void) #endif #endif + COM_AddCommand("replaymarker", Command_ReplayMarker); + // for master server connection AddMServCommands(); @@ -2756,6 +2760,26 @@ static void Got_Pause(UINT8 **cp, INT32 playernum) } } +static void Command_ReplayMarker(void) +{ + if (gamestate != GS_LEVEL) + { + CONS_Printf(M_GetText("You must be in a level to use this.\n")); + return; + } + if (demo.savemode == DSM_WILLSAVE) { + demo.savemode = DSM_NOTSAVING; + CONS_Printf("Replay unmarked.\n"); + } else { + demo.savemode = DSM_WILLSAVE; + int adjustedleveltime = leveltime - starttime; + if (adjustedleveltime < 0) + adjustedleveltime = 0; + snprintf(demo.titlename, 64, "%s - %i:%i - %s", G_BuildMapTitle(gamemap), G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); + CONS_Printf("Replay will be saved!\n"); + } +} + // Command for stuck characters in netgames, griefing, etc. static void Command_Respawn(void) { From 8758065856e54212ddcbd9b7ab47f5cb1d6997da Mon Sep 17 00:00:00 2001 From: AJ Martinez Date: Sun, 16 Aug 2020 10:23:59 -0500 Subject: [PATCH 11/42] C90 wizard shit --- src/d_netcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 42f9e040b..163861321 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2771,8 +2771,8 @@ static void Command_ReplayMarker(void) demo.savemode = DSM_NOTSAVING; CONS_Printf("Replay unmarked.\n"); } else { - demo.savemode = DSM_WILLSAVE; int adjustedleveltime = leveltime - starttime; + demo.savemode = DSM_WILLSAVE; if (adjustedleveltime < 0) adjustedleveltime = 0; snprintf(demo.titlename, 64, "%s - %i:%i - %s", G_BuildMapTitle(gamemap), G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); From 1e5f1418e192f905fa9ed88450b46cbdf81bbcff Mon Sep 17 00:00:00 2001 From: Ashnal Date: Wed, 19 Aug 2020 23:10:53 -0400 Subject: [PATCH 12/42] Isolate G_BeginRecording in P_SetupLevel to only dedicated servers Everything else goes back to doing it in Got_Mapcmd --- src/d_netcmd.c | 4 ++-- src/m_menu.c | 4 ---- src/p_setup.c | 3 ++- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index a431595be..54a831dbb 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2667,8 +2667,8 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) if (metalrecording) G_BeginMetal(); - //if (demo.recording) // Okay, level loaded, character spawned and skinned, - // G_BeginRecording(); // I AM NOW READY TO RECORD. + if (demo.recording) // Okay, level loaded, character spawned and skinned, + G_BeginRecording(); // I AM NOW READY TO RECORD. demo.deferstart = true; } diff --git a/src/m_menu.c b/src/m_menu.c index 579175e1e..e08a53c56 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7966,7 +7966,6 @@ static void M_ChooseTimeAttack(INT32 choice) I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); I_mkdir(va("%s"PATHSEP"replay"PATHSEP"%s", srb2home, timeattackfolder), 0755); - if ((gpath = malloc(glen)) == NULL) I_Error("Out of memory for replay filepath\n"); @@ -7976,10 +7975,7 @@ static void M_ChooseTimeAttack(INT32 choice) if (!cv_autorecord.value) remove(va("%s"PATHSEP"%s.lmp", srb2home, nameofdemo)); else - { G_RecordDemo(nameofdemo); - G_BeginRecording(); - } G_DeferedInitNew(false, G_BuildMapName(cv_nextmap.value), (UINT8)(cv_chooseskin.value-1), 0, false); } diff --git a/src/p_setup.c b/src/p_setup.c index 09b61f3e8..be73a2cd7 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3243,7 +3243,8 @@ boolean P_SetupLevel(boolean skipprecip) I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); I_mkdir(va("%s"PATHSEP"replay"PATHSEP"online", srb2home), 0755); G_RecordDemo(buf); - G_BeginRecording(); //this has to move here, since dedicated servers dont run got_mapcmd + if (dedicated) + G_BeginRecording(); //this has to move here, since dedicated servers dont run got_mapcmd } // =========== From 06e5d74c4f8d7d44e65085853f7c4de546f2addb Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sun, 20 Sep 2020 21:16:53 +0300 Subject: [PATCH 13/42] Render distance option for opengl mode --- src/hardware/hw_defs.h | 1 + src/hardware/hw_drv.h | 2 +- src/hardware/hw_main.c | 93 +++++++++++++++++++++++++++++++- src/hardware/hw_main.h | 1 + src/hardware/r_opengl/r_opengl.c | 7 ++- src/m_menu.c | 4 +- src/sdl/ogl_sdl.c | 2 +- 7 files changed, 103 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index af545191a..0392de554 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -23,6 +23,7 @@ #define ZCLIP_PLANE 4.0f // Used for the actual game drawing #define NZCLIP_PLANE 0.9f // Seems to be only used for the HUD and screen textures +#define FAR_ZCLIP_DEFAULT 32768.0f // ========================================================================== // SIMPLE TYPES diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index bf8eb40f3..5e3e14a94 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -39,7 +39,7 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags); EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor); EXPORT void HWRAPI(SetTexture) (FTextureInfo *TexInfo); EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height, INT32 dst_stride, UINT16 *dst_data); -EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip); +EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip, float farclip); EXPORT void HWRAPI(ClearMipMapCache) (void); //Hurdler: added for backward compatibility diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9b7b31e49..2387ed91e 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -79,6 +79,18 @@ consvar_t cv_grsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL, consvar_t cv_grbatching = {"gr_batching", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t grrenderdistance_cons_t[] = { + {0, "Max"}, {1, "1024"}, {2, "2048"}, {3, "4096"}, {4, "6144"}, {5, "8192"}, {0, NULL}}; +consvar_t cv_grrenderdistance = {"gr_renderdistance", "Max", NULL, grrenderdistance_cons_t, + NULL, 0, NULL, NULL, 0, 0, NULL}; +// values for the far clipping plane +static float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f}; +// values for bsp culling +// slightly higher than the far clipping plane to compensate for impreciseness +static INT32 bsp_culling_distances[] = {(1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT, + (6144+512)*FRACUNIT, (8192+512)*FRACUNIT}; +static INT32 current_bsp_culling_distance = 0; + static void CV_filtermode_ONChange(void) { HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_grfiltermode.value); @@ -2096,6 +2108,70 @@ boolean HWR_CheckBBox(fixed_t *bspcoord) px2 = bspcoord[checkcoord[boxpos][2]]; py2 = bspcoord[checkcoord[boxpos][3]]; + if (current_bsp_culling_distance) + { + //fixed_t midx = (px1 >> 1) + (px2 >> 1); + //fixed_t midy = (py1 >> 1) + (py2 >> 1); + //fixed_t mindist = min(min(R_PointToDist(px1, py1), R_PointToDist(px2, py2)), R_PointToDist(midx, midy)); + + //fixed_t mindist = ClosestPointOnLineDistance(px1, py1, px2, py2); + + //fixed_t mindist1 = ClosestPointOnLineDistance(bspcoord[BOXLEFT], bspcoord[BOXTOP], bspcoord[BOXRIGHT], bspcoord[BOXTOP]); // top line + //fixed_t mindist2 = ClosestPointOnLineDistance(bspcoord[BOXLEFT], bspcoord[BOXTOP], bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]); // left line + //fixed_t mindist3 = ClosestPointOnLineDistance(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM], bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM]); // bottom line + //fixed_t mindist4 = ClosestPointOnLineDistance(bspcoord[BOXRIGHT], bspcoord[BOXTOP], bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM]); // right line + // this one seems too lax.. maybe closestpointonlinedistance is glitchy and returns points that are not on the line segment? + // could try building an if-else structure that determines what point or line is closest + // 1 | 2 | 3 + //-------------- + // 4 |node| 5 + //-------------- + // 6 | 7 | 8 + // y + // ^ + // | + // -----> x + // inside node: always inside draw distance. the above boxpos thing might have returned true already? + // 1. check top left corner 2. check top line 3. check top right corner + // 4. check left line 5. check right line + // 6. check bottom left corner 7. check bottom line 8. check bottom right corner + // one if statement will split the space in two for one coordinate + // for example: + // x < BOXLEFT || BOXLEFT || !(x < BOXLEFT) <-- (same as x >= BOXLEFT) + fixed_t mindist;// = min(min(mindist1, mindist2), min(mindist3, mindist4)); + + // new thing + // calculate distance to axis aligned bounding box. + if (viewx < bspcoord[BOXLEFT]) // 1,4,6 + { + if (viewy > bspcoord[BOXTOP]) // 1 + mindist = R_PointToDist(bspcoord[BOXLEFT], bspcoord[BOXTOP]); + else if (viewy < bspcoord[BOXBOTTOM]) // 6 + mindist = R_PointToDist(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]); + else // 4 + mindist = bspcoord[BOXLEFT] - viewx; + } + else if (viewx > bspcoord[BOXRIGHT]) // 3,5,8 + { + if (viewy > bspcoord[BOXTOP]) // 3 + mindist = R_PointToDist(bspcoord[BOXRIGHT], bspcoord[BOXTOP]); + else if (viewy < bspcoord[BOXBOTTOM]) // 8 + mindist = R_PointToDist(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM]); + else // 5 + mindist = viewx - bspcoord[BOXRIGHT]; + } + else // 2,node,7 + { + if (viewy > bspcoord[BOXTOP]) // 2 + mindist = viewy - bspcoord[BOXTOP]; + else if (viewy < bspcoord[BOXBOTTOM]) // 7 + mindist = bspcoord[BOXBOTTOM] - viewy; + else // node + mindist = 0; + } + if (mindist > current_bsp_culling_distance) return false; + } + angle1 = R_PointToAngleEx(viewx, viewy, px1, py1); angle2 = R_PointToAngleEx(viewx, viewy, px2, py2); return gld_clipper_SafeCheckRange(angle2, angle1); @@ -4514,7 +4590,7 @@ static inline void HWR_ClearView(void) (INT32)gr_viewwindowy, (INT32)(gr_viewwindowx + gr_viewwidth), (INT32)(gr_viewwindowy + gr_viewheight), - ZCLIP_PLANE); + ZCLIP_PLANE, FAR_ZCLIP_DEFAULT); HWD.pfnClearBuffer(false, true, 0); } @@ -4644,6 +4720,16 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) if (skybox) drewsky = true; + if (!skybox && cv_grrenderdistance.value) + { + HWD.pfnGClipRect((INT32)gr_viewwindowx, + (INT32)gr_viewwindowy, + (INT32)(gr_viewwindowx + gr_viewwidth), + (INT32)(gr_viewwindowy + gr_viewheight), + ZCLIP_PLANE, clipping_distances[cv_grrenderdistance.value - 1]); + current_bsp_culling_distance = bsp_culling_distances[cv_grrenderdistance.value - 1]; + } + a1 = gld_FrustumAngle(gr_aimingangle); gld_clipper_Clear(); gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1); @@ -4667,6 +4753,8 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) // Recursively "render" the BSP tree. HWR_RenderBSPNode((INT32)numnodes-1); + current_bsp_culling_distance = 0; + if (cv_grbatching.value) { int dummy = 0;// the vars in RenderBatches are meant for render stats. But we don't have that stuff in this branch @@ -4698,7 +4786,7 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) // added by Hurdler for correct splitscreen // moved here by hurdler so it works with the new near clipping plane - HWD.pfnGClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE); + HWD.pfnGClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT); } // ========================================================================== @@ -4758,6 +4846,7 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_grsolvetjoin); CV_RegisterVar(&cv_grbatching); + CV_RegisterVar(&cv_grrenderdistance); } // -------------------------------------------------------------------------- diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index bc4a74e5f..55de46976 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -148,6 +148,7 @@ extern consvar_t cv_grsolvetjoin; extern consvar_t cv_grspritebillboarding; extern consvar_t cv_grfakecontrast; extern consvar_t cv_grfallbackplayermodel; +extern consvar_t cv_grrenderdistance; extern CV_PossibleValue_t granisotropicmode_cons_t[]; diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index eef723e51..0f9964c53 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -50,7 +50,9 @@ static const GLubyte white[4] = { 255, 255, 255, 255 }; #define N_PI_DEMI (M_PIl/2.0f) //(1.5707963268f) #define ASPECT_RATIO (1.0f) //(320.0f/200.0f) -#define FAR_CLIPPING_PLANE 32768.0f // Draw further! Tails 01-21-2001 +//#define FAR_CLIPPING_PLANE 32768.0f // Draw further! Tails 01-21-2001 +//#define FAR_CLIPPING_PLANE (4096.0f - 512.0f) +static float FAR_CLIPPING_PLANE = 32768.0f; static float NEAR_CLIPPING_PLANE = NZCLIP_PLANE; // ************************************************************************** @@ -1232,12 +1234,13 @@ EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height, // -----------------+ // GClipRect : Defines the 2D hardware clipping window // -----------------+ -EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip) +EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip, float farclip) { //GL_DBG_Printf("GClipRect(%d, %d, %d, %d)\n", minx, miny, maxx, maxy); pglViewport(minx, screen_height-maxy, maxx-minx, maxy-miny); NEAR_CLIPPING_PLANE = nearclip; + FAR_CLIPPING_PLANE = farclip; //pglScissor(minx, screen_height-maxy, maxx-minx, maxy-miny); pglMatrixMode(GL_PROJECTION); diff --git a/src/m_menu.c b/src/m_menu.c index 480c887b6..35c39ca86 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1300,7 +1300,9 @@ static menuitem_t OP_OpenGLOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Sprite Billboarding", &cv_grspritebillboarding, 100}, {IT_STRING|IT_CVAR, NULL, "Software Perspective", &cv_grshearing, 110}, - {IT_SUBMENU|IT_STRING, NULL, "Gamma...", &OP_OpenGLColorDef, 130}, + {IT_STRING|IT_CVAR, NULL, "Rendering Distance", &cv_grrenderdistance, 130}, + + {IT_SUBMENU|IT_STRING, NULL, "Gamma...", &OP_OpenGLColorDef, 150}, }; static menuitem_t OP_OpenGLColorMenu[] = diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index eb8e12cbc..39b95b4df 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -229,7 +229,7 @@ void OglSdlFinishUpdate(boolean waitvbl) HWR_DrawScreenFinalTexture(sdlw, sdlh); SDL_GL_SwapWindow(window); - GClipRect(0, 0, realwidth, realheight, NZCLIP_PLANE); + GClipRect(0, 0, realwidth, realheight, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT); // Sryder: We need to draw the final screen texture again into the other buffer in the original position so that // effects that want to take the old screen can do so after this From b5548b296b22aff4e03ec449682457e801440757 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sun, 20 Sep 2020 22:23:55 +0300 Subject: [PATCH 14/42] Add more render distance options and take it into account in sprite rendering --- src/hardware/hw_main.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 2387ed91e..c3de05b9f 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -80,15 +80,16 @@ consvar_t cv_grsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL, consvar_t cv_grbatching = {"gr_batching", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t grrenderdistance_cons_t[] = { - {0, "Max"}, {1, "1024"}, {2, "2048"}, {3, "4096"}, {4, "6144"}, {5, "8192"}, {0, NULL}}; -consvar_t cv_grrenderdistance = {"gr_renderdistance", "Max", NULL, grrenderdistance_cons_t, + {0, "Max"}, {1, "1024"}, {2, "2048"}, {3, "4096"}, {4, "6144"}, {5, "8192"}, + {6, "12288"}, {7, "16384"}, {0, NULL}}; +consvar_t cv_grrenderdistance = {"gr_renderdistance", "Max", CV_SAVE, grrenderdistance_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // values for the far clipping plane -static float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f}; +static float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f}; // values for bsp culling // slightly higher than the far clipping plane to compensate for impreciseness static INT32 bsp_culling_distances[] = {(1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT, - (6144+512)*FRACUNIT, (8192+512)*FRACUNIT}; + (6144+512)*FRACUNIT, (8192+512)*FRACUNIT, (12288+512)*FRACUNIT, (16384+512)*FRACUNIT}; static INT32 current_bsp_culling_distance = 0; static void CV_filtermode_ONChange(void) @@ -4071,7 +4072,7 @@ void HWR_AddSprites(sector_t *sec) { mobj_t *thing; precipmobj_t *precipthing; - fixed_t approx_dist, limit_dist; + fixed_t approx_dist, limit_dist, precip_limit_dist; INT32 splitflags; boolean split_drawsprite; // drawing with splitscreen flags @@ -4086,9 +4087,24 @@ void HWR_AddSprites(sector_t *sec) // Well, now it will be done. sec->validcount = validcount; + if (current_bsp_culling_distance) + { + // Use the smaller setting + if (cv_drawdist.value) + limit_dist = min(current_bsp_culling_distance, cv_drawdist.value << FRACBITS); + else + limit_dist = current_bsp_culling_distance; + precip_limit_dist = min(current_bsp_culling_distance, cv_drawdist_precip.value << FRACBITS); + } + else + { + limit_dist = cv_drawdist.value << FRACBITS; + precip_limit_dist = cv_drawdist_precip.value << FRACBITS; + } + // Handle all things in sector. // If a limit exists, handle things a tiny bit different. - if ((limit_dist = (fixed_t)(/*(maptol & TOL_NIGHTS) ? cv_drawdist_nights.value : */cv_drawdist.value) << FRACBITS)) + if (limit_dist) { for (thing = sec->thinglist; thing; thing = thing->snext) { @@ -4174,7 +4190,7 @@ void HWR_AddSprites(sector_t *sec) } // No to infinite precipitation draw distance. - if ((limit_dist = (fixed_t)cv_drawdist_precip.value << FRACBITS)) + if (precip_limit_dist) { for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext) { From fdca019a74018fae66d6146fd4e59197874d7314 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Mon, 21 Sep 2020 23:17:22 +0300 Subject: [PATCH 15/42] Fix rain bug introduced by render distance --- src/hardware/hw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c3de05b9f..e717220c9 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4199,7 +4199,7 @@ void HWR_AddSprites(sector_t *sec) approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y); - if (approx_dist > limit_dist) + if (approx_dist > precip_limit_dist) continue; HWR_ProjectPrecipitationSprite(precipthing); From b1eb59dd43c9d2cdd0edd996efcdef766aea8175 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Nov 2019 19:53:46 -0800 Subject: [PATCH 16/42] Hey it's audio- ....resynching... --- src/i_sound.h | 2 ++ src/s_sound.c | 4 ++++ src/s_sound.h | 2 ++ src/sdl/mixer_sound.c | 45 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+) diff --git a/src/i_sound.h b/src/i_sound.h index 9a5c2930a..422cfb8ff 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -158,6 +158,8 @@ UINT32 I_GetSongLoopPoint(void); boolean I_SetSongPosition(UINT32 position); UINT32 I_GetSongPosition(void); +void I_UpdateSongLagThreshold (void); + /// ------------------------ // MUSIC PLAYBACK /// ------------------------ diff --git a/src/s_sound.c b/src/s_sound.c index 225863211..7611cf605 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -120,6 +120,8 @@ consvar_t cv_gamesounds = {"sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, consvar_t cv_playmusicifunfocused = {"playmusicifunfocused", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, PlayMusicIfUnfocused_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_playsoundifunfocused = {"playsoundsifunfocused", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, PlaySoundIfUnfocused_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_music_resync_threshold = {"music_resync_threshold", "100", CV_SAVE|CV_CALL, CV_Unsigned, I_UpdateSongLagThreshold}; + #define S_MAX_VOLUME 127 // when to clip out sounds @@ -286,6 +288,8 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&cv_playmusicifunfocused); CV_RegisterVar(&cv_playsoundifunfocused); + CV_RegisterVar(&cv_music_resync_threshold); + COM_AddCommand("tunes", Command_Tunes_f); COM_AddCommand("restartaudio", Command_RestartAudio_f); diff --git a/src/s_sound.h b/src/s_sound.h index eeb1f0ab0..530049328 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -36,6 +36,8 @@ extern consvar_t cv_gamesounds; extern consvar_t cv_playmusicifunfocused; extern consvar_t cv_playsoundifunfocused; +extern consvar_t cv_music_resync_threshold; + #ifdef SNDSERV extern consvar_t sndserver_cmd, sndserver_arg; #endif diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index c5650192d..34edda818 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -13,6 +13,12 @@ #if defined(HAVE_SDL) && defined(HAVE_MIXER) && SOUND==SOUND_MIXER +/* +Just for hu_stopped. I promise I didn't +write netcode into the sound code, OKAY? +*/ +#include "../d_clisrv.h" + #include "../sounds.h" #include "../s_sound.h" #include "../i_sound.h" @@ -74,12 +80,16 @@ UINT8 sound_started = false; +static UINT32 stutter_threshold; + static Mix_Music *music; static UINT8 music_volume, sfx_volume, internal_volume; static float loop_point; static float song_length; // length in seconds static boolean songpaused; +static UINT32 music_end_bytes; static UINT32 music_bytes; +static UINT32 music_stutter_bytes; static boolean is_looping; // fading @@ -101,6 +111,8 @@ static void var_cleanup(void) loop_point = song_length =\ music_bytes = fading_source = fading_target =\ fading_timer = fading_duration = 0; + music_end_bytes = 0; + music_stutter_bytes = 0; songpaused = is_looping =\ is_fading = false; @@ -537,6 +549,8 @@ static void do_fading_callback(void) static void count_music_bytes(int chan, void *stream, int len, void *udata) { + UINT32 bytes; + (void)chan; (void)stream; (void)udata; @@ -544,12 +558,35 @@ static void count_music_bytes(int chan, void *stream, int len, void *udata) if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID) return; music_bytes += len; + if (hu_stopped) + { + music_stutter_bytes += len; + } + else + { + if (music_stutter_bytes >= stutter_threshold) + { + /* + This would be after looping. If we're too near to the start of the + file, subtracting the delta will just underflow. + */ + if (music_stutter_bytes > music_bytes) + { + /* We already know where the end is because we looped. */ + bytes = ( music_end_bytes - ( music_stutter_bytes - music_bytes )); + } + else + bytes = ( music_bytes - music_stutter_bytes ); + I_SetSongPosition((int)( bytes/4/44100.0*1000 )); + } + } } static void music_loop(void) { if (is_looping) { + music_end_bytes = music_bytes; Mix_PlayMusic(music, 0); Mix_SetMusicPosition(loop_point); music_bytes = loop_point*44100.0L*4; //assume 44.1khz, 4-byte length (see I_GetSongPosition) @@ -831,6 +868,8 @@ boolean I_SetSongPosition(UINT32 position) // NOT if position input is greater than song length. music_bytes = 0; + music_stutter_bytes = 0; + return true; } } @@ -875,6 +914,12 @@ UINT32 I_GetSongPosition(void) // 8M: 1 | 8S: 2 | 16M: 2 | 16S: 4 } +void +I_UpdateSongLagThreshold (void) +{ + stutter_threshold = cv_music_resync_threshold.value/1000.0*(4*44100); +} + /// ------------------------ /// Music Playback /// ------------------------ From 12c53012e4a90d51265ab0c329f23932694f1fe4 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Nov 2019 20:25:23 -0800 Subject: [PATCH 17/42] Menu option for music resync --- src/m_menu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index 480c887b6..51084e56e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1343,6 +1343,8 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, + + {IT_STRING|IT_CVAR, NULL, "Music Resynch Threshold (MS)", &cv_music_resync_threshold, 150}, }; static menuitem_t OP_DataOptionsMenu[] = From b4091004667f0808f5bfac7a954247b4ab8beb88 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Nov 2019 20:40:12 -0800 Subject: [PATCH 18/42] Limit music resync threshold to one second --- src/s_sound.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index 7611cf605..e6c76909c 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -120,7 +120,16 @@ consvar_t cv_gamesounds = {"sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, consvar_t cv_playmusicifunfocused = {"playmusicifunfocused", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, PlayMusicIfUnfocused_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_playsoundifunfocused = {"playsoundsifunfocused", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, PlaySoundIfUnfocused_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_music_resync_threshold = {"music_resync_threshold", "100", CV_SAVE|CV_CALL, CV_Unsigned, I_UpdateSongLagThreshold}; +static CV_PossibleValue_t music_resync_threshold_cons_t[] = { + {0, "MIN"}, + {1000, "MAX"}, + + {0} +}; +consvar_t cv_music_resync_threshold = { + "music_resync_threshold", "100", CV_SAVE|CV_CALL, + music_resync_threshold_cons_t, I_UpdateSongLagThreshold +}; #define S_MAX_VOLUME 127 From ff119f322ad0b1d04b07ab874a09915fc54072df Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Nov 2019 21:00:08 -0800 Subject: [PATCH 19/42] More intuitive menu for music resync option --- src/m_menu.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 51084e56e..2e5261257 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1344,7 +1344,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, - {IT_STRING|IT_CVAR, NULL, "Music Resynch Threshold (MS)", &cv_music_resync_threshold, 150}, + {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "Music Resynch Threshold", &cv_music_resync_threshold, 150}, }; static menuitem_t OP_DataOptionsMenu[] = @@ -6577,12 +6577,23 @@ static void M_DrawSkyRoom(void) (midi_disabled ? warningflags : highlightflags), (midi_disabled ? "OFF" : "ON"));*/ + V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, + currentMenu->y+currentMenu->menuitems[12].alphaKey, + highlightflags, + ( (cv_music_resync_threshold.value) ? + va("%s MS", cv_music_resync_threshold.string) : "OFF" )); + if (itemOn == 0) lengthstring = 8*(sound_disabled ? 3 : 2); else if (itemOn == 2) lengthstring = 8*(digital_disabled ? 3 : 2); /*else if (itemOn == 5) lengthstring = 8*(midi_disabled ? 3 : 2);*/ + else if (itemOn == 12) + { + lengthstring = 8*( (cv_music_resync_threshold.value) ? + strlen(cv_music_resync_threshold.string) + 3 : 3 ); + } } for (i = 0; i < currentMenu->numitems; ++i) From e27d54f0fa29c733de80adde84ed3201f0c9a871 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 27 Nov 2019 21:03:25 -0800 Subject: [PATCH 20/42] Don't resync if it's disabled --- src/sdl/mixer_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 34edda818..678155b8b 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -562,7 +562,7 @@ static void count_music_bytes(int chan, void *stream, int len, void *udata) { music_stutter_bytes += len; } - else + else if (stutter_threshold) { if (music_stutter_bytes >= stutter_threshold) { From 7f0fa6987a871f53481957e1a0a6cf6e82143751 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 28 Nov 2019 17:09:06 -0800 Subject: [PATCH 21/42] Only resync music if in a level --- src/sdl/mixer_sound.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 678155b8b..30463fbbc 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -547,17 +547,11 @@ static void do_fading_callback(void) /// Music Hooks /// ------------------------ -static void count_music_bytes(int chan, void *stream, int len, void *udata) +static void +Countstutter (int len) { UINT32 bytes; - (void)chan; - (void)stream; - (void)udata; - - if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID) - return; - music_bytes += len; if (hu_stopped) { music_stutter_bytes += len; @@ -582,6 +576,20 @@ static void count_music_bytes(int chan, void *stream, int len, void *udata) } } +static void count_music_bytes(int chan, void *stream, int len, void *udata) +{ + (void)chan; + (void)stream; + (void)udata; + + if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID) + return; + music_bytes += len; + + if (gamestate == GS_LEVEL) + Countstutter(len); +} + static void music_loop(void) { if (is_looping) From 823ff04e2add46d87b77424244a61717cdd14f99 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 28 Nov 2019 22:05:49 -0800 Subject: [PATCH 22/42] Fade level music back in after Invincibility and Grow Cvars are invincibilitymusicfade and growmusicfade. Both measure milliseconds. --- src/d_netcmd.c | 3 +++ src/g_game.c | 3 +++ src/g_game.h | 3 +++ src/p_user.c | 9 ++++++++- src/s_sound.c | 18 ++++++++++++++++++ src/s_sound.h | 3 +++ 6 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 4a90de333..fe18ba733 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -972,6 +972,9 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_soundtest); + CV_RegisterVar(&cv_invincmusicfade); + CV_RegisterVar(&cv_growmusicfade); + // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); COM_AddCommand("writethings", Command_Writethings_f); diff --git a/src/g_game.c b/src/g_game.c index d9d7b7f12..ddbe65987 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -519,6 +519,9 @@ consvar_t cv_fireaxis4 = {"joyaxis4_fire", "Z-Axis", CV_SAVE, joyaxis_cons_t, NU consvar_t cv_driftaxis4 = {"joyaxis4_drift", "Z-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_deadzone4 = {"joy4_deadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; + #if MAXPLAYERS > 16 #error "please update player_name table using the new value for MAXPLAYERS" diff --git a/src/g_game.h b/src/g_game.h index 493be5d49..dcbe84db0 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -124,6 +124,9 @@ extern consvar_t cv_turnaxis3,cv_moveaxis3,cv_brakeaxis3,cv_aimaxis3,cv_lookaxis extern consvar_t cv_turnaxis4,cv_moveaxis4,cv_brakeaxis4,cv_aimaxis4,cv_lookaxis4,cv_fireaxis4,cv_driftaxis4,cv_deadzone4; extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff; +extern consvar_t cv_invincmusicfade; +extern consvar_t cv_growmusicfade; + typedef enum { AXISNONE = 0, diff --git a/src/p_user.c b/src/p_user.c index cb6b7bd62..83a296a39 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1275,10 +1275,16 @@ void P_RestoreMusic(player_t *player) // Item - Grow if (wantedmus == 2) + { S_ChangeMusicInternal("kgrow", true); + S_SetRestoreMusicFadeInCvar(&cv_growmusicfade); + } // Item - Invincibility else if (wantedmus == 1) + { S_ChangeMusicInternal("kinvnc", true); + S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade); + } else { #if 0 @@ -1287,7 +1293,8 @@ void P_RestoreMusic(player_t *player) if (G_RaceGametype() && player->laps >= (UINT8)(cv_numlaps.value - 1)) S_SpeedMusic(1.2f); #endif - S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, + S_GetRestoreMusicFadeIn()); } } } diff --git a/src/s_sound.c b/src/s_sound.c index e6c76909c..84d9d241d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1565,6 +1565,7 @@ static char music_name[7]; // up to 6-character name static void *music_data; static UINT16 music_flags; static boolean music_looping; +static consvar_t *music_refade_cv; static char queue_name[7]; static UINT16 queue_flags; @@ -1948,6 +1949,8 @@ static void S_UnloadMusic(void) music_name[0] = 0; music_flags = 0; music_looping = false; + + music_refade_cv = 0; } static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) @@ -2169,6 +2172,21 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) } } +void +S_SetRestoreMusicFadeInCvar (consvar_t *cv) +{ + music_refade_cv = cv; +} + +int +S_GetRestoreMusicFadeIn (void) +{ + if (music_refade_cv) + return music_refade_cv->value; + else + return 0; +} + /// ------------------------ /// Music Fading /// ------------------------ diff --git a/src/s_sound.h b/src/s_sound.h index 530049328..b1f558df8 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -186,6 +186,9 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 #define S_ChangeMusicInternal(a,b) S_ChangeMusicEx(a,0,b,0,0,0) #define S_ChangeMusic(a,b,c) S_ChangeMusicEx(a,b,c,0,0,0) +void S_SetRestoreMusicFadeInCvar (consvar_t *cvar); +int S_GetRestoreMusicFadeIn (void); + // Stops the music. void S_StopMusic(void); From b6b7ec92edf9a2812a4946ba8127d327fbb4aadc Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 01:56:44 -0800 Subject: [PATCH 23/42] Restore level music to where it left off Toggleable via the resume cvar. --- src/d_netcmd.c | 2 ++ src/doomstat.h | 1 + src/g_game.c | 2 ++ src/g_game.h | 2 ++ src/p_user.c | 10 +++++++++- src/s_sound.c | 3 +++ 6 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index fe18ba733..e885b44a2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -975,6 +975,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_invincmusicfade); CV_RegisterVar(&cv_growmusicfade); + CV_RegisterVar(&cv_resume); + // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); COM_AddCommand("writethings", Command_Writethings_f); diff --git a/src/doomstat.h b/src/doomstat.h index 232a5af8e..39b057ad0 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -34,6 +34,7 @@ extern INT16 gamemap; extern char mapmusname[7]; extern UINT16 mapmusflags; extern UINT32 mapmusposition; +extern UINT32 mapmusresume; #define MUSIC_TRACKMASK 0x0FFF // ----************ #define MUSIC_RELOADRESET 0x8000 // *--------------- #define MUSIC_FORCERESET 0x4000 // -*-------------- diff --git a/src/g_game.c b/src/g_game.c index ddbe65987..8738d15da 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -85,6 +85,7 @@ static void G_DoStartVote(void); char mapmusname[7]; // Music name UINT16 mapmusflags; // Track and reset bit UINT32 mapmusposition; // Position to jump to +UINT32 mapmusresume; INT16 gamemap = 1; INT16 maptol; @@ -522,6 +523,7 @@ consvar_t cv_deadzone4 = {"joy4_deadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_con consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_resume = {"resume", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; #if MAXPLAYERS > 16 #error "please update player_name table using the new value for MAXPLAYERS" diff --git a/src/g_game.h b/src/g_game.h index dcbe84db0..1acdd72b7 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -127,6 +127,8 @@ extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_gu extern consvar_t cv_invincmusicfade; extern consvar_t cv_growmusicfade; +extern consvar_t cv_resume; + typedef enum { AXISNONE = 0, diff --git a/src/p_user.c b/src/p_user.c index 83a296a39..e98badbab 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1219,6 +1219,8 @@ boolean P_EndingMusic(player_t *player) // void P_RestoreMusic(player_t *player) { + UINT32 position; + if (!P_IsLocalPlayer(player)) // Only applies to a local player return; @@ -1293,8 +1295,14 @@ void P_RestoreMusic(player_t *player) if (G_RaceGametype() && player->laps >= (UINT8)(cv_numlaps.value - 1)) S_SpeedMusic(1.2f); #endif - S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, + if (mapmusresume && cv_resume.value) + position = mapmusresume; + else + position = mapmusposition; + + S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, S_GetRestoreMusicFadeIn()); + mapmusresume = 0; } } } diff --git a/src/s_sound.c b/src/s_sound.c index 84d9d241d..a31b93b31 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2075,6 +2075,9 @@ void S_StopMusic(void) || demo.title) // SRB2Kart: Demos don't interrupt title screen music return; + if (strcasecmp(music_name, mapmusname) == 0) + mapmusresume = I_GetSongPosition(); + if (I_SongPaused()) I_ResumeSong(); From 651e28758710728bfc8a1986b278e27fe8c8870a Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 02:55:45 -0800 Subject: [PATCH 24/42] Death fades music Cvars are respawnfademusicout and respawnfademusicback. Both measure milliseconds. --- src/d_netcmd.c | 3 +++ src/g_game.c | 17 ++++++++++++++++- src/g_game.h | 3 +++ src/p_inter.c | 15 +++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e885b44a2..9269008b9 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -975,6 +975,9 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_invincmusicfade); CV_RegisterVar(&cv_growmusicfade); + CV_RegisterVar(&cv_respawnfademusicout); + CV_RegisterVar(&cv_respawnfademusicback); + CV_RegisterVar(&cv_resume); // ingame object placing diff --git a/src/g_game.c b/src/g_game.c index 8738d15da..fcffa51f7 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -523,6 +523,9 @@ consvar_t cv_deadzone4 = {"joy4_deadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_con consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_respawnfademusicout = {"respawnfademusicout", "1000", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_respawnfademusicback = {"respawnfademusicback", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_resume = {"resume", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; #if MAXPLAYERS > 16 @@ -2767,7 +2770,19 @@ void G_PlayerReborn(INT32 player) } } - P_RestoreMusic(p); + if (S_MusicPlaying()) + { + P_RestoreMusic(p); + /* mid-way fading out, fade back up */ + S_FadeMusic(100, cv_respawnfademusicback.value); + } + else + { + /* this could be considered a hack, but I like it ...kinda */ + S_SetRestoreMusicFadeInCvar(&cv_respawnfademusicback); + P_RestoreMusic(p); + } + if (songcredit) S_ShowMusicCredit(); diff --git a/src/g_game.h b/src/g_game.h index 1acdd72b7..8104114f3 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -127,6 +127,9 @@ extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_gu extern consvar_t cv_invincmusicfade; extern consvar_t cv_growmusicfade; +extern consvar_t cv_respawnfademusicout; +extern consvar_t cv_respawnfademusicback; + extern consvar_t cv_resume; typedef enum diff --git a/src/p_inter.c b/src/p_inter.c index abb12811e..df7aab723 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2106,6 +2106,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { mobjtype_t item; mobj_t *mo; + int ms; //if (inflictor && (inflictor->type == MT_SHELL || inflictor->type == MT_FIREBALL)) // P_SetTarget(&target->tracer, inflictor); @@ -2319,6 +2320,20 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) } target->player->playerstate = PST_DEAD; + if (netgame || multiplayer) + ms = cv_respawntime.value * 1000; + else + ms = 1000; + + /* + If the time spent with the music paused is less than half + a second, continue playing the song (just mute it). + */ + if (( ms - cv_respawnfademusicout.value ) < 500) + S_FadeMusic(0, cv_respawnfademusicout.value); + else + S_FadeOutStopMusic(cv_respawnfademusicout.value); + if (target->player == &players[consoleplayer]) { // don't die in auto map, From b428549994178b2d90dae543eed0b1fc9aa5647e Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 03:01:01 -0800 Subject: [PATCH 25/42] Reset mapmusresume on level load etc. This is probably important, right? --- src/g_game.c | 1 + src/p_spec.c | 1 + src/s_sound.c | 2 ++ 3 files changed, 4 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index fcffa51f7..d8dbebfed 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2766,6 +2766,7 @@ void G_PlayerReborn(INT32 player) mapmusname[6] = 0; mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); mapmusposition = mapheaderinfo[gamemap-1]->muspos; + mapmusresume = 0; songcredit = true; } } diff --git a/src/p_spec.c b/src/p_spec.c index 04d69c9b9..9e6faf505 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2478,6 +2478,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) mapmusflags |= MUSIC_FORCERESET; mapmusposition = position; + mapmusresume = 0; S_ChangeMusicEx(mapmusname, mapmusflags, !(line->flags & ML_EFFECT4), position, !(line->flags & ML_EFFECT2) ? prefadems : 0, diff --git a/src/s_sound.c b/src/s_sound.c index a31b93b31..4f54336cc 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2234,6 +2234,7 @@ void S_Start(void) mapmusname[6] = 0; mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); mapmusposition = mapheaderinfo[gamemap-1]->muspos; + mapmusresume = 0; } //if (cv_resetmusic.value) // Starting ambience should always be restarted @@ -2308,6 +2309,7 @@ static void Command_Tunes_f(void) mapmusname[6] = 0; mapmusflags = (track & MUSIC_TRACKMASK); mapmusposition = position; + mapmusresume = 0; S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); From aec7682d92a8203cdcc1e3884036a9d87b072da1 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 03:01:41 -0800 Subject: [PATCH 26/42] Reset the music fade in cvar pointer too This fixes a bug with death fades. --- src/p_user.c | 1 + src/s_sound.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index e98badbab..3f0f09d5a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1302,6 +1302,7 @@ void P_RestoreMusic(player_t *player) S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, S_GetRestoreMusicFadeIn()); + S_ClearRestoreMusicFadeInCvar(); mapmusresume = 0; } } diff --git a/src/s_sound.h b/src/s_sound.h index b1f558df8..0a0f9cf50 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -187,6 +187,8 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 #define S_ChangeMusic(a,b,c) S_ChangeMusicEx(a,b,c,0,0,0) void S_SetRestoreMusicFadeInCvar (consvar_t *cvar); +#define S_ClearRestoreMusicFadeInCvar() \ + S_SetRestoreMusicFadeInCvar(0) int S_GetRestoreMusicFadeIn (void); // Stops the music. From 119d60eb16c45d90a8b5fced819cfcd59e30b815 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 03:24:10 -0800 Subject: [PATCH 27/42] 3 AM Moment: The death fades now only apply to local players --- src/g_game.c | 13 +------------ src/p_inter.c | 27 +++++++++++++++------------ src/p_user.c | 21 +++++++++++++++++++-- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index d8dbebfed..cea848de3 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2771,18 +2771,7 @@ void G_PlayerReborn(INT32 player) } } - if (S_MusicPlaying()) - { - P_RestoreMusic(p); - /* mid-way fading out, fade back up */ - S_FadeMusic(100, cv_respawnfademusicback.value); - } - else - { - /* this could be considered a hack, but I like it ...kinda */ - S_SetRestoreMusicFadeInCvar(&cv_respawnfademusicback); - P_RestoreMusic(p); - } + P_RestoreMusic(p); if (songcredit) S_ShowMusicCredit(); diff --git a/src/p_inter.c b/src/p_inter.c index df7aab723..7fe77cb02 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2320,19 +2320,22 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) } target->player->playerstate = PST_DEAD; - if (netgame || multiplayer) - ms = cv_respawntime.value * 1000; - else - ms = 1000; + if (P_IsLocalPlayer(target->player)) + { + if (netgame || multiplayer) + ms = cv_respawntime.value * 1000; + else + ms = 1000; - /* - If the time spent with the music paused is less than half - a second, continue playing the song (just mute it). - */ - if (( ms - cv_respawnfademusicout.value ) < 500) - S_FadeMusic(0, cv_respawnfademusicout.value); - else - S_FadeOutStopMusic(cv_respawnfademusicout.value); + /* + If the time spent with the music paused is less than half + a second, continue playing the song (just mute it). + */ + if (( ms - cv_respawnfademusicout.value ) < 500) + S_FadeMusic(0, cv_respawnfademusicout.value); + else + S_FadeOutStopMusic(cv_respawnfademusicout.value); + } if (target->player == &players[consoleplayer]) { diff --git a/src/p_user.c b/src/p_user.c index 3f0f09d5a..b840ab785 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1220,6 +1220,8 @@ boolean P_EndingMusic(player_t *player) void P_RestoreMusic(player_t *player) { UINT32 position; + boolean playing; + int fadein; if (!P_IsLocalPlayer(player)) // Only applies to a local player return; @@ -1300,10 +1302,25 @@ void P_RestoreMusic(player_t *player) else position = mapmusposition; - S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, - S_GetRestoreMusicFadeIn()); + playing = S_MusicPlaying(); + + /* + So if the music isn't playing, it's + most likely because we were dead. + */ + if (! playing) + fadein = cv_respawnfademusicback.value; + + if (playing || ! fadein) + fadein = S_GetRestoreMusicFadeIn(); + + S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, fadein); S_ClearRestoreMusicFadeInCvar(); mapmusresume = 0; + + /* mid-way fading out, fade back up */ + if (playing) + S_FadeMusic(100, cv_respawnfademusicback.value); } } } From 8d64faee879a6ae5950284dd8581eaecbf84f839 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 03:31:50 -0800 Subject: [PATCH 28/42] Revert "More intuitive menu for music resync option" This reverts commit ee78597a42b4e5edf5b22466682b9a00da6bcecf. --- src/m_menu.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 2e5261257..51084e56e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1344,7 +1344,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, - {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "Music Resynch Threshold", &cv_music_resync_threshold, 150}, + {IT_STRING|IT_CVAR, NULL, "Music Resynch Threshold (MS)", &cv_music_resync_threshold, 150}, }; static menuitem_t OP_DataOptionsMenu[] = @@ -6577,23 +6577,12 @@ static void M_DrawSkyRoom(void) (midi_disabled ? warningflags : highlightflags), (midi_disabled ? "OFF" : "ON"));*/ - V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, - currentMenu->y+currentMenu->menuitems[12].alphaKey, - highlightflags, - ( (cv_music_resync_threshold.value) ? - va("%s MS", cv_music_resync_threshold.string) : "OFF" )); - if (itemOn == 0) lengthstring = 8*(sound_disabled ? 3 : 2); else if (itemOn == 2) lengthstring = 8*(digital_disabled ? 3 : 2); /*else if (itemOn == 5) lengthstring = 8*(midi_disabled ? 3 : 2);*/ - else if (itemOn == 12) - { - lengthstring = 8*( (cv_music_resync_threshold.value) ? - strlen(cv_music_resync_threshold.string) + 3 : 3 ); - } } for (i = 0; i < currentMenu->numitems; ++i) From 48deaacf288d3df0888eff5b518128ef9bb012af Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 03:32:24 -0800 Subject: [PATCH 29/42] Revert "Menu option for music resync" This reverts commit a210874ae421007d0bc97b827b4e52c9b076cd90. --- src/m_menu.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 51084e56e..480c887b6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1343,8 +1343,6 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, - - {IT_STRING|IT_CVAR, NULL, "Music Resynch Threshold (MS)", &cv_music_resync_threshold, 150}, }; static menuitem_t OP_DataOptionsMenu[] = From 8c0df23a91ad4efb269a88ad9f56b739f5e32903 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 16:17:09 -0800 Subject: [PATCH 30/42] Let invincibility and grow music fades work again --- src/g_game.c | 26 ++++++++++++++++++++++++++ src/p_user.c | 21 ++------------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index cea848de3..e4c73c329 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2612,6 +2612,9 @@ void G_PlayerReborn(INT32 player) INT32 respawnflip; boolean songcredit = false; + boolean local; + boolean playing; + score = players[player].score; marescore = players[player].marescore; lives = players[player].lives; @@ -2771,8 +2774,31 @@ void G_PlayerReborn(INT32 player) } } + /* I'm putting this here because lol */ + + local = P_IsLocalPlayer(p); + + if (local) + { + playing = S_MusicPlaying(); + + /* + Fade it in with the same call to avoid + max volume for a few milliseconds (?). + */ + if (! playing) + S_SetRestoreMusicFadeInCvar(&cv_respawnfademusicback); + } + P_RestoreMusic(p); + if (local) + { + /* mid-way fading out, fade back up */ + if (playing) + S_FadeMusic(100, cv_respawnfademusicback.value); + } + if (songcredit) S_ShowMusicCredit(); diff --git a/src/p_user.c b/src/p_user.c index b840ab785..3f0f09d5a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1220,8 +1220,6 @@ boolean P_EndingMusic(player_t *player) void P_RestoreMusic(player_t *player) { UINT32 position; - boolean playing; - int fadein; if (!P_IsLocalPlayer(player)) // Only applies to a local player return; @@ -1302,25 +1300,10 @@ void P_RestoreMusic(player_t *player) else position = mapmusposition; - playing = S_MusicPlaying(); - - /* - So if the music isn't playing, it's - most likely because we were dead. - */ - if (! playing) - fadein = cv_respawnfademusicback.value; - - if (playing || ! fadein) - fadein = S_GetRestoreMusicFadeIn(); - - S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, fadein); + S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, + S_GetRestoreMusicFadeIn()); S_ClearRestoreMusicFadeInCvar(); mapmusresume = 0; - - /* mid-way fading out, fade back up */ - if (playing) - S_FadeMusic(100, cv_respawnfademusicback.value); } } } From ea8123abb47471f92fa608fabad83bd9bb3e00d6 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 17:23:40 -0800 Subject: [PATCH 31/42] Optionally only resync Invincibility and Grow music --- src/i_sound.h | 1 + src/p_user.c | 2 ++ src/s_sound.c | 22 ++++++++++++++++++++++ src/s_sound.h | 9 +++++++++ src/sdl/mixer_sound.c | 13 ++++++++++++- 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/i_sound.h b/src/i_sound.h index 422cfb8ff..93e3f6dd0 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -159,6 +159,7 @@ boolean I_SetSongPosition(UINT32 position); UINT32 I_GetSongPosition(void); void I_UpdateSongLagThreshold (void); +void I_UpdateSongLagConditions (void); /// ------------------------ // MUSIC PLAYBACK diff --git a/src/p_user.c b/src/p_user.c index 3f0f09d5a..04e9f446b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1279,12 +1279,14 @@ void P_RestoreMusic(player_t *player) if (wantedmus == 2) { S_ChangeMusicInternal("kgrow", true); + S_SetMusicUsage(MUS_SPECIAL); S_SetRestoreMusicFadeInCvar(&cv_growmusicfade); } // Item - Invincibility else if (wantedmus == 1) { S_ChangeMusicInternal("kinvnc", true); + S_SetMusicUsage(MUS_SPECIAL); S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade); } else diff --git a/src/s_sound.c b/src/s_sound.c index 4f54336cc..d82be2608 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -130,6 +130,10 @@ consvar_t cv_music_resync_threshold = { "music_resync_threshold", "100", CV_SAVE|CV_CALL, music_resync_threshold_cons_t, I_UpdateSongLagThreshold }; +consvar_t cv_music_resync_powerups_only = { + "music_resync_powerups_only", "No", CV_SAVE|CV_CALL, + CV_YesNo, I_UpdateSongLagConditions +}; #define S_MAX_VOLUME 127 @@ -298,6 +302,7 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&cv_playsoundifunfocused); CV_RegisterVar(&cv_music_resync_threshold); + CV_RegisterVar(&cv_music_resync_powerups_only); COM_AddCommand("tunes", Command_Tunes_f); COM_AddCommand("restartaudio", Command_RestartAudio_f); @@ -1566,6 +1571,7 @@ static void *music_data; static UINT16 music_flags; static boolean music_looping; static consvar_t *music_refade_cv; +static int music_usage; static char queue_name[7]; static UINT16 queue_flags; @@ -1951,6 +1957,7 @@ static void S_UnloadMusic(void) music_looping = false; music_refade_cv = 0; + music_usage = 0; } static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) @@ -1958,6 +1965,8 @@ static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) if (S_MusicDisabled()) return false; + I_UpdateSongLagConditions(); + if ((!fadeinms && !I_PlaySong(looping)) || (fadeinms && !I_FadeInPlaySong(fadeinms, looping))) { @@ -2190,6 +2199,19 @@ S_GetRestoreMusicFadeIn (void) return 0; } +void +S_SetMusicUsage (int type) +{ + music_usage = type; + I_UpdateSongLagConditions(); +} + +int +S_MusicUsage (void) +{ + return music_usage; +} + /// ------------------------ /// Music Fading /// ------------------------ diff --git a/src/s_sound.h b/src/s_sound.h index 0a0f9cf50..44eb0c06a 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -37,6 +37,7 @@ extern consvar_t cv_playmusicifunfocused; extern consvar_t cv_playsoundifunfocused; extern consvar_t cv_music_resync_threshold; +extern consvar_t cv_music_resync_powerups_only; #ifdef SNDSERV extern consvar_t sndserver_cmd, sndserver_arg; @@ -178,6 +179,11 @@ UINT32 S_GetMusicPosition(void); // Music Playback // +enum +{ + MUS_SPECIAL = 1,/* powerups--invincibility, grow */ +}; + // Start music track, arbitrary, given its name, and set whether looping // note: music flags 12 bits for tracknum (gme, other formats with more than one track) // 13-15 aren't used yet @@ -191,6 +197,9 @@ void S_SetRestoreMusicFadeInCvar (consvar_t *cvar); S_SetRestoreMusicFadeInCvar(0) int S_GetRestoreMusicFadeIn (void); +void S_SetMusicUsage (int type); +int S_MusicUsage (void); + // Stops the music. void S_StopMusic(void); diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 30463fbbc..f871851dc 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -80,6 +80,7 @@ write netcode into the sound code, OKAY? UINT8 sound_started = false; +static UINT32 stutter_threshold_user; static UINT32 stutter_threshold; static Mix_Music *music; @@ -925,7 +926,17 @@ UINT32 I_GetSongPosition(void) void I_UpdateSongLagThreshold (void) { - stutter_threshold = cv_music_resync_threshold.value/1000.0*(4*44100); + stutter_threshold_user = cv_music_resync_threshold.value/1000.0*(4*44100); + I_UpdateSongLagConditions(); +} + +void +I_UpdateSongLagConditions (void) +{ + if (! cv_music_resync_powerups_only.value || S_MusicUsage() == MUS_SPECIAL) + stutter_threshold = stutter_threshold_user; + else + stutter_threshold = 0; } /// ------------------------ From 0528e4a686ba47708307ff8e0b16658541187d11 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 17:38:55 -0800 Subject: [PATCH 32/42] Reset Invincibility (and Grow) music to the start if stacked Toggleable via the resetspecialmusic cvar. --- src/d_netcmd.c | 2 ++ src/g_game.c | 2 ++ src/g_game.h | 2 ++ src/p_user.c | 6 ++---- src/s_sound.c | 9 +++++++++ src/s_sound.h | 2 ++ 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9269008b9..9c2dd6d80 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -978,6 +978,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_respawnfademusicout); CV_RegisterVar(&cv_respawnfademusicback); + CV_RegisterVar(&cv_resetspecialmusic); + CV_RegisterVar(&cv_resume); // ingame object placing diff --git a/src/g_game.c b/src/g_game.c index e4c73c329..41365e40e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -526,6 +526,8 @@ consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL consvar_t cv_respawnfademusicout = {"respawnfademusicout", "1000", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_respawnfademusicback = {"respawnfademusicback", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_resetspecialmusic = {"resetspecialmusic", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_resume = {"resume", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; #if MAXPLAYERS > 16 diff --git a/src/g_game.h b/src/g_game.h index 8104114f3..7a340f668 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -130,6 +130,8 @@ extern consvar_t cv_growmusicfade; extern consvar_t cv_respawnfademusicout; extern consvar_t cv_respawnfademusicback; +extern consvar_t cv_resetspecialmusic; + extern consvar_t cv_resume; typedef enum diff --git a/src/p_user.c b/src/p_user.c index 04e9f446b..b3079101d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1278,15 +1278,13 @@ void P_RestoreMusic(player_t *player) // Item - Grow if (wantedmus == 2) { - S_ChangeMusicInternal("kgrow", true); - S_SetMusicUsage(MUS_SPECIAL); + S_ChangeMusicSpecial("kgrow"); S_SetRestoreMusicFadeInCvar(&cv_growmusicfade); } // Item - Invincibility else if (wantedmus == 1) { - S_ChangeMusicInternal("kinvnc", true); - S_SetMusicUsage(MUS_SPECIAL); + S_ChangeMusicSpecial("kinvnc"); S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade); } else diff --git a/src/s_sound.c b/src/s_sound.c index d82be2608..6acbee8cd 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2077,6 +2077,15 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 } } +void +S_ChangeMusicSpecial (const char *mmusic) +{ + if (cv_resetspecialmusic.value) + S_ChangeMusic(mmusic, MUSIC_FORCERESET, true); + else + S_ChangeMusicInternal(mmusic, true); +} + void S_StopMusic(void) { if (!I_SongPlaying() diff --git a/src/s_sound.h b/src/s_sound.h index 44eb0c06a..c433aa974 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -192,6 +192,8 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 #define S_ChangeMusicInternal(a,b) S_ChangeMusicEx(a,0,b,0,0,0) #define S_ChangeMusic(a,b,c) S_ChangeMusicEx(a,b,c,0,0,0) +void S_ChangeMusicSpecial (const char *mmusic); + void S_SetRestoreMusicFadeInCvar (consvar_t *cvar); #define S_ClearRestoreMusicFadeInCvar() \ S_SetRestoreMusicFadeInCvar(0) From 97a58f48befcbf8a43afc2c5dae90e67467845e0 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 11 Mar 2020 19:39:06 -0700 Subject: [PATCH 33/42] Don't reset special music in P_RestoreMusic Because that resets Grow music when you stack Grow over Invincibility, and Invincibility ends. (Also Megamix Themes.) Thanks Snu, for calling P_RestoreMusic every tic! --- src/k_kart.c | 12 ++++++++---- src/p_user.c | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index c4bade950..9e6f861e9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5561,9 +5561,11 @@ void K_MoveKartPlayer(player_t *player, boolean onground) P_SetScale(overlay, player->mo->scale); } player->kartstuff[k_invincibilitytimer] = itemtime+(2*TICRATE); // 10 seconds - P_RestoreMusic(player); - if (!P_IsLocalPlayer(player)) + if (P_IsLocalPlayer(player)) + S_ChangeMusicSpecial("kinvnc"); + else S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmi : sfx_kinvnc)); + P_RestoreMusic(player); K_PlayPowerGloatSound(player->mo); player->kartstuff[k_itemamount]--; } @@ -5764,9 +5766,11 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (cv_kartdebugshrink.value && !modeattacking && !player->bot) player->mo->destscale = (6*player->mo->destscale)/8; player->kartstuff[k_growshrinktimer] = itemtime+(4*TICRATE); // 12 seconds - P_RestoreMusic(player); - if (!P_IsLocalPlayer(player)) + if (P_IsLocalPlayer(player)) + S_ChangeMusicSpecial("kgrow"); + else S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmg : sfx_kgrow)); + P_RestoreMusic(player); S_StartSound(player->mo, sfx_kc5a); } player->kartstuff[k_itemamount]--; diff --git a/src/p_user.c b/src/p_user.c index b3079101d..3f0f09d5a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1278,13 +1278,13 @@ void P_RestoreMusic(player_t *player) // Item - Grow if (wantedmus == 2) { - S_ChangeMusicSpecial("kgrow"); + S_ChangeMusicInternal("kgrow", true); S_SetRestoreMusicFadeInCvar(&cv_growmusicfade); } // Item - Invincibility else if (wantedmus == 1) { - S_ChangeMusicSpecial("kinvnc"); + S_ChangeMusicInternal("kinvnc", true); S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade); } else From 8515bc410ec0b5f1e75c6618692793fe041c5f9e Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 19 Apr 2020 22:08:37 -0700 Subject: [PATCH 34/42] C90 moment --- src/s_sound.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 6acbee8cd..eca6029bf 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -126,14 +126,9 @@ static CV_PossibleValue_t music_resync_threshold_cons_t[] = { {0} }; -consvar_t cv_music_resync_threshold = { - "music_resync_threshold", "100", CV_SAVE|CV_CALL, - music_resync_threshold_cons_t, I_UpdateSongLagThreshold -}; -consvar_t cv_music_resync_powerups_only = { - "music_resync_powerups_only", "No", CV_SAVE|CV_CALL, - CV_YesNo, I_UpdateSongLagConditions -}; +consvar_t cv_music_resync_threshold = {"music_resync_threshold", "100", CV_SAVE|CV_CALL, music_resync_threshold_cons_t, I_UpdateSongLagThreshold, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_music_resync_powerups_only = {"music_resync_powerups_only", "No", CV_SAVE|CV_CALL, CV_YesNo, I_UpdateSongLagConditions, 0, NULL, NULL, 0, 0, NULL}; #define S_MAX_VOLUME 127 From 6fbd518b9769844ed5895e8f39f5274983f01c43 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 28 Sep 2020 14:34:17 -0700 Subject: [PATCH 35/42] cv_fading to disable music fading entirely --- src/d_netcmd.c | 1 + src/g_game.c | 9 +++++---- src/g_game.h | 1 + src/p_inter.c | 2 +- src/s_sound.c | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9c2dd6d80..0a32fda78 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -981,6 +981,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_resetspecialmusic); CV_RegisterVar(&cv_resume); + CV_RegisterVar(&cv_fading); // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); diff --git a/src/g_game.c b/src/g_game.c index 41365e40e..034713f09 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -529,6 +529,7 @@ consvar_t cv_respawnfademusicback = {"respawnfademusicback", "500", CV_SAVE, CV_ consvar_t cv_resetspecialmusic = {"resetspecialmusic", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_resume = {"resume", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_fading = {"fading", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #if MAXPLAYERS > 16 #error "please update player_name table using the new value for MAXPLAYERS" @@ -2614,7 +2615,7 @@ void G_PlayerReborn(INT32 player) INT32 respawnflip; boolean songcredit = false; - boolean local; + boolean fade; boolean playing; score = players[player].score; @@ -2778,9 +2779,9 @@ void G_PlayerReborn(INT32 player) /* I'm putting this here because lol */ - local = P_IsLocalPlayer(p); + fade = ( cv_fading.value && P_IsLocalPlayer(p) ); - if (local) + if (fade) { playing = S_MusicPlaying(); @@ -2794,7 +2795,7 @@ void G_PlayerReborn(INT32 player) P_RestoreMusic(p); - if (local) + if (fade) { /* mid-way fading out, fade back up */ if (playing) diff --git a/src/g_game.h b/src/g_game.h index 7a340f668..4761f5c31 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -133,6 +133,7 @@ extern consvar_t cv_respawnfademusicback; extern consvar_t cv_resetspecialmusic; extern consvar_t cv_resume; +extern consvar_t cv_fading; typedef enum { diff --git a/src/p_inter.c b/src/p_inter.c index 7fe77cb02..7aec8115f 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2320,7 +2320,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) } target->player->playerstate = PST_DEAD; - if (P_IsLocalPlayer(target->player)) + if (cv_fading.value && P_IsLocalPlayer(target->player)) { if (netgame || multiplayer) ms = cv_respawntime.value * 1000; diff --git a/src/s_sound.c b/src/s_sound.c index eca6029bf..a7ae485d3 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2197,7 +2197,7 @@ S_SetRestoreMusicFadeInCvar (consvar_t *cv) int S_GetRestoreMusicFadeIn (void) { - if (music_refade_cv) + if (music_refade_cv && cv_fading.value) return music_refade_cv->value; else return 0; From 5dcf65df8a9a519af9ab7a11254e76781b39ece1 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 6 Oct 2020 16:59:02 -0700 Subject: [PATCH 36/42] Fix NOMIXER --- src/sdl/sdl_sound.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 929ac79f5..5c93642bd 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1409,6 +1409,9 @@ UINT32 I_GetSongPosition(void) return 0; } +void I_UpdateSongLagThreshold (void) {} +void I_UpdateSongLagConditions (void) {} + /// ------------------------ // MUSIC PLAYBACK /// ------------------------ From b850afaa1252f8223047918967b3cd4767945e67 Mon Sep 17 00:00:00 2001 From: AJ Martinez Date: Wed, 14 Oct 2020 21:52:57 -0500 Subject: [PATCH 37/42] Correctly pad time + slim down titlename format --- src/d_netcmd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 5adb0f4b9..93f3df9da 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2815,15 +2815,15 @@ static void Command_ReplayMarker(void) CONS_Printf(M_GetText("You must be in a level to use this.\n")); return; } - if (demo.savemode == DSM_WILLSAVE) { + if (demo.savemode == DSM_WILLAUTOSAVE) { demo.savemode = DSM_NOTSAVING; CONS_Printf("Replay unmarked.\n"); } else { int adjustedleveltime = leveltime - starttime; - demo.savemode = DSM_WILLSAVE; + demo.savemode = DSM_WILLAUTOSAVE; if (adjustedleveltime < 0) adjustedleveltime = 0; - snprintf(demo.titlename, 64, "%s - %i:%i - %s", G_BuildMapTitle(gamemap), G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); + snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", G_BuildMapTitle(gamemap), G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); CONS_Printf("Replay will be saved!\n"); } } From a88f4aaf0017276bf0bf2aa99517d57fa38d7db2 Mon Sep 17 00:00:00 2001 From: Fafabis Date: Mon, 5 Jul 2021 20:56:41 -0300 Subject: [PATCH 38/42] show the track addon --- src/dehacked.c | 7 +++++-- src/m_menu.c | 17 +++++++++++++++++ src/m_menu.h | 2 ++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 00f4fa96d..f1cf96ce0 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -871,7 +871,7 @@ static const struct { {NULL, 0} }; -static void readlevelheader(MYFILE *f, INT32 num) +static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) { char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); char *word; @@ -884,6 +884,9 @@ static void readlevelheader(MYFILE *f, INT32 num) // This call automatically saves all previous information when DELFILE is defined. // We don't need to do it ourselves. P_AllocMapHeader((INT16)(num-1)); + + if (!strstr(wadfiles[wadnum]->filename, ".soc")) + mapwads[num-1] = wadnum; do { @@ -3387,7 +3390,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) { if (mapheaderinfo[i]) G_SetGameModified(multiplayer, true); // only mark as a major mod if it replaces an already-existing mapheaderinfo - readlevelheader(f, i); + readlevelheader(f, i, wad); } else { diff --git a/src/m_menu.c b/src/m_menu.c index 15a619871..f97f7a996 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -135,6 +135,8 @@ const char *quitmsg[NUM_QUITMESSAGES]; // Stuff for customizing the player select screen Tails 09-22-2003 description_t description[MAXSKINS]; +INT32 mapwads[NUMMAPS]; + //static char *char_notes = NULL; //static fixed_t char_scroll = 0; @@ -8908,6 +8910,21 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) trans = G_GetGametypeColor(cv_newgametype.value); V_DrawFill(x-1, y-1, w+2, i+2, trans); // variable reuse... + + if (cv_nextmap.value) + { + char *addonname = wadfiles[mapwads[cv_nextmap.value-1]]->filename; + INT32 len, sw = 0; + INT32 charlimit = 21 + (dupadjust/5); + nameonly(addonname); + len = strlen(addonname); +#define charsonside 14 + if (len > charlimit) + V_DrawThinString(x+w+5, y+i-8, V_TRANSLUCENT, va("%.*s...%s", charsonside, addonname, addonname+((len-charlimit) + charsonside))); // variable reuse... +#undef charsonside + else + V_DrawThinString(x+w+5, y+i-8, V_TRANSLUCENT, addonname); // variable reuse... + } if (!cv_kartencore.value || gamestate == GS_TIMEATTACK || cv_newgametype.value != GT_RACE) V_DrawSmallScaledPatch(x, y, 0, PictureOfLevel); diff --git a/src/m_menu.h b/src/m_menu.h index 28fdd44e6..70cb0f9cb 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -235,6 +235,8 @@ typedef struct UINT8 netgame; } saveinfo_t; +extern INT32 mapwads[NUMMAPS]; + extern description_t description[MAXSKINS]; extern consvar_t cv_showfocuslost; From c96d85156e8b61d175efa40829c18706d4f299de Mon Sep 17 00:00:00 2001 From: Fafabis Date: Mon, 5 Jul 2021 21:03:29 -0300 Subject: [PATCH 39/42] add cvar --- src/d_netcmd.c | 4 ++++ src/d_netcmd.h | 2 ++ src/m_menu.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 84c1045a1..c2c3017fa 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -467,6 +467,8 @@ consvar_t cv_mute = {"mute", "Off", CV_NETVAR|CV_CALL, CV_OnOff, Mute_OnChange, consvar_t cv_sleep = {"cpusleep", "1", CV_SAVE, sleeping_cons_t, NULL, -1, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showtrackaddon = {"showtrackaddon", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; + INT16 gametype = GT_RACE; // SRB2kart boolean forceresetplayers = false; boolean deferencoremode = false; @@ -708,6 +710,8 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_pingtimeout); CV_RegisterVar(&cv_showping); + CV_RegisterVar(&cv_showtrackaddon); + #ifdef SEENAMES CV_RegisterVar(&cv_allowseenames); #endif diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 1e1588083..3c61e9156 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -151,6 +151,8 @@ extern consvar_t cv_skipmapcheck; extern consvar_t cv_sleep; +extern consvar_t cv_showtrackaddon; + typedef enum { XD_NAMEANDCOLOR = 1, diff --git a/src/m_menu.c b/src/m_menu.c index f97f7a996..8805eaec2 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8911,7 +8911,7 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) V_DrawFill(x-1, y-1, w+2, i+2, trans); // variable reuse... - if (cv_nextmap.value) + if (cv_nextmap.value && cv_showtrackaddon.value) { char *addonname = wadfiles[mapwads[cv_nextmap.value-1]]->filename; INT32 len, sw = 0; From 5f446737e6cd7433c86be179d108120179d78976 Mon Sep 17 00:00:00 2001 From: Fafabis Date: Tue, 6 Jul 2021 09:18:47 -0300 Subject: [PATCH 40/42] Add Menu Option --- src/m_menu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 8805eaec2..0670341fc 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1453,7 +1453,8 @@ static menuitem_t OP_HUDOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Console Text Size", &cv_constextsize, 120}, - {IT_STRING | IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 135}, + {IT_STRING | IT_CVAR, NULL, "Show Track Addon Name", &cv_showtrackaddon, 135}, + {IT_STRING | IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 145}, }; // Ok it's still called chatoptions but we'll put ping display in here to be clean From fa890eb1a8c30464c1d82903b822a479c86dd023 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Fri, 10 Jul 2020 19:32:48 -0400 Subject: [PATCH 41/42] Merge branch 'percent-speedomitor-justspeedomitor' into backup-percent-speedomitor --- src/d_netcmd.c | 2 +- src/k_kart.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 057bdf2a2..5d891073e 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -378,7 +378,7 @@ static CV_PossibleValue_t kartvoterulechanges_cons_t[] = {{0, "Never"}, {1, "Som consvar_t cv_kartvoterulechanges = {"kartvoterulechanges", "Frequent", CV_NETVAR, kartvoterulechanges_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t kartgametypepreference_cons_t[] = {{-1, "None"}, {GT_RACE, "Race"}, {GT_MATCH, "Battle"}, {0, NULL}}; consvar_t cv_kartgametypepreference = {"kartgametypepreference", "None", CV_NETVAR, kartgametypepreference_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -static CV_PossibleValue_t kartspeedometer_cons_t[] = {{0, "Off"}, {1, "Kilometers"}, {2, "Miles"}, {3, "Fracunits"}, {0, NULL}}; +static CV_PossibleValue_t kartspeedometer_cons_t[] = {{0, "Off"}, {1, "Kilometers"}, {2, "Miles"}, {3, "Fracunits"}, {4, "Percent"}, {0, NULL}}; consvar_t cv_kartspeedometer = {"kartdisplayspeed", "Off", CV_SAVE, kartspeedometer_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // use tics in display static CV_PossibleValue_t kartvoices_cons_t[] = {{0, "Never"}, {1, "Tasteful"}, {2, "Meme"}, {0, NULL}}; consvar_t cv_kartvoices = {"kartvoices", "Tasteful", CV_SAVE, kartvoices_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/k_kart.c b/src/k_kart.c index d040b8d28..5d2c34b56 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7928,6 +7928,17 @@ static void K_drawKartSpeedometer(void) convSpeed = FixedDiv(stplyr->speed, mapobjectscale)/FRACUNIT; V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%3d fu/t", convSpeed)); } + else if (cv_kartspeedometer.value == 4) // Percent + { + // so code breaks if someone attempts to join from spectator since it sets + // their mo to NULL + // so can we just check if their mo is NULL???? + if (stplyr->mo) + { + convSpeed = (FixedDiv(stplyr->speed, FixedMul(K_GetKartSpeed(stplyr, false), ORIG_FRICTION))*100)>>FRACBITS; + V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%4d P", convSpeed)); + } + } } static void K_drawKartBumpersOrKarma(void) From 61683c96a3243cdeb8b8cedd29518f2bbdfa4452 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Fri, 10 Jul 2020 18:56:04 -0400 Subject: [PATCH 42/42] Merge branch 'driftspark-pulse-on-charge' into backup-driftspark-pulse-on-charge --- src/d_netcmd.c | 5 ++++ src/d_netcmd.h | 2 ++ src/g_game.c | 2 ++ src/g_game.h | 2 ++ src/k_kart.c | 70 +++++++++++++++++++++++++++++++++++++++++--------- src/m_menu.c | 2 ++ src/r_main.c | 2 ++ 7 files changed, 73 insertions(+), 12 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 057bdf2a2..4b92acd49 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2323,6 +2323,8 @@ static void Command_StopMovie_f(void) INT32 mapchangepending = 0; +tic_t driftsparkGrowTimer[MAXPLAYERS]; + /** Runs a map change. * The supplied data are assumed to be good. If provided by a user, they will * have already been checked in Command_Map_f(). @@ -2356,6 +2358,9 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pencoremode, boolean r CONS_Debug(DBG_GAMELOGIC, "Map change: mapnum=%d gametype=%d encoremode=%d resetplayers=%d delay=%d skipprecutscene=%d\n", mapnum, newgametype, pencoremode, resetplayers, delay, skipprecutscene); + // just gonna hack in a timer reset here... + memset(driftsparkGrowTimer, 0, sizeof(driftsparkGrowTimer)); + if (netgame || multiplayer) FLS = false; diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 5b1c7c859..a56cb780c 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -231,6 +231,8 @@ typedef union { #pragma pack() #endif +extern tic_t driftsparkGrowTimer[16]; + // add game commands, needs cleanup void D_RegisterServerCommands(void); void D_RegisterClientCommands(void); diff --git a/src/g_game.c b/src/g_game.c index a76d4770e..7f8283ca3 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -526,6 +526,8 @@ consvar_t cv_driftaxis4 = {"joyaxis4_drift", "None", CV_SAVE, joyaxis_cons_t, NU consvar_t cv_xdeadzone4 = {"joy4_xdeadzone", "0.3", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_ydeadzone4 = {"joy4_ydeadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}}; +consvar_t cv_driftsparkpulse = {"driftsparkpulse", "1.4", CV_FLOAT | CV_SAVE, driftsparkpulse_t, NULL, 0, NULL, NULL, 0, 0, NULL}; #if MAXPLAYERS > 16 #error "please update player_name table using the new value for MAXPLAYERS" diff --git a/src/g_game.h b/src/g_game.h index 0dcc69c39..5086bb4d1 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -124,6 +124,8 @@ extern consvar_t cv_turnaxis3,cv_moveaxis3,cv_brakeaxis3,cv_aimaxis3,cv_lookaxis extern consvar_t cv_turnaxis4,cv_moveaxis4,cv_brakeaxis4,cv_aimaxis4,cv_lookaxis4,cv_fireaxis4,cv_driftaxis4,cv_xdeadzone4,cv_ydeadzone4; extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff; +extern consvar_t cv_driftsparkpulse; + typedef enum { AXISNONE = 0, diff --git a/src/k_kart.c b/src/k_kart.c index d040b8d28..627f82a75 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2798,6 +2798,8 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I return NULL; } +#define DRIFTSPARKGROWTICS 8 + static void K_SpawnDriftSparks(player_t *player) { fixed_t newx; @@ -2823,14 +2825,28 @@ static void K_SpawnDriftSparks(player_t *player) for (i = 0; i < 2; i++) { + UINT8 pindex; + fixed_t driftExtraScale = 0; newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(32*FRACUNIT, player->mo->scale)); newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(32*FRACUNIT, player->mo->scale)); spark = P_SpawnMobj(newx, newy, player->mo->z, MT_DRIFTSPARK); P_SetTarget(&spark->target, player->mo); spark->angle = travelangle-(ANGLE_45/5)*player->kartstuff[k_drift]; - spark->destscale = player->mo->scale; - P_SetScale(spark, player->mo->scale); + + // scale increase while driftspark level gained timer is running + + // hack to find the correct player number + for (pindex = 0; pindex < MAXPLAYERS; pindex++) + { + if (player == &players[pindex]) + { + driftExtraScale = FixedDiv(driftsparkGrowTimer[pindex], DRIFTSPARKGROWTICS); + break; + } + } + spark->destscale = FixedMul(player->mo->scale, FRACUNIT + FixedMul(driftExtraScale, cv_driftsparkpulse.value)); + P_SetScale(spark, FixedMul(player->mo->scale, FRACUNIT + FixedMul(driftExtraScale, cv_driftsparkpulse.value))); spark->momx = player->mo->momx/2; spark->momy = player->mo->momy/2; @@ -5196,24 +5212,54 @@ static void K_KartDrift(player_t *player, boolean onground) if (player->speed > minspeed*2) player->kartstuff[k_getsparks] = 1; + // Sound whenever you get a different tier of sparks + if ((player->kartstuff[k_driftcharge] < dsone && player->kartstuff[k_driftcharge]+driftadditive >= dsone) + || (player->kartstuff[k_driftcharge] < dstwo && player->kartstuff[k_driftcharge]+driftadditive >= dstwo) + || (player->kartstuff[k_driftcharge] < dsthree && player->kartstuff[k_driftcharge]+driftadditive >= dsthree)) + { + UINT8 pindex; + //S_StartSound(player->mo, sfx_s3ka2); + if (P_IsLocalPlayer(player)) // UGHGHGH... + S_StartSoundAtVolume(player->mo, sfx_s3ka2, 192); // Ugh... + + // hack to find the correct player number + for (pindex = 0; pindex < MAXPLAYERS; pindex++) + { + if (player == &players[pindex]) + { + driftsparkGrowTimer[pindex] = DRIFTSPARKGROWTICS; + break; + } + } + } + + + // moved this below sounds to help with scaling // This spawns the drift sparks if (player->kartstuff[k_driftcharge] + driftadditive >= dsone) K_SpawnDriftSparks(player); - // Sound whenever you get a different tier of sparks - if (P_IsLocalPlayer(player) // UGHGHGH... - && ((player->kartstuff[k_driftcharge] < dsone && player->kartstuff[k_driftcharge]+driftadditive >= dsone) - || (player->kartstuff[k_driftcharge] < dstwo && player->kartstuff[k_driftcharge]+driftadditive >= dstwo) - || (player->kartstuff[k_driftcharge] < dsthree && player->kartstuff[k_driftcharge]+driftadditive >= dsthree))) - { - //S_StartSound(player->mo, sfx_s3ka2); - S_StartSoundAtVolume(player->mo, sfx_s3ka2, 192); // Ugh... - } - player->kartstuff[k_driftcharge] += driftadditive; player->kartstuff[k_driftend] = 0; } + { + //im putting this in a block because i want the variables here, not at the top of the block + UINT8 pindex; + + // hack to find the correct player number + for (pindex = 0; pindex < MAXPLAYERS; pindex++) + { + if (player == &players[pindex]) + { + if (driftsparkGrowTimer[pindex]) + driftsparkGrowTimer[pindex]--; + break; + } + } + } + + // Stop drifting if (player->kartstuff[k_spinouttimer] > 0 || player->speed < minspeed) { diff --git a/src/m_menu.c b/src/m_menu.c index b657d1c9b..d01a8b6ff 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1271,6 +1271,7 @@ static menuitem_t OP_VideoOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 90}, {IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 100}, {IT_STRING | IT_CVAR, NULL, "FPS Cap", &cv_fpscap, 110}, + {IT_STRING | IT_CVAR, NULL, "Drift spark pulse size",&cv_driftsparkpulse, 125}, #ifdef HWRENDER {IT_SUBMENU|IT_STRING, NULL, "OpenGL Options...", &OP_OpenGLOptionsDef, 130}, @@ -1292,6 +1293,7 @@ enum op_video_fps, op_video_vsync, op_video_fpscap, + op_video_driftsparkpulse, #ifdef HWRENDER op_video_ogl, #endif diff --git a/src/r_main.c b/src/r_main.c index b6643f06d..78c9672c9 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1520,6 +1520,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_cam4_rotate); CV_RegisterVar(&cv_cam4_rotspeed); + CV_RegisterVar(&cv_driftsparkpulse); + CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud);