Author: segfault
Date: Sun Jul 20 22:45:53 2008
New Revision: 28111

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28111&view=rev
Log:
Fix bug #11988. Add an identifier to event_handler object using the 
config.hash() function. Test unicity during handler writting.

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=28111&r1=28110&r2=28111&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Sun Jul 20 22:45:53 2008
@@ -3457,9 +3457,14 @@
                void write_events(config& cfg)
                {
                        assert(manager_running);
+                       std::set<std::string> id_handlers;
+                       std::string id;
                        
for(std::multimap<std::string,game_events::event_handler>::const_iterator i = 
events_map.begin(); i != events_map.end(); ++i) {
-                               if(!i->second.disabled() && 
!i->second.is_menu_item()) {
+                               id = i->second.get_id();
+                               if(!i->second.disabled() && 
!i->second.is_menu_item() && 
+                                  id_handlers.find(id)==id_handlers.end()) {
                                        i->second.write(cfg.add_child("event"));
+                                       id_handlers.insert(i->second.get_id());
                                }
                        }
 

Modified: trunk/src/game_events.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.hpp?rev=28111&r1=28110&r2=28111&view=diff
==============================================================================
--- trunk/src/game_events.hpp (original)
+++ trunk/src/game_events.hpp Sun Jul 20 22:45:53 2008
@@ -96,8 +96,11 @@
                                
first_time_only_(utils::string_bool(cfg["first_time_only"],true)),
                                disabled_(false),mutated_(true),
                                skip_messages_(false),rebuild_screen_(false),
-                               cfg_(cfg)
-               {}
+                               cfg_(cfg),
+                               id_(cfg.get_config().hash())
+                       {}
+         
+                       const std::string get_id() const {return id_;}
 
                        void write(config& cfg) const
                        {
@@ -163,6 +166,7 @@
                        bool skip_messages_;
                        bool rebuild_screen_;
                        vconfig cfg_;
+                       std::string id_;
        };
 
        typedef void (*wml_handler_function)(event_handler& eh,


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

Reply via email to