ofs | hex dump | ascii |
---|
0000 | 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 01 58 00 00 00 c1 08 06 00 00 00 8a 72 a8 | .PNG........IHDR...X..........r. |
0020 | 7f 00 00 00 04 73 42 49 54 08 08 08 08 7c 08 64 88 00 00 20 00 49 44 41 54 78 9c ed bd 6b 8c 5d | .....sBIT....|.d.....IDATx...k.] |
0040 | d7 95 a0 f7 9d 7d 1e f7 5e 56 b1 58 2a b2 48 ca 94 4c 8a 6c 59 a2 44 8a 2d 83 6d 5b 69 25 6a cb | .....}..^V.X*.H..L.lY.D.-.m[i%j. |
0060 | ed 44 86 d1 03 78 60 c8 8d 41 7e 4d 26 03 64 80 69 23 80 e0 34 1c 38 fa a1 81 a1 08 16 6c 37 0c | .D...x`..A~M&.d.i#..4.8......l7. |
0080 | c4 86 7f 38 01 f2 a3 6d 18 30 26 80 21 fd 90 14 f8 29 51 12 c5 91 4c 37 29 d2 a1 48 4a 2c 8a 64 | ...8...m.0&.!....)Q...L7)..HJ,.d |
00a0 | 91 aa e7 7d 9d 73 f6 ce 8f bd cf eb d6 a1 5c 55 ac 07 c9 5a 9f 20 f0 dc 7b cf 73 d5 5e fb ac bd | ...}.s........\U...Z....{.s.^... |
00c0 | f6 da 6b 79 87 0f 1f 36 08 82 20 08 2b 8e 5a ef 1b 10 04 41 b8 5d 91 0e 56 10 04 61 95 90 0e 56 | ..ky...6....+.Z....A.]..V..a...V |
00e0 | 10 04 61 95 90 0e 56 10 04 61 95 08 ea be 3c fb de 07 6b 7d 1f eb c2 9e 7b ee 5a d2 fe 22 97 7a | ..a...V..a....<...k}....{.Z..".z |
0100 | 44 2e 82 50 4f 6d 07 0b 30 34 dc 58 cb fb 58 73 e6 e7 7a cb 3a 4e e4 52 8f c8 45 10 16 22 2e 02 | D..POm..04.X..Xs..z.:N.R..E..".. |
0120 | 41 10 84 55 e2 ba 16 ec 5a f1 fc f3 cf 13 c7 31 00 93 93 93 7c e7 3b df 59 e7 3b ba 39 10 b9 d4 | A..U....Z......1....|.;.Y.;.9... |
0140 | 23 72 11 6e 25 d6 ad 83 fd c6 37 be 91 6f 1f 3a f4 10 00 2f bf fc 0a 4f 3d f5 14 c0 86 55 1c 91 | #r.n%.....7..o.:.../...O=....U.. |
0160 | 4b 3d 22 17 e1 56 c4 ab 5b c9 75 f6 bd 0f 56 cd a7 f6 fd 7f fa 7e be bd 6f df 5f d4 ee f3 db df | K="..V..[.u...V......~..o._..... |
0180 | fc 26 df 7e f6 d9 67 57 e5 3e e6 e7 7a cb 9a cc 11 b9 2c 44 e4 22 08 f5 ac 59 07 fb ec b3 cf 72 | .&.~..gW.>..z.....,D."...Y.....r |
01a0 | ed da 35 00 3e ff f9 bf 21 49 34 00 41 a0 f2 6d 4f 79 18 6d 6f 27 40 f3 f2 af 7e 0d c0 dd 9f bc | ..5.>...!I4.A..mOy.mo'@...~..... |
01c0 | 9b af ff c3 d7 57 f4 7e 6e 96 8e 44 e4 52 cf ed 20 17 41 58 f5 0e f6 9b df fc 26 00 23 23 23 1c | .....W.~n..D.R....AX......&.###. |
01e0 | 38 78 10 00 5f 79 15 85 e9 f5 ec 0c 6d 10 46 f8 ca b3 07 26 09 04 d6 83 71 ea f4 69 66 a6 67 00 | 8x.._y......m.F....&....q..if.g. |
0200 | f8 d6 b7 be b5 22 f7 b5 de 1d 89 c8 a5 9e db 49 2e 82 b0 6a 1d ec f7 be f7 bd 7c fb 7a 43 3b 2f | .....".........I...j......|.zC;/ |
0220 | 53 0e 28 14 65 80 4c b1 00 7e f7 bb df e6 db 37 3a 14 5c af 8e 44 e4 52 cf ed 28 17 41 58 f1 0e | S.(.e.L..~.....7:.\..D.R..(.AX.. |
0240 | f6 99 67 9e c9 b7 0f 1e 3c 88 e7 59 45 30 c6 a0 94 8d 0a d3 5a d3 ed 5a 2b 24 8c 42 a2 30 fa d8 | ..g.....<..YE0......Z..Z+$.B.0.. |
0260 | 73 a6 69 42 af 5f c4 21 9e 7a f7 14 00 b3 b3 b3 3c f7 dc 73 cb ba cf b5 ee 48 44 2e f5 dc ce 72 | s.iB._.!.z......<..s.....HD....r |
0280 | 11 84 15 eb 60 9f 7e fa 69 00 82 20 e0 53 f7 7d 0a 80 46 d4 b8 ae c2 a4 b1 bb ac 6f 08 7c 1f 00 | ....`.~.i....S.}..F........o.|.. |
02a0 | a5 fc ca 39 83 c0 ee df eb f5 2b 0a 13 78 56 c1 8e bc f1 6a 7e ce a5 5a 28 6b d5 91 88 5c ea d9 | ...9......+..xV....j~..Z(k...\.. |
02c0 | 08 72 11 84 1b ee 60 9f 7f fe f9 7c 7b df be 7d f9 f6 ec ec 6c be bd 79 f3 e6 7c 3b 49 93 7c 3b | .r....`....|{..}....l..y..|;I.|; |
02e0 | f0 8b 28 31 df af 8f 18 33 a6 18 f2 f5 e3 7e be 5d b6 62 5e 7b ed b5 7c fb db df fe f6 a2 ee 7b | ..(1....3.....~.].b^{..|.......{ |
0300 | b5 3b 12 91 4b 3d 1b 49 2e 82 b0 ec 0e f6 47 3f fa 11 1f 7d f4 11 00 0f 3c f0 00 5a bb 99 5d cf | .;..K=.I......G?...}....<..Z..]. |
0320 | a3 df b7 0d 3b 8a a2 8a 95 91 35 fe 38 49 f2 ed 30 08 73 ab c5 1e af f2 7d cb db c6 2c cc 0b ae | ....;.....5.8I..0.s.....}...,... |
0340 | 94 5f 51 a8 a3 47 8f da f3 c7 f1 9f 55 9c d5 ea 48 44 2e f5 6c 44 b9 08 c2 92 3b d8 6c 96 77 f7 | ._Q..G......U...HD..lD....;.l.w. |
0360 | ee dd ec dc b9 d3 9e c4 f3 88 7b 29 00 41 a4 f2 c6 ed 79 5e ae 0c 9e a7 d0 da ee 93 a4 29 3a b5 | ..........{).A....y^.........):. |
0380 | db 51 54 58 16 9e e7 55 8e 2d 53 56 c8 6e af 0b c0 a6 d6 50 fe 7b 59 a9 8e 1c 39 c2 8e 9d 3b 00 | .QTX...U.-SV.n.....P.{Y...9...;. |
03a0 | ae 1b ae b3 d2 1d 89 c8 45 e4 22 08 83 2c ba 83 2d fb ac 1e 7c f0 40 be dd eb 77 f3 ed a1 52 e3 | ........E."..,..-...|.@...w...R. |
03c0 | cf 1a 35 40 d0 d8 94 6f b7 3b f3 f9 76 23 2a ae 51 51 10 95 e6 9b 26 ad 4f 97 b0 98 21 e2 7b 67 | ..5@...o.;..v#*.QQ....&.O...!.{g |
03e0 | df cb b7 07 15 67 a5 3a 12 91 8b c8 45 10 ae c7 a2 97 ca 1e 39 72 04 80 47 1f 7d 94 53 a7 de 05 | .....g.:....E.......9r..G.}.S... |
0400 | 60 ef ee bb f1 81 5e 62 30 68 a6 e2 18 ad 0d 8d 46 04 9e 22 89 53 5a ad 26 5a a7 24 69 8a af 14 | `.....^b0h......F..".SZ.&Z.$i... |
0420 | 8d a8 41 b7 db c3 f7 15 71 1c 13 86 21 0d df 29 45 10 30 df 6e db 4d 3f 20 08 43 50 30 37 3b 47 | ..A.....q...!..)E.0.n.M?..CP07;G |
0440 | 23 70 96 4d 10 e1 79 1e 5a a7 74 3a 5d 86 86 ac 55 d2 ee cc d3 6a b6 00 78 fb ed b7 d9 b4 c9 2a | #p.M..y.Z.t:]...U....j..x......* |
0460 | e9 c5 0f 2f de b8 94 44 2e 22 17 41 58 06 8b ee 60 7d d
#include "debug.h"
#include "config.h"
#define SCRIPTAPI_LOCK_DEBUG
// MUST be an invalid mod name so that mods can't
// use that name to bypass security!
#define BUILTIN_MOD_NAME "*builtin*"
#define PCALL_RES(RES) { \
int result_ = (RES); \
if (result_ != 0) { \
scriptError(result_, __FUNCTION__); \
} \
}
#define runCallbacks(nargs, mode) \
runCallbacksRaw((nargs), (mode), __FUNCTION__)
#define setOriginFromTable(index) \
setOriginFromTableRaw(index, __FUNCTION__)
enum class ScriptingType: u8 {
Async,
Client,
MainMenu,
Server
};
class Server;
#ifndef SERVER
class Client;
#endif
class IGameDef;
class Environment;
class GUIEngine;
class ServerActiveObject;
struct PlayerHPChangeReason;
class ScriptApiBase : protected LuaHelper {
public:
ScriptApiBase(ScriptingType type);
// fake constructor to allow script API classes (e.g ScriptApiEnv) to virtually inherit from this one.
ScriptApiBase()
{
FATAL_ERROR("ScriptApiBase created without ScriptingType!");
}
virtual ~ScriptApiBase();
DISABLE_CLASS_COPY(ScriptApiBase);
// These throw a ModError on failure
void loadMod(const std::string &script_path, const std::string &mod_name);
void loadScript(const std::string &script_path);
#ifndef SERVER
void loadModFromMemory(const std::string &mod_name);
#endif
void runCallbacksRaw(int nargs,
RunCallbacksMode mode, const char *fxn);
/* object */
void addObjectReference(ServerActiveObject *cobj);
void removeObjectReference(ServerActiveObject *cobj);
IGameDef *getGameDef() { return m_gamedef; }
Server* getServer();
ScriptingType getType() { return m_type; }
#ifndef SERVER
Client* getClient();
#endif
// IMPORTANT: these cannot be used for any security-related uses, they exist
// only to enrich error messages
const std::string &getOrigin() { return m_last_run_mod; }
void setOriginDirect(const char *origin);
void setOriginFromTableRaw(int index, const char *fxn);
void clientOpenLibs(lua_State *L);
protected:
friend class LuaABM;
friend class LuaLBM;
friend class InvRef;
friend class ObjectRef;
friend class NodeMetaRef;
friend class ModApiBase;
friend class ModApiEnvMod;
friend class LuaVoxelManip;
/*
Subtle edge case with coroutines: If for whatever reason you have a
method in a subclass that's called from existing lua_CFunction
(any of the l_*.cpp files) then make it static and take the lua_State*
as an argument. This is REQUIRED because getStack() will not return the
correct state if called inside coroutines.
|
0960 | c6 54 15 41 d7 17 a0 83 6a 5a b9 eb 25 ef c8 48 b5 c9 ad 11 80 34 89 3f 66 ef 62 3f 3f 08 e8 27 | .T.A....jZ..%..H.....4.?f.b??..' |
0980 | c5 67 e5 29 54 29 0c 27 5b 7b be 1a 88 5c ea 11 b9 08 c2 12 3a 58 a8 2a 0d b8 84 c7 aa ea cf ca | .g.)T).'[{...\......:X.*........ |
09a0 | 14 69 81 52 61 67 8b eb e8 f7 fb 4c 4e 16 a1 36 41 a0 72 65 f9 38 0b c4 90 60 48 4a 9f 35 69 5a | .i.Rag.....LN..6A.re.8...`HJ.5iZ |
09c0 | ec af b5 5e 13 65 11 b9 d4 23 72 11 36 3a 2b e2 d1 37 4a 93 ea a2 66 52 a6 2c 83 59 e6 a1 f0 b7 | ...^.e...#r.6:+..7J...fR.,.Y.... |
09e0 | 29
void setGameDef(IGameDef* gamedef) { m_gamedef = gamedef; }
Environment* getEnv() { return m_environment; }
void setEnv(Environment* env) { m_environment = env; }
#ifndef SERVER
GUIEngine* getGuiEngine() { return m_guiengine; }
void setGuiEngine(GUIEngine* guiengine) { m_guiengine = guiengine; }
#endif
void objectrefGetOrCreate(lua_State *L, ServerActiveObject *cobj);
void pushPlayerHPChangeReason(lua_State *L, const PlayerHPChangeReason& reason);
std::recursive_mutex m_luastackmutex;
std::string m_last_run_mod;
bool m_secure = false;
#ifdef SCRIPTAPI_LOCK_DEBUG
int m_lock_recursion_count{};
std::thread::id m_owning_thread;
#endif
private:
static int luaPanic(lua_State *L);
lua_State *m_luastack = nullptr;
IGameDef *m_gamedef = nullptr;
Environment *m_environment = nullptr;
#ifndef SERVER
GUIEngine *m_guiengine = nullptr;
#endif
ScriptingType m_type;
};
|