summaryrefslogtreecommitdiff
path: root/src/game-server
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-03-03 22:58:34 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-03-03 23:22:43 +0100
commitf08b62e1a0b9719bb03fd0db89353f69f0680def (patch)
treeacdec3cb220802c36169df43f4c9dabd1b6bdc88 /src/game-server
parent72881e2a713a29fc7eaaa1d7159129e0e4f9867f (diff)
downloadmanaserv-f08b62e1a0b9719bb03fd0db89353f69f0680def.tar.gz
manaserv-f08b62e1a0b9719bb03fd0db89353f69f0680def.tar.bz2
manaserv-f08b62e1a0b9719bb03fd0db89353f69f0680def.tar.xz
manaserv-f08b62e1a0b9719bb03fd0db89353f69f0680def.zip
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
Diffstat (limited to 'src/game-server')
-rw-r--r--src/game-server/trigger.cpp17
-rw-r--r--src/game-server/trigger.h5
2 files changed, 15 insertions, 7 deletions
diff --git a/src/game-server/trigger.cpp b/src/game-server/trigger.cpp
index c4cec2f4..dd1392e1 100644
--- a/src/game-server/trigger.cpp
+++ b/src/game-server/trigger.cpp
@@ -27,6 +27,8 @@
#include "utils/logger.h"
+#include <cassert>
+
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();
diff --git a/src/game-server/trigger.h b/src/game-server/trigger.h
index f6f0e170..2a3aa611 100644
--- a/src/game-server/trigger.h
+++ b/src/game-server/trigger.h
@@ -50,14 +50,13 @@ class WarpAction : public TriggerAction
class ScriptAction : public TriggerAction
{
public:
- ScriptAction(Script *script, const std::string &function, int arg)
- : mScript(script), mFunction(function), mArg(arg) {}
+ ScriptAction(Script *script, Script::Ref callback, int arg);
virtual void process(Actor *obj);
private:
Script *mScript; // Script object to be called
- std::string mFunction; // Name of the function called in the script object
+ Script::Ref mCallback; // Reference to the function to call
int mArg; // Argument passed to script function (meaning is function-specific)
};