From f08b62e1a0b9719bb03fd0db89353f69f0680def Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Sat, 3 Mar 2012 22:58:34 +0100 Subject: Removed the last direct call to global script function The ScriptAction of the TriggerArea (which can be created by mana.trigger_create) was still using a named global function for its callback. Now it also uses a reference to a script function. Since it was the last occurrence of a call to a global script function, I've also removed the Script::prepare(std::string) overload. Reviewed-by: Erik Schilling Mantis-issue: 299 --- src/game-server/trigger.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/game-server/trigger.cpp') diff --git a/src/game-server/trigger.cpp b/src/game-server/trigger.cpp index c4cec2f..dd1392e 100644 --- a/src/game-server/trigger.cpp +++ b/src/game-server/trigger.cpp @@ -27,6 +27,8 @@ #include "utils/logger.h" +#include + void WarpAction::process(Actor *obj) { if (obj->getType() == OBJECT_CHARACTER) @@ -35,13 +37,20 @@ void WarpAction::process(Actor *obj) } } +ScriptAction::ScriptAction(Script *script, Script::Ref callback, int arg) : + mScript(script), + mCallback(callback), + mArg(arg) +{ + assert(mCallback.isValid()); +} + void ScriptAction::process(Actor *obj) { - LOG_DEBUG("Script trigger area activated: " << mFunction + LOG_DEBUG("Script trigger area activated: " << "(" << obj << ", " << mArg << ")"); - if (!mScript || mFunction.empty()) - return; - mScript->prepare(mFunction); + + mScript->prepare(mCallback); mScript->push(obj); mScript->push(mArg); mScript->execute(); -- cgit