Author: shadowmaster
Date: Sun Nov  2 21:00:02 2008
New Revision: 30547

URL: http://svn.gna.org/viewcvs/wesnoth?rev=30547&view=rev
Log:
* Make sound_source WML function use the new sourcespec config-based
  constructor
* Sound sources are dumped to saved game state. (Pre-final step for
  fixing bug #11495).

Modified:
    trunk/src/game_events.cpp

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=30547&r1=30546&r2=30547&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Sun Nov  2 21:00:02 2008
@@ -1625,48 +1625,10 @@
 
        WML_HANDLER_FUNCTION(sound_source,/*handler*/,/*event_info*/,cfg)
        {
-               std::string sounds = cfg["sounds"];
-               std::string id = cfg["id"];
-               std::string delay = cfg["delay"];
-               std::string chance = cfg["chance"];
-               std::string play_fogged = cfg["check_fogged"];
-               std::string x = cfg["x"];
-               std::string y = cfg["y"];
-               std::string loop = cfg["loop"];
-               std::string full_range = cfg["full_range"];
-               std::string fade_range = cfg["fade_range"];
-
-               assert(state_of_game != NULL);
-
-               if(!sounds.empty() && !delay.empty() && !chance.empty()) {
-                       const std::vector<std::string>& vx = utils::split(x);
-                       const std::vector<std::string>& vy = utils::split(y);
-
-                       if(vx.size() != vy.size()) {
-                               lg::wml_error << "invalid number of sound 
source location coordinates";
-                               return;
-                       }
-
-                       soundsource::sourcespec spec(id, sounds, 
lexical_cast_default<int>(delay, 1000), lexical_cast_default<int>(chance, 100));
-
-                       spec.set_loops(lexical_cast_default<int>(loop, 0));
-                       spec.set_check_fogged(utils::string_bool(play_fogged, 
true));
-
-                       if(!full_range.empty()) {
-                               
spec.set_full_range(lexical_cast<int>(full_range));
-                       }
-
-                       if(!fade_range.empty()) {
-                               
spec.set_fade_range(lexical_cast<int>(fade_range));
-                       }
-
-                       for(unsigned int i = 0; i < std::min(vx.size(), 
vy.size()); ++i) {
-                               map_location loc(lexical_cast<int>(vx[i]), 
lexical_cast<int>(vy[i]));
-                               spec.add_location(loc);
-                       }
-
-                       (soundsources)->add(spec);
-               }
+               assert(state_of_game != NULL);
+               assert(soundsources != NULL);
+               soundsource::sourcespec spec(cfg.get_parsed_config());
+               (soundsources)->add(spec);
        }
 
        WML_HANDLER_FUNCTION(remove_sound_source,/*handler*/,/*event_info*/,cfg)
@@ -3554,6 +3516,9 @@
 
                cfg["unit_wml_ids"] = ids.str();
 
+               if(soundsources != NULL)
+                       (soundsources)->write_sourcespecs(cfg);
+
                if(screen != NULL)
                        (screen)->write_overlays(cfg);
        }


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to