From fbaacaf971360b9b5dd45397c0e5f3331cf51869 Mon Sep 17 00:00:00 2001
From: nehalmistry <>
Date: Sat, 15 Feb 2003 00:43:47 +0000
Subject: [PATCH] converted CDPlaySection to PlaySection enum

---
 src/game/intro.cpp          |  2 +-
 src/include/sound_server.h  |  7 ++++++-
 src/sound/music.cpp         | 12 ++++++------
 src/stratagus/mainloop.cpp  |  5 ++---
 src/stratagus/stratagus.cpp |  2 ++
 5 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/game/intro.cpp b/src/game/intro.cpp
index e6451b41d..9c6b8bf4d 100644
--- a/src/game/intro.cpp
+++ b/src/game/intro.cpp
@@ -434,7 +434,7 @@ global void ShowIntro(const Intro *intro)
 
     CallbackMusicOff();
     StopMusic();
-    CDPlaySection = "briefing";
+    PlaySection = PlaySectionBriefing;
     CDRomCheck(NULL);
     if( intro->VoiceFile[0] ) {
 	PlayFile(intro->VoiceFile[0]);
diff --git a/src/include/sound_server.h b/src/include/sound_server.h
index 85e0c47c3..817bfdf11 100644
--- a/src/include/sound_server.h
+++ b/src/include/sound_server.h
@@ -237,7 +237,12 @@ extern unsigned CompressedSoundMemory;
     /// cd play mode, ":off" ":random" ":all" or ":defined"
 extern char *CDMode;
     /// FIXME: docu
-extern char *CDPlaySection;
+enum _play_section_ {
+    PlaySectionMainMenu,
+    PlaySectionGame,
+    PlaySectionStats,
+    PlaySectionBriefing,
+} PlaySection;
 #if defined(USE_SDLCD) || defined(USE_LIBCDA) || defined(USE_CDDA)
     /// FIXME: docu
 extern int CDTrack;
diff --git a/src/sound/music.cpp b/src/sound/music.cpp
index b7473781a..641a47343 100644
--- a/src/sound/music.cpp
+++ b/src/sound/music.cpp
@@ -67,7 +67,7 @@ global Sample* MusicSample;		/// Music samples
 #endif
 
 global char *CDMode = ":off";	/// cd play mode, ":off" ":random" ":all" or ":defined"
-global char *CDPlaySection = "menu";
+//global char *CDPlaySection = "menu";
 #if defined(USE_SDLCD) || defined(USE_LIBCDA) || defined(USE_CDDA)
 global int CDTrack = 0;			/// Current cd track
 #endif
@@ -361,7 +361,7 @@ global int PlayCDRom(const char* name)
 	if (!strcmp(name, ":defined")) {
 	    CDMode = ":defined";
 	    track = cd_current_track();
-	    if (!strcmp(CDPlaySection, "showstats")) {
+	    if (PlaySection == PlaySectionStats) {
 		if (GameResult == GameVictory) {
 		    if (!ThisPlayer->Race && track != 8) {
 			cd_play(8);
@@ -375,20 +375,20 @@ global int PlayCDRom(const char* name)
 			cd_play(17);
 		    }
 		}
-	    } else if (!strcmp(CDPlaySection, "briefing")) {
+	    } else if (PlaySection == PlaySectionBriefing) {
 		if (!ThisPlayer->Race && track != 7) {
 		    cd_play(7);
 		} else if (ThisPlayer->Race && track != 15) {
 		    cd_play(15);
 		}
-	    } else if (!strcmp(CDPlaySection, "menu") && track != 15) {
+	    } else if ((PlaySection == PlaySectionMainMenu) && track != 15) {
 		cd_play(15);
-	    } else if (!strcmp(CDPlaySection, "game") && 
+	    } else if ((PlaySection == PlaySectionGame) && 
 		       !ThisPlayer->Race && (track < 3 || track > 6)) {
 		do CDTrack = (MyRand() % NumCDTracks) + 3;
 		while (CDTrack < 3 || CDTrack > 7); 
 		cd_play(CDTrack);
-	    } else if (!strcmp(CDPlaySection, "game") && 
+	    } else if ((PlaySection == PlaySectionGame) && 
 		       ThisPlayer->Race && (track < 10 || track > 14)) {
 		do CDTrack = (MyRand() % NumCDTracks) + 9;
 		while (CDTrack < 11 || CDTrack > 14); 
diff --git a/src/stratagus/mainloop.cpp b/src/stratagus/mainloop.cpp
index 2c1417fba..1a1bbaf21 100644
--- a/src/stratagus/mainloop.cpp
+++ b/src/stratagus/mainloop.cpp
@@ -639,7 +639,7 @@ global void GameMainLoop(void)
 
     MultiPlayerReplayEachCycle();
 
-    CDPlaySection = "game";
+    PlaySection = PlaySectionGame;
     CDRomCheck(NULL);
 
     while( GameRunning ) {
@@ -813,7 +813,7 @@ global void GameMainLoop(void)
     }
 
     if( GameResult==GameVictory || GameResult==GameDefeat ) {
-	CDPlaySection = "showstats";
+	PlaySection = PlaySectionStats;
 	CDRomCheck(NULL);
 	ShowStats();
     }
@@ -822,7 +822,6 @@ global void GameMainLoop(void)
     ReplayRevealMap=0;
     GamePaused=0;
     GodMode=0;
-    CDPlaySection = "menu";
 }
 
 //@}
diff --git a/src/stratagus/stratagus.cpp b/src/stratagus/stratagus.cpp
index 628013097..bbbf5e00c 100644
--- a/src/stratagus/stratagus.cpp
+++ b/src/stratagus/stratagus.cpp
@@ -1122,6 +1122,8 @@ global void MenuLoop(char* filename, WorldMap* map)
 	CleanModules();
 	CleanFonts();
 
+	PlaySection = PlaySectionMainMenu;
+
 	LoadCcl();			// Reload the main config file
 
 	PreMenuSetup();