39#include "angelscript.h"
48 AngelScript::asIScriptObject *
obj{
nullptr};
49 AngelScript::asIScriptFunction *
func{
nullptr};
82 void gameCmd(
int uid,
const std::string &cmd);
114 void addCallback(
const std::string &type, AngelScript::asIScriptFunction *func, AngelScript::asIScriptObject *obj);
122 void addCallbackScript(
const std::string &type,
const std::string &func, AngelScript::asIScriptObject *obj);
130 void deleteCallback(
const std::string &type, AngelScript::asIScriptFunction *func, AngelScript::asIScriptObject *obj);
138 void deleteCallbackScript(
const std::string &type,
const std::string &_func, AngelScript::asIScriptObject *obj);
152 bool callbackExists(
const std::string &type, AngelScript::asIScriptFunction *func, AngelScript::asIScriptObject *obj);
181 void msgCallback(
const AngelScript::asSMessageInfo *msg);
196 void PrintVariables(AngelScript::asIScriptContext *ctx,
int stackLevel);
201 void LineCallback(AngelScript::asIScriptContext *ctx,
void *param);
bool callbackExists(const std::string &type, AngelScript::asIScriptFunction *func, AngelScript::asIScriptObject *obj)
This checks if a script callback exists.
void init()
This function initialzies the engine and registeres all types.
void TimerThreadMain()
A loop that periodically the frameStep() script callback.
void deleteAllCallbacks()
Deletes all script callbacks.
AngelScript::asIScriptEngine * engine
instance of the scripting engine
void addCallback(const std::string &type, AngelScript::asIScriptFunction *func, AngelScript::asIScriptObject *obj)
Adds a script callback.
void playerDeleted(int uid, int crash=0)
void playerAdded(RoRnet::UserInfo &user)
void deleteCallback(const std::string &type, AngelScript::asIScriptFunction *func, AngelScript::asIScriptObject *obj)
Deletes a script callback.
ThreadState m_timer_thread_state
AngelScript::asIScriptContext * context
context in which all scripting happens
void curlStatus(ServerScriptCurlStatusType type, int n1, int n2, std::string displayname, std::string message)
Params n1, n2 and message depend on status type :
std::map< std::string, callbackList > callbacks
A map containing the script callbacks by type.
void setException(const std::string &message)
Sets an exception that aborts the currently running script and shows the exception in the log file.
void LineCallback(AngelScript::asIScriptContext *ctx, void *param)
unused
void addCallbackScript(const std::string &type, const std::string &func, AngelScript::asIScriptObject *obj)
This method checks and converts the parameters and then adds a script callback.
void gameCmd(int uid, const std::string &cmd)
ServerScriptSequencer * seq
int streamAdded(int uid, RoRnet::StreamRegister *reg)
AngelScript::asIScriptEngine * getEngine()
Gets the currently used AngelScript script engine.
int loadScript(std::string scriptName)
std::thread m_timer_thread
void ExceptionCallback(AngelScript::asIScriptContext *ctx, void *param)
This callback gets called when an exception occurs in the script.
std::mutex m_timer_thread_mutex
void PrintVariables(AngelScript::asIScriptContext *ctx, int stackLevel)
This logs all variables and their values at the specified stack level.
int playerChat(int uid, std::string msg)
ThreadState GetTimerThreadState()
void msgCallback(const AngelScript::asSMessageInfo *msg)
This is the callback function that gets called when script error occur.
void deleteCallbackScript(const std::string &type, const std::string &_func, AngelScript::asIScriptObject *obj)
This method checks and converts the parameters and then deletes a script callback.
void EnsureTimerThreadRunning()
std::vector< rorserver_callback_t > callbackList
ServerScriptCurlStatusType
This struct holds the information for a script callback.
AngelScript::asIScriptObject * obj
The object instance that will need to be used with the function.
AngelScript::asIScriptFunction * func
The function or method pointer that will be called.
< Sent from the client to server and vice versa, to broadcast a new stream