Author: anonymissimus
Date: Mon Oct 17 19:21:04 2011
New Revision: 51518

URL: http://svn.gna.org/viewcvs/wesnoth?rev=51518&view=rev
Log:
rewrite game_events::add_events

to optionally filter by event id whether to add an event

Modified:
    trunk/src/game_events.cpp
    trunk/src/game_events.hpp

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=51518&r1=51517&r2=51518&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Mon Oct 17 19:21:04 2011
@@ -3310,13 +3310,19 @@
                return pump();
        }
 
-       void add_events(const config::const_child_itors &cfgs, const 
std::string &id)
-       {
-               if(std::find(unit_wml_ids.begin(),unit_wml_ids.end(),id) == 
unit_wml_ids.end()) {
-                       unit_wml_ids.insert(id);
-                       foreach (const config &new_ev, cfgs) {
-                               
event_handlers.add_event_handler(game_events::event_handler(new_ev));
-                       }
+       void add_events(const config::const_child_itors &cfgs, const 
std::string& type)
+       {
+               if(!type.empty()) {
+                       
if(std::find(unit_wml_ids.begin(),unit_wml_ids.end(),type) != 
unit_wml_ids.end()) return;
+                       unit_wml_ids.insert(type);
+               }
+               foreach (const config &new_ev, cfgs) {
+                       if(type.empty() && new_ev["id"].empty())
+                       {
+                               WRN_NG << "attempt to add an [event] with empty 
id=, ignoring \n";
+                               continue;
+                       }
+                       
event_handlers.add_event_handler(game_events::event_handler(new_ev));
                }
        }
 

Modified: trunk/src/game_events.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.hpp?rev=51518&r1=51517&r2=51518&view=diff
==============================================================================
--- trunk/src/game_events.hpp (original)
+++ trunk/src/game_events.hpp Mon Oct 17 19:21:04 2011
@@ -114,7 +114,9 @@
                const queued_event &event_info, const vconfig &cfg);
 
        void write_events(config& cfg);
-       void add_events(const config::const_child_itors &cfgs,const 
std::string& id);
+       void add_events(
+               const config::const_child_itors &cfgs,
+               const std::string& type = std::string());
 
        bool unit_matches_filter(const unit &, const vconfig& filter);
 


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

Reply via email to