From 19487ef2ebada39fb6a6a372b30ca4f66bb78ada Mon Sep 17 00:00:00 2001
From: divverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Date: Fri, 19 Oct 2018 06:40:49 +0000
Subject: [PATCH] Remove the CONFIG_CD macro, and enable faketracks
 unconditionally.

All support for playing back CD-DA has been removed by leaving only the
SDL2 clients, and it is rather unlikely for CD-DA support to come back.
However while doing so, the CONFIG_CD macro was disabled in the makefile
but not the MSVC project, which broke faketracks (i.e. background music
via track003.ogg files) on Linux.

This change removes all #ifdefs for CONFIG_CD as well as its enablement
in the MSVC project, which is basically equivalent to having the feature
always being enabled.

Fixes background music in Quake with ripped music, Nexuiz, Xonotic, and
probably many other DP-based games. Also fixes Xonotic log spam about
gettime(GETTIME_CDTRACK).

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12466 d7cf8633-e32d-0410-b094-e92efae38249
---
 cl_parse.c                     | 10 ----------
 darkplaces-sdl2-vs2017.vcxproj | 10 +++++-----
 host.c                         | 10 ----------
 menu.c                         |  6 ------
 prvm_cmds.c                    |  4 ----
 snd_main.c                     |  4 ----
 vid_shared.c                   |  2 --
 7 files changed, 5 insertions(+), 41 deletions(-)

diff --git a/cl_parse.c b/cl_parse.c
index 82d64cb8..4d4c2f64 100644
--- a/cl_parse.c
+++ b/cl_parse.c
@@ -20,9 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 // cl_parse.c  -- parse a message received from the server
 
 #include "quakedef.h"
-#ifdef CONFIG_CD
 #include "cdaudio.h"
-#endif
 #include "cl_collision.h"
 #include "csprogs.h"
 #include "libcurl.h"
@@ -3642,12 +3640,10 @@ void CL_ParseServerMessage(void)
 
 			case qw_svc_cdtrack:
 				cl.cdtrack = cl.looptrack = MSG_ReadByte(&cl_message);
-#ifdef CONFIG_CD
 				if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
 					CDAudio_Play ((unsigned char)cls.forcetrack, true);
 				else
 					CDAudio_Play ((unsigned char)cl.cdtrack, true);
-#endif
 				break;
 
 			case qw_svc_intermission:
@@ -3766,12 +3762,10 @@ void CL_ParseServerMessage(void)
 
 			case qw_svc_setpause:
 				cl.paused = MSG_ReadByte(&cl_message) != 0;
-#ifdef CONFIG_CD
 				if (cl.paused)
 					CDAudio_Pause ();
 				else
 					CDAudio_Resume ();
-#endif
 				S_PauseGameSounds (cl.paused);
 				break;
 			}
@@ -4096,12 +4090,10 @@ void CL_ParseServerMessage(void)
 
 			case svc_setpause:
 				cl.paused = MSG_ReadByte(&cl_message) != 0;
-#ifdef CONFIG_CD
 				if (cl.paused)
 					CDAudio_Pause ();
 				else
 					CDAudio_Resume ();
-#endif
 				S_PauseGameSounds (cl.paused);
 				break;
 
@@ -4148,12 +4140,10 @@ void CL_ParseServerMessage(void)
 			case svc_cdtrack:
 				cl.cdtrack = MSG_ReadByte(&cl_message);
 				cl.looptrack = MSG_ReadByte(&cl_message);
-#ifdef CONFIG_CD
 				if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
 					CDAudio_Play ((unsigned char)cls.forcetrack, true);
 				else
 					CDAudio_Play ((unsigned char)cl.cdtrack, true);
-#endif
 				break;
 
 			case svc_intermission:
diff --git a/darkplaces-sdl2-vs2017.vcxproj b/darkplaces-sdl2-vs2017.vcxproj
index 7842ecb8..69bf1fc0 100644
--- a/darkplaces-sdl2-vs2017.vcxproj
+++ b/darkplaces-sdl2-vs2017.vcxproj
@@ -93,7 +93,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>CONFIG_MENU;CONFIG_CD;CONFIG_VIDEO_CAPTURE;WIN32;_DEBUG;_WINDOWS;_FILE_OFFSET_BITS=64;__KERNEL_STRICT_NAMES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>CONFIG_MENU;CONFIG_VIDEO_CAPTURE;WIN32;_DEBUG;_WINDOWS;_FILE_OFFSET_BITS=64;__KERNEL_STRICT_NAMES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -120,7 +120,7 @@
     </Midl>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>CONFIG_MENU;CONFIG_CD;CONFIG_VIDEO_CAPTURE;WIN32;WIN64;_DEBUG;_WINDOWS;_FILE_OFFSET_BITS=64;__KERNEL_STRICT_NAMES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>CONFIG_MENU;CONFIG_VIDEO_CAPTURE;WIN32;WIN64;_DEBUG;_WINDOWS;_FILE_OFFSET_BITS=64;__KERNEL_STRICT_NAMES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -144,7 +144,7 @@
     <ClCompile>
       <Optimization>MaxSpeed</Optimization>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>CONFIG_MENU;CONFIG_CD;CONFIG_VIDEO_CAPTURE;WIN32;NDEBUG;_WINDOWS;_FILE_OFFSET_BITS=64;__KERNEL_STRICT_NAMES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>CONFIG_MENU;CONFIG_VIDEO_CAPTURE;WIN32;NDEBUG;_WINDOWS;_FILE_OFFSET_BITS=64;__KERNEL_STRICT_NAMES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <PrecompiledHeader />
@@ -172,7 +172,7 @@
     <ClCompile>
       <Optimization>MaxSpeed</Optimization>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>CONFIG_MENU;CONFIG_CD;CONFIG_VIDEO_CAPTURE;WIN32;WIN64;NDEBUG;_WINDOWS;_FILE_OFFSET_BITS=64;__KERNEL_STRICT_NAMES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>CONFIG_MENU;CONFIG_VIDEO_CAPTURE;WIN32;WIN64;NDEBUG;_WINDOWS;_FILE_OFFSET_BITS=64;__KERNEL_STRICT_NAMES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <PrecompiledHeader />
@@ -393,4 +393,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/host.c b/host.c
index 62dcf474..8fc6c082 100644
--- a/host.c
+++ b/host.c
@@ -23,9 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include <time.h>
 #include "libcurl.h"
-#ifdef CONFIG_CD
 #include "cdaudio.h"
-#endif
 #include "cl_video.h"
 #include "progsvm.h"
 #include "csprogs.h"
@@ -1036,10 +1034,8 @@ void Host_Main(void)
 			else
 				S_Update(&r_refdef.view.matrix);
 
-#ifdef CONFIG_CD
 			CDAudio_Update();
 			R_TimeReport("audio");
-#endif
 
 			// reset gathering of mouse input
 			in_mouse_x = in_mouse_y = 0;
@@ -1087,9 +1083,7 @@ void Host_StartVideo(void)
 		// make sure we open sockets before opening video because the Windows Firewall "unblock?" dialog can screw up the graphics context on some graphics drivers
 		NetConn_UpdateSockets();
 		VID_Start();
-#ifdef CONFIG_CD
 		CDAudio_Startup();
-#endif
 	}
 }
 
@@ -1292,9 +1286,7 @@ static void Host_Init (void)
 		VID_Init();
 		Render_Init();
 		S_Init();
-#ifdef CONFIG_CD
 		CDAudio_Init();
-#endif
 		Key_Init();
 		CL_Init();
 	}
@@ -1436,9 +1428,7 @@ void Host_Shutdown(void)
 
 	Host_SaveConfig();
 
-#ifdef CONFIG_CD
 	CDAudio_Shutdown ();
-#endif
 	S_Terminate ();
 	Curl_Shutdown ();
 	NetConn_Shutdown ();
diff --git a/menu.c b/menu.c
index 34712e21..05abaa86 100644
--- a/menu.c
+++ b/menu.c
@@ -18,9 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 */
 #include "quakedef.h"
-#ifdef CONFIG_CD
 #include "cdaudio.h"
-#endif
 #include "image.h"
 #include "progsvm.h"
 
@@ -1624,9 +1622,7 @@ static void M_Menu_Options_AdjustSliders (int dir)
 	else if (options_cursor == optnum++) Cvar_SetValueQuick(&v_contrast, bound(1, v_contrast.value + dir * 0.0625, 4));
 	else if (options_cursor == optnum++) Cvar_SetValueQuick(&v_gamma, bound(0.5, v_gamma.value + dir * 0.0625, 3));
 	else if (options_cursor == optnum++) Cvar_SetValueQuick(&volume, bound(0, volume.value + dir * 0.0625, 1));
-#ifdef CONFIG_CD
 	else if (options_cursor == optnum++) Cvar_SetValueQuick(&bgmvolume, bound(0, bgmvolume.value + dir * 0.0625, 1));
-#endif
 }
 
 static int m_optnum;
@@ -1703,9 +1699,7 @@ static void M_Options_Draw (void)
 	M_Options_PrintSlider(  "            Brightness", true, v_contrast.value, 1, 2);
 	M_Options_PrintSlider(  "                 Gamma", true, v_gamma.value, 0.5, 3);
 	M_Options_PrintSlider(  "          Sound Volume", snd_initialized.integer, volume.value, 0, 1);
-#ifdef CONFIG_CD
 	M_Options_PrintSlider(  "          Music Volume", cdaudioinitialized.integer, bgmvolume.value, 0, 1);
-#endif
 	M_Options_PrintCommand( "     Customize Effects", true);
 	M_Options_PrintCommand( "       Effects:  Quake", true);
 	M_Options_PrintCommand( "       Effects: Normal", true);
diff --git a/prvm_cmds.c b/prvm_cmds.c
index 01787f46..81f62467 100644
--- a/prvm_cmds.c
+++ b/prvm_cmds.c
@@ -2875,9 +2875,7 @@ VM_gettime
 float	gettime(prvm_prog_t *prog)
 =========
 */
-#ifdef CONFIG_CD
 float CDAudio_GetPosition(void);
-#endif
 void VM_gettime(prvm_prog_t *prog)
 {
 	int timer_index;
@@ -2905,11 +2903,9 @@ void VM_gettime(prvm_prog_t *prog)
 			case 3: // GETTIME_UPTIME
 				PRVM_G_FLOAT(OFS_RETURN) = realtime;
 				break;
-#ifdef CONFIG_CD
 			case 4: // GETTIME_CDTRACK
 				PRVM_G_FLOAT(OFS_RETURN) = CDAudio_GetPosition();
 				break;
-#endif
 			default:
 				VM_Warning(prog, "VM_gettime: %s: unsupported timer specified, returning realtime\n", prog->name);
 				PRVM_G_FLOAT(OFS_RETURN) = realtime;
diff --git a/snd_main.c b/snd_main.c
index 62807eb0..53e63d52 100644
--- a/snd_main.c
+++ b/snd_main.c
@@ -25,9 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "snd_ogg.h"
 #include "csprogs.h"
 #include "cl_collision.h"
-#ifdef CONFIG_CD
 #include "cdaudio.h"
-#endif
 
 
 #define SND_MIN_SPEED 8000
@@ -1820,10 +1818,8 @@ void S_StopAllSounds (void)
 	if (snd_renderbuffer == NULL)
 		return;
 
-#ifdef CONFIG_CD
 	// stop CD audio because it may be using a faketrack
 	CDAudio_Stop();
-#endif
 
 	if (simsound || SndSys_LockRenderBuffer ())
 	{
diff --git a/vid_shared.c b/vid_shared.c
index 093f9f7d..86ec4592 100644
--- a/vid_shared.c
+++ b/vid_shared.c
@@ -1,8 +1,6 @@
 
 #include "quakedef.h"
-#ifdef CONFIG_CD
 #include "cdaudio.h"
-#endif
 #include "image.h"
 
 #ifdef WIN32
-- 
2.39.5