wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src sound.cpp


From: Yann Dirson
Subject: [Wesnoth-cvs-commits] wesnoth/src sound.cpp
Date: Fri, 07 Jan 2005 19:40:45 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Yann Dirson <address@hidden>    05/01/08 00:28:41

Modified files:
        src            : sound.cpp 

Log message:
        allow reading sound effects (not music, because of curent SDL_mixer 
limitation) from zip files

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/sound.cpp.diff?tr1=1.25&tr2=1.26&r1=text&r2=text

Patches:
Index: wesnoth/src/sound.cpp
diff -u wesnoth/src/sound.cpp:1.25 wesnoth/src/sound.cpp:1.26
--- wesnoth/src/sound.cpp:1.25  Thu Nov 18 22:00:12 2004
+++ wesnoth/src/sound.cpp       Sat Jan  8 00:28:41 2005
@@ -1,4 +1,4 @@
-/* $Id: sound.cpp,v 1.25 2004/11/18 22:00:12 ydirson Exp $ */
+/* $Id: sound.cpp,v 1.26 2005/01/08 00:28:41 ydirson Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -133,7 +133,20 @@
 
        std::map<std::string,Mix_Chunk*>::const_iterator itor = 
sound_cache.find(file);
        if(itor == sound_cache.end()) {
+#ifdef USE_ZIPIOS
+               std::string s = read_file("sounds/" + file);
+               if (s.empty()) {
+                       return;
+               }
 
+               SDL_RWops* ops = SDL_RWFromMem((void*)s.c_str(), s.size());
+               Mix_Chunk* const sfx = Mix_LoadWAV_RW(ops,0);
+               if(sfx == NULL) {
+                       std::cerr << "Could not load sound file '" << file << 
"': "
+                                 << SDL_GetError() << "\n";
+                       return;
+               }
+#else
                const std::string& filename = 
get_binary_file_location("sounds",file);
 
                if(filename.empty()) {
@@ -146,6 +159,7 @@
                                  << SDL_GetError() << "\n";
                        return;
                }
+#endif
 
                itor = 
sound_cache.insert(std::pair<std::string,Mix_Chunk*>(file,sfx)).first;
        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]