From 1e2a6ff5e4fc81e2010f3ba47b333a6e74bc4cd2 Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Sat, 13 Dec 2014 04:21:51 -0500 Subject: [PATCH] move rarely used fcn from game_events to a support namespace --- src/game_events/action_wml.cpp | 5 +++++ src/game_events/handlers.cpp | 4 +++- src/game_events/pump.cpp | 6 ------ src/game_events/pump.hpp | 5 ----- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/game_events/action_wml.cpp b/src/game_events/action_wml.cpp index 33d127aaac00..40d3b341b6b0 100644 --- a/src/game_events/action_wml.cpp +++ b/src/game_events/action_wml.cpp @@ -53,6 +53,7 @@ #include "replay.hpp" #include "random_new.hpp" #include "resources.hpp" +#include "scripting/game_lua_kernel.hpp" #include "side_filter.hpp" #include "sound.hpp" #include "soundsource.hpp" @@ -502,6 +503,10 @@ namespace { // Support functions resources::screen->invalidate_all(); } + void handle_event_commands(const queued_event& event_info, const vconfig &cfg) { + assert(resources::lua_kernel); + resources::lua_kernel->run_wml_action("command", cfg, event_info); + } } // end anonymous namespace (support functions) void handle_deprecated_message(const config& cfg) diff --git a/src/game_events/handlers.cpp b/src/game_events/handlers.cpp index ee0943a1cfa0..4db93317c2b6 100644 --- a/src/game_events/handlers.cpp +++ b/src/game_events/handlers.cpp @@ -469,8 +469,10 @@ void event_handler::handle_event(const queued_event& event_info, handler_ptr& ha handler_p.reset(); } // *WARNING*: At this point, dereferencing this could be a memory violation! + // ^ this comment does not refer to resources::lua_kernel below, but to the vconfig - handle_event_commands(event_info, vcfg); + assert(resources::lua_kernel); + resources::lua_kernel->run_wml_action("command", vcfg, event_info); } bool event_handler::matches_name(const std::string &name) const diff --git a/src/game_events/pump.cpp b/src/game_events/pump.cpp index f9a5d5592170..f8d282508387 100644 --- a/src/game_events/pump.cpp +++ b/src/game_events/pump.cpp @@ -425,12 +425,6 @@ void put_wml_message(const std::string& logger, const std::string& message, bool } } -void handle_event_commands(const queued_event& event_info, const vconfig &cfg) -{ - assert(resources::lua_kernel); - resources::lua_kernel->run_wml_action("command", cfg, event_info); -} - bool fire(const std::string& event, const entity_location& loc1, const entity_location& loc2, diff --git a/src/game_events/pump.hpp b/src/game_events/pump.hpp index 04831fbb00f6..c9a3cb129c29 100644 --- a/src/game_events/pump.hpp +++ b/src/game_events/pump.hpp @@ -99,11 +99,6 @@ namespace game_events /// really be pushed into the wml_messages_stream, and does it. void put_wml_message(const std::string& logger, const std::string& message, bool in_chat); - /** - * Runs the action handler associated to the command sequence @a cfg. - */ - void handle_event_commands(const queued_event &event_info, const vconfig &cfg); - /** * Function to fire an event. *