Do a dumb-ass static string copy for const-incorrect old versions of ov_fopen
authorPerttu Ahola <celeron55@gmail.com>
Mon, 26 Mar 2012 21:06:26 +0000 (00:06 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Mon, 26 Mar 2012 21:06:26 +0000 (00:06 +0300)
src/sound_openal.cpp

index e635e0fa17e840088e0aa3afa9e86b33b86dc241..8d76b69e16621105b6fdb0cbb8048fa1e8721589 100644 (file)
@@ -116,9 +116,14 @@ SoundBuffer* loadOggFile(const std::string &filepath)
        char array[BUFFER_SIZE]; // Local fixed size array
        vorbis_info *pInfo;
        OggVorbis_File oggFile;
-
+       
+       // Do a dumb-ass static string copy for old versions of ov_fopen
+       // because they expect a non-const char*
+       char nonconst[10000];
+       snprintf(nonconst, 10000, "%s", filepath.c_str());
        // Try opening the given file
-       if(ov_fopen(filepath.c_str(), &oggFile) != 0)
+       //if(ov_fopen(filepath.c_str(), &oggFile) != 0)
+       if(ov_fopen(nonconst, &oggFile) != 0)
        {
                infostream<<"Audio: Error opening "<<filepath<<" for decoding"<<std::endl;
                return NULL;