Vultraz

Untitled

May 20th, 2015
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.80 KB | None | 0 0
  1.  src/game_events/handlers.hpp | 1 +
  2.  1 file changed, 1 insertion(+)
  3.  
  4. diff --git a/src/game_events/handlers.hpp b/src/game_events/handlers.hpp
  5. index db0986a..8592559 100644
  6. --- a/src/game_events/handlers.hpp
  7. +++ b/src/game_events/handlers.hpp
  8. @@ -70,6 +70,7 @@ namespace game_events
  9.  
  10.         private:
  11.             bool first_time_only_;
  12. +           bool remove_on_fire_;
  13.             bool is_menu_item_;
  14.             handler_vec::size_type index_;
  15.             manager * man_;
  16.  
  17.  
  18.  src/game_events/handlers.cpp | 8 ++++++--
  19.  1 file changed, 6 insertions(+), 2 deletions(-)
  20.  
  21. diff --git a/src/game_events/handlers.cpp b/src/game_events/handlers.cpp
  22. index 960828a..83b6416 100644
  23. --- a/src/game_events/handlers.cpp
  24. +++ b/src/game_events/handlers.cpp
  25. @@ -78,6 +78,7 @@ handler_ptr handler_list::iterator::operator*()
  26.  
  27.  event_handler::event_handler(const config &cfg, bool imi, handler_vec::size_type index, manager & man)
  28.     : first_time_only_(cfg["first_time_only"].to_bool(true))
  29. +   , remove_on_fire_(cfg["remove_on_fire"].to_bool(false))
  30.     , is_menu_item_(imi)
  31.     , index_(index)
  32.     , man_(&man)
  33. @@ -120,8 +121,7 @@ void event_handler::handle_event(const queued_event& event_info, handler_ptr& ha
  34.         DBG_NG << cfg_["name"] << " will now invoke the following command(s):\n" << cfg_;
  35.     }
  36.  
  37. -   if (first_time_only_)
  38. -   {
  39. +   if (first_time_only_) {
  40.         // Disable this handler.
  41.         disable();
  42.         // Also remove our caller's hold on us.
  43. @@ -130,6 +130,10 @@ void event_handler::handle_event(const queued_event& event_info, handler_ptr& ha
  44.     // *WARNING*: At this point, dereferencing this could be a memory violation!
  45.  
  46.     lk.run_wml_action("command", vcfg, event_info);
  47. +
  48. +   if (remove_on_fire_) {
  49. +       (*man_->event_handlers_).remove_event_handler(cfg_["id"]);
  50. +   }  
  51.  }
  52.  
  53.  bool event_handler::matches_name(const std::string &name, const game_data * gd) const
Advertisement
Add Comment
Please, Sign In to add comment