mirror of
https://github.com/xtjoeytx/GServer-v2.git
synced 2026-05-08 00:30:28 -04:00
893aebaaaa
- Changed sendtorc/sendtonc functions to print all arguments to the function
- Modified call signature of onActionServerSide - onActionServerSide(player: Player, params: String[]) {}
- Fixed GS2 triggeractions to serverside
- Slightly improved some runtime execution errors in NC-tab
- Exposed some common functionality into the global object, so you can call them directly without referencing the server object:
- functions: findlevel, findnpc, findplayer, savelog, sendtorc, sendtonc
- global variables: allplayers, timevar, timevar2
97 lines
1.5 KiB
C++
97 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#ifndef SCRIPTACTION_H
|
|
#define SCRIPTACTION_H
|
|
|
|
#include <cassert>
|
|
#include <string>
|
|
#include "ScriptArguments.h"
|
|
|
|
class IScriptFunction;
|
|
|
|
class ScriptAction
|
|
{
|
|
public:
|
|
ScriptAction() :
|
|
_function(nullptr), _args(nullptr)
|
|
{
|
|
|
|
}
|
|
|
|
explicit ScriptAction(IScriptFunction *function, IScriptArguments *args, const std::string& action = "")
|
|
: _function(function), _args(args), _action(action)
|
|
{
|
|
_function->increaseReference();
|
|
}
|
|
|
|
ScriptAction(const ScriptAction& o) = delete;
|
|
ScriptAction& operator=(const ScriptAction& o) = delete;
|
|
|
|
ScriptAction(ScriptAction&& o) noexcept
|
|
{
|
|
_action = std::move(o._action);
|
|
_args = o._args;
|
|
_function = o._function;
|
|
|
|
o._args = nullptr;
|
|
o._function = nullptr;
|
|
}
|
|
|
|
ScriptAction& operator=(ScriptAction&& o) noexcept
|
|
{
|
|
_action = std::move(o._action);
|
|
_args = o._args;
|
|
_function = o._function;
|
|
|
|
o._args = nullptr;
|
|
o._function = nullptr;
|
|
return *this;
|
|
}
|
|
|
|
~ScriptAction()
|
|
{
|
|
if (_args)
|
|
{
|
|
delete _args;
|
|
}
|
|
|
|
if (_function)
|
|
{
|
|
_function->decreaseReference();
|
|
if (!_function->isReferenced())
|
|
{
|
|
delete _function;
|
|
}
|
|
}
|
|
}
|
|
|
|
bool Invoke() const
|
|
{
|
|
assert(_args);
|
|
|
|
return _args->Invoke(_function, true);
|
|
}
|
|
|
|
const std::string& getAction() const
|
|
{
|
|
return _action;
|
|
}
|
|
|
|
IScriptArguments * getArguments() const
|
|
{
|
|
return _args;
|
|
}
|
|
|
|
IScriptFunction * getFunction() const
|
|
{
|
|
return _function;
|
|
}
|
|
|
|
protected:
|
|
std::string _action;
|
|
IScriptArguments *_args;
|
|
IScriptFunction *_function;
|
|
};
|
|
|
|
#endif
|