mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
SAPI: Track last executed mod and include in error messages
This commit is contained in:
parent
738fbc66d0
commit
2b04ab874d
19 changed files with 231 additions and 45 deletions
|
@ -34,6 +34,7 @@ extern "C" {
|
|||
#include "common/c_internal.h"
|
||||
|
||||
#define SCRIPTAPI_LOCK_DEBUG
|
||||
#define SCRIPTAPI_DEBUG
|
||||
|
||||
#define SCRIPT_MOD_NAME_FIELD "current_mod_name"
|
||||
// MUST be an invalid mod name so that mods can't
|
||||
|
@ -47,6 +48,12 @@ extern "C" {
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define runCallbacks(nargs, mode) \
|
||||
runCallbacksRaw((nargs), (mode), __FUNCTION__)
|
||||
|
||||
#define setOriginFromTable(index) \
|
||||
setOriginFromTableRaw(index, __FUNCTION__)
|
||||
|
||||
class Server;
|
||||
class Environment;
|
||||
class GUIEngine;
|
||||
|
@ -61,12 +68,19 @@ public:
|
|||
std::string *error=NULL);
|
||||
bool loadScript(const std::string &script_path, std::string *error=NULL);
|
||||
|
||||
void runCallbacksRaw(int nargs,
|
||||
RunCallbacksMode mode, const char *fxn);
|
||||
|
||||
/* object */
|
||||
void addObjectReference(ServerActiveObject *cobj);
|
||||
void removeObjectReference(ServerActiveObject *cobj);
|
||||
|
||||
Server* getServer() { return m_server; }
|
||||
|
||||
std::string getOrigin() { return m_last_run_mod; }
|
||||
void setOriginDirect(const char *origin);
|
||||
void setOriginFromTableRaw(int index, const char *fxn);
|
||||
|
||||
protected:
|
||||
friend class LuaABM;
|
||||
friend class InvRef;
|
||||
|
@ -95,6 +109,7 @@ protected:
|
|||
void objectrefGet(lua_State *L, u16 id);
|
||||
|
||||
JMutex m_luastackmutex;
|
||||
std::string m_last_run_mod;
|
||||
// Stack index of Lua error handler
|
||||
int m_errorhandler;
|
||||
bool m_secure;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue