From 3a8a0c9fdd5b153d778cc85618e3d8f42af05a2f Mon Sep 17 00:00:00 2001
From: nehalmistry <>
Date: Thu, 13 Feb 2003 20:55:54 +0000
Subject: [PATCH] added :wc2 cdmode

---
 src/include/sound_server.h  |  2 +-
 src/sound/music.cpp         | 10 ++++++++--
 src/sound/sound_server.cpp  |  6 +-----
 src/stratagus/stratagus.cpp |  9 ++++++---
 4 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/src/include/sound_server.h b/src/include/sound_server.h
index 6e129b752..ef47e55b9 100644
--- a/src/include/sound_server.h
+++ b/src/include/sound_server.h
@@ -234,7 +234,7 @@ extern unsigned AllocatedSoundMemory;
 extern unsigned CompressedSoundMemory;
 #endif
 
-    /// cd play mode, ":off" ":random" or ":all"
+    /// cd play mode, ":off" ":random" ":all" or ":wc2"
 extern char *CDMode;
 #if defined(USE_SDLCD) || defined(USE_LIBCDA) || defined(USE_CDDA)
     /// FIXME: docu
diff --git a/src/sound/music.cpp b/src/sound/music.cpp
index 5b319a9ae..fc89fc1ce 100644
--- a/src/sound/music.cpp
+++ b/src/sound/music.cpp
@@ -49,6 +49,7 @@
 #include "iocompat.h"
 #include "sound.h"
 #include "sound_server.h"
+#include "menus.h"
 
 /*----------------------------------------------------------------------------
 --	Declaration
@@ -64,7 +65,7 @@
 global Sample* MusicSample;		/// Music samples
 #endif
 
-global char *CDMode = ":off";	/// cd play mode, ":off" ":random" or ":all"
+global char *CDMode = ":off";	/// cd play mode, ":off" ":random" ":all" or ":wc2"
 #if defined(USE_SDLCD) || defined(USE_LIBCDA) || defined(USE_CDDA)
 global int CDTrack = 0;			/// Current cd track
 #endif
@@ -287,7 +288,7 @@ global int PlayCDRom(const char* name)
 /**
 **	Play music from cdrom.
 **
-**	:all :random :off
+**	:all :random :off :wc2
 **
 **	@param name	Name starting with ":".
 **
@@ -352,6 +353,11 @@ global int PlayCDRom(const char* name)
 		CDMode = ":stopped";
 	    return 1;
 	}
+	if (!strcmp(name, ":wc2")) {
+	    CDMode = ":wc2";
+	    if (GuiGameStarted == 0)
+		cd_play(15);
+	}
 	return 1;
     }
 
diff --git a/src/sound/sound_server.cpp b/src/sound/sound_server.cpp
index 166310470..51e2f5972 100644
--- a/src/sound/sound_server.cpp
+++ b/src/sound/sound_server.cpp
@@ -243,11 +243,7 @@ global int CDRomCheck(void *unused __attribute__ ((unused)))
     if (strcmp(CDMode, ":off") && strcmp(CDMode, ":stopped")
 	    && !cd_current_track()) {
 	DebugLevel0Fn("Playing new track\n");
-	if (!strcmp(CDMode, ":all")) {
-	    PlayCDRom(":all");
-	} else if (!strcmp(CDMode, ":random")) {
-	    PlayCDRom(":random");
-	}
+	PlayCDRom(CDMode);
     } else if (strcmp(CDMode, ":off") && strcmp(CDMode, ":stopped")) {
 	DebugLevel0Fn("get track\n");
 	CDTrack = cd_current_track() + 1;
diff --git a/src/stratagus/stratagus.cpp b/src/stratagus/stratagus.cpp
index 97b93d991..628013097 100644
--- a/src/stratagus/stratagus.cpp
+++ b/src/stratagus/stratagus.cpp
@@ -1074,9 +1074,12 @@ global void MenuLoop(char* filename, WorldMap* map)
 	    // Start new music for menus?
 	    // FIXME: If second loop?
 
-	    if( !PlayingMusic && strcmp(TitleMusic,MenuMusic) 
-		&& (!strcmp(CDMode, ":off")) ) {
-		PlayMusic(MenuMusic);
+	    if( !PlayingMusic && strcmp(TitleMusic,MenuMusic) ) {
+		if (!strcmp(CDMode, ":off")) {
+		    PlayMusic(MenuMusic);
+		} else {
+		    CDRomCheck(NULL);
+		}
 	    }
 	    EnableRedraw=RedrawMenu;