changeset 2509:fc5e83bbafd1

FileExists
author Ritor1
date Thu, 02 Oct 2014 12:23:52 +0600
parents 491f0babd563
children ae2b7048b3eb
files Engine/MMT.cpp Engine/MMT.h Media/Audio/AudioPlayer.cpp
diffstat 3 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Engine/MMT.cpp	Thu Oct 02 11:52:31 2014 +0600
+++ b/Engine/MMT.cpp	Thu Oct 02 12:23:52 2014 +0600
@@ -1,7 +1,7 @@
 #define _CRTDBG_MAP_ALLOC
 #include <stdlib.h>
 #include <crtdbg.h>
-
+#include <io.h>
 #define _CRT_SECURE_NO_WARNINGS
 
 #include "MMT.h"
@@ -19,6 +19,10 @@
 #include "Game.h"
 #include "Log.h"
 
+bool FileExists(const char *fname)
+{
+    return access(fname, 0) != -1;
+}
 
 void  ShowLogoVideo()
 {
@@ -86,6 +90,11 @@
     {
 	  if ( use_music_folder )
 	  {
+        if (!FileExists("Music\\14.mp3"))
+		{
+          Log::Warning(L"File 14.mp3 in Music\\ folder not found");
+		  return;
+		}
 	    PlayAudio(L"Music\\14.mp3");
 	    alSourcef (mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]);
 	  }
--- a/Engine/MMT.h	Thu Oct 02 11:52:31 2014 +0600
+++ b/Engine/MMT.h	Thu Oct 02 12:23:52 2014 +0600
@@ -4,6 +4,7 @@
 void MMT_MainMenu_Loop();
 void MMT_MenuMessageProc();
 void DrawMMTCopyrightWindow();
+extern bool FileExists(const char *fname);
 
 extern bool use_MMT;
 extern bool use_music_folder;
--- a/Media/Audio/AudioPlayer.cpp	Thu Oct 02 11:52:31 2014 +0600
+++ b/Media/Audio/AudioPlayer.cpp	Thu Oct 02 12:23:52 2014 +0600
@@ -447,6 +447,11 @@
 	{
       alSourceStop(mSourceID);
 	  sprintf(string, "Music\\%d.mp3", eTrack);
+      if (!FileExists(string))
+	  {
+        Log::Warning(L"File 14.mp3 in Music\\ folder not found");
+		return;
+	  }
 	  char2wchar_t(string,wStr);
 	  PlayAudio(wStr);
 	  alSourcef (mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]);